/* ==========================================================================
   BESU — Design tokens
   Layout concept: an editorial reading column on a warm paper ground,
   hairline structure instead of cards, one cobalt accent used sparingly.
   ========================================================================== */

:root {
  /* Paper & ink */
  --bg: #FAF9F6;          /* warm off-white page */
  --surface: #FFFFFF;     /* raised panels: search, diagrams */
  --sunken: #F3F1EC;      /* code, subtle fills */
  --ink: #1B1A17;         /* headings, primary text */
  --text: #34322D;        /* long-form body */
  --ink-2: #57544C;       /* secondary text */
  --muted: #7A766C;       /* metadata */
  --faint: #ACA79B;       /* placeholders, disabled */
  --line: #E7E4DC;        /* hairlines */
  --line-2: #D6D2C6;      /* stronger hairlines, inputs */

  /* The one accent: cobalt */
  --accent: #2F47D1;
  --accent-ink: #2537A8;
  --accent-wash: #EEF0FB;
  --accent-line: #CDD3F3;
  --on-accent: #FFFFFF;

  /* Semantic (quiz feedback only) */
  --success: #17784A;
  --success-wash: #E8F3EC;
  --success-line: #BCDCC8;
  --danger: #B63A27;
  --danger-wash: #FAEEEA;
  --danger-line: #EDC4BA;

  --overlay: rgba(27, 26, 23, 0.32);
  --shadow-pop: 0 1px 2px rgba(27, 26, 23, 0.04), 0 18px 48px -12px rgba(27, 26, 23, 0.18);
  --shadow-soft: 0 1px 2px rgba(27, 26, 23, 0.05);

  /* Type */
  --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-display: clamp(2.125rem, 1.25rem + 3.9vw, 4rem);      /* 34 → 64 */
  --fs-title: clamp(2rem, 1.4rem + 2.4vw, 3rem);             /* 32 → 48 */
  --fs-h2: clamp(1.5rem, 1.25rem + 0.9vw, 1.875rem);         /* 24 → 30 */
  --fs-h3: 1.1875rem;                                        /* 19 */
  --fs-lede: clamp(1.125rem, 1.05rem + 0.35vw, 1.3125rem);   /* 18 → 21 */
  --fs-body: clamp(1.0625rem, 1.02rem + 0.18vw, 1.15rem);    /* 17 → 18.4 */
  --fs-ui: 0.9375rem;                                        /* 15 */
  --fs-small: 0.875rem;                                      /* 14 */
  --fs-meta: 0.8125rem;                                      /* 13 */
  --fs-label: 0.71875rem;                                    /* 11.5 */

  --lh-body: 1.75;
  --tracking-tight: -0.028em;
  --tracking-label: 0.1em;

  /* Space & shape */
  --maxw: 1240px;
  --read: 42.5rem;        /* ~680px reading column */
  --gutter: clamp(16px, 4vw, 40px);
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 320ms;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131312;
    --surface: #1A1A18;
    --sunken: #1F1E1B;
    --ink: #EFEDE7;
    --text: #D6D3CB;
    --ink-2: #B4B0A6;
    --muted: #8D897F;
    --faint: #5E5B54;
    --line: #2A2926;
    --line-2: #3A3934;

    --accent: #93A2FF;
    --accent-ink: #B3BEFF;
    --accent-wash: #1C2036;
    --accent-line: #2F3765;
    --on-accent: #10132A;

    --success: #6FCF97;
    --success-wash: #15261C;
    --success-line: #2A4A36;
    --danger: #F08C78;
    --danger-wash: #2B1914;
    --danger-line: #57302A;

    --overlay: rgba(0, 0, 0, 0.55);
    --shadow-pop: 0 1px 2px rgba(0, 0, 0, 0.3), 0 18px 48px -12px rgba(0, 0, 0, 0.6);
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #131312;
  --surface: #1A1A18;
  --sunken: #1F1E1B;
  --ink: #EFEDE7;
  --text: #D6D3CB;
  --ink-2: #B4B0A6;
  --muted: #8D897F;
  --faint: #5E5B54;
  --line: #2A2926;
  --line-2: #3A3934;

  --accent: #93A2FF;
  --accent-ink: #B3BEFF;
  --accent-wash: #1C2036;
  --accent-line: #2F3765;
  --on-accent: #10132A;

  --success: #6FCF97;
  --success-wash: #15261C;
  --success-line: #2A4A36;
  --danger: #F08C78;
  --danger-wash: #2B1914;
  --danger-line: #57302A;

  --overlay: rgba(0, 0, 0, 0.55);
  --shadow-pop: 0 1px 2px rgba(0, 0, 0, 0.3), 0 18px 48px -12px rgba(0, 0, 0, 0.6);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

/* Reading preference: larger text */
:root[data-text="l"] {
  --fs-body: clamp(1.1875rem, 1.12rem + 0.2vw, 1.28rem);
  --fs-lede: clamp(1.25rem, 1.15rem + 0.4vw, 1.4375rem);
}
