/* =========================================================================
 * Design tokens — the single source of truth for colour and type.
 *
 * Tokens are named by ROLE/FUNCTION (primary, accent, danger, surface...),
 * never by hue, so a future reskin (or user-controlled recolouring) only has
 * to reassign these variables. Nothing else in the stylesheet hard-codes a
 * colour literal — everything references var(--color-*).
 *
 * ---------------------------------------------------------------------------
 * THE PALETTE: "Dual Land"
 *
 * Scrubland is the Alpha W/B dual — Plains and Swamp on one piece of
 * cardboard. So the app is built from exactly those two materials, INK and
 * BONE, with GOLD LEAF as the only thing that is allowed to be bright. It is
 * the Orzhov reading of the name: ostentatious gilt laid over something that
 * is, at heart, a room where friends argue about jank. The pomp is the joke.
 *
 * Three consequences run through every rule below:
 *   1. There are no cold greys. Every neutral is warmed toward bone, so the
 *      whole app reads as aged paper and lampblack rather than #888.
 *   2. Gold is scarce. It marks the primary action, the rules, and the
 *      wordmark — nothing else. Scarcity is what makes it read as gold
 *      instead of yellow.
 *   3. Corners are CHAMFERED, never rounded (see --ch / --chamfer below).
 *      A 45° cut is the single most load-bearing deco cue we have.
 *
 * Hues that had to exist for FUNCTION (success, danger, phases) are chosen as
 * materials that belong in the same cathedral rather than stock UI colours:
 * verdigris for tarnished copper, carnelian for blood-red stone, lapis for
 * the blue, amethyst for the AI seats.
 * ========================================================================= */

:root {
  /* -- Type ---------------------------------------------------------------
   * Cinzel: Roman inscriptional capitals — lettering CUT INTO stone. Used
   * only in caps, only for the wordmark and section headers, always
   * letterspaced. Jost: a Futura descendant, i.e. the actual typeface of the
   * deco era, doing the unglamorous work of rendering deck lists at 12px. */
  --font-display: 'Cinzel', 'Trajan Pro', 'Times New Roman', serif;
  --font-body: 'Jost', system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Menlo, monospace;

  /* -- Deco geometry ------------------------------------------------------
   * --ch is the 45° corner cut. Every plate, button and input is clipped to
   * an octagon with this bite taken out of each corner (see .plate in
   * styles.css). Rounding any of them breaks the whole conceit, so there is
   * deliberately no --radius token to reach for. */
  --ch: 9px;          /* standard plate */
  --ch-sm: 5px;       /* buttons, inputs, chips */
  --ch-lg: 16px;      /* the masthead + hero plates */
  --chamfer: polygon(
    var(--ch) 0%, calc(100% - var(--ch)) 0%,
    100% var(--ch), 100% calc(100% - var(--ch)),
    calc(100% - var(--ch)) 100%, var(--ch) 100%,
    0% calc(100% - var(--ch)), 0% var(--ch));
  --chamfer-sm: polygon(
    var(--ch-sm) 0%, calc(100% - var(--ch-sm)) 0%,
    100% var(--ch-sm), 100% calc(100% - var(--ch-sm)),
    calc(100% - var(--ch-sm)) 100%, var(--ch-sm) 100%,
    0% calc(100% - var(--ch-sm)), 0% var(--ch-sm));
  --chamfer-lg: polygon(
    var(--ch-lg) 0%, calc(100% - var(--ch-lg)) 0%,
    100% var(--ch-lg), 100% calc(100% - var(--ch-lg)),
    calc(100% - var(--ch-lg)) 100%, var(--ch-lg) 100%,
    0% calc(100% - var(--ch-lg)), 0% var(--ch-lg));

  /* Native form controls (inputs, selects, scrollbars) follow the theme. */
  color-scheme: dark;

  /* -- Gold leaf ----------------------------------------------------------
   * Three golds, because real gilt is not one colour: the flat leaf, the lit
   * edge where it catches light, and the dim recess. --leaf-hair is the
   * hairline rule that separates everything from everything. */
  --color-leaf: #c9a227;
  --color-leaf-bright: #f0d878;
  --color-leaf-dim: #7d6417;
  --color-leaf-hair: rgba(201, 162, 39, 0.42);
  --color-leaf-glow: rgba(201, 162, 39, 0.22);

  /* -- Surfaces & background ---------------------------------------------- */
  --color-bg: #14110d;              /* app background — lampblack           */
  --color-bg-sunken: #0c0a07;       /* recessed areas (game panel)          */
  --color-surface: #1d1913;         /* raised plates/panels                  */
  --color-surface-raised: #262019;  /* zones sitting on a surface            */
  --color-surface-hover: #322a20;   /* hover wash on list rows               */

  /* -- Text --------------------------------------------------------------- */
  --color-text: #ece3d2;            /* default body text — bone             */
  --color-text-muted: #b9ab92;      /* section labels                       */
  --color-text-subtle: #90836f;     /* zone labels, secondary info          */
  --color-text-faint: #6f6353;      /* placeholders, empty states           */
  --color-text-dim: #574d40;        /* least-emphasis details               */

  /* -- Borders ------------------------------------------------------------ */
  --color-border: #3f3629;
  --color-border-strong: #5b4f3c;
  --color-border-soft: #2d261c;
  --color-border-subtle: #221c15;

  /* -- Primary action — GOLD LEAF ----------------------------------------- */
  --color-primary: #c9a227;
  --color-primary-hover: #e3bc44;
  --color-primary-border: #c9a227;
  --color-on-primary: #14110d;

  /* -- Neutral buttons ---------------------------------------------------- */
  --color-control: #262019;
  --color-control-hover: #342c21;
  --color-control-active: #43392b;
  --color-control-border: #5b4f3c;

  /* -- Danger / destructive — carnelian ----------------------------------- */
  --color-danger: #d97a66;
  --color-danger-hover: #e89a86;
  --color-danger-border: #d97a66;
  --color-on-danger: #1a0f0b;
  --color-danger-glow: rgba(217, 122, 102, 0.14);

  /* -- Status & feedback — verdigris (tarnished copper) -------------------
   * --color-success is the only status hue that is ever a FILL (the ready
   * button wipes to it), and that pulls it in the opposite direction from a
   * signal colour. A bright mint (#6fbf9a) hit 8.6:1 against ink — LOUDER
   * than the gold primary it wipes over, so "done" shouted over "act on me".
   * This is aged copper instead: low chroma, and deliberately quieter than
   * the leaf (5.1:1 vs 7.8:1), so the button calms down once you're ready.
   * Still clears 4.5:1 as text, which it also has to be (.chip-deck.ok).
   * --color-status-ok stays bright: it is only ever an 8px dot, and small
   * marks need the chroma to register at all. */
  --color-success: #5c8f7a;         /* deck OK, ready fill                  */
  --color-status-ok: #6fbf9a;       /* connected, ack — dots only           */
  --color-status-error: #d9614d;    /* errors                               */
  --color-status-error-bright: #f27a63;/* disconnected indicator            */
  --color-warning: #d9a441;         /* card counters                        */
  --color-warning-glow: rgba(217, 164, 65, 0.14);

  /* -- Accent / selection -------------------------------------------------
   * Deliberately HOTTER and purer than the leaf: gold is chrome (it never
   * moves), accent is interaction (selection, drop targets, arrows). Keeping
   * them one hue apart is what stops a selected card reading as decoration. */
  --color-accent: #ff9d2e;
  --color-accent-glow: rgba(255, 157, 46, 0.5);

  /* -- Header (inverse surface) ------------------------------------------- */
  --color-header-bg: #0c0a07;
  --color-header-text: #ece3d2;
  --color-header-text-dim: #90836f;

  /* -- Console / event log (inverse surface) ------------------------------ */
  --color-console-bg: #0c0a07;
  --color-console-header-bg: #1a1610;
  --color-console-text: #d8cfbe;
  --color-console-rule: #1a1610;
  --color-console-time: #6f6353;
  --color-console-type: #d9b64f;
  --color-console-scope: #90836f;
  --color-console-seq: #6fbf9a;
  --color-console-payload: #b9ab92;
  --color-console-pong: #574d40;

  /* -- AI players — amethyst ---------------------------------------------- */
  --color-ai: #9b87d4;
  --color-on-ai: #16111f;

  /* -- Replay (themed surface) — deep amethyst ---------------------------- */
  --color-replay-bg: #221a33;
  --color-replay-text: #ece3d2;
  --color-replay-label: #c9b3e6;
  --color-replay-progress: #90836f;
  --color-replay-control: #3d2f59;
  --color-replay-control-hover: #56417a;
  --color-replay-control-border: #2c2140;

  /* -- Zones (by function) — each a faint wash of its own material -------- */
  --color-zone-battlefield: #17201a;
  --color-zone-hand: #201c12;
  --color-zone-graveyard: #1c1915;
  --color-zone-exile: #1b1a24;
  --color-zone-stack: #241d12;
  --color-zone-stack-border: #5b4f2a;

  /* -- Turn phases (phase bar) --------------------------------------------
   * Four materials that stay legible side by side. `main` gets its own LAPIS
   * rather than inheriting --color-primary: primary is gold now, and a gold
   * main phase would be indistinguishable from the rail's own gilding. */
  --color-phase-beginning: #6fbf9a;   /* verdigris */
  --color-phase-main: #6d9fd4;        /* lapis     */
  --color-phase-combat: #d9614d;      /* carnelian */
  --color-phase-ending: #6fbf9a;      /* verdigris */

  /* -- Cards -------------------------------------------------------------- */
  --color-card-bg: #262019;
  --color-card-border: #6b5f4a;
  --color-card-border-hover: #d8cfbe;
  --color-card-facedown-bg: #2e2740;
  --color-card-facedown-text: #ece3d2;
  --color-card-facedown-border: #4c4166;
  --color-card-back-sheen: #4a3f66;   /* card-back gradient highlight */
  --color-card-token-border: #a88ab0;
  --color-card-own-border: #5da07f;
  --color-card-own-bg: #17241d;
  --color-card-annotation: #b9ab92;
  --color-card-attachment: #9a92c8;

  /* -- Misc surfaces ------------------------------------------------------ */
  --color-turn-info-bg: #221f18;
  --color-action-bar-bg: #1a160f;
  --color-badge-bg: #342c21;
  --color-overlay: rgba(12, 10, 7, 0.88);
  --color-tooltip-bg: #2d261c;
  --color-tooltip-text: #ece3d2;
  --color-menu-shadow: rgba(0, 0, 0, 0.62);
  --color-active-outline: #c9a227;

  /* -- Teams (lobby badges) ----------------------------------------------- */
  --color-team-a: #6d9fd4;
  --color-team-b: #d9614d;

  /* -- Modal scrim --------------------------------------------------------- */
  --color-scrim: rgba(8, 6, 4, 0.72);
}

/* =========================================================================
 * Light theme — activated by <html data-theme="light">.
 *
 * Not "the dark theme but inverted": it is the same two materials read in
 * daylight — ink ON bone rather than bone ON ink. Parchment, not #fff. The
 * gold has to go DARKER here (#8f6f14, not #c9a227) because bright leaf on
 * pale parchment is unreadable; it is the same metal, lit from a different
 * side. Only tokens are overridden; layout rules never change per theme.
 * ========================================================================= */
:root[data-theme="light"] {
  color-scheme: light;

  /* -- Gold leaf ----------------------------------------------------------- */
  --color-leaf: #8f6f14;
  --color-leaf-bright: #b8912a;
  --color-leaf-dim: #614907;   /* recessed gold — DARKER, as in dark theme */
  --color-leaf-hair: rgba(143, 111, 20, 0.38);
  --color-leaf-glow: rgba(143, 111, 20, 0.16);

  /* -- Surfaces & background ---------------------------------------------- */
  --color-bg: #e5dbc5;
  --color-bg-sunken: #d8cdb4;
  --color-surface: #f4ecdc;
  --color-surface-raised: #ebe1cd;
  --color-surface-hover: #ded2b8;

  /* -- Text --------------------------------------------------------------- */
  --color-text: #211b13;
  --color-text-muted: #4d4335;
  --color-text-subtle: #6d6152;
  --color-text-faint: #8c8070;
  --color-text-dim: #a89c8a;

  /* -- Borders ------------------------------------------------------------ */
  --color-border: #bcae94;
  --color-border-strong: #97886d;
  --color-border-soft: #d0c4a9;
  --color-border-subtle: #ded3bb;

  /* -- Primary action ----------------------------------------------------- */
  --color-primary: #8f6f14;
  --color-primary-hover: #a98422;
  --color-primary-border: #8f6f14;
  --color-on-primary: #f8f3e6;

  /* -- Neutral buttons ---------------------------------------------------- */
  --color-control: #ebe1cd;
  --color-control-hover: #ded2b8;
  --color-control-active: #cdbf9f;
  --color-control-border: #97886d;

  /* -- Danger / destructive ----------------------------------------------- */
  --color-danger: #a83a2c;
  --color-danger-hover: #8d2e22;
  --color-danger-border: #a83a2c;
  --color-on-danger: #f8f3e6;
  --color-danger-glow: rgba(168, 58, 44, 0.12);

  /* -- Status & feedback --------------------------------------------------
   * Darker than it looks like it should be: as the ready button's FILL it
   * carries bone text, and the old #3f7d5f only managed 4.4:1 against it —
   * a real miss. #356b52 clears both jobs (5.6:1 as fill, 5.3:1 as text). */
  --color-success: #356b52;
  --color-status-ok: #3f7d5f;
  --color-status-error: #a83a2c;
  --color-status-error-bright: #c0392b;
  --color-warning: #9a6b12;
  --color-warning-glow: rgba(154, 107, 18, 0.12);

  /* -- Accent / selection ------------------------------------------------- */
  --color-accent: #d97706;
  --color-accent-glow: rgba(217, 119, 6, 0.34);

  /* -- Header (inverse surface) ------------------------------------------- */
  --color-header-bg: #211b13;
  --color-header-text: #f4ecdc;
  --color-header-text-dim: #a89c8a;

  /* -- AI players --------------------------------------------------------- */
  --color-ai: #5c4b9e;
  --color-on-ai: #f4ecdc;

  /* -- Zones (by function) ------------------------------------------------ */
  --color-zone-battlefield: #dfe6d5;
  --color-zone-hand: #eee6cd;
  --color-zone-graveyard: #ddd6c6;
  --color-zone-exile: #dcdae6;
  --color-zone-stack: #f0e3c6;
  --color-zone-stack-border: #c4ab6b;

  /* -- Turn phases (phase bar) -------------------------------------------- */
  --color-phase-beginning: #3f7d5f;
  --color-phase-main: #3a6ea8;
  --color-phase-combat: #a83a2c;
  --color-phase-ending: #3f7d5f;

  /* -- Cards -------------------------------------------------------------- */
  --color-card-bg: #f8f3e6;
  --color-card-border: #97886d;
  --color-card-border-hover: #211b13;
  --color-card-facedown-bg: #4c4166;
  --color-card-facedown-text: #f4ecdc;
  --color-card-facedown-border: #2e2740;
  --color-card-back-sheen: #6b5c8f;
  --color-card-token-border: #8a6d95;
  --color-card-own-border: #3f7d5f;
  --color-card-own-bg: #e3ecdf;
  --color-card-annotation: #6d6152;
  --color-card-attachment: #5c5490;

  /* -- Misc surfaces ------------------------------------------------------ */
  --color-turn-info-bg: #e6dcc4;
  --color-action-bar-bg: #dcd1b7;
  --color-badge-bg: #ded2b8;
  --color-overlay: rgba(33, 27, 19, 0.9);
  --color-tooltip-bg: #211b13;
  --color-tooltip-text: #f4ecdc;
  --color-menu-shadow: rgba(66, 52, 26, 0.22);
  --color-active-outline: #8f6f14;

  /* -- Teams (lobby badges) ----------------------------------------------- */
  --color-team-a: #3a6ea8;
  --color-team-b: #a83a2c;

  /* -- Modal scrim --------------------------------------------------------- */
  --color-scrim: rgba(33, 27, 19, 0.5);
}
