/*
 * Notes Tracker design tokens.
 * Decisions and rationale live in DESIGN.md. Keep the two in sync.
 *
 * Theme strategy: light palette on bare :root, dark redefined twice so both
 * `prefers-color-scheme` and an explicit [data-theme] choice win in both
 * directions. No color is defined only inside a media query.
 */

:root {
  color-scheme: light dark;

  /* ---- Surfaces and ink (light) ---- */
  --bg:            oklch(1 0 0);
  --surface-2:     oklch(0.975 0.004 150);
  --surface-3:     oklch(0.955 0.006 150);
  --surface-hover: oklch(0.965 0.006 150);
  --ink:           oklch(0.20 0 0);
  --ink-muted:     oklch(0.45 0.010 150);
  --ink-faint:     oklch(0.58 0.008 150);
  --border:        oklch(0.905 0.006 150);
  --border-strong: oklch(0.82 0.008 150);
  /* Separators inside a panel, quieter than the panel's own edge. */
  --border-subtle: oklch(0.945 0.005 150);

  /* ---- Brand ---- */
  --primary:       oklch(0.52 0.13 150);
  --primary-hover: oklch(0.47 0.13 150);
  --primary-soft:  oklch(0.94 0.03 150);
  --on-primary:    oklch(1 0 0);
  --focus-ring:    oklch(0.52 0.13 150);

  /* ---- Semantic state ---- */
  --recording:     oklch(0.58 0.20 25);
  --danger:        oklch(0.55 0.19 27);
  --danger-soft:   oklch(0.95 0.03 27);
  --on-danger:     oklch(1 0 0);
  --warning:       oklch(0.58 0.13 75);
  --success:       oklch(0.55 0.13 150);
  --info:          oklch(0.55 0.12 240);

  /* ---- Typography ---- */
  --font-sans: Geist, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "Cascadia Mono", "SF Mono", Menlo, monospace;

  --text-2xs:  0.75rem;
  --text-xs:   0.8125rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.1875rem;
  --text-xl:   1.4375rem;
  --text-2xl:  1.75rem;
  --text-3xl:  2.125rem;

  --leading-tight: 1.25;
  --leading-body:  1.6;
  --measure:       70ch;

  --weight-regular: 400;
  --weight-medium:  500;
  --weight-semibold: 600;

  /* ---- Space (4px scale) ---- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* ---- Shape ---- */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* ---- Elevation (tinted, never pure black) ---- */
  --shadow-sm: 0 1px 2px oklch(0.20 0.02 150 / 0.06),
               0 2px 8px oklch(0.20 0.02 150 / 0.06);
  --shadow-md: 0 4px 12px oklch(0.20 0.02 150 / 0.10),
               0 16px 32px oklch(0.20 0.02 150 / 0.08);
  --scrim: oklch(0.20 0.02 150 / 0.45);

  /* ---- Motion ---- */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-fast: 150ms;
  --duration-base: 200ms;
  --duration-slow: 250ms;

  /* ---- Layers ---- */
  --z-base: 0;
  --z-sticky: 100;
  --z-drawer: 200;
  --z-dropdown: 300;
  --z-scrim: 400;
  --z-modal: 500;
  --z-toast: 600;
  --z-tooltip: 700;

  /* ---- Fixed sizes ---- */
  --sidebar-width: 244px;
  --list-width: 340px;
  --touch-min: 44px;

  /* Icon scale. 14 for inline meta, 16 for controls, 18 for nav, 20 for headers. */
  --icon-xs: 14px;
  --icon-sm: 16px;
  --icon-md: 18px;
  --icon-lg: 20px;

  /* ---- Density ----
     The app is a tool people open many times a day, so rows are compact and
     separated by hairlines rather than by whitespace. These are the heights the
     whole chrome is tuned to; changing one changes the feel of everything.

     Touch targets stay at 44px on coarse pointers, below.  */
  --row-h: 30px;        /* sidebar items, menu rows */
  --control-h: 32px;    /* buttons, inputs */
  --list-row-h: 56px;   /* a note in the list: two lines plus breathing room */
  --header-h: 52px;     /* page header */
}

/* A finger needs more than a cursor. Density is for pointers, not for thumbs. */
@media (pointer: coarse) {
  :root {
    --row-h: 44px;
    --control-h: 44px;
    --list-row-h: 68px;
    --header-h: 56px;
  }
}

/* Dark: system preference, unless the user explicitly chose light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            oklch(0.13 0 0);
    --surface-2:     oklch(0.17 0.004 150);
    --surface-3:     oklch(0.21 0.006 150);
    --surface-hover: oklch(0.23 0.006 150);
    --ink:           oklch(0.93 0 0);
    --ink-muted:     oklch(0.72 0.010 150);
    --ink-faint:     oklch(0.60 0.008 150);
    --border:        oklch(0.275 0.006 150);
    --border-strong: oklch(0.38 0.008 150);
    --border-subtle: oklch(0.225 0.005 150);

    --primary:       oklch(0.75 0.14 150);
    --primary-hover: oklch(0.80 0.14 150);
    --primary-soft:  oklch(0.26 0.05 150);
    --on-primary:    oklch(0.15 0.02 150);
    --focus-ring:    oklch(0.80 0.14 150);

    --recording:     oklch(0.68 0.19 25);
    --danger:        oklch(0.70 0.17 27);
    --danger-soft:   oklch(0.26 0.06 27);
    --on-danger:     oklch(0.15 0.02 27);
    --warning:       oklch(0.78 0.13 75);
    --success:       oklch(0.74 0.13 150);
    --info:          oklch(0.72 0.11 240);

    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.35), 0 2px 8px oklch(0 0 0 / 0.30);
    --shadow-md: 0 4px 12px oklch(0 0 0 / 0.45), 0 16px 32px oklch(0 0 0 / 0.35);
    --scrim: oklch(0 0 0 / 0.60);
  }
}

/* Dark: explicit user choice wins over system light. */
:root[data-theme="dark"] {
  --bg:            oklch(0.13 0 0);
  --surface-2:     oklch(0.17 0.004 150);
  --surface-3:     oklch(0.21 0.006 150);
  --surface-hover: oklch(0.23 0.006 150);
  --ink:           oklch(0.93 0 0);
  --ink-muted:     oklch(0.72 0.010 150);
  --ink-faint:     oklch(0.60 0.008 150);
  --border:        oklch(0.275 0.006 150);
  --border-strong: oklch(0.38 0.008 150);
  --border-subtle: oklch(0.225 0.005 150);

  --primary:       oklch(0.75 0.14 150);
  --primary-hover: oklch(0.80 0.14 150);
  --primary-soft:  oklch(0.26 0.05 150);
  --on-primary:    oklch(0.15 0.02 150);
  --focus-ring:    oklch(0.80 0.14 150);

  --recording:     oklch(0.68 0.19 25);
  --danger:        oklch(0.70 0.17 27);
  --danger-soft:   oklch(0.26 0.06 27);
  --on-danger:     oklch(0.15 0.02 27);
  --warning:       oklch(0.78 0.13 75);
  --success:       oklch(0.74 0.13 150);
  --info:          oklch(0.72 0.11 240);

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.35), 0 2px 8px oklch(0 0 0 / 0.30);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.45), 0 16px 32px oklch(0 0 0 / 0.35);
  --scrim: oklch(0 0 0 / 0.60);
}

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

/* ---------------------------------------------------------------- accents

   The accent is one hue, swapped wholesale. Everything is derived from it at
   fixed lightness and chroma, so a new accent cannot quietly break contrast:
   the ramp is the same shape every time, only the hue moves.

   Set on the root element as data-accent. Absent, the moss green above stands.

   Deliberately a small set. A colour picker would let someone choose a yellow
   that fails against white and calls it their brand.  */

:root[data-accent="moss"]     { --accent-hue: 150; }
:root[data-accent="ink"]      { --accent-hue: 265; }
:root[data-accent="tide"]     { --accent-hue: 230; }
:root[data-accent="ember"]    { --accent-hue: 45;  }
:root[data-accent="rose"]     { --accent-hue: 12;  }
:root[data-accent="plum"]     { --accent-hue: 320; }

:root[data-accent] {
  --primary:       oklch(0.52 0.13 var(--accent-hue));
  --primary-hover: oklch(0.47 0.13 var(--accent-hue));
  --primary-soft:  oklch(0.94 0.03 var(--accent-hue));
  --on-primary:    oklch(1 0 0);
}

/* Dark needs a lighter, less saturated accent to stay readable, and dark text
   on top of it rather than white. */
@media (prefers-color-scheme: dark) {
  :root[data-accent]:not([data-theme="light"]) {
    --primary:       oklch(0.75 0.14 var(--accent-hue));
    --primary-hover: oklch(0.80 0.14 var(--accent-hue));
    --primary-soft:  oklch(0.26 0.05 var(--accent-hue));
    --on-primary:    oklch(0.15 0.02 var(--accent-hue));
  }
}

:root[data-theme="dark"][data-accent] {
  --primary:       oklch(0.75 0.14 var(--accent-hue));
  --primary-hover: oklch(0.80 0.14 var(--accent-hue));
  --primary-soft:  oklch(0.26 0.05 var(--accent-hue));
  --on-primary:    oklch(0.15 0.02 var(--accent-hue));
}

