/* ============================================================================
   Survey Says — UI design layer (SS-UI-01)
   ----------------------------------------------------------------------------
   Shared scales + components consumed by the player and host surfaces. Loaded
   AFTER each page's inline :root theme block, so every color here resolves to
   an existing theme token (var(--...)). This file introduces NO palette values
   of its own — only the numeric spacing/radius/type scales below and rgba()
   black/white shadows. Colors that a given page's :root may not define
   (--card-border, --btn-bg, --btn-text are absent on the leaner reveal_control
   root) carry a fallback to a token that every root does define.

   Design intent: the game content owns the top of the viewport; brand moments
   live on join, waiting, and results states — not above the answer form.
   ========================================================================== */

:root {
    /* Spacing scale (px) */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;

    /* Radius scale */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 20px;

    /* Type scale (em, relative to each surface's base) */
    --fs-sm: 0.85em;
    --fs-base: 1em;
    --fs-lg: 1.2em;
    --fs-xl: 1.5em;
    --fs-display: 2.1em;
    --track-display: 1px;   /* letter-spacing for uppercase display treatments */
}

/* ── Status component ───────────────────────────────────────────────────────
   Two-line status pattern (ported from Linked Up play.html #status): a colored
   dot + bold title + muted subtitle. States are driven by the .connecting /
   .online / .offline classes the existing page JS already toggles. */
.ui-status {
    border-radius: var(--r-md);
    padding: var(--sp-5) var(--sp-4);
    border: 2px solid var(--card-border, var(--accent));
    background: var(--bg-color);
}
.ui-status .ui-status-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: var(--sp-2);
    vertical-align: middle;
    background: var(--text-muted);
}
.ui-status .ui-status-title {
    font-size: var(--fs-lg);
    font-weight: bold;
    margin-bottom: var(--sp-1);
    color: var(--text);
}
.ui-status .ui-status-sub {
    color: var(--text-muted);
    font-size: var(--fs-base);
}

/* Online / connected */
.ui-status.online { border-color: var(--success); }
.ui-status.online .ui-status-dot {
    background: var(--success);
    box-shadow: 0 0 12px var(--success);
}
.ui-status.online .ui-status-title { color: var(--success); }

/* Connecting / reconnecting */
.ui-status.connecting { border-color: var(--accent); }
.ui-status.connecting .ui-status-dot {
    background: var(--accent);
    animation: ui-pulse 1.2s infinite;
}
.ui-status.connecting .ui-status-title { color: var(--accent); }

/* Offline / disconnected */
.ui-status.offline { border-color: var(--text-muted); }
.ui-status.offline .ui-status-dot { background: var(--text-muted); }
.ui-status.offline .ui-status-title { color: var(--text-muted); }

/* Crowned — ceremony beats (final results, champion). WR-1's fourth state;
   its other three map onto connecting / online / offline above. Theme tokens
   only, matching the states before it. */
.ui-status.crowned { border-color: var(--accent); }
.ui-status.crowned .ui-status-dot {
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
}
.ui-status.crowned .ui-status-title { color: var(--accent); }

@keyframes ui-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── Slim live header ───────────────────────────────────────────────────────
   Compact sticky strip (LU-22 pattern) carrying team name · CODE · PIN. Sits
   at the top of the viewport during active answering so the question, not the
   branding, leads. Hidden by default; a surface reveals it by adding .is-live
   on its container (class toggle only — no behavior change). */
.ui-slim-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-color);
    border-bottom: 2px solid var(--accent);
    padding: var(--sp-3) var(--sp-4);
    padding-top: calc(env(safe-area-inset-top) + var(--sp-3));
    text-align: left;
}
.ui-slim-header .ui-sh-team {
    font-size: var(--fs-lg);
    font-weight: bold;
    color: var(--text-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.ui-slim-header .ui-sh-meta {
    flex-shrink: 0;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    letter-spacing: 2px;
    white-space: nowrap;
}
.ui-slim-header .ui-sh-meta strong { color: var(--text); letter-spacing: 3px; }

/* ── Card utility ───────────────────────────────────────────────────────── */
.ui-card {
    background: var(--bg-color);
    border: 2px solid var(--card-border, var(--accent));
    border-radius: var(--r-lg);
    padding: var(--sp-5);
}

/* ── Button utilities ───────────────────────────────────────────────────────
   Consume the existing btn tokens; fall back to accent where a leaner root
   omits them. */
.ui-btn,
.ui-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    border: none;
    border-radius: var(--r-md);
    padding: var(--sp-3) var(--sp-4);
    font-family: inherit;
    font-size: var(--fs-base);
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.05s ease, filter 0.15s ease;
}
.ui-btn {
    background: var(--btn-bg, var(--accent));
    color: var(--btn-text, var(--bg-color));
}
.ui-btn-secondary {
    background: transparent;
    color: var(--text);
    border: 2px solid var(--card-border, var(--accent));
}
.ui-btn:hover,
.ui-btn-secondary:hover { filter: brightness(1.08); }
.ui-btn:active,
.ui-btn-secondary:active { transform: translateY(1px); }
.ui-btn:disabled,
.ui-btn-secondary:disabled { opacity: 0.55; cursor: default; filter: none; transform: none; }

/* ── Layout helpers ─────────────────────────────────────────────────────── */
.ui-fullheight {
    min-height: 100vh;
    min-height: 100dvh;
}
.ui-sticky-bottom {
    position: sticky;
    bottom: 0;
    padding-bottom: calc(env(safe-area-inset-bottom) + var(--sp-3));
}

/* ── Global guards ──────────────────────────────────────────────────────────
   Keyboard focus is always visible on interactive controls; nonessential
   motion is suppressed for users who ask for it (existing pulse/shine still
   runs for everyone else). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
.ui-btn:focus-visible,
.ui-btn-secondary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .ui-status.connecting .ui-status-dot { animation: none; }
    .ui-btn,
    .ui-btn-secondary { transition: none; }
}
