/* =============================================================
   Chess Sprint A — globals.css
   Adopted from ~/designs/penumbra (dark-only). Plain CSS, no build step.
   Every color in the project traces back to a token in this file.
   Rules for applying these tokens live in ../style.md.
   ============================================================= */

/* Fonts — loaded via the preconnect + <link> tags in index.html <head>
   (the faster equivalent documented in style.md > Typography > Fonts). */

:root {
  color-scheme: dark;

  /* -----------------------------------------------------------
     Semantic tokens (shadcn-style names) — mapped to Penumbra
     ----------------------------------------------------------- */
  --background: #08080a;            /* Obsidian */
  --foreground: #f4f4f5;            /* Vellum */
  --card: #101013;                  /* Graphite */
  --card-foreground: #f4f4f5;
  --popover: #1b1b21;               /* surface-raised: menus, dialogs, banner */
  --popover-foreground: #f4f4f5;
  --primary: #e8e5dc;               /* Beacon warm-white: the ONE primary action */
  --primary-hover: #ffffff;
  --primary-foreground: #08080a;
  --secondary: #101013;             /* secondary button hover fill (rests transparent) */
  --secondary-foreground: #f4f4f5;
  --accent: #1b1b21;                /* NOT chromatic — Penumbra has no chromatic accent; hover/raised fill */
  --accent-foreground: #f4f4f5;
  --muted: #17171c;                 /* Slate: inset wells, inputs */
  --muted-foreground: #9ba0ab;      /* Moonstone */
  --destructive: #e47c7c;           /* pack error */
  --destructive-foreground: #08080a;
  --border: #23232a;                /* Hairline */
  --input: #23232a;                 /* input border (hairline) */
  --ring: #e8e5dc;                  /* focus = Beacon */
  --radius: 10px;                   /* = --radius-md, cards and panels */

  /* -----------------------------------------------------------
     Penumbra pack tokens (verbatim names and values)
     ----------------------------------------------------------- */
  /* Surfaces */
  --color-background: #08080a;
  --color-surface: #101013;
  --color-surface-inset: #17171c;
  --color-surface-raised: #1b1b21;

  /* Borders */
  --color-border: #23232a;
  --color-border-strong: #2e2e36;

  /* Foreground */
  --color-neutral: #f4f4f5;
  --color-on-surface: #f4f4f5;
  --color-on-surface-muted: #9ba0ab;  /* pack "secondary" */
  --color-on-surface-faint: #5c6068;  /* pack "tertiary" */

  /* Accent */
  --color-primary: #e8e5dc;
  --color-primary-hover: #ffffff;
  --color-on-primary: #08080a;
  --color-focus: #e8e5dc;
  --color-focus-ring: rgba(232, 229, 220, 0.18);
  --color-focus-glow: rgba(232, 229, 220, 0.08);

  /* Feedback */
  --color-error: #e47c7c;
  --color-success: #b6c9a8;

  /* Typography — families */
  --font-display: "Instrument Serif", "Cormorant Garamond", Georgia, serif;
  --font-ui: "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  --font-serif: var(--font-display);
  --font-sans: var(--font-ui);

  /* Typography — sizes (pack scale) */
  --text-display-xl: 72px;
  --text-display-lg: 56px;
  --text-headline-lg: 40px;
  --text-headline-md: 28px;
  --text-title-md: 18px;
  --text-body-md: 15px;
  --text-body-sm: 13px;
  --text-label-sm: 12px;
  --text-eyebrow: 11px;
  --text-mono-sm: 12px;

  /* Typography — line heights (pack scale) */
  --leading-display-xl: 1.02;
  --leading-display-lg: 1.05;
  --leading-headline-lg: 1.1;
  --leading-headline-md: 1.15;
  --leading-title-md: 1.35;
  --leading-body-md: 1.55;
  --leading-body-sm: 1.5;
  --leading-label-sm: 1.3;
  --leading-eyebrow: 1.2;
  --leading-mono-sm: 1.45;

  /* Typography — tracking (pack scale) */
  --tracking-display: -0.02em;
  --tracking-headline: -0.01em;
  --tracking-title: -0.005em;
  --tracking-label: 0.02em;
  --tracking-eyebrow: 0.16em;

  /* Typography — weights */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Typography — project extensions (sizes reuse pack scale steps; see style.md) */
  --text-input: 16px;               /* override: pack 15px; iOS Safari focus-zoom floor */
  --text-input-editor: 18px;        /* override: mobile UX guide §6, lobby form fields */
  --text-clock: 28px;               /* = headline-md size, set in mono */
  --leading-clock: 1;
  --text-move: 13px;                /* = body-sm size, set in mono */
  --leading-move: 1.5;

  /* Spacing scale (4px base) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  --space-4xl: 72px;
  --space-section: 48px;            /* mobile-first; 96px at >=769px (below) */
  --space-gutter: 24px;

  /* Radii */
  --radius-none: 0;
  --radius-xs: 2px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 999px;

  /* Borders */
  --border-hairline: 1px solid var(--color-border);
  --border-strong: 1px solid var(--color-border-strong);
  --border-focus: 1px solid var(--color-focus);
  --border-destructive: 1px solid var(--destructive);
  --border-primary: 1px solid rgba(255, 255, 255, 0.12);  /* pack .btn-primary border */

  /* Elevation */
  --elevation-flat: none;
  --elevation-inset-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --elevation-raised: inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 8px 30px rgba(0, 0, 0, 0.45);
  --elevation-glow: 0 0 0 6px var(--color-focus-glow);
  --elevation-raised-drop: drop-shadow(0 8px 30px rgba(0, 0, 0, 0.45)); /* raised, as a filter (for SVG drag ghost) */

  /* Layout */
  --container-max: 1120px;
  --container-narrow: 720px;
  --page-max: 1200px;               /* pack: page never exceeds 1200px */
  --sidebar-width: 360px;           /* game side column at >=1024px */

  /* Interactive sizing — UX doctrine (hybrid: touch wins on sizing) */
  --control-height: 44px;           /* override: pack 40px */
  --control-height-sm: 44px;        /* override: pack 32px; no sub-44 controls on a hybrid surface */
  --tap-min: 44px;                  /* absolute floor for any tappable */
  --tap-gap: 12px;                  /* absolute floor between adjacent tappables (= --space-md) */
  --icon-button: 44px;              /* icon-only target, not the glyph */

  /* Motion */
  --transition-fast: 120ms ease;
  --transition-base: 180ms ease;
  --transition-slow: 260ms ease;

  /* -----------------------------------------------------------
     Board tokens — project-specific, derived from Penumbra values
     (no new hues). Contrast math in style.md > Board Tokens.
     ----------------------------------------------------------- */
  --board-light: #cdcac3;           /* Beacon #E8E5DC shaded 12% toward Obsidian */
  --board-dark: #6f737c;            /* Faint #5C6068 tinted 30% toward Moonstone #9BA0AB */
  --board-selected: rgba(8, 8, 10, 0.85);    /* Obsidian 85% — 3px inset RING */
  --board-target: rgba(8, 8, 10, 0.72);      /* Obsidian 72% — centered DOT / capture CIRCLE */
  --board-last: rgba(158, 156, 150, 0.6);    /* Beacon shaded to 68% — full-square WASH */
  --board-check: rgba(228, 124, 124, 0.75);  /* --destructive at 75% — king-square WASH + label */
  --board-hover: rgba(255, 255, 255, 0.12);  /* pointer hover on a movable piece (desktop) */
  --board-focus: var(--ring);                /* keyboard focus: outer 2px Beacon + inner 2px Obsidian */
  --board-focus-inner: #08080a;
  --board-coord-on-light: #2e2e36;  /* coordinates on light squares (8.2:1) */
  --board-coord-on-dark: #ffffff;   /* coordinates on dark squares (4.8:1) */
  --board-coord-on-wash: #08080a;   /* coords on last-move/check washes: 5.9:1 (last-dark), 6:1 (check-dark), higher on light */
  --player-bar-min: 56px;           /* player-bar height; used in the board viewport-fit cap */
  --board-max: 640px;               /* board edge cap; square = board / 8, max 80px */
  --board-square-min: 44px;         /* tap floor for a square; board full-bleed below 768px */
  --board-radius: var(--radius-md); /* --radius-none when full-bleed below 768px */

  /* Pieces */
  --piece-light: #f4f4f5;           /* white pieces fill (Vellum) */
  --piece-dark: #08080a;            /* black pieces fill (Obsidian) */
  --piece-outline: #08080a;         /* 1px outline on white pieces — carries contrast on light squares */
}

/* Mobile-first breakpoints (pack breakpoint is 768px) */
@media (min-width: 769px) {
  :root {
    --space-section: 96px;
  }
}

@media (max-width: 767px) {
  :root {
    --board-radius: var(--radius-none);
  }
}

/* .dark — not applicable: Penumbra is a dark-only system; :root IS the dark theme. */

/* -------------------------------------------------------------
   Base (element defaults only — components are built elsewhere)
   ------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background-color: var(--background);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-body-md);
  line-height: var(--leading-body-md);
  color: var(--foreground);
  background-color: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

::selection {
  background: var(--primary);
  color: var(--primary-foreground);
}

:focus-visible {
  outline: 1px solid var(--ring);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
