/* ---------- Tokens (after slanter.ai: warm paper, near-black ink, olive accent, light serif) ---------- */
:root {
  color-scheme: light;
  --bg: #f3f3f1;
  --bg-alt: #ebebe6;
  --surface: #fafaf9;
  --ink: #292929;
  --ink-deep: #1b1b18;
  --ink-soft: #5e5e5a;
  --ink-faint: #878784;
  --line: #dddcd6;
  --grid: rgb(150 150 64 / .09);
  --accent: #6e6e2c;          /* Slanter's olive, darkened to read on paper */
  --accent-bright: #969640;
  --on-dark: #f3f3f1;
  --btn-bg: #1b1b18;
  --btn-ink: #f3f3f1;
  --block: #1b1b18;
  --todo-bg: #fff4c2;
  --todo-line: #d9b300;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --wrap: 1140px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 10px;
  --radius-lg: 20px;
  --section: clamp(80px, 11vw, 144px);
}


/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.1; margin: 0; letter-spacing: -0.015em; }
h1 { font-size: clamp(2.6rem, 6.6vw, 5rem); font-weight: 300; letter-spacing: -0.025em; }
h2 { font-size: clamp(2.1rem, 4.6vw, 3.4rem); font-weight: 300; letter-spacing: -0.02em; }
h3 { font-size: 1.4rem; margin: 2em 0 0.5em; }
.prose h3:first-child { margin-top: 0; }
p { margin: 0 0 1em; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.eyebrow {
  font-size: 0.95rem; font-weight: 500;
  color: var(--ink-faint); margin-bottom: 1.2rem;
}
.lede { font-size: clamp(1.08rem, 2vw, 1.3rem); color: var(--ink-soft); max-width: 36em; line-height: 1.55; }
.fine { font-size: 0.8rem; color: var(--ink-faint); margin: 0; }

/* ---------- Placeholders ---------- */
.todo {
  background: var(--todo-bg);
  outline: 1.5px dashed var(--todo-line);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.nav.scrolled { border-bottom-color: var(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { font-family: var(--serif); font-size: 1.25rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.nav-links { display: flex; gap: 28px; align-items: center; }
.nav-links a { color: var(--ink-soft); text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: color .15s; }
.nav-links a:hover, .nav-links a.active { color: var(--ink); }
.nav-toggle { display: none; }

@media (max-width: 720px) {
  .nav-toggle {
    display: flex; flex-direction: column; gap: 6px; justify-content: center;
    width: 40px; height: 40px; background: none; border: 0; cursor: pointer; padding: 8px;
  }
  .nav-toggle span { display: block; height: 1.5px; background: var(--ink); border-radius: 2px; transition: transform .2s; }
  .nav-toggle[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }
  .nav-links {
    position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--line);
    padding: 8px var(--gutter) 16px;
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 0; font-size: 1.05rem; width: 100%; }
}

/* ---------- Buttons ---------- */
.actions, .card-links { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 20px; border-radius: var(--radius);
  border: 1px solid var(--line); background: transparent;
  color: var(--ink); text-decoration: none; font-weight: 500; font-size: 0.95rem;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: var(--ink-faint); background: var(--surface); }
.btn-primary { background: var(--btn-bg); color: var(--btn-ink); border-color: var(--btn-bg); }
.btn-primary:hover { background: var(--btn-bg); border-color: var(--btn-bg); opacity: .88; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: clamp(80px, 14vw, 168px) 0 var(--section); }
/* The faint square grid slanter.ai draws behind its hero, fading out towards the edges. */
.hero-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 72px 72px;
  background-position: center top;
  mask-image: radial-gradient(ellipse 70% 65% at 60% 40%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 65% at 60% 40%, #000 30%, transparent 75%);
}
.hero-inner { position: relative; }
.hero h1 { max-width: 13.5em; margin-bottom: 1.6rem; }
.hero .lede { margin-bottom: 2.2rem; }
.facts {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  margin: clamp(56px, 9vw, 104px) 0 0; border-top: 1px solid var(--line);
}
.facts div { padding: 24px 20px 0 0; }
.facts div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.facts dt { font-family: var(--serif); font-weight: 300; font-size: clamp(2.2rem, 4.6vw, 3.2rem); line-height: 1; margin-bottom: 10px; letter-spacing: -0.02em; }
.facts dd { margin: 0; color: var(--ink-soft); font-size: 0.9rem; line-height: 1.4; }
@media (max-width: 720px) {
  .facts { grid-template-columns: repeat(2, 1fr); row-gap: 24px; }
  .facts div:nth-child(3) { padding-left: 0; border-left: 0; }
}

/* ---------- Project sections ---------- */
.project { padding: var(--section) 0; border-top: 1px solid var(--line); }
.project.alt { background: var(--bg-alt); }
.section-head { display: block; margin-bottom: clamp(40px, 6vw, 72px); }
.section-sub { color: var(--ink-soft); font-size: 1.15rem; margin: 0.8rem 0 0; max-width: 34em; }

.split { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: clamp(32px, 6vw, 80px); align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.prose { max-width: 40em; }
.prose p { color: var(--ink-soft); }

.ticks { list-style: none; padding: 0; margin: 0 0 1em; }
.ticks li { position: relative; padding-left: 1.6em; margin-bottom: 0.7em; color: var(--ink-soft); }
.ticks li::before {
  content: ""; position: absolute; left: 0.15em; top: 0.72em;
  width: 8px; height: 1.5px; background: var(--accent);
}

.media-col { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 96px; }
@media (max-width: 900px) { .media-col { position: static; } }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: clamp(22px, 3vw, 32px);
}
.card-label { font-family: var(--serif); font-size: 1.2rem; color: var(--ink); margin: 0 0 18px; }

.timeline { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.timeline li { position: relative; padding: 0 0 20px 22px; color: var(--ink); font-size: 0.95rem; line-height: 1.45; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -4.5px; top: 5px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent-bright);
}
.when { display: block; font-size: 0.82rem; font-weight: 500; color: var(--ink-faint); margin-bottom: 3px; }

.subjects { list-style: none; margin: 0; padding: 0; }
.subjects li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.93rem; }
.subjects li:last-child { border-bottom: 0; padding-bottom: 0; }
.subjects b { font-weight: 500; color: var(--accent); white-space: nowrap; }

.story { margin: 0 auto clamp(40px, 6vw, 64px); }
.story p { font-family: var(--serif); font-size: clamp(1.2rem, 2.2vw, 1.45rem); line-height: 1.5; color: var(--ink); font-weight: 300; }
.access {
  margin-top: clamp(40px, 6vw, 64px); display: grid; grid-template-columns: 1fr auto; gap: 32px; align-items: center;
  background: var(--block); color: var(--on-dark); border-radius: var(--radius-lg); padding: clamp(24px, 3.5vw, 36px);
}
.access h3 { margin: 0 0 6px; color: var(--on-dark); font-size: 1.5rem; }
.access p { margin: 0; color: rgb(243 243 241 / .75); font-size: 0.97rem; max-width: 40em; }
.access-creds { display: grid; gap: 10px; min-width: 260px; }
.access-creds dl { margin: 0; }
.access-creds dl div { padding: 8px 0; border-bottom: 1px solid rgb(243 243 241 / .14); }
.access-creds dl div:first-child { padding-top: 0; }
.access-creds dt { font-size: 0.82rem; color: rgb(243 243 241 / .55); }
.access-creds dd { margin: 2px 0 0; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.95rem; color: var(--on-dark); user-select: all; }
.access .btn-primary { background: var(--on-dark); color: var(--block); border-color: var(--on-dark); }
@media (max-width: 900px) {
  .access { grid-template-columns: 1fr; }
    .access-creds { min-width: 0; }
}

.earlier-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
@media (max-width: 800px) { .earlier-grid { grid-template-columns: 1fr; } }
.earlier-card h3 { margin: 0.2em 0 0.6em; }
.earlier-card p:last-child { margin-bottom: 0; color: var(--ink-soft); }

/* ---------- Live lab ---------- */
.lab { margin-bottom: clamp(48px, 7vw, 72px); }
.lab-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.lab-tabs::-webkit-scrollbar { display: none; }
.lab-tab {
  flex: none; font: 500 0.9rem var(--sans); color: var(--ink-soft);
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 16px; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.lab-tab:hover { color: var(--ink); border-color: var(--ink-faint); }
.lab-tab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.lab-tabs { align-items: center; }
.lab-tabs-label {
  flex: none; margin-left: 12px; padding-left: 20px; border-left: 1px solid var(--line);
  font-size: 0.85rem; font-weight: 500; color: var(--ink-faint);
}

.lab-window { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 30px 60px -30px rgb(27 27 24 / .25); }
.lab-bar { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 0.8rem; }
.lab-dots { display: flex; gap: 6px; }
.lab-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.lab-url {
  flex: 1; min-width: 0; color: var(--ink-faint); font-family: ui-monospace, "SF Mono", Menlo, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lab-open { color: var(--ink-soft); text-decoration: none; white-space: nowrap; }
.lab-open:hover { color: var(--ink); }

/* The stage is laid out at a fixed desktop size and scaled to fit, like a screen recording you can touch. */
.lab-viewport { position: relative; overflow: hidden; background: var(--bg); }
.lab-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.lab-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--bg); }
.lab.native .lab-stage { position: relative; width: 100% !important; height: 78vh !important; transform: none !important; }

/* While the tour plays the layer covers the frame: the page still scrolls, but nothing inside the frame moves under the
   cursor. A click on it pauses the tour and hands over control. */
.tour-layer { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s; }
.lab.touring .tour-layer { opacity: 1; pointer-events: auto; cursor: pointer; }
.tour-cursor, .tour-ripple { pointer-events: none; }
.tour-cursor {
  position: absolute; left: 0; top: 0; fill: var(--ink); stroke: var(--bg); stroke-width: 1.5;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / .3));
  transition: transform .9s cubic-bezier(.45, 0, .2, 1);
}
.tour-cursor.dragging { transition: transform .05s linear; }
.tour-ripple {
  position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%;
  border: 3px solid var(--accent); opacity: 0; transform: scale(.3);
}
.tour-ripple.go { animation: ripple .55s ease-out; }
@keyframes ripple { from { opacity: .9; transform: scale(.3); } to { opacity: 0; transform: scale(1.4); } }

.tour-bar {
  display: none; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.lab.tour-mode .tour-bar { display: flex; }
.tour-caption { margin: 0; font-size: 0.95rem; color: var(--ink); min-height: 1.5em; }
.tour-controls { display: flex; align-items: center; gap: 10px; flex: none; }
.tour-progress { display: flex; gap: 5px; margin-right: 6px; }
.tour-progress i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); transition: background .3s; }
.tour-progress i.on { background: var(--accent); }
.tour-controls button {
  font: 500 0.85rem var(--sans); padding: 7px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.lab-note { font-size: 0.85rem; color: var(--ink-faint); margin: 12px 0 0; }
@media (max-width: 640px) {
  .tour-bar { flex-direction: column; align-items: flex-start; }
  .tour-progress { display: none; }
}

/* ---------- About (a dark rounded block, like slanter.ai's) ---------- */
.project.earlier { padding-bottom: clamp(40px, 5vw, 56px); }
.about { padding: 0 0 var(--section); }
.about-card {
  background: var(--block); color: var(--on-dark); border-radius: var(--radius-lg);
  padding: clamp(32px, 6vw, 80px);
}
.about .eyebrow { color: rgb(243 243 241 / .5); }
.about h2 { margin-bottom: 1.6rem; color: var(--on-dark); }
.about-grid { display: grid; grid-template-columns: 1.3fr 0.7fr; gap: clamp(32px, 6vw, 80px); align-items: start; }
@media (max-width: 900px) { .about-grid { grid-template-columns: 1fr; } }
.about-text p { font-size: 1.08rem; color: rgb(243 243 241 / .78); }
.about .todo { color: var(--ink); }
.quick { display: grid; gap: 18px; margin: 0; padding-top: 6px; }
.quick div { padding-bottom: 16px; border-bottom: 1px solid rgb(243 243 241 / .12); }
.quick div:last-child { border-bottom: 0; }
.quick dt { font-size: 0.82rem; color: rgb(243 243 241 / .55); }
.quick dd { margin: 4px 0 0; font-size: 0.97rem; line-height: 1.45; }

/* ---------- Contact & footer ---------- */
.contact { padding: var(--section) 0; text-align: center; }
.contact-inner { display: flex; flex-direction: column; align-items: center; }
.contact .lede { margin: 1.2rem auto 2.2rem; }
.contact .actions { justify-content: center; }
.footer { border-top: 1px solid var(--line); padding: 24px 0; font-size: 0.85rem; color: var(--ink-faint); }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; }
.footer a { color: var(--ink-faint); text-decoration: none; }

/* ---------- Reveal on scroll ---------- */
@media (prefers-reduced-motion: no-preference) {
  .hero-inner > * { animation: rise .9s cubic-bezier(.2, .7, .2, 1) both; }
  .hero-inner > :nth-child(2) { animation-delay: .08s; }
  .hero-inner > :nth-child(3) { animation-delay: .16s; }
  .hero-inner > :nth-child(4) { animation-delay: .24s; }
  .hero-inner > :nth-child(5) { animation-delay: .34s; }
  @keyframes rise { from { opacity: 0; transform: translateY(18px); } }
}

/* ---------- 404 ---------- */
.not-found { min-height: calc(100vh - 64px); display: flex; flex-direction: column; justify-content: center; padding-top: 48px; padding-bottom: 96px; }
.not-found h1 { margin-bottom: 1.2rem; }
.not-found .lede { margin-bottom: 2rem; }

/* The library section's heading sits in the same centered column as its story */
#simulations .section-head { max-width: 40em; margin-left: auto; margin-right: auto; }
#earlier .section-head { text-align: center; }
#earlier .section-sub { margin-left: auto; margin-right: auto; }
