/* Official test dates — shared by the account dashboard and the public test-prep pages.
   Loaded by public/js/views/official-test.mjs, which renders everything here. */

/* ─── Timeline: colour-coded tests floating along the next 6 months ─── */

/* a gentle bob; `translate` composes with the positioning `transform`, and stays off layout */
@keyframes official-test-float {
    from {
        translate: 0 -0.4rem;
    }
    to {
        translate: 0 0.4rem;
    }
}

.official-test-timeline {
    --ot-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    margin: 0.5rem 2rem 1.25rem;
    height: 5rem;
}

.timeline-line {
    position: absolute;
    width: 100%;
    top: 50%;
    border-top: 1px solid rgba(0, 0, 0, 0.2);
}

.timeline-tick {
    position: absolute;
    top: 50%;
    height: 1.5rem;
    transform: translate(0, -50%);
    border-left: 1px solid rgba(0, 0, 0, 0.2);
}

.timeline-label {
    position: absolute;
    top: calc(50% + 1rem);
    transform: translate(-50%, 0);
    font-size: 0.8rem;
    color: var(--bs-secondary-color, #6c757d);
    white-space: nowrap;
}

/* Collapsed: a small coloured square. Hover/focus: the same square opens into the test's card.
   The body has a fixed width, so opening only reveals it — text never re-wraps mid-animation.
   Closing fades the content first, then shrinks; opening waits a beat so sweeping across doesn't pop cards. */
.timeline-event {
    z-index: 10;
    position: absolute;
    top: 50%;
    width: 1.5rem;
    height: auto;
    max-height: 1.5rem;
    transform: translate(-50%, -50%);
    border: 2px solid;
    border-radius: 0.375rem;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.08),
        0 4px 10px rgba(0, 0, 0, 0.12);
    overflow: clip;
    transition:
        width 0.18s var(--ot-ease) 0.06s,
        max-height 0.18s var(--ot-ease) 0.06s,
        border-radius 0.18s var(--ot-ease) 0.06s,
        box-shadow 0.18s ease 0.06s;
    animation: official-test-float 2.4s ease-in-out infinite alternate both;
}

/* near the edges, open inward instead of off the side (the square stays centred on its date) */
.timeline-event--start {
    transform: translate(-0.75rem, -50%);
}
.timeline-event--end {
    transform: translate(calc(-100% + 0.75rem), -50%);
}

.timeline-event:hover,
.timeline-event:focus-within {
    z-index: 11;
    width: 20rem;
    max-height: 20rem;
    border-radius: 0.75rem;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.06),
        0 12px 32px rgba(0, 0, 0, 0.16);
    transition-duration: 0.26s;
    transition-delay: 0.08s;
    animation-play-state: paused;
    outline: none;
}
.timeline-event:focus-visible {
    box-shadow:
        0 0 0 3px rgba(13, 110, 253, 0.35),
        0 12px 32px rgba(0, 0, 0, 0.16);
}

.timeline-event-body {
    width: calc(20rem - 4px);
    padding: 0.9rem 1rem 1rem;
    opacity: 0;
    transition: opacity 0.1s ease;
}
.timeline-event:hover .timeline-event-body,
.timeline-event:focus-within .timeline-event-body {
    opacity: 1;
    transition: opacity 0.18s ease 0.2s;
}

.official-test-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}
.official-test-name {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}
.official-test-countdown {
    flex-shrink: 0;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.75);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.official-test-when {
    margin-top: 0.15rem;
    font-size: 0.8125rem;
    opacity: 0.7;
}
.official-test-dates {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.35rem 1rem;
    margin: 0.75rem 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.8125rem;
}
.official-test-dates dt {
    font-weight: 400;
    opacity: 0.7;
}
.official-test-dates dd {
    margin: 0;
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.official-test-card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.85rem;
}
.official-test-card-footer .official-test-chip {
    margin-right: auto;
}

@media (prefers-reduced-motion: reduce) {
    .timeline-event,
    .timeline-event-body {
        animation: none;
        transition: none !important;
    }
}

/* the expanded cards need room — phones get the table alone */
@media (max-width: 767.98px) {
    .official-test-timeline {
        display: none;
    }
}

/* ─── Section labels, legend, actions (Past Tests / Register) ─── */

/* Upcoming / Past section labels + a muted Past table so the two are never confused */
.fp-test-section-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.05rem;
    color: #1B2A4A;
    margin: 0 0 0.75rem;
}
.fp-test-section-label i {
    display: flex;
    font-size: 1.05rem;
    color: var(--fp-accent, var(--brand-primary, var(--bs-primary)));
}
.fp-test-section-label--past {
    color: #6c757d;
}
.fp-test-section-label--past i {
    color: #adb5bd;
}
.fp-test-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}
.fp-test-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid #e9ecef;
    border-radius: 50px;
    background: #fff;
    padding: 0.25rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #495057;
}
.fp-test-legend-item i { display: flex; line-height: 1; font-size: 0.85rem; color: #6c757d; }
.fp-test-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
}
.fp-test-dates-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
}
.fp-outline-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid #d0d5db;
    border-radius: 50px;
    background: #fff;
    color: #1B2A4A;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.45rem 1.25rem;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.fp-outline-pill:hover {
    border-color: var(--fp-accent, var(--brand-primary, var(--bs-primary)));
    color: var(--fp-accent, var(--brand-primary, var(--bs-primary)));
    text-decoration: none;
}
.fp-outline-pill i { display: flex; line-height: 1; }
.fp-test-dates-actions .dropdown-menu {
    min-width: 15rem;
}

/* ─── Table ─── */

.fp-test-dates-card {
    border: 1px solid #e9ecef;
    border-radius: 14px;
    max-height: 420px;
    overflow: auto;
    background: #fff;
}
.fp-test-dates-card table {
    margin: 0 !important;
    border-collapse: separate;
    border-spacing: 0;
}
.fp-test-dates-card thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #1b2a4a;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: none;
    padding: 0.75rem 1rem;
    white-space: nowrap;
}
.fp-test-dates-card--past thead th {
    background: #6c757d;
}
.fp-test-dates-card tbody td {
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    vertical-align: middle;
    border-color: #f1f3f5;
}
.fp-test-dates-card tbody tr:hover {
    background: #f8fafc;
}
.fp-test-dates-card tbody tr:last-child td {
    border-bottom: none;
}
/* the card scrolls (both ways) so the sticky header sticks to it, not to Bootstrap's wrapper */
.fp-test-dates-card .table-responsive {
    overflow: visible;
}

/* ─── Actions + chips: one size everywhere (timeline card and table) ─── */

.official-test-action,
.official-test-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    height: 2rem;
    padding: 0 0.875rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}
.official-test-action {
    min-width: 7.5rem; /* Attend → Adding… → Attending never changes width */
}
.official-test-action .bi {
    display: flex;
    font-size: 0.875rem;
}
.official-test-action .spinner-border {
    width: 0.875rem;
    height: 0.875rem;
    border-width: 0.15em;
}
/* outline buttons sit on pastel cards, so give them a solid face */
.official-test-action.btn-outline-primary {
    --bs-btn-bg: #fff;
}
.official-test-action.btn-light {
    --bs-btn-bg: #fff;
    --bs-btn-border-color: rgba(0, 0, 0, 0.1);
}
