/* ==========================================================================
   base.css: design tokens, fonts, reset, typography.

   Visual identity: a ruined castle overgrown with ivy.
   - Neutrals are weathered stone, from deep shadow to sunlit wall.
   - Text is parchment. The one interactive accent is tarnished gold,
     used for links, focus, primary actions and selection.
   - Semantic colors: ivy green = strength, rust red = weakness,
     ember = placeholder / caution.
   - Each game can set --game (see gameRegistry.js) to tint its own marks.
   - Type: Cinzel (carved Roman capitals) for headings and labels,
     EB Garamond for body text and numbers (lining, tabular figures).
     Both are SIL Open Font License fonts, self-hosted in assets/fonts.
   - Stone textures, crumbling wall edges and ivy live in theme.css.
   ========================================================================== */

@font-face {
  font-family: 'Cinzel';
  src: url('../fonts/Cinzel-Variable-Latin.woff2') format('woff2');
  font-weight: 400 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('../fonts/EBGaramond-Variable-Latin.woff2') format('woff2');
  font-weight: 400 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('../fonts/EBGaramond-Italic-Variable-Latin.woff2') format('woff2');
  font-weight: 400 800; font-style: italic; font-display: swap;
}

:root {
  color-scheme: dark;

  /* Stone, darkest to lightest */
  --bg-sunken: #0c0b09;
  --bg: #12110e;
  --surface: #1a1814;
  --surface-2: #23201b;
  --surface-3: #2e2a23;
  --line: #2f2b24;
  --line-strong: #463f33;

  /* Parchment text */
  --text: #ece2c9;
  --text-2: #bcae8f;
  --text-3: #85795f;

  /* Interactive accent: tarnished gold */
  --accent: #c9a45c;
  --accent-strong: #e0bf7a;
  --accent-ink: #1b150b;
  --accent-tint: rgba(201, 164, 92, 0.14);

  /* Meaning */
  --good: #8fae5e;
  --good-tint: rgba(143, 174, 94, 0.14);
  --bad: #c4603f;
  --bad-tint: rgba(196, 96, 63, 0.14);
  --warn: #d79a4a;
  --warn-tint: rgba(215, 154, 74, 0.13);

  /* Ivy (ornaments) */
  --ivy: #5d7a3e;
  --ivy-dark: #3c5228;
  --ivy-light: #86a35a;

  /* Per-game tint (overridden per game) */
  --game: #c9a45c;

  /* Type */
  --font-body: 'EB Garamond', 'Garamond', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --font-display: 'Cinzel', 'Trajan Pro', 'Optima', 'Palatino Linotype', Georgia, serif;
  --font-mono: var(--font-body);

  --fs-xs: 0.8125rem;   /* 13 */
  --fs-sm: 0.9375rem;   /* 15 */
  --fs-md: 1.0625rem;   /* 17 */
  --fs-lg: 1.25rem;     /* 20 */
  --fs-xl: 1.625rem;    /* 26 */
  --fs-2xl: clamp(2rem, 3.8vw, 2.875rem);

  /* Geometry: 4px spacing grid */
  --r-sm: 2px;
  --r: 3px;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  /* Component dimensions */
  --control-h: 34px;
  --control-h-sm: 28px;
  --header-h: 58px;
  --container: 1320px;
  --sec-pad: 16px;   /* padding inside workspace sections */
  --row-gap: 8px;    /* vertical rhythm inside lists */
}

:root[data-density='compact'] {
  --sec-pad: 12px;
  --row-gap: 4px;
  --control-h: 28px;
}

/* Short UI transitions. Users can turn motion off in Settings. */
:root { --t: 140ms; }
@media (prefers-reduced-motion: reduce) { :root { --t: 0ms; } }
:root[data-reduce-motion='true'] { --t: 0ms; }

/* ----- Reset ----- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.5;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; font-family: var(--font-display); font-weight: 700; letter-spacing: 0.02em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }
::selection { background: var(--accent-tint); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* ----- Type helpers ----- */
.label {
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.num, .mono { font-family: var(--font-body); font-variant-numeric: lining-nums tabular-nums; }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; padding: 6px 10px; background: var(--surface-3); color: var(--text); }
.skip-link:focus { left: 8px; }
