/* Dark only, by choice. */
:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --fg: #f2f1ee;
  --muted: #8f8d88;
  --faint: rgba(242, 241, 238, 0.07);
  --line: rgba(242, 241, 238, 0.12);
  --accent: #ff6a3d;
  --glow: rgba(255, 106, 61, 0.16);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter Tight", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* ---------- Atmosphere ---------- */
.grid-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--faint) 1px, transparent 1px),
    linear-gradient(90deg, var(--faint) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: center center;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 75%);
}
.spotlight {
  position: fixed; z-index: 0; pointer-events: none;
  left: 0; top: 0;
  width: 900px; height: 900px;
  margin: -450px 0 0 -450px;
  background: radial-gradient(circle at center, var(--glow), transparent 60%);
  transform: translate3d(50vw, 40vh, 0);
  will-change: transform;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.spotlight.is-on { opacity: 1; }
.grain {
  position: fixed; inset: -50%; z-index: 0; pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Chrome ---------- */
header, footer, main { position: relative; z-index: 1; }
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 24px clamp(16px, 4vw, 40px);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; letter-spacing: 0.02em;
  color: var(--muted);
}
.mark {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border: 1px solid var(--line); border-radius: 8px;
  color: var(--fg); text-decoration: none;
  font-family: "Instrument Serif", Georgia, serif; font-size: 17px; font-style: italic;
  letter-spacing: -0.02em;
}
.status { display: inline-flex; align-items: center; gap: 10px; }
.dot {
  position: relative; width: 7px; height: 7px; border-radius: 50%;
  background: #3ecf8e;
}
.dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: inherit;
  animation: ping 2.4s var(--ease-out) infinite;
}
.dot.off { background: var(--accent); }
@keyframes ping {
  0% { transform: scale(1); opacity: 0.6; }
  70%, 100% { transform: scale(3); opacity: 0; }
}

/* ---------- Hero ---------- */
main {
  display: grid; align-content: center;
  padding: 0 clamp(16px, 6vw, 96px);
  max-width: 1280px; width: 100%; margin: 0 auto;
}
.eyebrow {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--muted);
  margin: 0 0 28px;
  display: flex; align-items: center; gap: 14px;
}
.eyebrow::before {
  content: ""; width: 28px; height: 1px; background: var(--accent);
  transform-origin: left center;
}
h1 {
  margin: 0;
  font-weight: 500;
  font-size: clamp(64px, 15vw, 208px);
  line-height: 0.88;
  letter-spacing: -0.055em;
}
h1 .row { display: block; white-space: nowrap; }
h1 .serif {
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic; font-weight: 400;
  letter-spacing: -0.035em;
  padding-right: 0.06em;
}
h1 .ch { display: inline-block; }
.period { color: var(--accent); }

.lede {
  margin: 40px 0 0;
  max-width: 36ch;
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.45;
  color: var(--muted);
  text-wrap: pretty;
}
.lede strong { color: var(--fg); font-weight: 500; }

.meta {
  margin: 56px 0 0;
  display: flex; flex-wrap: wrap; gap: 12px 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px; color: var(--muted);
  max-width: 640px;
}
.meta dt { text-transform: uppercase; letter-spacing: 0.14em; font-size: 11px; opacity: 0.7; margin-bottom: 6px; }
.meta dd { margin: 0; color: var(--fg); font-variant-numeric: tabular-nums; }

/* ---------- Button (404) ---------- */
.actions { margin-top: 48px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 20px;
  border-radius: 999px;
  background: var(--fg); color: var(--bg);
  font: 500 15px/1 "Inter Tight", ui-sans-serif, system-ui, sans-serif;
  text-decoration: none;
  transition: transform 160ms var(--ease-out), background-color 200ms ease;
}
.btn .arrow { display: inline-block; transition: transform 200ms var(--ease-out); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: #fff; }
  .btn:hover .arrow { transform: translateX(-3px); }
}
.hint {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px; color: var(--muted);
}
.hint code { color: var(--fg); overflow-wrap: anywhere; }

footer.bar { justify-content: space-between; }

/* ---------- Entrance choreography ---------- */
/* Rare, first-visit animation: allowed some delight. Strong ease-out,
   blur bridges the in-between frames, never from scale(0). */
.js h1 .ch {
  opacity: 0;
  filter: blur(12px);
  transform: translateY(0.28em);
  animation: rise 900ms var(--ease-out) forwards;
  animation-delay: calc(var(--i) * 38ms + 120ms);
}
@keyframes rise {
  to { opacity: 1; filter: blur(0); transform: none; }
}
.js .fade {
  opacity: 0;
  transform: translateY(10px);
  animation: fadeUp 700ms var(--ease-out) forwards;
  animation-delay: var(--d, 0ms);
}
@keyframes fadeUp { to { opacity: 1; transform: none; } }
.js .eyebrow::before {
  transform: scaleX(0.2); opacity: 0;
  animation: draw 900ms var(--ease-in-out) 200ms forwards;
}
@keyframes draw { to { transform: scaleX(1); opacity: 1; } }

/* 404: the zero glitches once after landing, then settles. */
.js h1 .ch.glitch {
  animation:
    rise 900ms var(--ease-out) calc(var(--i) * 38ms + 120ms) forwards,
    jitter 420ms steps(2, end) 1300ms 1;
}
h1.small { font-size: clamp(56px, 12vw, 176px); }
@keyframes jitter {
  0%   { transform: translate(0, 0) skewX(0); color: inherit; }
  25%  { transform: translate(-0.03em, 0.01em) skewX(-8deg); color: var(--accent); }
  50%  { transform: translate(0.04em, -0.02em) skewX(6deg); }
  75%  { transform: translate(-0.01em, 0) skewX(-3deg); color: var(--accent); }
  100% { transform: none; color: inherit; }
}

@media (prefers-reduced-motion: reduce) {
  /* Keep the opacity fades, drop all movement and blur. */
  .js h1 .ch, .js h1 .ch.glitch, .js .fade {
    filter: none; transform: none;
    animation: fadeOnly 400ms ease forwards;
    animation-delay: 0ms;
  }
  @keyframes fadeOnly { from { opacity: 0; } to { opacity: 1; } }
  .js .eyebrow::before { animation: none; transform: none; opacity: 1; }
  .dot::after { animation: none; }
  .spotlight { display: none; }
}

@media (max-width: 560px) {
  .bar .hide-sm { display: none; }
  .lede { margin-top: 28px; }
  .meta { margin-top: 40px; gap: 20px 32px; }
}

::selection { background: var(--accent); color: #fff; }
