/* ============================================================
   Wooden — design tokens
   Every colour, size, radius, shadow, texture and motion value
   lives here. Component sheets in styles/ reference these only.
   Copy this whole :root block into a game's styles.css.
   Fonts: copy assets/fonts/ into the game and link its fonts.css
   before styles.css (this file imports it for the kit and cards).
   ============================================================ */

:root {
  /* ── Parchment ramp (page + light surfaces) ────────────── */
  --parchment-50:  #FCF8EF;
  --parchment-100: #F6EDD6;   /* page background */
  --parchment-200: #EEE0BF;
  --parchment-300: #E3CFA4;
  --parchment-400: #D3B986;

  /* ── Wood ramp (frames, dark surfaces, primary buttons) ── */
  --wood-200: #D5B07C;   /* pale oak */
  --wood-300: #BE9358;
  --wood-400: #A3773F;
  --wood-500: #86592C;
  --wood-600: #68421E;
  --wood-700: #4E3017;   /* primary button, frame */
  --wood-800: #3A2210;   /* dark sheet / modal */
  --wood-900: #26150A;

  /* ── Ink ramp (text on parchment) ──────────────────────── */
  --ink-900: #2A170A;   /* headings, numbers */
  --ink-700: #4A2E16;   /* body */
  --ink-500: #6E4D2E;   /* secondary, 6.5:1 on parchment-100 */
  --ink-400: #7A5A3B;   /* muted labels, 5:1 on parchment-100 */

  /* ── Cream (text on wood) ──────────────────────────────── */
  --cream-100: #FBF6EA;
  --cream-300: #EBDDBF;
  --cream-500: #CDB890;   /* muted text on wood-800 */

  /* ── Gold (reward, selection, current turn) ────────────── */
  --gold-200: #F0DC8C;
  --gold-300: #E3C65B;
  --gold-500: #C9A227;
  --gold-700: #7E6310;   /* gold text/accents on light, 4.9:1 on parchment-100 */

  /* ── Semantic ──────────────────────────────────────────── */
  --success-500: #3C7A4A;   /* legal move, win */
  --success-700: #2F6B3F;   /* success text, 5.5:1 */
  --success-100: #DCEBD7;
  --warning-500: #B5741A;
  --warning-700: #8F5A0E;   /* warning text */
  --warning-100: #F6E3C0;
  --danger-500:  #B5402F;
  --danger-700:  #A3362A;   /* danger text, 5.8:1 */
  --danger-100:  #F3D7D0;

  /* ── Piece colours ─────────────────────────────────────── */
  --piece-light:       #ECD9B4;
  --piece-light-edge:  #B6925E;
  --piece-dark:        #5A3A1E;
  --piece-dark-edge:   #2A170A;
  --piece-light-rim:   var(--wood-500);   /* opaque perimeter, 3.6:1 on --cell-hex */

  /* ── Semantic aliases (use these in components) ────────── */
  --bg:               var(--parchment-100);
  --bg-sunken:        var(--parchment-200);
  --surface:          var(--parchment-50);     /* cards, sheets */
  --surface-raised:   #FFFDF7;
  --surface-dark:     var(--wood-800);         /* modal, dark sheet */
  --fg:               var(--ink-700);
  --fg-strong:        var(--ink-900);
  --fg-muted:         var(--ink-400);
  --fg-on-dark:       var(--cream-100);
  --fg-on-dark-muted: var(--cream-500);
  --fg-on-accent:     var(--cream-100);
  --accent:           var(--wood-700);         /* primary action */
  --accent-hover:     var(--wood-600);
  --accent-active:    var(--wood-800);
  --highlight:        var(--gold-500);         /* selection, turn */
  --border:           rgba(74, 46, 22, 0.18);
  --border-strong:    rgba(74, 46, 22, 0.34);
  --border-on-dark:   rgba(251, 246, 234, 0.16);
  --tint:             rgba(134, 89, 44, 0.08);  /* hover wash */
  --tint-strong:      rgba(134, 89, 44, 0.16);  /* active wash */
  --focus-ring:       0 0 0 3px var(--parchment-100), 0 0 0 5px var(--gold-700);
  --focus-ring-inset: inset 0 0 0 3px var(--gold-700);   /* inside clipped groups */
  --focus-cell:       inset 0 0 0 3px var(--gold-300), inset 0 0 0 6px var(--wood-900);   /* board cell: gold vs board, walnut vs maple */
  --focus-ring-dark:  0 0 0 3px var(--wood-800), 0 0 0 5px var(--gold-300);
  --scrim:            rgba(38, 21, 10, 0.62);

  /* ── Translucent washes (bevels, grain, highlights) ────── */
  --shade-faint:        rgba(38, 21, 10, 0.08);
  --shade-soft:         rgba(38, 21, 10, 0.18);
  --shade-mid:          rgba(38, 21, 10, 0.3);
  --shade-strong:       rgba(38, 21, 10, 0.5);
  --line-dark:          rgba(38, 21, 10, 0.4);
  --line-light:         rgba(255, 240, 210, 0.16);
  --sheen-faint:        rgba(255, 250, 240, 0.12);
  --sheen-soft:         rgba(255, 250, 240, 0.3);
  --sheen-strong:       rgba(255, 250, 240, 0.55);
  --gloss:              rgba(255, 255, 255, 0.45);
  --tint-light:         rgba(255, 253, 247, 0.5);
  --tint-on-dark:       rgba(251, 246, 234, 0.08);
  --tint-on-dark-strong: rgba(251, 246, 234, 0.16);
  --gold-wash:          rgba(201, 162, 39, 0.3);
  --gold-ring:          rgba(201, 162, 39, 0.55);

  /* ── Board states ──────────────────────────────────────── */
  --cell-light:        #E5CFA3;
  --cell-dark:         #B08754;
  --cell-hex:          #DFC79A;
  --cell-legal:        rgba(60, 122, 74, 0.55);
  --cell-legal-dot:    var(--success-500);
  --cell-last:         rgba(201, 162, 39, 0.42);
  --cell-selected:     var(--gold-500);
  --cell-capture:      rgba(181, 64, 47, 0.5);
  --cell-hover:        rgba(255, 253, 247, 0.28);

  /* ── Material textures (self-contained, copy as-is) ────── */
  --texture-grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='0.014 0.42' numOctaves='3' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.5 0'/></filter><rect width='180' height='180' filter='url(%23g)'/></svg>");
  --texture-paper: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.3  0 0 0 0 0.18  0 0 0 0 0.06  0 0 0 0.09 0'/></filter><rect width='120' height='120' filter='url(%23p)'/></svg>");
  --wood-sheen: linear-gradient(100deg, rgba(255, 245, 220, 0.16), rgba(255, 245, 220, 0) 38%, rgba(38, 21, 10, 0.18) 100%);
  --surface-wood:        var(--texture-grain), var(--wood-sheen), linear-gradient(180deg, var(--wood-600), var(--wood-700));
  --surface-wood-dark:   var(--texture-grain), var(--wood-sheen), linear-gradient(180deg, var(--wood-800), var(--wood-900));
  --surface-wood-light:  var(--texture-grain), linear-gradient(180deg, var(--wood-200), var(--wood-300));
  --surface-parchment:   var(--texture-paper), linear-gradient(180deg, var(--parchment-50), var(--parchment-100));
  --bevel-wood:   inset 0 1px 0 rgba(255, 240, 210, 0.22), inset 0 -2px 0 rgba(38, 21, 10, 0.45), inset 0 0 0 1px rgba(38, 21, 10, 0.35);
  --bevel-inlay:  inset 0 2px 4px rgba(38, 21, 10, 0.35), inset 0 -1px 0 rgba(255, 245, 220, 0.25);

  /* ── Icons used by component sheets (data URIs, copy as-is; crown = bespoke king inlay) ── */
  --icon-crown: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M3 8.5 7.2 12 12 5l4.8 7L21 8.5 19.2 18H4.8z'/><rect x='4.8' y='19.2' width='14.4' height='2.2' rx='1'/></svg>");
  /* Hex cell focus ring = --focus-cell drawn as a hex (gold-300 outer band, wood-900 inner band) */
  --focus-hex: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 86.6 100' fill='none'><polygon points='43.3,0 86.6,25 86.6,75 43.3,100 0,75 0,25' stroke='%2326150A' stroke-width='24'/><polygon points='43.3,0 86.6,25 86.6,75 43.3,100 0,75 0,25' stroke='%23E3C65B' stroke-width='12'/></svg>");
  --icon-chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' fill='%234A2E16'><path d='M208,96l-80,80L48,96Z' opacity='0.2'/><path d='M215.39,92.94A8,8,0,0,0,208,88H48a8,8,0,0,0-5.66,13.66l80,80a8,8,0,0,0,11.32,0l80-80A8,8,0,0,0,215.39,92.94ZM128,164.69,67.31,104H188.69Z'/></svg>");   /* Phosphor caret-down, ink-700 */

  /* ── Spacing (4px rhythm) ──────────────────────────────── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --gutter:  16px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* ── Radii ─────────────────────────────────────────────── */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --radius-round: 50%;

  /* ── Elevation (warm-tinted) ───────────────────────────── */
  --shadow-1: 0 1px 2px rgba(42, 23, 10, 0.12), 0 1px 1px rgba(42, 23, 10, 0.06);
  --shadow-2: 0 2px 6px rgba(42, 23, 10, 0.14), 0 1px 2px rgba(42, 23, 10, 0.08);
  --shadow-3: 0 8px 20px rgba(42, 23, 10, 0.18), 0 2px 6px rgba(42, 23, 10, 0.10);
  --shadow-4: 0 20px 48px rgba(42, 23, 10, 0.32), 0 6px 14px rgba(42, 23, 10, 0.16);
  --shadow-piece: 0 2px 2px rgba(42, 23, 10, 0.25), 0 6px 10px rgba(42, 23, 10, 0.22);
  --shadow-piece-lift: 0 6px 6px rgba(42, 23, 10, 0.25), 0 16px 24px rgba(42, 23, 10, 0.28);
  --glow-gold: 0 0 0 3px rgba(201, 162, 39, 0.35), 0 0 18px rgba(201, 162, 39, 0.45);

  /* ── Typography (fonts in assets/fonts/, OFL) ───────────── */
  --font-display: "Alegreya", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-ui: "Alegreya Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Alegreya Sans runs small (low x-height), so the UI steps sit 1px above a system-sans scale. */
  --fs-2xs:  0.75rem;    /* 12 — counters */
  --fs-xs:   0.8125rem;  /* 13 — eyebrows, captions */
  --fs-sm:   0.9375rem;  /* 15 — secondary, buttons sm */
  --fs-md:   1.0625rem;  /* 17 — body, buttons */
  --fs-lg:   1.1875rem;  /* 19 — status line */
  --fs-xl:   1.5rem;     /* 24 — panel titles */
  --fs-2xl:  1.875rem;   /* 30 — modal titles, scores */
  --fs-3xl:  2.5rem;     /* 40 — hero / result */
  --fs-display: clamp(2rem, 1.4rem + 2.6vw, 3rem);

  /* Alegreya is variable (400–800); Alegreya Sans ships 400/500/700, so 600 renders as 700. */
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-display: 800;     /* display + result titles */

  --lh-tight: 1.1;
  --lh-snug: 1.3;
  --lh-body: 1.5;

  --tracking-caps: 0.1em;
  --tracking-display: -0.005em;
  --num-tabular: tabular-nums lining-nums;   /* every digit that must line up */

  /* ── Sizes ─────────────────────────────────────────────── */
  --control-h: 44px;       /* touch target */
  --control-h-sm: 36px;
  --control-h-lg: 52px;
  --appbar-h: 56px;
  --icon-size: 22px;
  --icon-size-sm: 18px;
  --icon-size-xs: 16px;
  --icon-size-lg: 32px;
  --icon-size-xl: 64px;
  --piece-inline: 22px;
  --piece-inline-sm: 16px;
  --switch-w: 52px;
  --switch-h: 30px;
  --switch-knob: 22px;
  --drawer-w: min(360px, 88vw);
  --modal-w: 440px;
  --modal-w-wide: 640px;
  --toast-w: 420px;
  --board-max: 560px;
  --content-max: 960px;

  /* ── Motion ────────────────────────────────────────────── */
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
}

/* ============================================================
   Base
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface-parchment) fixed;
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--gold-200); color: var(--ink-900); }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); }

@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;
  }
}

/* ============================================================
   Icons — assets/icons/ui (Phosphor duotone) and assets/icons/game
   (Kenney CC0 silhouettes + Phosphor). All paint with currentColor:
   set `color` to tint, use the size modifiers.
   ============================================================ */

.icon {
  width: var(--icon-size);
  height: var(--icon-size);
  flex: none;
  fill: currentColor;
  vertical-align: middle;
}
.icon--sm { width: var(--icon-size-sm); height: var(--icon-size-sm); }
.icon--xs { width: var(--icon-size-xs); height: var(--icon-size-xs); }
.icon--lg { width: var(--icon-size-lg); height: var(--icon-size-lg); }
.icon--xl { width: var(--icon-size-xl); height: var(--icon-size-xl); }
.sprite { display: none; }

/* ============================================================
   Type roles
   ============================================================ */

.t-display {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: var(--fw-display);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-display);
  color: var(--fg-strong);
  margin: 0;
}

.t-title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-snug);
  color: var(--fg-strong);
  margin: 0;
}

.t-heading {
  font-family: var(--font-ui);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  color: var(--fg-strong);
  margin: 0;
}

.t-eyebrow {
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0;
}

.t-body { font-size: var(--fs-md); color: var(--fg); margin: 0; }
.t-small { font-size: var(--fs-sm); color: var(--fg-muted); margin: 0; }

.t-num {
  font-family: var(--font-ui);
  font-weight: var(--fw-bold);
  font-variant-numeric: var(--num-tabular);
  color: var(--fg-strong);
}

.t-score {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  line-height: 1;
  font-variant-numeric: var(--num-tabular);
  color: var(--fg-strong);
}

.t-link {
  color: var(--wood-600);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--border-strong);
}
@media (hover: hover) { .t-link:hover { text-decoration-color: currentColor; } }

.on-dark { color: var(--fg-on-dark); }
.on-dark .t-eyebrow, .on-dark .t-small { color: var(--fg-on-dark-muted); }
.on-dark .t-display, .on-dark .t-title, .on-dark .t-heading, .on-dark .t-num, .on-dark .t-score { color: var(--fg-on-dark); }
.on-dark :focus-visible { box-shadow: var(--focus-ring-dark); }
