/* Design tokens (docs/UI_PLAN.md §2.1). Loaded first on every page.

   Cascade layers, lowest priority first:
   - base:       tokens and element defaults (fonts, link colour, focus ring). The old
                 sheets can still override these.
   - legacy:     the old stylesheets (main.css, buttons.css, ...), retired page by page.
   - components: shared components; they beat legacy rules whatever the specificity.
   - pages:      page-specific styles.
   - utilities:  one-purpose helpers.
   Inline style="" attributes and unlayered <style> blocks still beat all of these.

   Two levels of token: palette tokens are raw values and are never used by rules;
   semantic tokens are what rules use. Dark mode later only redefines the semantic ones. */
@layer base, legacy, components, pages, utilities;

@layer base {
  :root {
    /* ---- Palette (raw values) ---- */
    --green-950: #0E2A1B;
    --green-900: #143826;
    --green-800: #1B4A32;
    --green-700: #21593C;
    --green-600: #2A6E4A;
    --green-100: #DCEBDF;
    --green-50:  #EFF5F0;
    --cream-50:  #FBF8F1;
    --cream-100: #F5F0E3;
    --cream-200: #EAE2CF;
    --stone-300: #D6CDB6;
    --stone-500: #9A9C92;
    --ink-900:   #1A1F1B;
    --ink-700:   #3A423C;
    --ink-500:   #5C655E;
    --gold-400:  #D4AF37;
    --gold-500:  #B8912F;
    --gold-100:  #F6EDD3;
    --claret-700: #8E1F1F;
    --claret-800: #741818;
    --claret-900: #5C1212;
    --claret-50:  #F8E9E7;
    --amber-700: #7A5300;
    --amber-50:  #FBF1D9;
    --white:     #FFFFFF;
    --red-600:   #C1121F;   /* scoreboard red: under par */

    /* ---- Semantic: surfaces and text ---- */
    --color-bg: var(--cream-100);
    --color-surface: var(--cream-50);
    --color-surface-sunk: var(--cream-200);
    --color-border: var(--stone-300);
    --color-text: var(--ink-900);
    --color-text-muted: var(--ink-500);
    --color-heading: var(--green-900);
    --color-link: var(--green-700);
    --color-on-primary: var(--cream-50);
    --color-header-bg: var(--green-900);
    --color-header-text: var(--cream-50);
    --color-tabbar-bg: var(--green-950);
    --color-tabbar-text: var(--cream-200);
    --color-tabbar-active: var(--color-selected);
    --color-focus: var(--amber-700);          /* 6:1 on the cream page */
    --color-focus-on-dark: var(--gold-400);   /* on the green header and tab bar */
    --color-accent: var(--green-700);   /* checkboxes, radios, range inputs */
    --color-badge: var(--gold-500);
    --color-overlay: rgb(14 42 27 / 0.55);
    --color-surface-glass: rgb(251 248 241 / 0.9);   /* translucent surface over the page */
    --color-shadow-soft: rgb(20 40 30 / 0.1);
    --color-shadow: rgb(20 40 30 / 0.2);
    --color-shadow-strong: rgb(20 40 30 / 0.5);

    /* ---- Semantic: selected / current state ----
       Selected buttons, switches, round pickers and the active tab. Gold with deep-green text
       (7.3:1), clearly different from the green buttons around it; the inner ring gives it an
       edge on the cream background. */
    --color-selected: var(--gold-400);
    --color-selected-text: var(--green-950);
    --color-selected-border: var(--green-950);

    /* ---- Semantic: buttons, every state ---- */
    --btn-primary-bg: var(--green-700);
    --btn-primary-text: var(--cream-50);
    --btn-primary-bg-hover: var(--green-800);
    --btn-primary-bg-active: var(--green-950);
    --btn-secondary-bg: transparent;
    --btn-secondary-text: var(--green-800);
    --btn-secondary-border: var(--green-700);
    --btn-secondary-bg-hover: var(--green-50);
    --btn-secondary-bg-active: var(--green-100);
    --btn-danger-bg: var(--claret-700);
    --btn-danger-text: #FFFFFF;
    --btn-danger-bg-hover: var(--claret-800);
    --btn-danger-bg-active: var(--claret-900);
    --btn-quiet-text: var(--green-800);
    --btn-quiet-bg-hover: var(--green-50);
    --btn-disabled-bg: var(--stone-500);
    --btn-disabled-text: #FFFFFF;
    --btn-tap-highlight: rgb(33 89 60 / 0.25);

    /* ---- Semantic: feedback (no blue: info is neutral) ---- */
    --color-success-bg: var(--green-50);
    --color-success-text: var(--green-800);
    --color-success-border: var(--green-100);
    --color-danger-bg: var(--claret-50);
    --color-danger-text: var(--claret-800);
    --color-danger-border: #EBC9C4;
    --color-warning-bg: var(--amber-50);
    --color-warning-text: var(--amber-700);
    --color-info-bg: var(--cream-200);
    --color-info-text: var(--ink-700);

    /* ---- Semantic: Live scores board (a traditional tournament leaderboard) ---- */
    --board-bg: var(--white);
    --board-frame: var(--green-900);
    --board-frame-text: var(--white);
    --board-head-bg: var(--green-800);
    --board-rule: var(--stone-300);
    --board-text: var(--ink-900);
    --board-under: var(--red-600);       /* under par: red */
    --board-even: var(--green-800);      /* E and over par: green */
    --board-over: var(--green-800);
    --board-stripe: var(--cream-50);

    /* ---- Semantic: scoring ---- */
    --score-best-bg: var(--green-100);
    --score-draw-bg: var(--cream-200);
    --score-eagle: var(--gold-500);
    --score-birdie: var(--claret-700);
    --score-second-bg: var(--gold-100);
    --score-bogey-bg: var(--stone-500);
    --score-double-bogey-bg: var(--ink-500);
    --score-ahead: var(--green-700);    /* e.g. points vs par above zero */
    --score-behind: var(--claret-700);
    /* Team colours keep their old hues (1 red, 2 blue, 3 yellow, 4 green) as muted tints.
       Team 2's navy tint is the only blue allowed (UI plan decision 4). */
    --team-1: #EFD3CF;
    --team-2: #D3DCEB;
    --team-3: #F0E2B6;
    --team-4: #D2E6D6;
    --team-none: var(--cream-200);

    /* ---- Type ---- */
    --font-heading: "Libre Baskerville", Georgia, "Times New Roman", serif;
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
    --text-2xs: 0.6875rem;  /* scorecard small print: par, SI, yards */
    --text-xs: 0.8125rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --text-score: 1.5rem;
    --leading-tight: 1.25;
    --leading: 1.5;

    /* ---- Space (4px grid), radius, shadow, sizes ---- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-8: 48px;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-pill: 999px;
    --shadow-1: 0 1px 2px rgb(20 40 30 / 0.08);
    --shadow-2: 0 4px 12px rgb(20 40 30 / 0.12);
    --shadow-sheet: 0 -8px 24px rgb(20 40 30 / 0.18);
    --tap: 44px;
    --tap-lg: 52px;
    --header-h: 60px;
    --tabbar-h: 64px;
    --actions-h: 68px;     /* a page's sticky action bar (e.g. Save scores) */
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --z-header: 1000;
    --z-tabbar: 1000;
    --z-sheet: 2000;
  }
}
