/* ========================================
   TOKENS — Design System Custom Properties
   CordiAlban Dark Theme — v3.0
   ======================================== */

:root {
  /* Background */
  --bg: #0C0B09;
  --bg-rgb: 12, 11, 9;
  --bg2: #131210;
  --bg3: #1A1814;
  --bg4: #211F1B;

  /* Surface (alias sémantiques DAT v3.0) */
  --surface: #1A1916;
  --surface-hover: #252320;

  /* Text */
  --text: #E8E2D8;
  --text2: #9B9484;
  --text3: #6B6459;
  --text-muted: #9A9590;

  /* Gold */
  --gold: #C8A46E;
  --gold2: #E4C07A;
  --gold3: #8B7345;
  --gold-hover: #D4B67E;
  --gold-muted: rgba(200, 164, 110, 0.3);

  /* Score Colors */
  --sa: #2D8B46;
  --sb: #6BAD4B;
  --sc: #D4A017;
  --sd: #D4652A;
  --se: #C42B2B;
  --sn: #6B6459;

  /* Pace / Pace-green */
  --pace: #2D8B46;
  --pace2: #38A856;
  --pace3: #1E6B33;
  --pace-green: #2A9D4A;

  /* Radius */
  --r: 12px;
  --r2: 8px;

  /* Fonts */
  --f1: 'Newsreader', Georgia, serif;
  --f2: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --f3: 'JetBrains Mono', 'Fira Code', monospace;

  /* Aliases sémantiques (DAT) */
  --font-display: 'Newsreader', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Widths */
  --max-w: 1200px;
  --max-t: 680px;
}

/* Light mode — activated by OS preference */
@media (prefers-color-scheme: light) {
  :root {
    /* Background — warm ivory layers */
    --bg:  #F5F0E8;
    --bg-rgb: 245, 240, 232;
    --bg2: #EDE8DE;
    --bg3: #E5DFD3;
    --bg4: #DDD7CA;

    --surface: #EDE8DE;
    --surface-hover: #E0DAD0;

    /* Text — warm dark browns */
    --text:  #1A1714;
    --text2: #5A4E42;
    --text3: #8A7D70;
    --text-muted: #7A7068;

    /* Gold — darkened for contrast on light bg */
    --gold:  #9A6E30;
    --gold2: #B07F3A;
    --gold3: #7A5520;
    --gold-hover: #A87838;
    --gold-muted: rgba(154, 110, 48, 0.3);

    /* Pace — base unchanged, bright darkened for hover contrast */
    --pace2: #1E6B33;
    --pace3: #38A856;

    /* Score colors stay vibrant — work equally on light bg */
  }

  ::selection {
    background: rgba(154, 110, 48, 0.25);
    color: var(--text);
  }
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

html {
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--f2);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Grain overlay */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
  opacity: .02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Manual theme override via data-theme attribute (theme.js) */
[data-theme="light"] {
  --bg:  #F5F0E8;
  --bg-rgb: 245, 240, 232;
  --bg2: #EDE8DE;
  --bg3: #E5DFD3;
  --bg4: #DDD7CA;
  --surface: #EDE8DE;
  --surface-hover: #E0DAD0;
  --text:  #1A1714;
  --text2: #5A4E42;
  --text3: #8A7D70;
  --text-muted: #7A7068;
  --gold:  #9A6E30;
  --gold2: #B07F3A;
  --gold3: #7A5520;
  --gold-hover: #A87838;
  --gold-muted: rgba(154, 110, 48, 0.3);
  --pace2: #1E6B33;
  --pace3: #38A856;
}

[data-theme="dark"] {
  --bg: #0C0B09;
  --bg-rgb: 12, 11, 9;
  --bg2: #131210;
  --bg3: #1A1814;
  --bg4: #211F1B;
  --surface: #1A1916;
  --surface-hover: #252320;
  --text: #E8E2D8;
  --text2: #9B9484;
  --text3: #6B6459;
  --text-muted: #9A9590;
  --gold: #C8A46E;
  --gold2: #E4C07A;
  --gold3: #8B7345;
  --gold-hover: #D4B67E;
  --gold-muted: rgba(200, 164, 110, 0.3);
  --pace2: #38A856;
  --pace3: #1E6B33;
}

::selection {
  background: rgba(200, 164, 110, 0.3);
  color: var(--text);
}
