/* ============================================================================
   FOOTER
   ============================================================================ */

.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sticky-bar);
    background: var(--footer-bg);
    border-top: 1px solid var(--border-subtle);
    padding: 0.5rem 2rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
    backdrop-filter: blur(12px);
    /* TASK-BA: height is the shared shell token, NOT a local magic number —
       bottom-pinned bars inset by var(--footer-h); change it in tokens.css only.
       Content must stay under --footer-h tall or the clearance contract breaks. */
    min-height: var(--footer-h);
    display: flex;
    align-items: center;
}

/* Mobile bottom quick-nav — hidden on desktop, shown on phones via 07-mobile */
.bottom-nav {
    display: none;
}

[data-theme="light"] .app-footer {
    background: var(--footer-bg);
    border-top: 1px solid var(--border-subtle);
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.06);  /* tokens-allow: directional shadow (out of --shadow scale) */
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: 0;
}

.footer-left {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);  /* tokens-allow: theme-tuned footer text (revisit: --text-muted) */
    letter-spacing: 0.01em;
}

[data-theme="light"] .footer-left {
    color: rgba(0, 0, 0, 0.55);  /* tokens-allow: theme-tuned footer text (revisit: --text-muted) */
}

.footer-user {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.7);  /* tokens-allow: theme-tuned footer text (revisit: --text-muted) */
    letter-spacing: 0.01em;
}

.footer-user strong {
    /* Identity chrome stays area-stable: --gsx-text (theme-aware, NOT rebound by
       [data-area]) so the user's own name never tracks the active mode's accent.
       Do NOT use --primary-*/--gold/--brand-ink here — those rebind to the area. */
    color: var(--gsx-text);
    font-weight: 700;
}

[data-theme="light"] .footer-user {
    color: rgba(0, 0, 0, 0.6);  /* tokens-allow: theme-tuned footer text (revisit: --text-muted) */
}

[data-theme="light"] .footer-user strong {
    /* --gsx-text already flips to #1a1a1a in light theme; kept explicit so no
       stale area token can win here. Identity is mode-neutral in both themes. */
    color: var(--gsx-text);
}

/* Footer Help Link — visible on mobile only */
.footer-help-link {
    display: none;
    color: rgba(255, 255, 255, 0.7);  /* tokens-allow: theme-tuned footer text (revisit: --text-muted) */
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: 0.02em;
    padding: var(--space-0-5) var(--space-1-5);
    border-radius: var(--radius-xs);
    transition: color var(--motion-base), background var(--motion-base);
}

@media (hover: hover) and (pointer: fine) {
    .footer-help-link:hover {
        color: var(--text-primary);
        background: var(--raise-4);
    }
}

[data-theme="light"] .footer-help-link {
    color: rgba(0, 0, 0, 0.55);  /* tokens-allow: theme-tuned footer text (revisit: --text-muted) */
}

@media (hover: hover) and (pointer: fine) {
    [data-theme="light"] .footer-help-link:hover {
        color: #000;  /* tokens-allow: pure black (3rd-party/brand) */
        background: var(--raise-4);
    }
}

/* Tournament Info Drawer — half-circle pull-out tab for mobile */
.info-drawer-tab {
    display: none;
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: var(--z-nav);
    width: 28px;
    height: 56px;
    border-radius: 28px 0 0 28px;
    background: var(--card-bg, #1e1e2e);
    border: 1px solid var(--border-subtle, #333);
    border-right: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.3);  /* tokens-allow: horizontal drawer shadow (out of --shadow scale) */
    transition: width var(--motion-base);
}

.info-drawer-tab::after {
    content: 'i';
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 700;
    font-size: 1rem;
    color: var(--brand-ink);
}

[data-theme="light"] .info-drawer-tab {
    background: var(--surface-solid);
    border-color: var(--border-subtle);
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.1);  /* tokens-allow: horizontal drawer shadow (out of --shadow scale) */
}

.info-drawer-panel {
    display: none;
    position: fixed;
    right: -300px;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: var(--z-nav-label);
    background: var(--card-bg, #1e1e2e);
    border-left: 1px solid var(--border-subtle, #333);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);  /* tokens-allow: horizontal drawer shadow (out of --shadow scale) */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: calc(env(safe-area-inset-top, 0px) + 1rem) 1rem 1rem;
    transition: right var(--motion-slower) var(--ease-decelerate);
}

.info-drawer-panel.open {
    right: 0;
}

.info-drawer-panel .drawer-close {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
}

.info-drawer-panel .drawer-section {
    margin-bottom: var(--space-4);
}

.info-drawer-panel .drawer-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.info-drawer-panel .drawer-value {
    font-size: 0.88rem;
    color: var(--text-primary, #e8e8e8);
    font-weight: 600;
}

[data-theme="light"] .info-drawer-panel {
    background: var(--surface-solid);
    border-left-color: var(--border-subtle);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);  /* tokens-allow: horizontal drawer shadow (out of --shadow scale) */
}

.info-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: var(--z-nav);
    background: var(--scrim);
    opacity: 0;
    animation: drawerBackdropIn 0.3s ease forwards;
}

@keyframes drawerBackdropIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Footer spacing — account for sticky footer */
.container {
    padding-bottom: var(--space-12);
}

body {
    padding-bottom: 0;
}

body.login-active {
    padding-bottom: 0 !important;
    overflow: hidden;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: var(--space-2);
}

.mt-2 {
    margin-top: var(--space-4);
}

.mt-3 {
    margin-top: var(--space-6);
}

.mb-1 {
    margin-bottom: var(--space-2);
}

.mb-2 {
    margin-bottom: var(--space-4);
}

.mb-3 {
    margin-bottom: var(--space-6);
}

/* TASK-V: rail-collapse control (footer resident, outside the nav element). */
.rail-collapse-btn {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
}
/* TASK-Z Z1: pinned to the top of the rail column it controls. Desktop-only —
   collapse does not exist at all below 1024px, and the element lives outside
   the nav so it can never become a mobile tab. */
@media (min-width: 1024px) {
    body[data-shell-nav="app"] .rail-collapse-btn,
    body[data-shell-nav="solo"] .rail-collapse-btn {
        display: inline-flex;
        position: fixed;
        top: 8px;
        left: calc(var(--rail-w, 200px) - 52px);
        z-index: calc(var(--z-sticky-bar, 950) - 5);
    }
}
body.rail-collapsed .rail-collapse-btn svg { transform: scaleX(-1); }

/* ── TASK-V step 3: in-page tabs (underline — never the switcher's pill) ── */
.gsx-page-tabs {
    display: flex;
    gap: var(--space-1);
    /* TASK-AI AI-4 sweep: same height-thief pattern as the mode tabs — the
       border consumed inner height and the tab's -1px overlap poked below
       the content box. Inset shadow costs no layout. */
    box-shadow: inset 0 -1px 0 var(--border-subtle);
    margin-bottom: var(--space-4);
}
.gsx-page-tab {
    min-height: 44px;
    padding: 0 var(--space-3);
    border: none;
    background: none;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}
.gsx-page-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--primary-color);
}

/* /account rows and /school/settings cards */
.acct-rows { display: flex; flex-direction: column; }
.acct-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 48px;
    padding: var(--space-2) 0;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
}
.acct-row:last-child { border-bottom: none; }
.acct-row-label { font-weight: 600; }
.acct-row-sub { display: block; font-size: 0.8rem; }
.acct-section-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-bottom: var(--space-2);
}
.acct-id-name { font-weight: 700; font-size: 1.05rem; }
.acct-signout-wrap {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-subtle);
}
.sset-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
}
@media (min-width: 769px) {
    .sset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.sset-card { text-align: left; border: none; padding: 0; cursor: pointer; }

/* TASK-W W2: the theme toggle's mobile home — an "Appearance" row on the
   account surface (/account for app-shell roles, Profile for solo). Hidden
   from >=769px, where the toggle lives in the footer (TASK-S S1). */
.acct-theme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 48px;
    margin-top: var(--space-4);
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}
.acct-theme-label { font-weight: 600; font-size: 0.95rem; color: var(--text-primary); }
@media (min-width: 769px) {
    .acct-theme-row { display: none; }
}
/* Real 44x44 in the slot — no overlay needed for an isolated leaf control. */
.acct-theme-row .nav-shell-theme { min-width: 44px; min-height: 44px; }

/* ── TASK-X X1: ambient context indicator (mobile) ─────────────────────────
   Answers "which world am I in" without being tappable: a plain span, no
   border, no pressed state, cursor default, not focusable. The 3px accent
   band on the navbar carries the colour; this carries the word. Desktop
   hides it — the real switcher is in the top bar there. */
.nav-context-chip {
    display: none;
    align-items: center;
    margin-left: var(--space-2);
    padding: 2px var(--space-2);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    /* Neutral ink on purpose: accents don't theme-mirror as text (the ratchet
       catches it), and the navbar's 3px accent band already carries the
       colour — the chip only needs to carry the word. */
    color: var(--text-secondary);
    cursor: default;
    user-select: none;
}
@media (max-width: 768px) {
    .nav-context-chip { display: inline-flex; }
}

/* The account-surface switch: full-width labelled rows behind a deliberate
   navigation step (X1's consequence/frequency rule). Current row is inert. */
.plat-switch-rows { display: flex; flex-direction: column; }
.plat-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 48px;
    padding: var(--space-2) 0;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
}
.plat-switch-row:last-child { border-bottom: none; }
.plat-switch-row.active { cursor: default; }
.plat-switch-name { font-weight: 600; }
.plat-switch-current {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    background: var(--primary-color);
    color: var(--area-on-accent, #ffffff);
}


/* ── TASK-Z Z2/Z3: footer order — [© · Terms · Privacy] .... [toggle][Logged In] ──
   The left group takes the auto margin so the right cluster hugs the edge;
   placeThemeToggle inserts the toggle immediately BEFORE .footer-user. Legal
   links get 44px-tall hit areas without changing the visual type size. */
.app-footer .footer-content { display: flex; align-items: center; gap: var(--space-3); }
.app-footer .footer-left { margin-right: auto; display: inline-flex; align-items: center; gap: var(--space-1); }
.app-footer .footer-left a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--space-1); }
.app-footer .footer-user { white-space: nowrap; }

/* ── TASK-AF (P0): content must clear the fixed footer ─────────────────────
   The footer is position:fixed at z-sticky-bar and ~61px tall; screens had
   padding-bottom: 0, so the last interactive element on any long page —
   measured live: Profile's Log Out, 37 of its 40px under the footer — was
   visually hidden AND hit-test intercepted (elementFromPoint returned the
   footer). Every signed-in screen gets bottom clearance >= footer height at
   the widths where the footer renders (>=769px; it is display:none below).
   The footer itself stays fixed at its z-index — that part is intended. */
@media (min-width: 769px) {
    body[data-shell-nav="app"] .screen.active,
    body[data-shell-nav="solo"] .screen.active {
        padding-bottom: calc(61px + var(--space-4) + env(safe-area-inset-bottom, 0px));
    }
}

/* ── TASK-AL: the footer may never STEAL a tap ─────────────────────────────
   Content scrolling under a fixed bar is normal; a tap landing on the bar
   instead of the control beneath it is the bug class (Roster's last row,
   Profile's Log Out before TASK-AF). The footer BODY passes pointer events
   through; only its own interactive children catch them. Combined with the
   TASK-AF screen clearance and the rail clearance above, nothing is ever
   tap-blocked by footer chrome. */
.app-footer { pointer-events: none; }
.app-footer a,
.app-footer button { pointer-events: auto; }   /* .footer-user is a label, not a control */
