/*
  SignCourt theme tokens and base - v0.2 "Hardwood and Scoreboard" direction
  (see DESIGN.md). Saturated maple-court field, near-black scoreboard plates
  with amber readouts, condensed athletic display type. Four theme layers:
  light (game day), dark (arena night), and a high-contrast variant of each.
  All body-text pairs hold 7:1 or better (WCAG AAA); checked by script, see
  DESIGN.md contrast table. No em dashes or curly quotes anywhere.
*/

:root {
  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Radii: tighter than v0.1, a harder athletic edge */
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Type: condensed athletic display over a plain readable body sans.
     No Space Grotesk, Inter, or Roboto anywhere. */
  --font-display: "Avenir Next Condensed", "Arial Narrow", "Helvetica Neue Condensed", "Franklin Gothic Medium", Impact, Arial, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;

  /* Light theme (default): "game day" lacquered maple */
  --bg: #f2ddae;
  --bg-elevated: #f8e9c4;
  --bg-sunken: #e7cd95;
  --ink: #241505;
  --ink-soft: #4d3714;
  --line: #8a6a33;
  --line-soft: #c4a86b;
  --link: #6e3400;
  --plate: #181008;
  --plate-ink: #ffb52e;
  --plate-soft: #e8d5ae;
  --plate-edge: rgba(255, 181, 46, 0.4);
  --amber: #ffb52e;
  --amber-ink: #241505;
  --success-bg: #dfeedb;
  --success-ink: #1d5230;
  --error-bg: #f7dbd2;
  --error-ink: #8c1c0e;
  --focus-ring: #1444c9;
  --shadow: 0 2px 8px rgba(36, 21, 5, 0.16);
  --plank-line: rgba(110, 70, 10, 0.07);
  --plank-sheen: rgba(255, 250, 230, 0.16);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161009;
    --bg-elevated: #221a10;
    --bg-sunken: #0d0a05;
    --ink: #f6e9c5;
    --ink-soft: #d3bd8d;
    --line: #6f5a33;
    --line-soft: #453722;
    --link: #ffc65e;
    --plate: #181008;
    --plate-ink: #ffb52e;
    --plate-soft: #e8d5ae;
    --plate-edge: rgba(255, 181, 46, 0.5);
    --amber: #ffb52e;
    --amber-ink: #241505;
    --success-bg: #14351f;
    --success-ink: #a8e0b4;
    --error-bg: #3d150c;
    --error-ink: #f5b4a5;
    --focus-ring: #6fb1ff;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    --plank-line: rgba(255, 220, 150, 0.035);
    --plank-sheen: rgba(255, 235, 190, 0.02);
  }
}

:root[data-theme="light"] {
  --bg: #f2ddae;
  --bg-elevated: #f8e9c4;
  --bg-sunken: #e7cd95;
  --ink: #241505;
  --ink-soft: #4d3714;
  --line: #8a6a33;
  --line-soft: #c4a86b;
  --link: #6e3400;
  --plate: #181008;
  --plate-ink: #ffb52e;
  --plate-soft: #e8d5ae;
  --plate-edge: rgba(255, 181, 46, 0.4);
  --amber: #ffb52e;
  --amber-ink: #241505;
  --success-bg: #dfeedb;
  --success-ink: #1d5230;
  --error-bg: #f7dbd2;
  --error-ink: #8c1c0e;
  --focus-ring: #1444c9;
  --shadow: 0 2px 8px rgba(36, 21, 5, 0.16);
  --plank-line: rgba(110, 70, 10, 0.07);
  --plank-sheen: rgba(255, 250, 230, 0.16);
}

:root[data-theme="dark"] {
  --bg: #161009;
  --bg-elevated: #221a10;
  --bg-sunken: #0d0a05;
  --ink: #f6e9c5;
  --ink-soft: #d3bd8d;
  --line: #6f5a33;
  --line-soft: #453722;
  --link: #ffc65e;
  --plate: #181008;
  --plate-ink: #ffb52e;
  --plate-soft: #e8d5ae;
  --plate-edge: rgba(255, 181, 46, 0.5);
  --amber: #ffb52e;
  --amber-ink: #241505;
  --success-bg: #14351f;
  --success-ink: #a8e0b4;
  --error-bg: #3d150c;
  --error-ink: #f5b4a5;
  --focus-ring: #6fb1ff;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  --plank-line: rgba(255, 220, 150, 0.035);
  --plank-sheen: rgba(255, 235, 190, 0.02);
}

/* High contrast: a visible product feature (see the display toolbar).
   Pushes text toward 21:1, kills the wood texture, thickens borders. */
:root[data-contrast="high"] {
  --bg: #fffdf4;
  --bg-elevated: #ffffff;
  --bg-sunken: #f4efdd;
  --ink: #000000;
  --ink-soft: #1c1200;
  --line: #000000;
  --line-soft: #4d4d4d;
  --link: #0000c7;
  --plate: #000000;
  --plate-ink: #ffc10a;
  --plate-soft: #ffffff;
  --plate-edge: #ffc10a;
  --amber: #ffc10a;
  --amber-ink: #000000;
  --success-bg: #ffffff;
  --success-ink: #04530f;
  --error-bg: #ffffff;
  --error-ink: #a80000;
  --focus-ring: #0000c7;
  --shadow: none;
  --plank-line: transparent;
  --plank-sheen: transparent;
}

@media (prefers-color-scheme: dark) {
  :root[data-contrast="high"]:not([data-theme="light"]) {
    --bg: #000000;
    --bg-elevated: #0d0d0d;
    --bg-sunken: #000000;
    --ink: #ffffff;
    --ink-soft: #f2e8cf;
    --line: #ffffff;
    --line-soft: #bfbfbf;
    --link: #ffd54a;
    --plate: #000000;
    --plate-ink: #ffd54a;
    --plate-soft: #ffffff;
    --plate-edge: #ffd54a;
    --amber: #ffd54a;
    --amber-ink: #000000;
    --success-bg: #000000;
    --success-ink: #7dffa0;
    --error-bg: #000000;
    --error-ink: #ffb3a6;
    --focus-ring: #6fb1ff;
    --shadow: none;
    --plank-line: transparent;
    --plank-sheen: transparent;
  }
}

:root[data-contrast="high"][data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #0d0d0d;
  --bg-sunken: #000000;
  --ink: #ffffff;
  --ink-soft: #f2e8cf;
  --line: #ffffff;
  --line-soft: #bfbfbf;
  --link: #ffd54a;
  --plate: #000000;
  --plate-ink: #ffd54a;
  --plate-soft: #ffffff;
  --plate-edge: #ffd54a;
  --amber: #ffd54a;
  --amber-ink: #000000;
  --success-bg: #000000;
  --success-ink: #7dffa0;
  --error-bg: #000000;
  --error-ink: #ffb3a6;
  --focus-ring: #6fb1ff;
  --shadow: none;
  --plank-line: transparent;
  --plank-sheen: transparent;
}

/* Text size steps, set from the display toolbar. Everything below the root
   is sized in rem/em so these scale the whole app, not just paragraphs. */
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
html[data-textsize="lg"] { font-size: 112.5%; }
html[data-textsize="xl"] { font-size: 125%; }
html[data-textsize="xxl"] { font-size: 150%; }

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
/* The hidden attribute must always win, even against display rules like
   .btn's inline-flex; without this, "hidden" buttons stay visible. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background-color: var(--bg);
  /* Plank seams: one faint vertical seam per "board" plus a soft sheen.
     Deliberately quiet (texture restraint); removed entirely in high
     contrast via transparent tokens. */
  background-image:
    repeating-linear-gradient(90deg, var(--plank-line) 0 1px, transparent 1px 112px),
    linear-gradient(180deg, var(--plank-sheen), transparent 320px);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  transition: background-color 0.2s ease, color 0.2s ease;
}

img, svg { max-width: 100%; display: block; }
ul, ol { padding-left: 1.25em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
a:hover, a:focus { color: var(--ink); }

/* Scoreboard-inspired display type: heavy, condensed, uppercase, tracked. */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1.12;
  margin: 0 0 var(--space-3);
  color: var(--ink);
}
h1 { font-size: clamp(2.1rem, 1.5rem + 2.4vw, 3.2rem); letter-spacing: 0.035em; }
h2 { font-size: clamp(1.45rem, 1.2rem + 1vw, 2rem); letter-spacing: 0.045em; }
h3 { font-size: 1.22rem; letter-spacing: 0.05em; }
p { margin: 0 0 var(--space-4); }

/* Motion: subtle, and off both for the OS preference and for the in-app
   "Reduce motion" toolbar toggle (data-motion="reduced" on the root). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* Focus visibility, never suppressed */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
:root[data-contrast="high"] :focus-visible {
  outline-width: 4px;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -100px;
  background: var(--plate);
  color: var(--plate-ink);
  border: 2px solid var(--plate-edge);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  z-index: 100;
  text-decoration: none;
  font-weight: 700;
}
.skip-link:focus {
  top: var(--space-3);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
