/* base.css, owner: track A. Holds: tokens (DESIGN_SPEC.md 4), reset, root font, type roles, focus, utilities, reduced motion.
   Load order 1 of 15: base, primitives, frame, home, room, friends, center, table, rails, chat, coach, meld, peek, results, dialogs.
   Wave 1 (docs/web-redesign/track-a.md): the section 4 block is verbatim; the "legacy" blocks keep what unmigrated CSS reads. */

:root {
  color-scheme: dark;

  /* greens */
  --bg: #0f261a; --bg-2: #14301f; --ink-0: #0a1a11;
  --felt: #1f5c3a; --table: #1c5234; --felt-edge: #123823;
  --panel: #10241a; --panel-2: #173024;
  /* gold */
  --gold: #e3b54a; --gold-strong: #f0c65e; --ink-on-gold: #1b1405;
  --gold-wash: rgba(227, 181, 74, .14); --gold-line: rgba(227, 181, 74, .5);
  /* text and status */
  --text: #eef3ef; --text-dim: #a8bcae; --text-faint: #8fa699; --prose: #dfe8e1;
  --good: #6fcf8e; --bad: #ef7d6f;
  --good-wash: rgba(111, 207, 142, .14); --bad-wash: rgba(239, 125, 111, .14);
  --team-ns: #f0b44a; --team-ew: #62d2cb;
  /* lines and washes */
  --hair: rgba(255, 255, 255, .09); --line: rgba(255, 255, 255, .16); --control-line: rgba(255, 255, 255, .4);
  --wash-hover: rgba(255, 255, 255, .07); --wash-press: rgba(255, 255, 255, .12); --scrim: rgba(5, 12, 8, .72);
  /* card paper and suits (deck CSS owns the rest) */
  --paper: #fbf8ef; --suit-red: #c62828; --suit-black: #111111;
  --suit-on-dark-red: #ff8a80; --suit-on-dark-white: #eef3ef;
  /* space */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem; --sp-5: 1.5rem;
  --sp-6: 2rem; --sp-7: 3rem; --sp-8: 4rem; --sp-9: 6rem;
  /* radius */
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-2xl: 20px; --r-full: 999px;
  /* elevation */
  --e-1: 0 4px 10px rgba(0,0,0,.30); --e-2: 0 12px 32px rgba(0,0,0,.45); --e-3: 0 24px 64px rgba(0,0,0,.55);
  --glow-gold: 0 0 0 2px var(--gold), 0 0 14px rgba(227,181,74,.45);
  --glow-button: 0 6px 14px -4px rgba(227,181,74,.38);
  /* faces */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* type roles (font shorthand: weight size/line family) */
  --t-eyebrow: 700 .75rem/1.2 var(--font-sans);   --t-caption: 500 .8125rem/1.4 var(--font-sans);
  --t-small: 500 .9375rem/1.45 var(--font-sans);  --t-body: 400 1rem/1.5 var(--font-sans);
  --t-label: 600 1rem/1.25 var(--font-sans);      --t-lead: 400 1.125rem/1.5 var(--font-sans);
  --t-prose: 400 1.125rem/1.7 var(--font-sans);
  --t-title-3: 700 1.25rem/1.3 var(--font-serif); --t-title-2: 700 1.5rem/1.25 var(--font-serif);
  --t-title-1: 700 2rem/1.15 var(--font-serif);
  --t-display: 700 clamp(2.75rem, 1.6rem + 2.6vw, 4.25rem)/1.02 var(--font-serif);
  --text-micro: .75rem;                            /* was .6875rem: the floor is now 12 px */
  /* layers */
  --z-rail: 20; --z-bar: 30; --z-drawer: 60; --z-menu: 70; --z-dialog: 80; --z-toast: 90; --z-banner: 100;
  /* motion */
  --ease-out: cubic-bezier(.23, 1, .32, 1); --ease-move: cubic-bezier(.65, 0, .35, 1);
  --dur-fast: 120ms; --dur: 200ms;
  /* control heights */
  --hit: 2.75rem;      /* 44: default and every touch control */
  --hit-sm: 2.25rem;   /* 36: mouse only (44 under any-pointer: coarse) */
  --hit-lg: 3.25rem;   /* 52: the one primary */
  --field-h: 3rem;     /* 48 */
  /* frame (set per band, 6.1) */
  --nav-w: 0px; --bar-h: 3.5rem; --page-pad: var(--sp-4); --page-max: 88rem;
  /* safe areas */
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* legacy aliases kept until track G's cleanup removes the last reader */
  --panel-border: var(--hair); --border: var(--line);
  --space-1: var(--sp-1); --space-2: var(--sp-2); --space-3: var(--sp-3); --space-4: var(--sp-4); --space-5: var(--sp-5); --space-6: var(--sp-6);
  --radius-xs: var(--r-xs); --radius-sm: var(--r-sm); --radius-md: var(--r-md); --radius-lg: var(--r-lg); --radius-xl: var(--r-xl); --radius-2xl: var(--r-2xl); --radius-full: var(--r-full);
  --red: var(--suit-red); --black: var(--suit-black);
  --card-width: 76px; --card-height: 108px;        /* deck defaults; the table overrides per area (7.4) */
  --card-small-width: 50px; --card-small-height: 75px;
}
@media (prefers-contrast: more) { :root { --hair: rgba(255,255,255,.30); --text-dim: #d3e0d6; } }

/* Wave 1 only: the old table (track D1's) still reads these, and it must not move by a pixel, so the values it was built
   on come back over the block above. Each line goes when the last reader is migrated (track-a.md section 3). */
:root {
  --text-micro: 0.6875rem;                 /* table.css, meld.css, dialogs.css, home.css; the spec's .75rem lands with D1 */
  --border: rgba(255, 255, 255, 0.12);     /* chat.css, coach.css, dialogs.css */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px;   /* px, not rem: Larger Text */
  --z-chat: 150; --z-panel: 200; --z-overlay: 300;
  --z-toast: 1000; --z-banner: 1100;       /* the old modals are inline z-index 900 to 1000 (dialog-kit.js, dialogs.js) */
  --ease-in-out: var(--ease-move);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.45);
  --card-w: 76px; --card-h: 108px;
  --card-width: var(--card-w); --card-height: var(--card-h);
}
@media (max-width: 599.98px), (max-height: 500px) {
  :root { --card-w: 58px; --card-h: 84px; --card-small-width: 40px; --card-small-height: 58px; }
}

/* Tokens the components of section 8 write as colors (AC-25: no literal outside this file). */
:root {
  --bad-edge: rgba(239, 125, 111, .4);        /* danger button edge */
  --bad-solid: #b3372b;                       /* connection and error bars */
  --badge-ink: #2a0d09;                       /* text on a red badge */
  --plate-fill: rgba(16, 36, 26, .78);        /* seat plate */
  --plate-fill-on: rgba(16, 36, 26, .95);     /* seat plate on turn, bid panel */
  --ink-92: rgba(10, 26, 17, .92);            /* lobby action bar, phone app bar */
  --wash-up: rgba(255, 255, 255, .18);        /* primary hover */
  --wash-down: rgba(0, 0, 0, .08);            /* primary pressed */
  --track-dark: rgba(0, 0, 0, .2);            /* scrollbar track */
  --switch-off: rgba(0, 0, 0, .35);           /* the Coach and Chat switches' track */
  --mask-on: #000;                            /* the opaque stop of a fade-out mask (only its alpha counts) */
  --track: rgba(255, 255, 255, .1);           /* progress and spinner track */
  --glow-card: drop-shadow(0 0 8px rgba(240, 198, 94, .8));
  --glow-resume: 0 8px 28px rgba(227, 181, 74, .25);
  --gold-deep: #c99a33;                       /* foot of the Resume card gradient */
  --white-edge: rgba(255, 255, 255, .35);     /* inner edge of the Resume card */
  --paper-ink: #17301f;                       /* text in a speech bubble */
  --bubble: #ffffff;
  --shimmer: rgba(255, 255, 255, .08);
  --control-line-hover: rgba(255, 255, 255, .6);
  /* the old buttons and links (primitives.css), kept to the value */
  --white: #fff; --white-04: rgba(255, 255, 255, .04); --white-08: rgba(255, 255, 255, .08); --white-30: rgba(255, 255, 255, .3);
  --gold-line-55: rgba(227, 181, 74, .55); --shadow-btn-old: 0 6px 16px rgba(227, 181, 74, .25);
  --bad-solid-edge: #d2503f; --bad-solid-hover: #c4412f; --bad-line-60: rgba(239, 125, 111, .6); --bad-wash-12: rgba(239, 125, 111, .12);
  --leave-wash: rgba(200, 50, 50, .25); --leave-edge: #e57373; --leave-ink: #ffcdd2; --warn-ink: #ffc4b8;
  --text-hair: 1px;                           /* the hidden glyph in the club mark */
  --shadow-banner: 0 6px 18px rgba(0, 0, 0, .35);   /* the moved banner and the toasts' older cousin */
  --chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M5 9l7 7 7-7' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/></svg>");   /* the chevron icon (render/icons.js chevron-down) as a mask, for the ::after of a disclosure (fix round 3 m11) */
  --select-caret: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23eef3ef' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

/* ========== RESET, ROOT SIZE, PAGE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* 3.3: the user's own size grows smoothly from 1440 to 2560 wide (16 to 20 px), and stays put on a short window. */
html { font-size: clamp(100%, calc(100% + (100vw - 1440px) * 0.00357), 125%); }
@media (max-height: 800px) { html { font-size: 100%; } }

body {
  font-family: var(--font-sans);
  background: radial-gradient(120% 90% at 50% 0%, var(--bg-2) 0%, var(--bg) 60%) fixed;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
/* 5: every framed page is flat --bg; Home and first run draw their own glow of the felt over it (home.css). The table has no frame and keeps the glow above. */
body:is(.has-frame, .has-bare) { background: var(--bg); }
/* 11: text can be selected (names, room code, rules, the bid history); cards, buttons, and the nav cannot (the table's own list is in table.css). */
:where(.has-frame, .has-bare) :where(.card, .hero-fan, .btn, button, summary, nav) { -webkit-user-select: none; user-select: none; }
/* Easy view (Settings, as in the app): larger text everywhere, and the hand in two rows of bigger cards. */
body.easy-view { font-size: 1.12em; }

/* Sleek, thin scrollbars in the page's own gold. */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--track-dark); border-radius: var(--r-xs); }
::-webkit-scrollbar-thumb { background: var(--gold-line); border-radius: var(--r-xs); }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }
* { scrollbar-width: thin; scrollbar-color: var(--gold-line) var(--track-dark); }

/* ========== TYPE ROLES (3.5) ========== */
.t-display { font: var(--t-display); }
.t-title-1 { font: var(--t-title-1); }
.t-title-2 { font: var(--t-title-2); }
.t-title-3 { font: var(--t-title-3); }
.t-lead { font: var(--t-lead); }
.t-label { font: var(--t-label); }
.t-body { font: var(--t-body); }
.t-small { font: var(--t-small); }
.t-caption { font: var(--t-caption); }
.t-eyebrow { font: var(--t-eyebrow); letter-spacing: .08em; text-transform: uppercase; }
.t-dim { color: var(--text-dim); }
.t-num { font-variant-numeric: tabular-nums; font-weight: 800; }

/* ========== FOCUS (AC-28, 11) ========== */
/* One ring everywhere: 2 px --gold-strong, 2 px off the edge. A text field draws it 1 px off (8.2).
   On a gold fill (a primary, the skip links, the lobby's own avatar on the gold team) the ring is light (--text) with a 2 px dark band (--ink-0) between it and the fill (AC-28, AC-05).
   The table has the same ring (D1): the on-gold rule is for the framed pages and the table's primary buttons. */
:focus-visible { outline: 2px solid var(--gold-strong); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 1px; }
.btn--primary:focus-visible, .skip-link:focus-visible, :is(.has-frame, .has-bare, .at-table) :is(.btn.btn-primary, .team-ns button.seat-avatar.is-mine):focus-visible {
  outline-color: var(--text);   /* light against the dark page (14:1) and the dark band inside it; the band is against the gold (AC-05: the ring must be 3:1 against both neighbors, and the button's own ink was 1.1:1) */
  box-shadow: 0 0 0 2px var(--ink-0);
  transition: none;   /* the ring is there the moment the key is pressed, not 150 ms later */
}
main:focus, body:is(.has-frame, .has-bare) [role="dialog"]:focus { outline: none; }   /* a dialog's own box takes focus only when its last control is gone (nav.js keepFocusIn); it needs no ring */
@media (forced-colors: active) { :focus-visible, .btn--primary:focus-visible, .skip-link:focus-visible { outline-color: Highlight; } }   /* 12.3: the ring is Highlight; the gold fill keeps ButtonText on ButtonFace (primitives.css) */
/* Wave 1 only: Home's name field draws its own gold ring (home.css, track B's); it gets the one ring until B moves it to .input. */
input.landing-input:focus-visible { outline-color: var(--gold-strong); }

/* ========== UTILITIES ========== */
/* 3.9: every icon() is 1.25rem square unless a component says otherwise (:where keeps this the weakest rule, so any component size wins). */
:where(svg.i) { flex: none; width: 1.25rem; height: 1.25rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.is-truncated { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

button, a, .card, .table-seat, .icon-btn, .menu-item, .table-talk-send-btn, .teach-toggle, .trick-history-title, .btn-sub-bot, .btn-leave-lobby {
  -webkit-tap-highlight-color: transparent;
}

/* ========== REDUCED MOTION (AC-26) ========== */
/* Anyone who asked their device for less motion gets no looping or sliding animations anywhere. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .player-zone.current-player .seat-plate, .table-swap-hint, .table-seat.table-seat-selected, .reconnecting-banner, .trick-complete-indicator {
    animation: none !important;
  }
}

/* A menu item with a one-line note under its name (Save for Later, Quit Without Saving). */
.menu-item .menu-note { display: block; margin-top: var(--sp-1); font: var(--t-caption); color: var(--text-dim); white-space: normal; }
.menu-item.is-danger .menu-note { color: var(--text-dim); }
