@font-face {
  font-family: "Instrument Sans";
  src: url("/fonts/instrument-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-stretch: 75% 100%;
  font-display: swap;
}
@font-face {
  font-family: "Martian Mono";
  src: url("/fonts/martian-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-display: swap;
}

:root {
  --midnight: #071434;
  --deep: #0b1b45;
  --panel: #0e2254;
  --line: #1d3576;
  --paper: #eef2fb;
  --muted: #98a8d0;
  --blue: #4a8df2;
  --blue-deep: #173c92;
  --gold: #e8c579;
  --gold-deep: #c08a35;

  --sans: "Instrument Sans", system-ui, sans-serif;
  --mono: "Martian Mono", ui-monospace, monospace;

  /* type scale: 1.333 (perfect fourth) */
  --t-0: 1rem;
  --t-1: 1.333rem;
  --t-2: 1.777rem;
  --t-3: 2.369rem;
  --t-4: clamp(3rem, 8.5vw, 7.5rem);

  --postmark: #d9a847;
  --ease: cubic-bezier(.2, .7, .2, 1);

  --radius-lg: 18px;
  --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--midnight);
  color: var(--paper);
  font: 400 1.0625rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
kbd {
  font: 500 0.78em/1 var(--mono);
  display: inline-grid;
  place-items: center;
  min-width: 1.9em;
  height: 1.9em;
  padding: 0 0.45em;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  color: var(--paper);
}
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 1rem; top: -4rem; background: var(--gold); color: var(--midnight); padding: .5rem 1rem; border-radius: var(--radius-sm); z-index: 10; }
.skip:focus { top: 1rem; }

.wrap { width: min(1200px, 100% - 3rem); margin-inline: auto; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .55rem;
  font: 600 1rem/1 var(--sans);
  padding: .95rem 1.4rem;
  border-radius: 999px;
  text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn-gold { background: var(--gold); color: var(--midnight); }
.btn-gold:hover { background: #f3d690; }
.btn-ghost { border: 1px solid var(--line); color: var(--paper); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-sm { padding: .6rem 1rem; font-size: .95rem; }
.gh { width: 1.05em; height: 1.05em; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding-block: 1.5rem; }
.brand img { height: 46px; width: auto; }
.top nav { display: flex; align-items: center; gap: 1.75rem; }
.top nav > a:not(.btn) { text-decoration: none; color: var(--muted); }
.top nav > a:not(.btn):hover { color: var(--paper); }

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 3rem;
  align-items: center;
  padding-block: clamp(2rem, 6vw, 5rem) clamp(4rem, 8vw, 7rem);
}
.hero h1 {
  font-size: clamp(3rem, 7vw, 6.5rem);
  font-stretch: 78%;
  font-weight: 650;
  line-height: .92;
  letter-spacing: -0.025em;
}
.hero .lede { margin-top: 1.75rem; }
.lede { font-size: var(--t-1); line-height: 1.45; color: var(--paper); max-width: 34ch; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }
.fine { margin-top: 1.25rem; color: var(--muted); font-size: .95rem; max-width: 40ch; }

/* the stamp + postmark */
.post { position: relative; justify-self: center; width: min(430px, 100%); }
.stamp { display: block; width: 100%; height: auto; transform: rotate(-3.5deg); filter: drop-shadow(0 30px 50px rgba(0, 0, 0, .45)); }
.postmark { position: absolute; left: 62%; top: 68%; width: 150%; height: auto; overflow: visible; pointer-events: none; }
.postmark g { fill: none; stroke: var(--postmark); stroke-width: 4; }
.postmark text { fill: var(--postmark); stroke: none; font-family: var(--sans); }
.pm-ring { font-size: 15px; font-weight: 600; letter-spacing: .2em; }
.pm-date { font-size: 22px; font-weight: 650; font-stretch: 80%; }
.pm-year { font-size: 17px; font-weight: 500; }

/* ---------- demo window ---------- */
.window {
  position: relative;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 40px 120px -40px rgba(23, 60, 146, .9);
  outline: none;
}
.window:focus-visible { border-color: var(--gold); }
.titlebar {
  display: flex; align-items: center; gap: .5rem;
  height: 44px; padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  font-size: .9rem; color: var(--muted);
}
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--line); }
.titlebar .title { margin-left: .75rem; }
.search {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: .4rem;
  font: 400 .8rem/1 var(--mono);
  color: var(--paper);
  background: var(--panel);
  border: 1px solid var(--blue);
  border-radius: 6px;
  padding: .45rem .7rem;
  min-width: 14rem;
}
.search[hidden] { display: none; }
.search .slash { color: var(--gold); }
.caret { width: 1px; height: 1em; background: var(--paper); animation: blink 1s steps(1) infinite; }

.panes { display: grid; grid-template-columns: 170px minmax(0, 1.1fr) minmax(0, 1fr); height: 430px; }
.folders { border-right: 1px solid var(--line); padding: 1rem .75rem; }
.folders ul { list-style: none; margin: 0; padding: 0; font-size: .92rem; }
.folders li { display: flex; justify-content: space-between; padding: .45rem .6rem; border-radius: 6px; color: var(--muted); }
.folders li.on { background: var(--panel); color: var(--paper); }
.folders span { font-variant-numeric: tabular-nums; }

.list { list-style: none; margin: 0; padding: .4rem; border-right: 1px solid var(--line); overflow: hidden; }
.msg {
  position: relative;
  display: grid; grid-template-columns: 1fr auto; gap: .1rem .75rem;
  padding: .7rem .8rem .7rem 1.1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .28s cubic-bezier(.5, 0, .75, 0), opacity .28s;
}
.msg + .msg { margin-top: 2px; }
.msg .from { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg .time { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.msg .subj { grid-column: 1 / -1; font-size: .88rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.unread .from::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: .5rem; border-radius: 50%; background: var(--blue); vertical-align: .12em; }
.msg.starred .time::before { content: "★ "; color: var(--gold); }
.msg.sel { background: var(--panel); }
.msg.sel::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--gold); }
.msg.leaving { transform: translateX(110%); opacity: 0; }
.msg.leaving::after {
  content: ""; position: absolute; inset: 40% auto 40% -40%; width: 40%;
  background: linear-gradient(90deg, transparent, var(--gold));
  border-radius: 2px;
}
.empty { padding: 3rem 1rem; text-align: center; color: var(--muted); font-size: .95rem; }

.reader { padding: 1.5rem 1.75rem; overflow: hidden; }
.reader h3 { font-size: var(--t-1); line-height: 1.25; }
.reader .meta { margin-top: .4rem; color: var(--muted); font-size: .9rem; }
.reader .body { margin-top: 1.25rem; font-size: .95rem; color: #c9d3ee; display: grid; gap: .8rem; }

.keybar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1rem;
  border-top: 1px solid var(--line);
  font-size: .88rem;
}
.hint { color: var(--gold); }
.keys { display: flex; flex-wrap: wrap; gap: .35rem; }
.keys button {
  display: inline-flex; align-items: center; gap: .4rem;
  font: inherit; color: var(--muted);
  background: none; border: 0; padding: .25rem .4rem; border-radius: 6px; cursor: pointer;
}
.keys button:hover { color: var(--paper); }
.keys button.hit kbd { background: var(--gold); color: var(--midnight); border-color: var(--gold-deep); }

/* ---------- keyboard + source pair ---------- */
.pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(2rem, 5vw, 5rem);
  padding-block: clamp(3rem, 6vw, 5rem) clamp(5rem, 10vw, 8rem);
}
.pillar { min-width: 0; }
.pillar h2 { font-size: var(--t-2); font-stretch: 85%; line-height: 1.1; letter-spacing: -0.01em; }
.pillar p { margin-top: 1rem; color: #c9d3ee; max-width: 38ch; }
.shortcuts { margin-top: 1.5rem; border-collapse: collapse; font-size: .95rem; }
.shortcuts td { padding: .4rem 0; border-top: 1px solid var(--line); color: var(--muted); }
.shortcuts td:first-child { padding-right: 1.25rem; white-space: nowrap; }
.term {
  margin: 1.5rem 0 0;
  padding: 1.1rem 1.2rem;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: 400 .78rem/1.9 var(--mono);
  overflow-x: auto;
  white-space: pre;
}
.term .p { color: var(--gold); }
.cursor { display: inline-block; width: .6em; height: 1.1em; vertical-align: -.2em; background: var(--paper); animation: blink 1s steps(1) infinite; }

/* ---------- scroll scenes ----------
   Without .motion (no JS, or reduced motion) every scene is a plain section
   in its final state. With .motion, a scene is a tall track whose .sticky child
   pins to the viewport while motion.js writes progress into custom properties. */
.scene { padding-block: clamp(4rem, 8vw, 7rem); }
.scene-title { text-align: center; font-size: var(--t-3); font-stretch: 80%; line-height: 1; letter-spacing: -0.02em; margin-bottom: 2.5rem; }
.motion .scene { padding: 0; }
.motion .scene > .sticky {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
}

/* inbox: tilts up to face you */
.motion .scene-inbox { height: 210vh; }
.tilt { perspective: 1800px; }
.motion .scene-inbox .window {
  transform-origin: 50% 100%;
  transform:
    translateY(calc((1 - var(--e, 1)) * 70px))
    rotateX(calc((1 - var(--e, 1)) * 30deg))
    scale(calc(.84 + var(--e, 1) * .16));
  opacity: calc(.45 + var(--e, 1) * .55);
  will-change: transform;
}
.motion .scene-inbox .scene-title { opacity: var(--t, 1); transform: translateY(calc((1 - var(--t, 1)) * 30px)); }

/* statement: words light up as you scroll */
.statement {
  font-size: clamp(1.9rem, 4.4vw, 3.75rem);
  font-stretch: 85%;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.015em;
  max-width: 24ch;
}
.motion .scene-words { height: 230vh; }
.motion .statement .w { opacity: clamp(.16, calc(var(--p, 1) * (var(--n) + 4) - var(--i)), 1); }

/* Pheme: the stamp holds still while we zoom in on her */
.scene-pheme .sticky {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
}
.motion .scene-pheme { height: 380vh; }
.motion .scene-pheme > .sticky { display: grid; }
.captions { display: grid; }
.cap { font-size: clamp(1.6rem, 3.2vw, 2.75rem); font-stretch: 85%; font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; max-width: 17ch; }
.cap + .cap { margin-top: 1.5rem; }
.motion .cap { grid-area: 1 / 1; margin: 0; opacity: var(--o, 0); transform: translateY(calc((1 - var(--o, 0)) * 28px)); }
.lens { margin: 0; justify-self: center; width: min(100%, calc(74svh * 600 / 792)); }
.lens-frame { aspect-ratio: 600 / 792; overflow: hidden; border-radius: 6px; }
.zoom { display: block; width: 100%; height: 100%; transform-origin: 27% 23%; transform: scale(var(--z, 1)); will-change: transform; }
.lens figcaption { margin-top: .9rem; font-size: .85rem; color: var(--muted); }

/* ---------- reveal on enter ---------- */
.motion [data-reveal] {
  opacity: 0;
  transform: translateY(48px);
  transition: opacity 1s var(--ease), transform 1.2s var(--ease);
  transition-delay: var(--d, 0s);
}
.motion [data-reveal].in { opacity: 1; transform: none; }

/* ---------- hero intro (plays once on load) ---------- */
.motion .intro { animation: rise 1.1s var(--ease) var(--d, 0s) both; }
.motion .stamp { animation: settle 1.5s var(--ease) .15s both; }
.motion .post { animation: bump .4s ease-out 1.5s; }
.motion .pm-stamp { transform-box: view-box; transform-origin: 100px 100px; animation: thunk .45s cubic-bezier(.3, 1.5, .5, 1) 1.38s both; }
.motion .pm-waves path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1s var(--ease) both; }
.motion .pm-waves path:nth-child(1) { animation-delay: 1.6s; }
.motion .pm-waves path:nth-child(2) { animation-delay: 1.67s; }
.motion .pm-waves path:nth-child(3) { animation-delay: 1.74s; }
.motion .pm-waves path:nth-child(4) { animation-delay: 1.81s; }
@keyframes rise { from { opacity: 0; transform: translateY(32px); } }
@keyframes settle { from { opacity: 0; transform: translateY(70px) rotate(5deg) scale(.95); } }
@keyframes thunk { from { opacity: 0; transform: scale(1.6); } 50% { opacity: 1; } }
@keyframes bump { 40% { transform: translateY(4px); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- roadmap ---------- */
.roadmap { padding-bottom: clamp(5rem, 10vw, 8rem); }
.roadmap > h2 { font-size: var(--t-3); font-stretch: 80%; line-height: 1; letter-spacing: -0.02em; }
.section-lede { margin-top: .9rem; color: var(--muted); }
.steps {
  list-style: none; margin: 3rem 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2rem;
}
.pm { width: 92px; height: 92px; transform: rotate(-9deg); overflow: visible; }
.pm circle { fill: none; stroke: var(--line); stroke-width: 3; stroke-dasharray: 5 7; }
.pm text { fill: var(--muted); font: 700 15px var(--sans); letter-spacing: .12em; }
.steps .done .pm circle { stroke: var(--postmark); stroke-dasharray: none; }
.steps .done .pm text { fill: var(--postmark); }
.steps .next .pm circle { stroke: var(--blue); stroke-dasharray: none; }
.steps .next .pm text { fill: var(--blue); }
.motion .steps li .pm {
  opacity: 0; transform: rotate(-9deg) scale(1.5);
  transition: transform .45s cubic-bezier(.3, 1.5, .5, 1), opacity .2s;
  transition-delay: calc(var(--d, 0s) + .3s);
}
.motion .steps li.in .pm { opacity: 1; transform: rotate(-9deg) scale(1); }
.steps h3 { margin-top: 1.25rem; font-size: var(--t-1); line-height: 1.2; }
.steps p { margin-top: .4rem; color: #c9d3ee; font-size: .95rem; }

/* ---------- closer + footer ---------- */
.closer {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: clamp(4rem, 8vw, 6rem) 1.5rem;
  border-top: 1px solid var(--line);
}
.closer img { width: 88px; height: auto; }
.closer h2 { margin-top: 1.5rem; font-size: var(--t-3); font-stretch: 80%; line-height: 1; letter-spacing: -0.02em; }
.closer p { margin: 1rem 0 2rem; color: var(--muted); max-width: 44ch; }

.foot {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding-block: 2rem 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: .92rem;
}
.foot img { height: 26px; width: auto; opacity: .85; }
.foot nav { margin-left: auto; display: flex; gap: 1.5rem; }
.foot nav a { text-decoration: none; }
.foot nav a:hover { color: var(--paper); }
.foot .credit { flex-basis: 100%; font-size: .8rem; max-width: 80ch; }
.foot .credit a { color: var(--muted); }

@keyframes blink { 50% { opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 3.5rem; }
  .post { width: min(340px, 78%); justify-self: start; margin-left: 4%; }
  .panes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .folders { display: none; }
  .pair { grid-template-columns: minmax(0, 1fr); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 3rem; }
  .scene-pheme .sticky, .motion .scene-pheme > .sticky { grid-template-columns: minmax(0, 1fr); align-content: center; gap: 1.5rem; }
  .lens { width: min(100%, calc(46svh * 600 / 792)); order: -1; }
  .cap { font-size: clamp(1.4rem, 5.5vw, 2rem); }
}
@media (max-width: 640px) {
  .wrap { width: min(1200px, 100% - 2rem); }
  .top nav > a:not(.btn) { display: none; }
  .panes { grid-template-columns: minmax(0, 1fr); height: 360px; }
  .reader { display: none; }
  .keybar .hint { width: 100%; }
  .foot nav { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .msg, .msg.leaving { transition: none; }
  .msg.leaving::after { display: none; }
  .caret, .cursor { animation: none; }
}
