/*
  Gibbs Toolkit's design tokens: every colour, size, space and duration, for both themes. docs/DESIGN.md explains them.

  Themes (021). Light is defined on :root. Dark redefines tokens in TWO blocks that must stay identical:
    - the device setting:  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) }
    - the person's choice: :root[data-theme="dark"]
  Change a dark value in both, then recompute contrast (028). Components style through these tokens only.

  Modules (024, 025). The layout sets data-module="<key>" on the page, and a module block below maps
  --module, --module-soft and --module-ink to that module's accent. A module skin, later, redefines tokens inside
  [data-module="<key>"] in its own stylesheet; it never edits this file.
*/

:root {
  /* ---- colour: neutrals, cool with a violet bias (022) ---- */
  --bg: #fbfbfd;              /* the page */
  --surface: #ffffff;         /* cards, lists, dialogs */
  --surface-side: #f3f2f8;    /* the rail, the phone top bar and tab bar */
  --surface-current: #e7e4f6; /* the current nav item */
  --chip: #efedf5;            /* chips, avatars, quiet fills */
  --line: #e3e1ec;            /* dividers and card edges: decoration, not a control's edge */
  --edge-control: #8a8799;    /* the edge of an input, checkbox or select: at least 3:1 against --surface */
  --fg: #1a1823;
  --fg-muted: #5f5c6e;

  /* ---- colour: the toolkit accent, Iris (022) ---- */
  --accent: #5a3fd6;          /* primary buttons, the logo, focus rings */
  --on-accent: #ffffff;
  --link: #4b31c4;

  /* ---- colour: meaning, never decoration ---- */
  --danger: #b42318;          /* something went wrong, is overdue, or will be destroyed */
  --danger-soft: #fdecea;

  /* ---- colour: module accents (024) ---- */
  --mod-tasks: #2563c9;  --mod-tasks-soft: #e3ecfb;  --mod-tasks-ink: #1d4f9f;
  --mod-ttrpg: #b4441f;  --mod-ttrpg-soft: #fbe9e2;  --mod-ttrpg-ink: #8f3415;
  --mod-sites: #0f7a5c;  --mod-sites-soft: #dff3ec;  --mod-sites-ink: #0b5e47;

  /* Outside any module (home, admin) the module tokens fall back to the toolkit accent. */
  --module: var(--accent);
  --module-soft: var(--surface-current);
  --module-ink: var(--link);

  /* ---- QR codes: dark on light in BOTH themes, so every camera reads them; never redefined for dark ---- */
  --qr-dark: #000000;
  --qr-light: #ffffff;

  /* ---- type (023): Inter, Inter Tight for titles; self-hosted ---- */
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Inter Tight", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --text-xs: 0.75rem;     /* 12px: chips, captions */
  --text-sm: 0.8125rem;   /* 13px: nav, secondary rows */
  --text-base: 0.9375rem; /* 15px: running text and lists */
  --text-input: 1rem;     /* 16px: every input, so iOS does not zoom on focus */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.375rem;    /* 22px: a page title */
  --text-2xl: 1.75rem;    /* 28px: home and empty states only */
  --weight-regular: 400;
  --weight-bold: 600;
  --leading-body: 1.5;
  --leading-tight: 1.2;
  --measure: 68ch;

  /* ---- space: a 4px scale ---- */
  --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;

  /* ---- shape and depth: only what can be pressed is raised ---- */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;
  --shadow-raised: 0 1px 2px rgb(26 24 35 / 0.18);
  --shadow-overlay: 0 8px 28px rgb(26 24 35 / 0.18), 0 2px 6px rgb(26 24 35 / 0.10);
  /* Focus is an outline, never a box-shadow: a component's own shadow would replace a shadow ring (found 2026-11-21). */
  --focus-ring: 2px solid var(--accent);
  --focus-offset: 2px;

  /* ---- layout (026) ---- */
  --rail-width: 4.5rem;    /* the icon rail, from 48rem */
  --panel-width: 13rem;   /* the current module's section panel beside it */
  --tabbar-height: 3.5rem;
  --target-min: 44px;     /* the smallest tap target */
  --page-max: 72rem;

  /* ---- motion: stops under prefers-reduced-motion ---- */
  --duration-fast: 120ms;
  --duration: 200ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  /* ---- stacking ---- */
  --z-sticky: 10;
  --z-overlay: 100;
  --z-toast: 200;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121118;
    --surface: #1c1b25;
    --surface-side: #17161f;
    --surface-current: #2a2645;
    --chip: #272533;
    --line: #2d2b3a;
    --edge-control: #6f6c82;
    --fg: #eceaf4;
    --fg-muted: #a3a0b4;
    --accent: #9d8cff;
    --on-accent: #15112b;
    --link: #b3a6ff;
    --danger: #f4a09a;
    --danger-soft: #3a1f1f;
    --mod-tasks: #7fb0ff;  --mod-tasks-soft: #1d2a40;  --mod-tasks-ink: #a9c9ff;
    --mod-ttrpg: #ff9b73;  --mod-ttrpg-soft: #3a2219;  --mod-ttrpg-ink: #ffb899;
    --mod-sites: #5fd3ac;  --mod-sites-soft: #16302a;  --mod-sites-ink: #8be3c4;
    --shadow-raised: 0 1px 2px rgb(0 0 0 / 0.45);
    --shadow-overlay: 0 8px 28px rgb(0 0 0 / 0.5), 0 2px 6px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121118;
  --surface: #1c1b25;
  --surface-side: #17161f;
  --surface-current: #2a2645;
  --chip: #272533;
  --line: #2d2b3a;
  --edge-control: #6f6c82;
  --fg: #eceaf4;
  --fg-muted: #a3a0b4;
  --accent: #9d8cff;
  --on-accent: #15112b;
  --link: #b3a6ff;
  --danger: #f4a09a;
  --danger-soft: #3a1f1f;
  --mod-tasks: #7fb0ff;  --mod-tasks-soft: #1d2a40;  --mod-tasks-ink: #a9c9ff;
  --mod-ttrpg: #ff9b73;  --mod-ttrpg-soft: #3a2219;  --mod-ttrpg-ink: #ffb899;
  --mod-sites: #5fd3ac;  --mod-sites-soft: #16302a;  --mod-sites-ink: #8be3c4;
  --shadow-raised: 0 1px 2px rgb(0 0 0 / 0.45);
  --shadow-overlay: 0 8px 28px rgb(0 0 0 / 0.5), 0 2px 6px rgb(0 0 0 / 0.35);
  color-scheme: dark;
}

/* ---- module mapping (024). Through var(), so each follows the theme on its own. ---- */
[data-module="tasks"] { --module: var(--mod-tasks); --module-soft: var(--mod-tasks-soft); --module-ink: var(--mod-tasks-ink); }
[data-module="ttrpg"] { --module: var(--mod-ttrpg); --module-soft: var(--mod-ttrpg-soft); --module-ink: var(--mod-ttrpg-ink); }
[data-module="sites"] { --module: var(--mod-sites); --module-soft: var(--mod-sites-soft); --module-ink: var(--mod-sites-ink); }

@media (prefers-reduced-motion: reduce) {
  :root { --duration-fast: 0ms; --duration: 0ms; }
}
