/* saucysetups.com — design tokens
   Direction 2a. Consumed by Tailwind v4 via @theme.
   Cascade order matters: :root (light) → prefers-color-scheme:dark → [data-theme] overrides.
   ------------------------------------------------------------------ */

/* ---------- 1. Theme-independent tokens ---------- */
:root {
  color-scheme: light dark;

  /* Type families */
  --font-sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Type scale — fluid via clamp(); min = 375px, max = 1280px viewport.
     Every step is defined; do not interpolate new ones. */
  --text-2xs: 0.6875rem;                                  /* 11px — mono meta labels, fixed */
  --text-xs:  0.75rem;                                    /* 12px — disclosure, fixed */
  --text-sm:  0.8125rem;                                  /* 13px — chips, controls, fixed */
  --text-base: 1rem;                                      /* 16px — fixed */
  --text-md:  clamp(1rem, 0.99rem + 0.11vw, 1.0625rem);   /* 16 → 17px — item name */
  --text-lg:  clamp(1rem, 0.95rem + 0.22vw, 1.1875rem);   /* 16 → 19px — body prose */
  --text-xl:  clamp(1.5625rem, 1.40rem + 0.70vw, 1.75rem);/* 25 → 28px — card title */
  --text-2xl: clamp(1.75rem, 1.45rem + 1.30vw, 2.125rem); /* 28 → 34px — empty-state h2 */
  --text-3xl: clamp(2rem, 1.35rem + 2.80vw, 3.375rem);    /* 32 → 54px — post h1 */

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-black: 800;                                    /* wordmark only */

  --leading-tight: 1.04;                                  /* h1 */
  --leading-snug: 1.15;                                    /* card titles */
  --leading-normal: 1.3;                                   /* item names */
  --leading-relaxed: 1.65;                                 /* prose, disclosure */

  --tracking-tighter: -0.035em;                            /* h1 */
  --tracking-tight: -0.028em;                              /* card titles */
  --tracking-snug: -0.015em;                               /* item names */
  --tracking-normal: 0em;
  --tracking-wide: 0.06em;                                 /* mono brand·category */
  --tracking-wider: 0.14em;                                /* mono uppercase labels */
  --tracking-widest: 0.16em;                               /* section eyebrows */

  /* Spacing — 4px base */
  --space-0: 0;
  --space-1: 0.25rem;   /* 4  */
  --space-2: 0.375rem;  /* 6  */
  --space-3: 0.5rem;    /* 8  */
  --space-4: 0.75rem;   /* 12 */
  --space-5: 0.875rem;  /* 14 */
  --space-6: 1rem;      /* 16 */
  --space-7: 1.125rem;  /* 18 — mobile page gutter */
  --space-8: 1.5rem;    /* 24 */
  --space-9: 1.75rem;   /* 28 — mobile card stack gap */
  --space-10: 2rem;     /* 32 — tablet gutter */
  --space-12: 2.75rem;  /* 44 — desktop grid gap, min touch target */
  --space-14: 3rem;     /* 48 — desktop gutter */
  --space-16: 3.5rem;   /* 56 — detail column gap */
  --space-20: 4rem;     /* 64 */

  --gutter-sm: var(--space-7);    /* <768  */
  --gutter-md: var(--space-10);   /* 768+  */
  --gutter-lg: var(--space-14);   /* 1280+ */
  --tap-min: 2.75rem;             /* 44px — every interactive element */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  /* Layout */
  --container-max: 90rem;         /* 1440 */
  --measure: 40rem;               /* 640 — prose max-width */
  --sidebar-w: 25rem;             /* 400 — item list column */
  --aspect-render: 3 / 2;         /* canonical image ratio, feed + detail + OG */

  /* Radius */
  --radius-xs: 0.25rem;   /* 4  — image plates */
  --radius-sm: 0.375rem;  /* 6  — controls, hero, item rows */
  --radius-md: 0.5rem;    /* 8  — panels, buttons, cards */
  --radius-lg: 1.25rem;   /* 20 — mobile sheet */
  --radius-full: 9999px;  /* chips, toggle */

  /* Border widths */
  --border-hairline: 1px;
  --border-thick: 2px;    /* focus ring, selected control */

  /* Motion */
  --duration-instant: 80ms;
  --duration-fast: 140ms;
  --duration-base: 200ms;
  --duration-slow: 320ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* Z layers */
  --z-base: 0;
  --z-sticky: 10;      /* sticky item sidebar */
  --z-header: 20;      /* mobile sticky header */
  --z-overlay: 30;     /* sheet scrim */
  --z-sheet: 40;       /* mobile filter sheet / panel */
  --z-skip-link: 50;   /* must sit above everything */
}

/* ---------- 2. Light tokens (default, no cookie, light OS) ---------- */
:root {
  --color-surface:        oklch(0.985 0.003 250);
  --color-surface-raised: oklch(1 0 0);
  --color-surface-sunken: oklch(0.955 0.004 250);
  --color-text:           oklch(0.22 0.010 250);
  --color-text-muted:     oklch(0.48 0.010 250);
  --color-text-subtle:    oklch(0.58 0.010 250);
  --color-text-inverse:   oklch(0.985 0.003 250);
  --color-border:         oklch(0.88 0.005 250);
  --color-border-strong:  oklch(0.80 0.006 250);
  --color-accent:         oklch(0.85 0.19 125);   /* fill only */
  --color-accent-text:    oklch(0.48 0.13 125);   /* 4.9:1 on surface — link/CTA text */
  --color-accent-on:      oklch(0.25 0.060 125);  /* text on accent fill — 9.4:1 */
  --color-focus:          oklch(0.42 0.16 125);
  --color-scrim:          oklch(0.22 0.010 250 / 0.42);

  /* Elevation — light: real shadows */
  --elevation-raised-bg:     var(--color-surface-raised);
  --elevation-raised-border: var(--color-border);
  --elevation-raised-shadow: 0 1px 2px oklch(0.22 0.01 250 / 0.06);
  --elevation-image-shadow:  0 1px 2px oklch(0.22 0.01 250 / 0.10),
                             0 8px 24px -12px oklch(0.22 0.01 250 / 0.22);
  --elevation-sheet-shadow:  0 -8px 32px -12px oklch(0.22 0.01 250 / 0.28);
}

/* ---------- 3. Dark tokens — no-cookie path, dark OS ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-surface:        oklch(0.205 0.006 250);
    --color-surface-raised: oklch(0.245 0.007 250);
    --color-surface-sunken: oklch(0.180 0.006 250);
    --color-text:           oklch(0.95 0.005 250);
    --color-text-muted:     oklch(0.70 0.008 250);
    --color-text-subtle:    oklch(0.60 0.008 250);
    --color-text-inverse:   oklch(0.16 0.010 250);
    --color-border:         oklch(0.325 0.008 250);
    --color-border-strong:  oklch(0.385 0.008 250);
    --color-accent:         oklch(0.85 0.19 125);
    --color-accent-text:    oklch(0.85 0.19 125);  /* 11.6:1 on surface */
    --color-accent-on:      oklch(0.16 0.010 250);
    --color-focus:          oklch(0.88 0.17 125);
    --color-scrim:          oklch(0.12 0.010 250 / 0.62);

    /* Elevation — dark: shadows are invisible, so elevation is
       surface lightening + a hairline border. Shadow tokens resolve to none
       so a component can reference them unconditionally. */
    --elevation-raised-bg:     var(--color-surface-raised);
    --elevation-raised-border: var(--color-border);
    --elevation-raised-shadow: none;
    --elevation-image-shadow:  none;
    --elevation-sheet-shadow:  none;
  }
}

/* ---------- 4. Explicit light — must beat a dark OS preference ---------- */
[data-theme="light"] {
  color-scheme: light;
  --color-surface:        oklch(0.985 0.003 250);
  --color-surface-raised: oklch(1 0 0);
  --color-surface-sunken: oklch(0.955 0.004 250);
  --color-text:           oklch(0.22 0.010 250);
  --color-text-muted:     oklch(0.48 0.010 250);
  --color-text-subtle:    oklch(0.58 0.010 250);
  --color-text-inverse:   oklch(0.985 0.003 250);
  --color-border:         oklch(0.88 0.005 250);
  --color-border-strong:  oklch(0.80 0.006 250);
  --color-accent:         oklch(0.85 0.19 125);
  --color-accent-text:    oklch(0.48 0.13 125);
  --color-accent-on:      oklch(0.25 0.060 125);
  --color-focus:          oklch(0.42 0.16 125);
  --color-scrim:          oklch(0.22 0.010 250 / 0.42);
  --elevation-raised-bg:     var(--color-surface-raised);
  --elevation-raised-border: var(--color-border);
  --elevation-raised-shadow: 0 1px 2px oklch(0.22 0.01 250 / 0.06);
  --elevation-image-shadow:  0 1px 2px oklch(0.22 0.01 250 / 0.10),
                             0 8px 24px -12px oklch(0.22 0.01 250 / 0.22);
  --elevation-sheet-shadow:  0 -8px 32px -12px oklch(0.22 0.01 250 / 0.28);
}

/* ---------- 5. Explicit dark ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --color-surface:        oklch(0.205 0.006 250);
  --color-surface-raised: oklch(0.245 0.007 250);
  --color-surface-sunken: oklch(0.180 0.006 250);
  --color-text:           oklch(0.95 0.005 250);
  --color-text-muted:     oklch(0.70 0.008 250);
  --color-text-subtle:    oklch(0.60 0.008 250);
  --color-text-inverse:   oklch(0.16 0.010 250);
  --color-border:         oklch(0.325 0.008 250);
  --color-border-strong:  oklch(0.385 0.008 250);
  --color-accent:         oklch(0.85 0.19 125);
  --color-accent-text:    oklch(0.85 0.19 125);
  --color-accent-on:      oklch(0.16 0.010 250);
  --color-focus:          oklch(0.88 0.17 125);
  --color-scrim:          oklch(0.12 0.010 250 / 0.62);
  --elevation-raised-bg:     var(--color-surface-raised);
  --elevation-raised-border: var(--color-border);
  --elevation-raised-shadow: none;
  --elevation-image-shadow:  none;
  --elevation-sheet-shadow:  none;
}

/* ---------- 6. Focus + reduced motion ---------- */
:where(a, button, input, select, summary, [tabindex]):focus-visible {
  outline: var(--border-thick) solid var(--color-focus);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-instant: 0ms;
    --duration-fast: 0ms;
    --duration-base: 0ms;
    --duration-slow: 0ms;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 7. Tailwind v4 bridge ---------- */
@theme inline {
  --color-surface: var(--color-surface);
  --color-surface-raised: var(--color-surface-raised);
  --color-surface-sunken: var(--color-surface-sunken);
  --color-text: var(--color-text);
  --color-text-muted: var(--color-text-muted);
  --color-text-subtle: var(--color-text-subtle);
  --color-text-inverse: var(--color-text-inverse);
  --color-border: var(--color-border);
  --color-border-strong: var(--color-border-strong);
  --color-accent: var(--color-accent);
  --color-accent-text: var(--color-accent-text);
  --color-accent-on: var(--color-accent-on);
  --color-focus: var(--color-focus);
  --font-sans: var(--font-sans);
  --font-mono: var(--font-mono);
  --radius-xs: var(--radius-xs);
  --radius-sm: var(--radius-sm);
  --radius-md: var(--radius-md);
  --radius-lg: var(--radius-lg);
}
