/* ============================================================
   Remade.md — cinematic design pass
   Tokens + base + nav + footer + shared systems
   Palette/type locked per HANDOVER-DESIGN.md:
   forest / paper / mint · Newsreader / Geist / Geist Mono
   ============================================================ */

:root {
  /* Surfaces */
  --ink: oklch(0.165 0.01 170);            /* deep green black */
  --forest: oklch(0.235 0.018 175);
  --moss: oklch(0.275 0.02 170);

  /* Accents */
  --mint: oklch(0.905 0.045 165);
  --mint-dim: oklch(0.755 0.045 165);

  /* Text */
  --bone: oklch(0.965 0.005 90);
  --bone-dim: oklch(0.755 0.005 90);
  --stone: oklch(0.65 0.005 175);

  /* Rules */
  --hairline: oklch(0.965 0.005 90 / 0.12);
  --hairline-strong: oklch(0.965 0.005 90 / 0.22);

  /* Paper surface */
  --paper: oklch(0.96 0.012 95);
  --paper-ink: oklch(0.22 0.012 175);
  --paper-stone: oklch(0.5 0.008 175);
  --paper-rule: oklch(0.22 0.012 175 / 0.18);

  /* Semantic (forest default) */
  --background: var(--ink);
  --foreground: var(--bone);
  --card: var(--forest);
  --rule: var(--hairline);
  --rule-strong: var(--hairline-strong);
  --meta: var(--stone);
  --accent: var(--mint);
  --accent-dim: var(--mint-dim);

  /* Type */
  --font-serif: "Newsreader", "Source Serif Pro", Georgia, serif;
  --font-sans: "Geist", ui-sans-serif, system-ui, "Helvetica Neue", sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;

  /* Motion system — tweakable. --motion scales 0..1.25 */
  --motion: 1;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);

  /* Atmosphere — tweakable 0..1.5 */
  --atmosphere: 1;
  --grain-opacity: 0.05;
}

/* Paper sections re-map the semantic tokens.
   Mint darkens to deep evergreen so accents stay legible on cream. */
[data-surface="paper"] {
  --background: var(--paper);
  --foreground: var(--paper-ink);
  --card: oklch(0.94 0.012 95);
  --rule: var(--paper-rule);
  --rule-strong: oklch(0.22 0.012 175 / 0.34);
  --meta: oklch(0.38 0.01 175);
  --accent: oklch(0.42 0.075 165);
  --accent-dim: oklch(0.55 0.06 165);
  background-color: var(--background);
  color: var(--foreground);
}

/* ---------- Base ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
* { border: 0 solid var(--rule); }

html { scroll-behavior: smooth; }
html, body { background-color: var(--ink); }

body {
  color: var(--bone);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

::selection { background: var(--mint); color: var(--ink); }

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; cursor: pointer; }

.serif { font-family: var(--font-serif); font-weight: 400; letter-spacing: -0.01em; }
.mono  { font-family: var(--font-mono); font-weight: 400; }

/* Mono metadata label */
.meta-label {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--accent);
}

/* Em — color shift, never italics (Brand Direction v1) */
.em { font-style: normal; color: var(--accent); }

.container { max-width: 1400px; margin-inline: auto; padding-inline: 24px; }
@media (min-width: 1024px) { .container { padding-inline: 40px; } }

/* ---------- Grain ---------- */
.grain { position: relative; }
.grain::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  z-index: 5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/></svg>");
}
html[data-grain="off"] .grain::after { display: none; }

/* ---------- Grid field ---------- */
.bg-grid {
  background-image:
    linear-gradient(to right, oklch(1 0 0 / 0.018) 1px, transparent 1px),
    linear-gradient(to bottom, oklch(1 0 0 / 0.018) 1px, transparent 1px);
  background-size: 72px 72px;
}

/* ============================================================
   Reveal system — lines unmask on scroll.
   Start (hidden) states live here; END states are driven by
   remade-motion.js as JS tweens (robust where CSS animation
   timelines are frozen). With JS off, everything stays visible.
   ============================================================ */
.js .reveal-line {
  display: block;
  overflow: hidden;
  /* room for serif overshoot — keeps ascenders/descenders of S, g, y
     from being shaved by the clip box at tight line-heights */
  padding-block: 0.09em;
  margin-block: -0.09em;
}
.js .reveal-line > span {
  display: block;
  transform: translateY(125%);
}

.js .fade-up {
  opacity: 0;
  transform: translateY(28px);
}

/* Mint rule that draws itself in */
.js .draw-rule {
  transform: scaleX(0);
  transform-origin: left center;
}

/* Motion fully off → everything instant + visible */
html[data-motion="0"] .reveal-line > span,
html[data-motion="0"] .fade-up,
html[data-motion="0"] .draw-rule {
  transform: none !important;
  opacity: 1 !important;
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .js .reveal-line > span,
  .js .fade-up,
  .js .draw-rule {
    transform: none !important;
    opacity: 1 !important;
    transition: none !important;
  }
  html { scroll-behavior: auto; }
}

/* Frozen-timeline fallback — remade-motion.js adds .no-anim to <html>
   when rAF never fires (some embedded previews freeze the animation
   timeline). State changes then apply instantly instead of hanging
   mid-transition. */
html.no-anim *, html.no-anim *::before, html.no-anim *::after {
  transition: none !important;
  animation: none !important;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px 40px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
  white-space: nowrap;
}
.btn .arr { transition: transform 0.3s ease; font-family: var(--font-sans); }
.btn:hover .arr { transform: translateX(4px); }

.btn-mint {
  background: var(--mint);
  border: 1px solid var(--mint);
  color: var(--ink);
}
.btn-mint:hover { background: var(--bone); border-color: var(--bone); }

.btn-ghost {
  border: 1px solid oklch(0.905 0.045 165 / 0.3);
  color: var(--mint);
}
.btn-ghost:hover { background: oklch(0.905 0.045 165 / 0.06); }

/* Paper-surface buttons */
[data-surface="paper"] .btn-ink {
  background: var(--paper-ink);
  border: 1px solid var(--paper-ink);
  color: var(--paper);
}
[data-surface="paper"] .btn-ink:hover { opacity: 0.85; }

/* ---------- Focus visibility ---------- */
:focus-visible {
  outline: 2px solid var(--accent, var(--mint));
  outline-offset: 3px;
  border-radius: 2px;
}
/* Full-height nav strips: an inset ring avoids clipping against the fixed header edge */
.nav-link:focus-visible,
.nav-cta:focus-visible,
.nav-menu-btn:focus-visible {
  outline-offset: -2px;
}

/* ============================================================
   Nav
   ============================================================ */
.nav {
  position: fixed;
  inset-inline: 0;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid oklch(0.905 0.045 165 / 0.1);
  background: oklch(0.165 0.01 170 / 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}
.nav.is-scrolled {
  border-bottom-color: oklch(0.905 0.045 165 / 0.15);
  background: oklch(0.165 0.01 170 / 0.8);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}
.nav-inner {
  display: flex;
  height: 64px;
  align-items: stretch;
  justify-content: space-between;
  padding-left: 24px;
}
@media (min-width: 1024px) { .nav-inner { padding-left: 40px; } }

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  transition: opacity 0.2s ease;
}
.nav-brand:hover { opacity: 0.75; }
.nav-brand svg { height: 24px; width: 24px; color: var(--mint); }
.nav-brand .wordmark {
  font-family: var(--font-serif);
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--bone);
}

.nav-rail { display: flex; align-items: stretch; }
.nav-links { display: none; align-items: stretch; }
@media (min-width: 1024px) { .nav-links { display: flex; } }

.nav-link {
  display: flex;
  align-items: center;
  border-left: 1px solid oklch(0.905 0.045 165 / 0.15);
  padding-inline: 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--stone);
  transition: color 0.2s ease, background-color 0.2s ease;
}
.nav-link:hover { color: var(--bone); background: oklch(0.905 0.045 165 / 0.04); }

.nav-cta {
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 1px solid oklch(0.905 0.045 165 / 0.15);
  background: var(--mint);
  padding-inline: 16px;
  transition: background-color 0.3s ease;
}
@media (min-width: 640px) { .nav-cta { padding-inline: 20px; } }
@media (min-width: 1280px) { .nav-cta { padding-inline: 28px; } }
.nav-cta:hover { background: var(--bone); }
.nav-cta span {
  white-space: nowrap;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.nav-cta .arr { transition: transform 0.3s ease; color: var(--ink); }
.nav-cta:hover .arr { transform: translateX(4px); }
.nav-cta .cta-short { display: inline; }
.nav-cta .cta-long { display: none; }
@media (min-width: 640px) {
  .nav-cta .cta-short { display: none; }
  .nav-cta .cta-long { display: inline; }
}

.nav-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 1px solid oklch(0.905 0.045 165 / 0.15);
  padding-inline: 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--mint);
  transition: background-color 0.2s ease;
}
.nav-menu-btn:hover { background: oklch(0.905 0.045 165 / 0.04); }
@media (min-width: 1024px) { .nav-menu-btn { display: none; } }

/* Mobile menu */
.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: oklch(0.165 0.01 170 / 0.97);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  /* hold visibility until the fade-out finishes, so links leave the tab
     order without cutting the closing animation short */
  transition: opacity 0.35s var(--ease-soft), visibility 0s 0.35s;
}
.mobile-menu.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.35s var(--ease-soft), visibility 0s 0s;
}

.mobile-menu-head {
  display: flex;
  height: 64px;
  align-items: stretch;
  justify-content: space-between;
  border-bottom: 1px solid oklch(0.905 0.045 165 / 0.15);
  padding-left: 24px;
}
.mobile-menu nav { display: grid; gap: 8px; max-width: 1400px; margin-inline: auto; padding: 48px 24px 0; }
.mobile-menu-link {
  display: flex;
  align-items: baseline;
  gap: 24px;
  border-bottom: 1px solid oklch(0.965 0.005 90 / 0.1);
  padding-block: 16px;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.5s var(--ease-soft), transform 0.5s var(--ease-soft), border-color 0.2s ease;
}
.mobile-menu.is-open .mobile-menu-link { opacity: 1; transform: translateY(0); }
.mobile-menu-link:hover { border-bottom-color: oklch(0.905 0.045 165 / 0.4); }
.mobile-menu-link .idx {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--stone);
}
.mobile-menu-link .lbl {
  flex: 1;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: clamp(2.5rem, 12vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  color: var(--bone);
  transition: color 0.2s ease;
}
.mobile-menu-link:hover .lbl { color: var(--mint); }
.mobile-menu-book {
  margin-top: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--mint);
  padding: 20px 24px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
}

/* ============================================================
   Footer — fixed per handover open item: mark + HTML wordmark
   ============================================================ */
.footer {
  border-top: 1px solid var(--hairline);
  background: var(--ink);
}
.footer-inner { padding-block: 64px; }
.footer-grid { display: grid; gap: 48px; }
@media (min-width: 768px) { .footer-grid { grid-template-columns: 6fr 3fr 3fr; } }

.footer-brand-row { display: flex; align-items: center; gap: 14px; }
.footer-brand-row svg { height: 32px; width: 32px; color: var(--mint); }
.footer-brand-row .wordmark {
  font-family: var(--font-serif);
  font-size: 26px;
  letter-spacing: -0.02em;
  color: var(--bone);
}
.footer-tagline {
  margin-top: 24px;
  max-width: 24rem;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--bone);
}
.footer-byline {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--stone);
}
.footer-col-label {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--mint);
}
.footer-links { list-style: none; margin-top: 16px; display: grid; gap: 8px; }
.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: oklch(0.965 0.005 90 / 0.8);
  transition: color 0.2s ease;
}
.footer-link .slash { color: var(--stone); transition: color 0.2s ease; }
.footer-link:hover, .footer-link:hover .slash { color: var(--mint); }

.footer-bottom {
  margin-top: 64px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--hairline);
  padding-top: 24px;
}
@media (min-width: 768px) { .footer-bottom { flex-direction: row; align-items: center; } }
.footer-bottom p {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--stone);
}
