/* ═══════════════════════════════════════════════════════════════════════
   l3xj redesign: shared design system (tokens, type, nav, menu, components)
   Every variant loads this first, then its own stylesheet for layout.
   Aesthetic: black canvas, white stipple / point-cloud / hairline art, one
   iridescent blue→violet accent and a small peach spark. Light mode is the
   same system printed in ink on paper.
═══════════════════════════════════════════════════════════════════════ */

:root {
  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --wrap: 1240px;
  --gutter: clamp(20px, 4vw, 48px);
  --radius: 14px;
  --radius-pill: 999px;
  --nav-h: 72px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 0.35s;
}

/* Dark is the default palette (and the fallback when no data-theme is set). */
:root,
[data-theme='dark'] {
  color-scheme: dark;
  --bg: #050505;
  --bg-2: #0b0b0d;
  --surface: #101013;
  --surface-2: #16161a;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.26);
  --ink: #f1f0ec;
  --ink-2: rgba(241, 240, 236, 0.64);
  --ink-3: rgba(241, 240, 236, 0.4);
  --art: #ffffff;            /* stipple / wireframe colour used by art.js */
  --art-soft: rgba(255, 255, 255, 0.35);
  --accent: #5aa8ff;         /* iridescent pair: blue → violet */
  --accent-2: #b27dff;
  --spark: #ff9e6d;          /* the lone peach dot */
  --glass: rgba(255, 255, 255, 0.035);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

[data-theme='light'] {
  color-scheme: light;
  --bg: #f2f1ec;
  --bg-2: #e9e7e0;
  --surface: #fbfaf6;
  --surface-2: #f5f3ee;
  --line: rgba(10, 10, 12, 0.12);
  --line-strong: rgba(10, 10, 12, 0.3);
  --ink: #0b0b0c;
  --ink-2: rgba(11, 11, 12, 0.66);
  --ink-3: rgba(11, 11, 12, 0.44);
  --art: #0b0b0c;
  --art-soft: rgba(11, 11, 12, 0.32);
  --accent: #1e6ae0;
  --accent-2: #7a3ddf;
  --spark: #e0592a;
  --glass: rgba(0, 0, 0, 0.025);
  --shadow: 0 30px 80px rgba(20, 20, 30, 0.14);
}

/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 16px); }
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;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, h4, h5, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
::selection { background: var(--accent); color: #fff; }

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

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  padding: 10px 16px; border-radius: var(--radius-pill);
  background: var(--ink); color: var(--bg); font-size: 14px;
}
.skip-link:focus { top: 12px; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }

/* ── Type ─────────────────────────────────────────────────────────────── */
/* Headlines mix a light weight with a heavier one, like the reference hero. */
.display {
  font-weight: 300;
  font-size: clamp(44px, 7.2vw, 108px);
  line-height: 0.98;
  letter-spacing: -0.035em;
}
.h1 { font-weight: 300; font-size: clamp(36px, 5vw, 72px); line-height: 1.02; letter-spacing: -0.03em; }
.h2 { font-weight: 300; font-size: clamp(30px, 3.6vw, 52px); line-height: 1.06; letter-spacing: -0.025em; }
.h3 { font-weight: 400; font-size: clamp(22px, 2vw, 28px); line-height: 1.2; letter-spacing: -0.015em; }
.display b, .h1 b, .h2 b, .h3 b { font-weight: 600; }
.lede { font-size: clamp(17px, 1.4vw, 20px); line-height: 1.65; color: var(--ink-2); }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }

/* Mono labels: the "technical annotation" voice. */
.label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.label-accent { color: var(--accent); }
.mono { font-family: var(--font-mono); }

/* Iridescent text, used sparingly (one or two words per page). */
.iri {
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.spark-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--spark); }

/* ── Buttons, tags, links ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 20px;
  border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 500;
  border: 1px solid var(--line-strong);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { border-color: var(--ink); }
.btn-solid { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-solid:hover { transform: translateY(-1px); }
.btn svg { width: 16px; height: 16px; }

.tag {
  display: inline-flex; align-items: center;
  height: 28px; padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.02em;
  color: var(--ink-2);
  white-space: nowrap;
}
.tag-accent { border-color: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }

.arrow-link { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.arrow-link svg { width: 14px; height: 14px; transition: transform var(--dur) var(--ease); }
.arrow-link:hover svg { transform: translate(2px, -2px); }

.hair { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ── Retro window chrome ("PROJECT.EXE") ──────────────────────────────── */
.win {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 6px;
  overflow: hidden;
}
.win-bar {
  display: flex; align-items: center; justify-content: space-between;
  height: 30px; padding: 0 8px 0 12px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface-2);
}
.win-title { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.win-ctrls { display: flex; gap: 4px; }
/* Markup: <span class="win-ctrls" aria-hidden="true"><i>_</i><i>□</i><i>×</i></span>
   (inside a dialog, make the last one a real <button> that closes it). */
.win-ctrls i, .win-ctrls button {
  width: 16px; height: 16px; display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 2px;
  font-style: normal; font-family: var(--font-mono); font-size: 10px; line-height: 1;
  color: var(--ink-2);
}
.win-ctrls button:hover { color: var(--ink); border-color: var(--ink); }
.win-body { padding: 20px; }

/* ── Textures that follow the theme ───────────────────────────────────── */
.dotgrid {
  background-image: radial-gradient(circle, var(--line-strong) 1px, transparent 1.4px);
  background-size: 18px 18px;
}
.hatch {
  background-image: repeating-linear-gradient(135deg, var(--line) 0 1px, transparent 1px 7px);
}

/* Canvases from art.js fill their box; the box decides the size. */
.art { position: relative; }
.art > canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ═══════════════════════════════════════════════════════════════════════
   SITE NAV (rendered by nav.js) + MENU SHEET
═══════════════════════════════════════════════════════════════════════ */
.site-nav {
  position: fixed; inset: 0 0 auto 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 var(--gutter);
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  border-bottom: 1px solid transparent;
}
.site-nav.is-scrolled {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom-color: var(--line);
}
.brand { font-weight: 600; font-size: 18px; letter-spacing: -0.02em; display: inline-flex; align-items: center; }
.brand span { color: var(--spark); }

.nav-pill {
  display: flex; gap: 2px; padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--glass);
  backdrop-filter: blur(10px);
}
.nav-pill a {
  padding: 7px 14px; border-radius: var(--radius-pill);
  font-size: 13px; color: var(--ink-2);
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.nav-pill a:hover { color: var(--ink); }
.nav-pill a.is-active { color: var(--bg); background: var(--ink); }

.nav-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.icon-btn:hover { border-color: var(--line-strong); background: var(--glass); }
.icon-btn svg { width: 18px; height: 18px; }
/* The toggle shows the theme you will switch TO. */
[data-theme='dark'] .theme-toggle .i-moon { display: none; }
[data-theme='light'] .theme-toggle .i-sun { display: none; }

.menu-btn {
  height: 40px; padding: 0 16px; border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); font-size: 13px;
}
.menu-btn:hover { border-color: var(--line-strong); }
.menu-btn .bars { width: 16px; display: grid; gap: 4px; }
.menu-btn .bars i { display: block; height: 1.5px; background: currentColor; border-radius: 2px; }

@media (min-width: 1100px) { .menu-btn { display: none; } }
@media (max-width: 1099px) { .nav-pill { display: none; } }

/* Menu sheet: a real dialog with a visible Close button, backdrop click,
   Escape, browser Back and link clicks all closing it. */
.menu[hidden] { display: none; }
.menu { position: fixed; inset: 0; z-index: 150; }
.menu-backdrop {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(6px);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.menu-panel {
  position: absolute; top: 10px; right: 10px; bottom: 10px;
  width: min(440px, calc(100% - 20px));
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transform: translateX(24px); opacity: 0;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
  overflow: auto;
}
.menu.is-open .menu-backdrop { opacity: 1; }
.menu.is-open .menu-panel { transform: none; opacity: 1; }
.menu-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 16px 24px; border-bottom: 1px solid var(--line);
}
.menu-close {
  height: 40px; padding: 0 14px 0 16px; border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong); font-size: 13px;
}
.menu-close:hover { background: var(--glass); }
.menu-close svg { width: 16px; height: 16px; }
.menu-links { padding: 12px 12px 0; display: grid; }
.menu-links a {
  display: flex; align-items: baseline; gap: 16px;
  padding: 14px 12px; border-radius: 10px;
  font-size: 28px; font-weight: 300; letter-spacing: -0.02em;
}
.menu-links a .label { min-width: 28px; }
.menu-links a:hover, .menu-links a.is-active { background: var(--glass); }
.menu-links a.is-active { color: var(--accent); }
.menu-foot { margin-top: auto; padding: 20px 24px 24px; display: grid; gap: 14px; border-top: 1px solid var(--line); }
.menu-foot .row { display: flex; flex-wrap: wrap; gap: 8px; }

body.menu-open { overflow: hidden; }

/* Back to top */
.to-top {
  position: fixed; right: var(--gutter); bottom: 22px; z-index: 90;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line-strong);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.to-top svg { width: 18px; height: 18px; }

/* Reveal on scroll (added by nav.js; content is visible without JS). */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.8s var(--ease), transform 0.8s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .js .reveal { opacity: 1; transform: none; }
}

/* ── Generic overlay (Site.overlay): dialogs, drawers, project windows ── */
.overlay[hidden] { display: none; }
.overlay { position: fixed; inset: 0; z-index: 160; display: grid; place-items: center; padding: 20px; }
.overlay-backdrop {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  backdrop-filter: blur(6px);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.overlay-panel {
  position: relative; width: min(760px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(16px) scale(0.985);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.overlay.is-open .overlay-backdrop { opacity: 1; }
.overlay.is-open .overlay-panel { opacity: 1; transform: none; }

@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
