/* ==========================================================================
   Shipfolder v1.1.0 - theme.css
   Every design token lives in this file as a CSS custom property.
   components.css only ever reads these tokens; it never hard-codes colours.

   Sections
     1. Scale tokens (type, spacing, radius, layout, shadow, motion)
     2. Colour presets (indigo = default, teal, ember)
     3. Light mode (default)
     4. Dark mode (two copies that MUST stay identical, see the note there)

   Switching preset:  <html data-preset="teal">   (or "indigo", "ember")
   Forcing a theme:   <html data-theme="dark">    (or "light"); the theme
                      toggle in js/main.js sets this for you and remembers it.
   After changing colours, run:  python3 qa/qa.py   to re-check contrast.
   ========================================================================== */

/* 1. Scale tokens ---------------------------------------------------------- */
:root {
  /* Type */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: clamp(1.75rem, 1.45rem + 1.3vw, 2.25rem);
  --text-4xl: clamp(2.125rem, 1.5rem + 3vw, 3.5rem);

  --leading-tight: 1.15;
  --leading-snug: 1.35;
  --leading-normal: 1.65;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Spacing (rem based, so it scales with the user's font size) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;

  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 999px;

  /* Layout */
  --container: 72rem;
  --container-narrow: 44rem;
  --header-height: 4rem;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 0.06);
  --shadow-md: 0 4px 16px rgb(16 24 40 / 0.08);
  --shadow-lg: 0 18px 40px rgb(16 24 40 / 0.14);

  /* Motion */
  --duration: 150ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* 2. Colour presets --------------------------------------------------------
   Each preset sets its accent colours for BOTH modes. The light/dark blocks
   below pick the right one. "indigo" is the default when no data-preset is set.
   -------------------------------------------------------------------------- */
:root,
:root[data-preset="indigo"] {
  --accent-light: #4338ca;        /* buttons, icons, focus ring */
  --accent-text-light: #3730a3;   /* links and accent text */
  --on-accent-light: #ffffff;     /* text on accent buttons */
  --accent-soft-light: #eef0ff;   /* tinted backgrounds (badges, active nav) */

  --accent-dark: #a5b4fc;
  --accent-text-dark: #b9c5fd;
  --on-accent-dark: #12142b;
  --accent-soft-dark: #1d2142;
}

:root[data-preset="teal"] {
  --accent-light: #0f766e;
  --accent-text-light: #115e59;
  --on-accent-light: #ffffff;
  --accent-soft-light: #e6f6f4;

  --accent-dark: #5eead4;
  --accent-text-dark: #7ff0de;
  --on-accent-dark: #042420;
  --accent-soft-dark: #0d2a29;
}

:root[data-preset="ember"] {
  --accent-light: #c2410c;
  --accent-text-light: #9a3412;
  --on-accent-light: #ffffff;
  --accent-soft-light: #fff1e8;

  --accent-dark: #fdba74;
  --accent-text-dark: #fec899;
  --on-accent-dark: #2b1204;
  --accent-soft-dark: #33200f;
}

/* 3. Light mode (default) ------------------------------------------------- */
:root {
  color-scheme: light;

  --color-bg: #ffffff;
  --color-surface: #f6f7fb;
  --color-surface-2: #eceff5;
  --color-text: #151821;
  --color-text-muted: #4a5163;
  --color-border: #dadee7;
  --color-border-strong: #8d95a7;
  --color-header-bg: rgb(255 255 255 / 0.9);

  --color-accent: var(--accent-light);
  --color-accent-text: var(--accent-text-light);
  --color-on-accent: var(--on-accent-light);
  --color-accent-soft: var(--accent-soft-light);
  --color-link: var(--accent-text-light);
  --color-focus: var(--accent-light);

  /* Code blocks stay dark in both modes */
  --color-code-bg: #0f1422;
  --color-code-header: #171d2e;
  --color-code-text: #e4e7ee;
  --color-code-comment: #9aa3b8;
  --color-code-keyword: #c4b5fd;
  --color-code-string: #86efac;
  --color-code-function: #7dd3fc;
  --color-code-number: #fcd34d;
  --color-inline-code-bg: #eceff5;
  --color-inline-code-text: #1f2433;

  /* Changelog / status tags */
  --color-tag-new-bg: #e3f6ea;
  --color-tag-new-text: #14532d;
  --color-tag-improved-bg: #e5effd;
  --color-tag-improved-text: #1e3a8a;
  --color-tag-fixed-bg: #fdf3dc;
  --color-tag-fixed-text: #713f12;
  --color-tag-breaking-bg: #fde8e8;
  --color-tag-breaking-text: #7f1d1d;
}

/* 4. Dark mode -------------------------------------------------------------
   Dark mode applies when the OS prefers dark (and the visitor has not chosen
   light), or when <html data-theme="dark"> is set.

   CSS cannot share one rule between a media query and a plain selector, so
   the two blocks below are deliberate copies. KEEP THEM IDENTICAL.
   qa/qa.py fails if they drift apart.
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --color-bg: #0c0f16;
    --color-surface: #131824;
    --color-surface-2: #1a2030;
    --color-text: #e7eaf1;
    --color-text-muted: #a3abbc;
    --color-border: #272e3e;
    --color-border-strong: #6b7488;
    --color-header-bg: rgb(12 15 22 / 0.88);

    --color-accent: var(--accent-dark);
    --color-accent-text: var(--accent-text-dark);
    --color-on-accent: var(--on-accent-dark);
    --color-accent-soft: var(--accent-soft-dark);
    --color-link: var(--accent-text-dark);
    --color-focus: var(--accent-dark);

    --color-code-bg: #070a11;
    --color-code-header: #10141f;
    --color-code-text: #e4e7ee;
    --color-code-comment: #9aa3b8;
    --color-code-keyword: #c4b5fd;
    --color-code-string: #86efac;
    --color-code-function: #7dd3fc;
    --color-code-number: #fcd34d;
    --color-inline-code-bg: #1d2333;
    --color-inline-code-text: #e7eaf1;

    --color-tag-new-bg: #0f2a1b;
    --color-tag-new-text: #86efac;
    --color-tag-improved-bg: #13213d;
    --color-tag-improved-text: #a5c8ff;
    --color-tag-fixed-bg: #2e2410;
    --color-tag-fixed-text: #fcd38d;
    --color-tag-breaking-bg: #351416;
    --color-tag-breaking-text: #fca5a5;
  }
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --color-bg: #0c0f16;
    --color-surface: #131824;
    --color-surface-2: #1a2030;
    --color-text: #e7eaf1;
    --color-text-muted: #a3abbc;
    --color-border: #272e3e;
    --color-border-strong: #6b7488;
    --color-header-bg: rgb(12 15 22 / 0.88);

    --color-accent: var(--accent-dark);
    --color-accent-text: var(--accent-text-dark);
    --color-on-accent: var(--on-accent-dark);
    --color-accent-soft: var(--accent-soft-dark);
    --color-link: var(--accent-text-dark);
    --color-focus: var(--accent-dark);

    --color-code-bg: #070a11;
    --color-code-header: #10141f;
    --color-code-text: #e4e7ee;
    --color-code-comment: #9aa3b8;
    --color-code-keyword: #c4b5fd;
    --color-code-string: #86efac;
    --color-code-function: #7dd3fc;
    --color-code-number: #fcd34d;
    --color-inline-code-bg: #1d2333;
    --color-inline-code-text: #e7eaf1;

    --color-tag-new-bg: #0f2a1b;
    --color-tag-new-text: #86efac;
    --color-tag-improved-bg: #13213d;
    --color-tag-improved-text: #a5c8ff;
    --color-tag-fixed-bg: #2e2410;
    --color-tag-fixed-text: #fcd38d;
    --color-tag-breaking-bg: #351416;
    --color-tag-breaking-text: #fca5a5;
}
