/* ============================================================
   EXAM SPACES — components (ADR 0014)
   ------------------------------------------------------------
   Space switcher, per-space sidebar scoping and space choice
   screen, transposed from Pilote Militaire's dashboard.css
   (l.419-858) — same geometry, same states, same anatomy.

   The switcher lives ON THE INK RAIL, so it reads the on-ink
   accents (bright hue on navy), never the on-white ones: a navy
   ASTB-E accent on a navy sidebar would be invisible. The space
   choice screen is a light panel holding dark cards, exactly as
   PM's, so it also stays on the on-ink side.

   Each switcher option and each choice card carries its OWN
   space's tint: css/ff-tokens.css keys --track-* on
   .dash-space-option[data-space] and
   .dash-space-choice__card[data-space], so an option is tinted
   by the space it offers, not by the space that is active. The
   --accent-on-ink fallbacks cover the switcher toggle, which is
   keyed on .dash-space-switcher[data-space] instead.

   No raw hex here beyond the ink scrims: every colour comes from
   a token.
   ============================================================ */

/* --- Space switcher ------------------------------------------------------ */

.dash-space-switcher {
    position: relative;
    margin: 0 12px 10px;
}

.dash-space-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--dash-sidebar-border);
    border-radius: 10px;
    background: var(--dash-sidebar-raised);
    color: var(--dash-sidebar-text);
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s, border-color 0.12s;
}

.dash-space-toggle:hover {
    background: var(--dash-sidebar-hover);
    border-color: var(--dash-sidebar-border-hover);
}

.dash-space-toggle:focus-visible {
    outline: 2px solid var(--track-on-ink, var(--accent-on-ink));
    outline-offset: 2px;
}

.dash-space-toggle__chip,
.dash-space-option__chip {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: var(--track-on-ink, var(--accent-on-ink));
    background: var(--track-on-ink-soft, var(--accent-on-ink-soft));
    box-shadow: inset 0 0 0 1px var(--track-on-ink-line, var(--accent-on-ink-line));
}

.dash-space-chip-ico {
    display: block;
    width: 22px;
    height: 22px;
}

.dash-space-chip-ico svg {
    display: block;
    width: 100%;
    height: 100%;
}

.dash-space-toggle__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.dash-space-toggle__eyebrow {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dash-sidebar-muted);
}

.dash-space-toggle__label {
    font-family: var(--dash-font-display);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--dash-sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* PM's toggle carries two lines; this one carries three (the space's branch
   line). Same micro-type as the option's second line, so the two agree. */
.dash-space-toggle__kicker,
.dash-space-option__kicker {
    font-size: 0.72rem;
    color: var(--dash-sidebar-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-space-toggle__caret {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    opacity: 0.9;
}

.dash-space-toggle__caret svg {
    display: block;
    transition: transform 0.18s;
}

.dash-space-toggle[aria-expanded='true'] .dash-space-toggle__caret svg {
    transform: rotate(180deg);
}

.dash-space-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 60;
    padding: 6px;
    background: var(--navy-800);
    border: 1px solid var(--dash-sidebar-border);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(9, 20, 32, 0.5);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dash-space-menu[hidden] {
    display: none;
}

/* Opening: fade + slight downward slide (closing is instant). */
@keyframes ffSpaceMenuIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dash-space-menu:not([hidden]) {
    animation: ffSpaceMenuIn 150ms ease-out;
}

.dash-space-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: var(--dash-sidebar-text);
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
}

.dash-space-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.dash-space-option:focus-visible {
    outline: 2px solid var(--track-on-ink, var(--accent-on-ink));
    outline-offset: -2px;
}

.dash-space-option[aria-selected='true'] {
    background: rgba(255, 255, 255, 0.04);
}

.dash-space-option[aria-selected='true']::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--track-on-ink, var(--accent-on-ink));
}

.dash-space-option__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.dash-space-option__label {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Only the active space's Exams are listed underneath the switcher. */
.dash-nav-details[hidden] {
    display: none;
}

/* --- Space choice screen -------------------------------------------------
   PM's "buffer page": a light panel holding tall dark doorway cards. The
   photography behind PM's cards lives in its own repository; here the frame
   is filled by a blueprint hairline grid washed with the space's tint —
   same dark-card reading, no half-transposed asset. */

.dash-space-choice {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(9, 20, 32, 0.72);
    backdrop-filter: blur(3px);
}

.dash-space-choice[hidden] {
    display: none;
}

.dash-space-choice__panel {
    position: relative;
    width: 100%;
    max-width: 1240px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: var(--surface-card);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(9, 20, 32, 0.35);
    padding: 32px 28px 28px;
}

.dash-space-choice__close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 8px;
}

.dash-space-choice__close:hover {
    background: var(--surface-raised);
    color: var(--text-primary);
}

.dash-space-choice__title {
    margin: 0;
    font-family: var(--dash-font-display);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-align: center;
}

.dash-space-choice__sub {
    margin: 8px 0 22px;
    text-align: center;
    font-size: 0.86rem;
    color: var(--text-secondary);
}

/* Four spaces where PM has three tracks: four columns, same card height. */
.dash-space-choice__grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.dash-space-choice__card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 440px;
    padding: 24px;
    border: 1px solid var(--border-on-ink);
    border-radius: 14px;
    overflow: hidden;
    background: var(--navy-950);
    color: var(--text-on-ink);
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.16s, transform 0.16s, box-shadow 0.16s;
}

/* Blueprint grid + tint, in place of PM's photograph, then PM's own scrim so
   the type sits on the same darkening at top and bottom. */
.dash-space-choice__card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.55;
    background-image:
        repeating-linear-gradient(
            0deg,
            var(--track-on-ink-line, var(--accent-on-ink-line)) 0 1px,
            transparent 1px 28px
        ),
        repeating-linear-gradient(
            90deg,
            var(--track-on-ink-line, var(--accent-on-ink-line)) 0 1px,
            transparent 1px 28px
        );
}

.dash-space-choice__card::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(to bottom, rgba(7, 15, 24, 0.42), rgba(7, 15, 24, 0) 26%),
        linear-gradient(to top, rgba(7, 15, 24, 0.93) 9%, rgba(7, 15, 24, 0.38) 44%, rgba(7, 15, 24, 0.05) 72%);
}

.dash-space-choice__card > * {
    position: relative;
    z-index: 1;
}

/* Hover: a ring halo through box-shadow (the focus-ring mechanism) — it follows
   the radius by construction and its soft edge survives Windows sub-pixel
   scaling; the card's own border never moves. */
.dash-space-choice__card:hover {
    transform: translateY(-3px);
    box-shadow:
        0 0 0 3px color-mix(in srgb, var(--track-on-ink, var(--accent-on-ink)) 45%, transparent),
        0 16px 32px rgba(9, 20, 32, 0.25);
}

.dash-space-choice__card:focus-visible {
    outline: 2px solid var(--track-on-ink, var(--accent-on-ink));
    outline-offset: 2px;
}

.dash-space-choice__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dash-space-choice__acro {
    font-family: var(--dash-font-display);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--text-on-ink);
}

.dash-space-choice__dot {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    background: var(--track-on-ink, var(--accent-on-ink));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--track-on-ink, var(--accent-on-ink)) 25%, transparent);
}

/* Pinned to the base of the card, as PM's absolutely positioned bottom block. */
.dash-space-choice__kicker {
    margin-top: auto;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--track-on-ink, var(--accent-on-ink));
}

.dash-space-choice__blurb {
    margin-top: 12px;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text-on-ink-secondary);
}

.dash-space-choice__foot {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(234, 241, 246, 0.16);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dash-space-choice__rail {
    font-family: var(--dash-font-mono);
    font-size: 11.5px;
    color: var(--text-on-ink-secondary);
}

.dash-space-choice__go {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--track-on-ink, var(--accent-on-ink));
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .dash-space-choice__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .dash-space-choice__grid {
        grid-template-columns: 1fr;
    }

    .dash-space-choice__card {
        min-height: 400px;
    }
}

/* --- Statistics scoped to the space -------------------------------------- */
/* The Statistics view only shows the active space's Exams; the tab bar itself
   disappears where there is nothing to choose between (every space but
   AFOQT & TBAS). Both need an explicit rule: the components set `display`, which
   would otherwise beat the [hidden] attribute. */
.ff-stats-tabs[hidden],
.ff-stats-tab[hidden] {
    display: none !important;
}
