/* ============================================================
   Lecchi Timer — base.css
   Design tokens, reset, theming (light / dark / auto)
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* Type */
  --font-ui: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Radii */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --r-pill: 999px;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-1: 0.14s;
  --dur-2: 0.26s;
  --dur-3: 0.5s;

  /* Category accent hues — same L/C, varied hue */
  --hue-amber: 70;
  --hue-coral: 28;
  --hue-violet: 300;
  --hue-teal: 195;
  --hue-green: 150;
  --hue-blue: 255;

  /* Layout */
  --sidebar-w: 264px;
  --content-max: 980px;
  --shadow-color: 30 8% 12%;
}

/* ---------- Light theme (default) ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: oklch(0.985 0.005 85);
  --bg-2: oklch(0.965 0.006 80);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.975 0.005 85);
  --surface-inset: oklch(0.955 0.007 80);
  --border: oklch(0.9 0.008 80);
  --border-strong: oklch(0.82 0.01 75);
  --text: oklch(0.22 0.012 65);
  --text-2: oklch(0.44 0.01 70);
  --text-3: oklch(0.6 0.008 75);
  --text-inv: oklch(0.98 0.004 85);

  --accent: oklch(0.7 0.155 var(--hue-amber));
  --accent-strong: oklch(0.62 0.16 var(--hue-amber));
  --accent-soft: oklch(0.95 0.04 var(--hue-amber));
  --accent-text: oklch(0.32 0.08 var(--hue-amber));
  --on-accent: oklch(0.2 0.02 70);

  /* Logo: white mark in light mode, with a slightly darker delimiting border */
  --logo-bg: oklch(1 0 0);
  --logo-border: oklch(0.8 0.012 75);

  --good: oklch(0.62 0.14 var(--hue-green));
  --warn: oklch(0.68 0.16 var(--hue-coral));
  --danger: oklch(0.58 0.18 25);

  --shadow-sm: 0 1px 2px hsl(var(--shadow-color) / 0.06), 0 1px 3px hsl(var(--shadow-color) / 0.05);
  --shadow-md: 0 4px 12px hsl(var(--shadow-color) / 0.08), 0 2px 4px hsl(var(--shadow-color) / 0.05);
  --shadow-lg: 0 18px 40px hsl(var(--shadow-color) / 0.12), 0 6px 14px hsl(var(--shadow-color) / 0.07);
  --ring: 0 0 0 3px oklch(0.7 0.155 var(--hue-amber) / 0.35);
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: oklch(0.17 0.008 70);
  --bg-2: oklch(0.155 0.008 70);
  --surface: oklch(0.215 0.009 72);
  --surface-2: oklch(0.24 0.01 72);
  --surface-inset: oklch(0.19 0.009 70);
  --border: oklch(0.3 0.01 72);
  --border-strong: oklch(0.4 0.012 72);
  --text: oklch(0.94 0.006 80);
  --text-2: oklch(0.74 0.008 78);
  --text-3: oklch(0.58 0.01 75);
  --text-inv: oklch(0.2 0.01 70);

  --accent: oklch(0.76 0.15 var(--hue-amber));
  --accent-strong: oklch(0.82 0.15 var(--hue-amber));
  --accent-soft: oklch(0.32 0.06 var(--hue-amber));
  --accent-text: oklch(0.82 0.12 var(--hue-amber));
  --on-accent: oklch(0.18 0.02 70);

  /* Logo: dark mark in dark mode, with a slightly lighter delimiting border */
  --logo-bg: oklch(0.13 0.008 70);
  --logo-border: oklch(0.34 0.012 72);

  --good: oklch(0.72 0.14 var(--hue-green));
  --warn: oklch(0.76 0.15 var(--hue-coral));
  --danger: oklch(0.68 0.17 25);

  --shadow-color: 0 0% 0%;
  --shadow-sm: 0 1px 2px hsl(var(--shadow-color) / 0.4);
  --shadow-md: 0 6px 16px hsl(var(--shadow-color) / 0.4);
  --shadow-lg: 0 22px 48px hsl(var(--shadow-color) / 0.5);
  --ring: 0 0 0 3px oklch(0.76 0.15 var(--hue-amber) / 0.4);
}

/* ---------- Auto theme follows device ---------- */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    color-scheme: dark;
    --bg: oklch(0.17 0.008 70);
    --bg-2: oklch(0.155 0.008 70);
    --surface: oklch(0.215 0.009 72);
    --surface-2: oklch(0.24 0.01 72);
    --surface-inset: oklch(0.19 0.009 70);
    --border: oklch(0.3 0.01 72);
    --border-strong: oklch(0.4 0.012 72);
    --text: oklch(0.94 0.006 80);
    --text-2: oklch(0.74 0.008 78);
    --text-3: oklch(0.58 0.01 75);
    --text-inv: oklch(0.2 0.01 70);
    --accent: oklch(0.76 0.15 var(--hue-amber));
    --accent-strong: oklch(0.82 0.15 var(--hue-amber));
    --accent-soft: oklch(0.32 0.06 var(--hue-amber));
    --accent-text: oklch(0.82 0.12 var(--hue-amber));
    --on-accent: oklch(0.18 0.02 70);
    --logo-bg: oklch(0.13 0.008 70);
    --logo-border: oklch(0.34 0.012 72);
    --good: oklch(0.72 0.14 var(--hue-green));
    --warn: oklch(0.76 0.15 var(--hue-coral));
    --danger: oklch(0.68 0.17 25);
    --shadow-color: 0 0% 0%;
    --shadow-sm: 0 1px 2px hsl(var(--shadow-color) / 0.4);
    --shadow-md: 0 6px 16px hsl(var(--shadow-color) / 0.4);
    --shadow-lg: 0 22px 48px hsl(var(--shadow-color) / 0.5);
    --ring: 0 0 0 3px oklch(0.76 0.15 var(--hue-amber) / 0.4);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-xs); }
::selection { background: var(--accent-soft); color: var(--accent-text); }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; text-wrap: balance; }
p { text-wrap: pretty; }

/* tabular numerals everywhere numbers matter */
.tnum { font-variant-numeric: tabular-nums; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
