/* ==========================================================================
   base.css — design tokens, reset, typography and UI primitives.
   Loaded by every page. Page-specific styles live in their own files.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Instrument Serif", ui-serif, Georgia, "Times New Roman", serif;
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --bg: #f3f0e8;
  --bg-2: #ebe7dc;
  --surface: #faf8f3;
  --ink: #17160f;
  --ink-2: #4b483e;
  --ink-3: #868174;
  --line: rgba(23, 22, 15, 0.12);
  --line-2: rgba(23, 22, 15, 0.22);
  --accent: #d6532a;
  --accent-soft: rgba(214, 83, 42, 0.13);
  --trace: rgba(23, 22, 15, 0.16);        /* faint signal lines (hero, diagrams) */
  --trace-strong: rgba(23, 22, 15, 0.34);
  --grid: rgba(23, 22, 15, 0.06);
  --ok: #3fa66b;
  --logo-gold: #9a7740;
  --shadow: 0 1px 2px rgba(23, 22, 15, 0.04), 0 18px 40px -18px rgba(23, 22, 15, 0.25);

  --nav-h: 64px;
  --gutter: clamp(16px, 4vw, 48px);
  --maxw: 1320px;
  --radius: 14px;
  --radius-sm: 8px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: light;
}

/* Dark tokens: the dark theme, plus any element that opts in with .tone-dark */
:root[data-theme="dark"],
.tone-dark {
  --bg: #0e0e0c;
  --bg-2: #151512;
  --surface: #191915;
  --ink: #ece8dd;
  --ink-2: #b4afa2;
  --ink-3: #7d796e;
  --line: rgba(236, 232, 221, 0.1);
  --line-2: rgba(236, 232, 221, 0.2);
  --accent: #ef6a3f;
  --accent-soft: rgba(239, 106, 63, 0.15);
  --trace: rgba(236, 232, 221, 0.13);
  --trace-strong: rgba(236, 232, 221, 0.3);
  --grid: rgba(236, 232, 221, 0.05);
  --logo-gold: #c2a67d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 20px 44px -18px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

/* No-JS fallback: follow the system theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0e0e0c;
    --bg-2: #151512;
    --surface: #191915;
    --ink: #ece8dd;
    --ink-2: #b4afa2;
    --ink-3: #7d796e;
    --line: rgba(236, 232, 221, 0.1);
    --line-2: rgba(236, 232, 221, 0.2);
    --accent: #ef6a3f;
    --accent-soft: rgba(239, 106, 63, 0.15);
    --trace: rgba(236, 232, 221, 0.13);
    --trace-strong: rgba(236, 232, 221, 0.3);
    --grid: rgba(236, 232, 221, 0.05);
    --logo-gold: #c2a67d;
    color-scheme: dark;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 12px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

img, svg, canvas, video { display: block; max-width: 100%; }
/* `display` rules above would otherwise override the hidden attribute */
[hidden] { display: none !important; }
img { height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

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

/* ---------- Utilities ---------- */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.mono { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase; }
.muted { color: var(--ink-3); }
.accent { color: var(--accent); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Colour swatch + hex code, used wherever a photo's dominant colour is shown */
.hex { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; }
.hex::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--swatch, currentColor); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }

/* ---------- Icons ---------- */
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.i--sm { width: 15px; height: 15px; }

/* ---------- Buttons & links ---------- */
.btn {
  --h: 48px;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: var(--h); padding: 0 22px;
  border-radius: 999px;
  font-size: 0.95rem; font-weight: 500; letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn--solid { background: var(--ink); color: var(--bg); }
.btn--solid:hover { background: var(--accent); color: #fff; }
.btn--ghost { border: 1px solid var(--line-2); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--sm { --h: 38px; padding: 0 16px; font-size: 0.86rem; }
.btn .i { transition: transform 0.3s var(--ease); }
.btn:hover .i--go { transform: translateX(3px); }
.btn:hover .i--out { transform: translate(2px, -2px); }

.icon-btn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink); }

.link {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 500;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size 0.35s var(--ease), color 0.2s;
}
.link:hover { background-size: 100% 1px; color: var(--accent); }

.chip {
  display: inline-flex; align-items: center;
  height: 28px; padding: 0 11px;
  border: 1px solid var(--line-2); border-radius: 999px;
  font-size: 0.8rem; color: var(--ink-2);
  white-space: nowrap;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }

.filter {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 15px;
  border: 1px solid var(--line-2); border-radius: 999px;
  font-size: 0.86rem; color: var(--ink-2);
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.filter:hover { border-color: var(--ink); color: var(--ink); }
.filter sup { font-family: var(--font-mono); font-size: 0.66rem; color: var(--ink-3); top: 0; }
.filter[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.filter[aria-pressed="true"] sup { color: inherit; opacity: 0.6; }

/* ---------- Scroll reveal (toggled by components/site-chrome.js) ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 1s var(--ease-out), transform 1s var(--ease-out);
  transition-delay: var(--d, 0s);
}
.js [data-reveal].is-visible { opacity: 1; transform: none; }

/* ---------- Opened from the folder ----------
   Pages opened straight from disk (file://) can't load ES modules, so the
   inline script in <head> adds .is-file instead of .js. This hint never
   appears on the deployed site. */
.is-file body::after {
  content: "Opened from the folder, so the interactive parts are off. Double-click preview.bat to see the full site.";
  position: fixed; left: 50%; bottom: 16px; z-index: 200; translate: -50% 0;
  width: max-content; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg);
  font: 500 0.85rem/1.4 var(--font-sans);
  box-shadow: var(--shadow);
}

/* ---------- Shared keyframes ---------- */
@keyframes fade { from { opacity: 0; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes rise { to { transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ping { 0% { transform: scale(0.6); opacity: 0.9; } 100% { transform: scale(1.8); opacity: 0; } }
