/* ─────────────────────────────────────────────────────────────
   Night. Greys and moonlight only.
   ───────────────────────────────────────────────────────────── */

@font-face { font-family: "Cormorant"; src: url(../fonts/cormorant-garamond-latin-300-normal.woff2) format("woff2"); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(../fonts/cormorant-garamond-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(../fonts/cormorant-garamond-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(../fonts/cormorant-garamond-latin-300-italic.woff2) format("woff2"); font-weight: 300; font-style: italic; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(../fonts/cormorant-garamond-latin-400-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Inter"; src: url(../fonts/inter-latin-300-normal.woff2) format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Inter"; src: url(../fonts/inter-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url(../fonts/inter-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url(../fonts/jetbrains-mono-latin-300-normal.woff2) format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url(../fonts/jetbrains-mono-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }

:root {
  color-scheme: dark;

  --ink-0: #0b0b0c;     /* the sky */
  --ink-1: #111113;
  --ink-2: #18181b;
  --ink-3: #222226;
  --ink-4: #2d2d32;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);

  --fg-0: #ececef;      /* moonlight */
  --fg-1: #c9c9cc;
  --fg-2: #8d8d93;
  --fg-3: #5e5e64;
  --silver: #d8dbe0;

  --serif: "Cormorant", "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  --rail-w: 76px;
  --rail-w-open: 248px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  background: var(--ink-0);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--ink-0);
  color: var(--fg-1);
  font: 300 17px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: rgba(216, 219, 224, 0.22); color: #fff; }
a { color: inherit; }
img, svg, canvas { display: block; }
:focus-visible { outline: 1px solid var(--silver); outline-offset: 4px; border-radius: 4px; }

/* ─── Scene layers ─────────────────────────────────────────── */

#moon-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100lvh;
  z-index: 0;
  opacity: 0;
  transition: opacity 2.4s ease;
}
#moon-canvas.is-live { opacity: 1; }

#crow-layer {
  position: fixed;
  inset: 0;
  z-index: 1; /* in front of the moon, behind the words */
  pointer-events: none;
  overflow: hidden;
}

.grain {
  position: fixed;
  inset: -50%;
  z-index: 4;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -4%); }
  60% { transform: translate(-4%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

main { position: relative; z-index: 2; }

/* ─── Left rail (bodpie glass, turned vertical) ───────────── */

.rail {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  background: linear-gradient(160deg, rgba(26, 26, 28, 0.55) 0%, rgba(40, 40, 44, 0.38) 100%);
  backdrop-filter: blur(20px) saturate(120%);
  -webkit-backdrop-filter: blur(20px) saturate(120%);
  border-right: 1px solid var(--line);
  box-shadow: 4px 0 30px rgba(0, 0, 0, 0.35);
  transition: width 0.45s var(--ease-out), background 0.5s var(--ease), backdrop-filter 0.5s var(--ease);
  overflow: hidden;
  animation: railIn 0.9s var(--ease-out) both 0.2s;
}
@keyframes railIn { from { transform: translateX(-100%); } to { transform: none; } }

/* the sweep of light from bodpie, now falling top to bottom */
.rail::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(216, 219, 224, 0.06) 50%, transparent 100%);
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.rail:hover::before, .rail:focus-within::before { opacity: 1; }
.rail:hover, .rail:focus-within { width: var(--rail-w-open); }
.rail.scrolled {
  background: linear-gradient(160deg, rgba(18, 18, 20, 0.78) 0%, rgba(30, 30, 33, 0.66) 100%);
  backdrop-filter: blur(30px) saturate(120%);
  -webkit-backdrop-filter: blur(30px) saturate(120%);
}

.rail-mark {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  color: var(--silver);
  border-radius: 14px;
  margin-bottom: 34px;
  flex: none;
  transition: transform 0.4s var(--ease), filter 0.4s var(--ease);
  filter: drop-shadow(0 0 6px rgba(216, 219, 224, 0.25));
}
.rail-mark svg { width: 36px; height: 36px; }
.rail-mark:hover { transform: scale(1.06); filter: drop-shadow(0 0 12px rgba(216, 219, 224, 0.5)); }

.rail-nav { display: flex; flex-direction: column; gap: 4px; }

.rail-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 46px;
  padding: 0 13px;
  border-radius: 12px;
  color: var(--fg-2);
  text-decoration: none;
  font: 400 14px/1 var(--sans);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  transition: color 0.3s var(--ease), background 0.3s var(--ease), transform 0.3s var(--ease);
}
.rail-link::before {
  content: "";
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(216, 219, 224, 0.10) 50%, transparent 100%);
  transition: left 0.6s ease;
}
.rail-link:hover::before { left: 100%; }
.rail-link:hover { color: var(--fg-0); background: rgba(255, 255, 255, 0.04); transform: translateX(3px); }
.rail-link.active { color: var(--fg-0); background: rgba(255, 255, 255, 0.06); }
.rail-link.active::after {
  content: "";
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 2px;
  border-radius: 2px;
  background: var(--silver);
  box-shadow: 0 0 10px rgba(216, 219, 224, 0.8);
}
.rail-link svg, .rail-sound svg {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round;
}
.rail-link span, .rail-sound span, .rail-clock { opacity: 0; transform: translateX(-6px); transition: opacity 0.3s var(--ease), transform 0.4s var(--ease-out); }
.rail:hover .rail-link span, .rail:focus-within .rail-link span,
.rail:hover .rail-sound span, .rail:focus-within .rail-sound span,
.rail:hover .rail-clock, .rail:focus-within .rail-clock { opacity: 1; transform: none; }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.rail-sound {
  display: flex; align-items: center; gap: 18px;
  height: 44px; padding: 0 13px;
  border: 0; border-radius: 12px;
  background: transparent;
  color: var(--fg-3);
  font: 400 13px/1 var(--sans);
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.3s var(--ease), background 0.3s var(--ease);
}
.rail-sound:hover { color: var(--fg-1); background: rgba(255, 255, 255, 0.04); }
.rail-sound .wave { opacity: 0.25; transition: opacity 0.3s; }
.rail-sound[aria-pressed="true"] { color: var(--fg-0); }
.rail-sound[aria-pressed="true"] .wave { opacity: 1; animation: wave 2.4s ease-in-out infinite; }
@keyframes wave { 50% { opacity: 0.35; } }

.rail-clock {
  padding: 0 13px;
  font: 300 12px/1.5 var(--mono);
  color: var(--fg-3);
  white-space: nowrap;
}
.rail-clock .clock-time { display: block; font-size: 18px; color: var(--fg-1); letter-spacing: 0.04em; }

.rail-toggle { display: none; }

/* ─── Content ──────────────────────────────────────────────── */

main { padding-left: var(--rail-w); }

.eyebrow {
  margin: 0 0 18px;
  font: 400 11px/1 var(--mono);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--fg-3);
}

h1, h2, h3 { font-family: var(--serif); font-weight: 300; color: var(--fg-0); margin: 0; }
h2 { font-size: clamp(34px, 4.6vw, 62px); line-height: 1.06; letter-spacing: -0.01em; }
h2 em, .prose em { font-style: italic; color: var(--fg-2); }
.prose em { color: var(--fg-0); }

.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-items: end;
  justify-items: center;
  padding: 0 24px 15vh;
  text-align: center;
  pointer-events: none;
}
.hero-text { pointer-events: auto; transform: translateY(var(--hero-shift, 0)); }
.hero h1 {
  font-size: clamp(40px, 6.4vw, 92px);
  font-weight: 300;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1;
  text-shadow: 0 0 40px rgba(216, 219, 224, 0.18);
}
.hero-sub {
  margin: 22px 0 0;
  font: italic 300 clamp(18px, 1.8vw, 23px)/1.4 var(--serif);
  color: var(--fg-2);
}
.hero .eyebrow { margin-bottom: 26px; min-height: 1em; }

.scroll-hint {
  position: absolute;
  bottom: 4vh;
  left: 50%;
  width: 1px; height: 56px;
  pointer-events: auto;
  background: linear-gradient(var(--line-strong), transparent);
  overflow: hidden;
}
.scroll-hint span {
  position: absolute; left: 0; top: -40%;
  width: 1px; height: 40%;
  background: var(--silver);
  animation: drip 2.6s var(--ease) infinite;
}
@keyframes drip { to { top: 110%; } }

.block {
  position: relative;
  padding: clamp(110px, 16vh, 200px) clamp(24px, 7vw, 120px);
  max-width: 1320px;
  margin: 0 auto;
}
.col { max-width: 760px; }

/* soft dark veil so text sits on the night, not on the moon */
.block::before {
  content: "";
  position: absolute;
  inset: 0 -20vw;
  z-index: -1;
  background: radial-gradient(ellipse at 30% 50%, rgba(11, 11, 12, 0.72), rgba(11, 11, 12, 0.35) 70%, transparent);
  pointer-events: none;
}

.prose { margin-top: 44px; max-width: 640px; }
.prose p { margin: 0 0 1.3em; color: var(--fg-1); }
.prose-small { margin-top: 26px; color: var(--fg-2); font-size: 15px; }

/* who: interests as a quiet constellation list */
.interests {
  list-style: none;
  margin: 90px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  border-top: 1px solid var(--line);
}
.interests li {
  padding: 22px 22px 22px 0;
  border-bottom: 1px solid var(--line);
  transition: background 0.4s var(--ease);
}
.interests span {
  display: block;
  font: 400 23px/1.2 var(--serif);
  color: var(--fg-0);
}
.interests small { display: block; margin-top: 6px; font-size: 13px; color: var(--fg-3); transition: color 0.4s; }
.interests li:hover small { color: var(--fg-2); }

/* work */
.piece {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: center;
  margin-top: clamp(80px, 12vh, 140px);
}
.piece--truffle .piece-visual { order: 2; }
.piece-visual {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 28px;
  background: radial-gradient(circle at 50% 45%, var(--ink-2), var(--ink-0) 72%);
  border: 1px solid var(--line);
  overflow: hidden;
}
.piece-visual canvas, .piece-visual .neon { position: absolute; inset: 0; width: 100%; height: 100%; }
.piece-text h3 { font-size: clamp(38px, 4vw, 56px); line-height: 1; }
.piece-kicker { margin: 10px 0 26px; font: italic 300 21px/1.3 var(--serif); color: var(--fg-2); }
.tags { font: 300 12.5px/1.8 var(--mono); color: var(--fg-3); letter-spacing: 0.02em; }
.piece-link {
  display: inline-block;
  margin-top: 8px;
  font: 400 13px/1 var(--mono);
  color: var(--fg-1);
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 4px;
  transition: color 0.3s, border-color 0.3s;
}
.piece-link:hover { color: #fff; border-color: var(--silver); }

.minor-work {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1px;
  margin-top: clamp(90px, 14vh, 160px);
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}
.minor-work article { padding: 34px 30px; background: rgba(15, 15, 17, 0.88); }
.minor-work h3 { font-size: 30px; margin-bottom: 12px; }
.minor-work p { margin: 0 0 12px; font-size: 15px; color: var(--fg-2); }

.stack { margin-top: clamp(90px, 14vh, 160px); }
.stack dl { margin: 0; border-top: 1px solid var(--line); }
.stack dl > div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.stack dt { font: 400 12px/1.9 var(--mono); color: var(--fg-3); letter-spacing: 0.18em; text-transform: uppercase; }
.stack dd { margin: 0; font-size: 15.5px; color: var(--fg-1); }

/* stars */
.stars-frame {
  position: relative;
  margin-top: 60px;
  height: min(72vh, 680px);
  border-radius: 28px;
  border: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 40%, #121215, var(--ink-0) 75%);
  overflow: hidden;
}
#stars-canvas { width: 100%; height: 100%; cursor: crosshair; }
.stars-tip {
  position: absolute;
  pointer-events: none;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(20, 20, 23, 0.78);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font: 400 12px/1.5 var(--mono);
  color: var(--fg-0);
  white-space: nowrap;
  transform: translate(14px, 14px);
}

/* terminal */
.term {
  margin-top: 54px;
  max-width: 900px;
  min-height: 420px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: rgba(10, 10, 11, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  font: 300 14px/1.7 var(--mono);
  color: var(--fg-1);
  overflow: hidden;
}

/* elsewhere */
.links { list-style: none; padding: 0; margin: 60px 0 0; }
.links li { border-bottom: 1px solid var(--line); }
.links a {
  display: flex; align-items: baseline; justify-content: space-between; gap: 20px;
  padding: 24px 0;
  font: 300 clamp(28px, 3.4vw, 44px)/1.1 var(--serif);
  color: var(--fg-0);
  text-decoration: none;
  transition: padding 0.4s var(--ease-out), color 0.3s;
}
.links a span { font: 300 13px/1 var(--mono); color: var(--fg-3); }
.links a:hover { padding-left: 18px; color: #fff; }

.foot {
  display: flex; align-items: center; gap: 16px;
  margin-top: 140px;
  color: var(--fg-3);
  font: 300 12px/1.5 var(--mono);
}
.foot svg { width: 28px; height: 28px; color: var(--fg-3); }

/* reveal on scroll */
.js .reveal { opacity: 0; transform: translateY(26px); transition: opacity 1.1s var(--ease-out), transform 1.1s var(--ease-out); }
.js .reveal.in { opacity: 1; transform: none; }

/* ─── Mobile: rail becomes a left drawer ──────────────────── */

@media (max-width: 820px) {
  main { padding-left: 0; }
  body { font-size: 16px; }

  .rail {
    width: min(300px, 82vw);
    transform: translateX(-102%);
    animation: none;
    transition: transform 0.45s var(--ease-out);
    background: linear-gradient(160deg, rgba(20, 20, 22, 0.86), rgba(34, 34, 38, 0.8));
  }
  .rail:hover, .rail:focus-within { width: min(300px, 82vw); }
  .rail.open { transform: none; }
  .rail .rail-link span, .rail .rail-sound span, .rail .rail-clock { opacity: 1; transform: none; }

  .rail-toggle {
    position: fixed;
    top: 14px; left: 14px;
    z-index: 60;
    display: grid;
    place-content: center;
    gap: 6px;
    width: 46px; height: 46px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(24, 24, 27, 0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    cursor: pointer;
  }
  .rail-toggle span { display: block; width: 18px; height: 1.5px; background: var(--fg-0); transition: transform 0.35s var(--ease); }
  .rail-toggle[aria-expanded="true"] span:first-child { transform: translateY(3.75px) rotate(45deg); }
  .rail-toggle[aria-expanded="true"] span:last-child { transform: translateY(-3.75px) rotate(-45deg); }

  .block { padding: 96px 16px; }
  .piece { grid-template-columns: 1fr; }
  .piece--truffle .piece-visual { order: 0; }
  .stack dl > div { grid-template-columns: 1fr; gap: 4px; }
  .stars-frame { height: 60vh; }
  .hero { padding-bottom: 13vh; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .grain, .scroll-hint span, .rail { animation: none; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
}

/* ─── Phones / touch (html.lite, set in main.js) ─────────────
   The page scrolls like a plain document: no animated full-screen grain, no backdrop blur on
   fixed layers (each one re-blurs on every scrolled frame), no fade-in on scroll. */
html.lite .grain { display: none; }
html.lite .rail, html.lite .rail.scrolled, html.lite .rail-toggle, html.lite .term, html.lite .stars-tip {
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
html.lite .rail, html.lite .rail.scrolled { background: linear-gradient(160deg, #141416, #1e1e21); }
html.lite .rail-toggle { background: rgba(22, 22, 25, 0.92); }
html.lite .term { background: rgba(10, 10, 11, 0.94); }
html.lite .hero-text { transform: none; }
