/* Carbonyl brand tokens, shared by carbonyl.org and leagues.carbonyl.org.
   Brand System (2026-10-09), drive/5 Website; loaded before site.css on
   every page (D-253).  One change from the drive's copy: the dark-mode
   selectors, light and dark, are wrapped in :where(), so a club's colours, set on :root in
   its page head, still win in dark mode (they never get part 4).

   The values in part 1 are carbonyl.org's own, unchanged, under the names that
   site already uses (--ground, --surface, --ink, --muted, --rule, --grid,
   --accent, --accent-ink, --mark, --display, --body, --mono, --measure).
   carbonyl.org can load this file in place of its inline :root block and
   nothing on the page changes.

   Part 2 adds what a product needs and the company site never did: status
   colours, a control edge that passes 3:1, a type and space scale, and the
   one shadow for floating layers.

   Part 3 is the product variant ("app"): the same family, tuned for phones
   and for dense admin screens. Apply it with class="app" (or data-surface="app")
   on <body> of the product's own and admin pages.

   Part 4 maps the names leagues.carbonyl.org's site.css already reads (--bg,
   --card, --text, --line, --brand, --link ...) onto these tokens, for our own
   pages and admin only. Club sites never get part 4: they keep their theme.

   Fonts: self-host Spectral, Hanken Grotesk and JetBrains Mono (SIL OFL 1.1,
   which allows self-hosting and redistribution) from carbonyl.org's fonts/
   folder; @font-face rules are in the Brand System doc. Load this file before
   any page stylesheet. Dark mode follows the system, with a data-theme
   override on <html>, the same as carbonyl.org. */

/* 1. Core brand: carbonyl.org's tokens, exactly ---------------------------- */
:where(:root) {
  --ground: #F1F2EE;     /* page */
  --surface: #FAFAF7;    /* panels, cards, the cover */
  --ink: #16181C;        /* text, 1px frame lines, primary outlines */
  --muted: #585E68;      /* secondary text, 6.2:1 on surface */
  --rule: #D3D6CF;       /* decorative dividers only, never a control's edge */
  --grid: rgba(22,24,28,.045); /* the blueprint grid, marketing pages only */
  --accent: #2F48C9;     /* the one action colour: primary buttons, links */
  --accent-ink: #FFFFFF; /* text on --accent, 7.3:1 */
  --mark: #956210;       /* gold: the bond in the logo, sheet codes. Never status, never a button */

  --display: "Spectral", Georgia, "Times New Roman", serif;
  --body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --measure: 64ch;
}

/* 2. Shared extensions ------------------------------------------------------ */
:where(:root) {
  --accent-hover: #2639A8;    /* white on it 9.4:1 */
  --accent-tint: #E6E9FA;     /* selected rows, info chips; --accent on it 6.0:1 */
  --raised: #FFFFFF;          /* inputs, menus, the app's cards */
  --field-border: #7D838C;    /* every control's edge: 3.0:1+ on ground, surface, white (WCAG 1.4.11) */
  --focus: var(--accent);

  /* Status: always text + tint + an icon or word, never colour alone. */
  --good: #1F6B35;  --good-bg: #E3F1E6;
  --warn: #7A4F00;  --warn-bg: #FBEFD2;
  --bad:  #A3231B;  --bad-bg:  #FBE6E3;
  --info: var(--accent); --info-bg: var(--accent-tint);
  /* D-343: live (a game on now), the error colour, so it changes with it. */
  --live: var(--bad); --live-bg: var(--bad-bg);

  /* Type scale (px at 16px root). Display sizes are Spectral; the rest Hanken. */
  --fs-label: .75rem;   /* 12  mono, uppercase, tracked .12em */
  --fs-sm: .875rem;     /* 14 */
  --fs-base: 1rem;      /* 16  app body */
  --fs-read: 1.0625rem; /* 17  marketing body (carbonyl.org's) */
  --fs-lede: 1.1875rem; /* 19 */
  --fs-h3: 1.25rem;     /* 20 */
  --fs-h2: clamp(1.7rem, 3.2vw, 2.4rem);   /* 27-38 */
  --fs-h1: clamp(2.4rem, 5.6vw, 4.1rem);   /* 38-66 */
  --lh-body: 1.6; --lh-tight: 1.12;
  --track-label: .12em; --track-display: -.015em;

  /* Space: a 4px base, the steps both sites use. */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px;
  --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-14: 56px; --s-16: 64px; --s-24: 96px;
  --wrap: 1160px; --gutter: clamp(16px, 4vw, 40px);

  /* Shape. Company: square. Frames have no radius; buttons 2px. */
  --r-frame: 0; --r-control: 2px; --r-chip: 2px;
  --hairline: 1px; --frame: 1px solid var(--ink); --divider: 1px solid var(--rule);

  /* Depth. The brand is flat: lines, not shadows. One shadow, for things that
     float over the page (menus, dialogs, toasts), and nothing else. */
  --shadow-float: 0 10px 30px rgba(22,24,28,.16), 0 1px 0 rgba(22,24,28,.06);

  /* The night cover (D-950): the front page's and /play's hero, the same in
     light and dark mode. */
  --night: #0D1015; --night-2: #151A23; --on-night: #F4F5F1;
  --on-night-muted: #AEB4BF; --on-night-link: #B4C3FF;

  --tap: 44px; /* smallest touch target on phones */
  --ease: 150ms ease-out;
}

/* 3. Product variant ("app"): same family, friendlier for players and admins.
   Differences from the company site, and only these:
   - body 16px, not 17; headings inside the app are Hanken 600, Spectral only
     for page titles 28px and up on our own pages;
   - controls and cards get a 6px radius; status chips 999px; frames stay square;
   - no blueprint grid behind app screens;
   - cards on --raised (white) with a --rule edge, not a 1px ink frame;
   - controls at least 44px tall on phones and tablets, 36px from 1000px
     (D-343: one of the three breakpoints, 600, 1000 and 1280). */
.app, [data-surface="app"] {
  --r-control: 6px; --r-card: 6px; --r-chip: 999px;
  --fs-body: var(--fs-base);
  --grid: transparent;
  --control-h: var(--tap);
}
@media (min-width: 1000px) { .app, [data-surface="app"] { --control-h: 36px; } }

/* Dark: follows the system unless the page says otherwise. ---------------- */
@media (prefers-color-scheme: dark) {
  :where(:root:not([data-theme="light"])) {
    --ground: #111317; --surface: #171A1F; --ink: #E6E8E3; --muted: #9BA1AA;
    --rule: #2B2F36; --grid: rgba(230,232,227,.035);
    --accent: #93A5FF; --accent-ink: #0E1330; --mark: #E0A443;
    --accent-hover: #ADBBFF; --accent-tint: #1C2347; --raised: #1E2228;
    --field-border: #6B727C;
    --good: #7FD99A; --good-bg: #16301F; --warn: #F3C969; --warn-bg: #3A2E10;
    --bad: #FF9D94;  --bad-bg: #3D1A18;
    --shadow-float: 0 12px 32px rgba(0,0,0,.5), 0 0 0 1px #2B2F36;
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .app,
  :root:not([data-theme="light"]) [data-surface="app"] { --grid: transparent; }
}
:where(:root[data-theme="dark"]) {
  --ground: #111317; --surface: #171A1F; --ink: #E6E8E3; --muted: #9BA1AA;
  --rule: #2B2F36; --grid: rgba(230,232,227,.035);
  --accent: #93A5FF; --accent-ink: #0E1330; --mark: #E0A443;
  --accent-hover: #ADBBFF; --accent-tint: #1C2347; --raised: #1E2228;
  --field-border: #6B727C;
  --good: #7FD99A; --good-bg: #16301F; --warn: #F3C969; --warn-bg: #3A2E10;
  --bad: #FF9D94;  --bad-bg: #3D1A18;
  --shadow-float: 0 12px 32px rgba(0,0,0,.5), 0 0 0 1px #2B2F36;
  color-scheme: dark;
}
:where(:root[data-theme="light"]) { color-scheme: light; }

/* 4. leagues.carbonyl.org compatibility: the names site.css reads today,
   pointed at the brand. Our own pages (body.svc) and admin (body.admin) only;
   a club's pages set their own --brand/--accent and never match these. */
body.svc, body.admin {
  --bg: var(--ground);
  --card: var(--raised);
  --text: var(--ink);
  --line: var(--rule);
  --brand: var(--accent);
  --brand-hover: var(--accent-hover);
  --on-brand: var(--accent-ink);
  --accent-strong: var(--accent);
  --on-accent: var(--accent-ink);
  --link: var(--accent);
  --link-dark: var(--accent);
  --font: var(--body);
  --heading-font: var(--body);
  --radius: var(--r-card, 6px);
  --r-sm: var(--r-control); --r-md: var(--r-control); --r-lg: var(--r-card, 6px);
  --shadow-sm: none; --shadow-md: none; --shadow-lg: var(--shadow-float);
}
/* --accent inside the product means "this page's brand colour". On our pages
   that is the Carbonyl blue; on a club's pages it is the club's, set in the
   club's page head after this file. */
