/* ==========================================================================
   base.css — tokens, themes, reset, typography primitives
   Shared by the portfolio and every demo page.
   ========================================================================== */

:root {
  /* Type */
  --f-display: "Instrument Serif", "Iowan Old Style", "Times New Roman", serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --fs-2xs: 0.6875rem;
  --fs-xs: clamp(0.6875rem, 0.66rem + 0.12vw, 0.75rem);
  --fs-sm: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  --fs-base: clamp(0.9375rem, 0.9rem + 0.2vw, 1.0625rem);
  --fs-lg: clamp(1.0625rem, 0.98rem + 0.45vw, 1.3125rem);
  --fs-xl: clamp(1.5rem, 1.2rem + 1.4vw, 2.375rem);
  --fs-2xl: clamp(2.125rem, 1.4rem + 3.4vw, 4.5rem);
  --fs-3xl: clamp(2.625rem, 0.9rem + 7.6vw, 9.5rem);
  --fs-index: clamp(4.5rem, 1.5rem + 12vw, 14rem);

  --lh-tight: 0.95;
  --lh-snug: 1.15;
  --lh-body: 1.7;

  /* Spacing scale (4px base) */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4rem;
  --s-9: 6rem;
  --s-10: 8rem;
  --s-section: clamp(5rem, 3rem + 9vw, 12rem);

  /* Layout */
  --gutter: clamp(1rem, 0.4rem + 2.6vw, 3rem);
  --max-w: 1680px;
  --header-h: 4.25rem;
  --radius: 2px;
  --hair: 1px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);     /* expo.out */
  --ease-soft: cubic-bezier(0.33, 1, 0.68, 1);   /* power3.out-ish */
  --ease-in-out: cubic-bezier(0.76, 0, 0.24, 1);
  --dur-fast: 0.35s;
  --dur: 0.8s;
  --dur-slow: 1.1s;

  color-scheme: dark;

  /* Dark theme (default) */
  --c-bg: #0c0d0b;
  --c-bg-2: #11120f;
  --c-surface: #161713;
  --c-surface-2: #1d1e19;
  --c-ink: #ece8de;
  --c-ink-2: #c8c4b9;
  --c-muted: #95918a;
  --c-faint: #4d4b45;
  --c-line: rgba(236, 232, 222, 0.12);
  --c-line-strong: rgba(236, 232, 222, 0.26);
  --c-grid: rgba(236, 232, 222, 0.045);
  --c-accent: #ffb238;
  --c-accent-fill: #ffb238;
  --c-accent-ink: #0c0d0b;
  --c-accent-soft: rgba(255, 178, 56, 0.12);
  --c-fault: #ec6f55;
}

:root[data-theme="light"] {
  color-scheme: light;
  --c-bg: #eeebe3;
  --c-bg-2: #e7e3d9;
  --c-surface: #f6f4ee;
  --c-surface-2: #e2ded3;
  --c-ink: #15150f;
  --c-ink-2: #34342c;
  --c-muted: #5c5950;
  --c-faint: #a9a598;
  --c-line: rgba(21, 21, 15, 0.14);
  --c-line-strong: rgba(21, 21, 15, 0.32);
  --c-grid: rgba(21, 21, 15, 0.05);
  --c-accent: #9a5500;
  --c-accent-fill: #f0a52a;
  --c-accent-ink: #15150f;
  --c-accent-soft: rgba(240, 165, 42, 0.18);
  --c-fault: #b23a22;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --c-bg: #eeebe3;
    --c-bg-2: #e7e3d9;
    --c-surface: #f6f4ee;
    --c-surface-2: #e2ded3;
    --c-ink: #15150f;
    --c-ink-2: #34342c;
    --c-muted: #5c5950;
    --c-faint: #a9a598;
    --c-line: rgba(21, 21, 15, 0.14);
    --c-line-strong: rgba(21, 21, 15, 0.32);
    --c-grid: rgba(21, 21, 15, 0.05);
    --c-accent: #9a5500;
    --c-accent-fill: #f0a52a;
    --c-accent-ink: #15150f;
    --c-accent-soft: rgba(240, 165, 42, 0.18);
    --c-fault: #b23a22;
  }
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

/* Lenis takes over scrolling when active */
html.lenis,
html.lenis body {
  height: auto;
}

html.lenis {
  scroll-behavior: auto;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

body {
  min-height: 100vh;
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: var(--f-mono);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  font-feature-settings: "calt" 0, "zero" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  transition: background-color var(--dur-fast) var(--ease-soft), color var(--dur-fast) var(--ease-soft);
}

img,
svg,
canvas,
video,
iframe {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
  padding: 0;
}

table {
  border-collapse: collapse;
}

h1,
h2,
h3,
h4 {
  font-weight: 400;
  line-height: var(--lh-snug);
  overflow-wrap: break-word;
}

p {
  overflow-wrap: break-word;
}

::selection {
  background: var(--c-accent-fill);
  color: var(--c-accent-ink);
}

[hidden] {
  display: none;
}

/* ---------- Focus ---------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: var(--radius);
}

/* ---------- Primitives ---------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  inset-block-start: var(--s-3);
  inset-inline-start: var(--s-3);
  z-index: 1000;
  padding: var(--s-2) var(--s-4);
  background: var(--c-accent-fill);
  color: var(--c-accent-ink);
  font-size: var(--fs-sm);
  transform: translateY(-200%);
  transition: transform var(--dur-fast) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

/* Silkscreen-style mono label */
.label {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
  line-height: 1.4;
}

.label--accent {
  color: var(--c-accent);
}

.display {
  font-family: var(--f-display);
  font-weight: 400;
  letter-spacing: -0.01em;
}

em,
.italic {
  font-style: italic;
}

.display em {
  font-family: var(--f-display);
}

.tnum {
  font-variant-numeric: tabular-nums;
}
