/* Dumi — sumi ink, washi paper, moss, a little vermilion.
   The app's own palette, one dark world. Everything is painted from these tokens. */
:root {
  --ink: #0A0A09;
  --washi: #F5F0E6;
  --dim: rgba(245, 240, 230, 0.56);
  --faint: rgba(245, 240, 230, 0.32);
  --hairline: rgba(245, 240, 230, 0.09);
  --moss: #95CD8C;
  --sakura: #F4B9CB;
  --vermilion: #EE6B4D;
  --wall: #161712;     /* the desktop behind the island — what the chapter videos' baked 0x1A1814 decodes to */
  --serif: "Instrument Serif", "New York", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;

  --bar: 38px;         /* the menu bar the island hangs from */
  --gutter: 24px;
  --rhythm: 150px;     /* one vertical step between sections */
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--washi);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, video { max-width: 100%; display: block; }
a { color: inherit; }

.grain {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: overlay;
  background-image: url("assets/grain.png");
}

h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.4px; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(40px, 5.6vw, 76px); line-height: 1.02; }
h2 { font-size: clamp(32px, 3.8vw, 48px); line-height: 1.08; }
em { font-style: italic; color: var(--sakura); }
em.hot { color: var(--vermilion); }

.eyebrow {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--moss);
}
.lede { color: var(--dim); font-size: 18px; max-width: 46ch; margin: 18px 0 0; }
.fineprint { font-size: 13px; color: var(--faint); margin: 0; }
.gatekeeper { max-width: 52ch; line-height: 1.6; }
.gatekeeper b { font-weight: 600; color: var(--dim); }
.kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.84em;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
}

/* The film arriving: one hairline under the bar, gone when every chapter is here. */
.loading {
  position: fixed;
  top: var(--bar);
  left: 0;
  right: 0;
  height: 2px;
  z-index: 50;
  pointer-events: none;
}
.loading i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--moss);
  opacity: 0.8;
  transition: width .3s linear, opacity .8s;
}
.loading.is-done i { opacity: 0; }

/* The gate: the page waits for the film. A voxel seedling gains a cube per few kilobytes.
   The body is pinned, not just overflow-hidden: Safari and trackpads scroll a merely hidden
   document underneath a fixed overlay, and the reader would surface halfway down the page. */
html.is-gated { overflow: hidden; height: 100%; }
html.is-gated body { position: fixed; inset: 0; overflow: hidden; }
.gate {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--ink);
  transition: opacity .7s cubic-bezier(.2,.7,.2,1);
}
.gate.is-gone { opacity: 0; pointer-events: none; }
#sprout { width: 260px; height: 260px; max-width: 70vw; }
.gate-count {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 0;
  font-family: var(--serif);
  font-size: 34px;
  color: var(--moss);
  font-variant-numeric: tabular-nums;
}
.gate-count .unit { font-size: 18px; color: var(--faint); }
.gate-skip {
  margin-top: 28px;
  padding: 8px 14px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: none;
  color: var(--dim);
  font: 500 13px var(--sans);
  cursor: pointer;
}
.gate-skip:hover { color: var(--washi); border-color: var(--dim); }
@media (prefers-reduced-motion: reduce) { .gate { transition: none; } }

/* ---------- the menu bar ---------- */

.bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--bar);
  padding: 0 var(--gutter);
  background: rgba(22, 23, 18, 0.94);   /* the wall itself, near enough: a patch of video over the bar must not show */
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--serif);
  font-size: 22px;
  text-decoration: none;
}
.leaf {
  width: 10px;
  height: 10px;
  border-radius: 0 62% 0 62%;
  background: var(--moss);
  transform: rotate(14deg);
}
.get {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(245, 240, 230, 0.18);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color .3s, color .3s, background .3s;
}
.get:hover { border-color: var(--moss); color: var(--moss); }
.get.is-under { opacity: 0; pointer-events: none; }
.get { transition: border-color .3s, color .3s, opacity .3s; }
.soon {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--faint);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  border-radius: 999px;
  background: var(--moss);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background .25s, transform .25s;
}
.btn:hover { background: #A6D89E; transform: translateY(-1px); }
.btn .soon { color: rgba(10, 10, 9, 0.5); }

/* ---------- the story ---------- *
 * A tall track with one pinned screen inside it. main.js turns scroll position into
 * a chapter, a frame, a camera and a cursor; everything written is ordinary DOM on top. */

.story { height: 780vh; position: relative; }

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  z-index: 31;             /* above the bar, so the island hangs over it like the real one */
  pointer-events: none;    /* …without the stage swallowing clicks meant for the bar */
}

/* A desktop, not a page: one flat tone, slightly lighter than ink so a black island has something to
   sit on. Flat on purpose — the videos carry the same colour, so wherever the camera puts them the
   join is invisible. */
.wall {
  position: absolute;
  inset: var(--bar) 0 0;   /* the bar paints its own strip; see .bar */
  background: var(--wall);
}

/* The island. Clip space is 1640×1040 at 2×, so 820×520 here at scale 1 — the size it is on a Mac.
   It hangs from y = 0 and scales around the point it hangs from, over the bar like the real thing.
   The video is opaque, so a mask decides what of it shows: across the bar only the island itself
   (--l to --r, set per frame by main.js), below the bar everything, with the sides and bottom fading
   into the wall so the rectangle never shows wherever the camera puts it. */
.screen {
  --band: 44px;   /* how deep the bar reaches into the video, in the video's own pixels */
  --l: 206px;
  --r: 334px;
  position: absolute;
  top: 0;
  left: 50%;
  width: 820px;
  height: 520px;
  -webkit-mask-image:
    linear-gradient(90deg, transparent calc(var(--l) - 12px), #000 var(--l), #000 var(--r), transparent calc(var(--r) + 12px)),
    linear-gradient(90deg, transparent, #000 40px, #000 calc(100% - 40px), transparent),
    linear-gradient(180deg, transparent calc(var(--band) - 6px), #000 var(--band), #000 calc(100% - 44px), transparent);
  -webkit-mask-size: 100% var(--band), 100% 100%, 100% 100%;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-composite: source-over, source-in;   /* the notch band ∪ (sides ∩ body) */
  mask-image:
    linear-gradient(90deg, transparent calc(var(--l) - 12px), #000 var(--l), #000 var(--r), transparent calc(var(--r) + 12px)),
    linear-gradient(90deg, transparent, #000 40px, #000 calc(100% - 40px), transparent),
    linear-gradient(180deg, transparent calc(var(--band) - 6px), #000 var(--band), #000 calc(100% - 44px), transparent);
  mask-size: 100% var(--band), 100% 100%, 100% 100%;
  mask-repeat: no-repeat;
  mask-composite: add, intersect;
  margin-left: -270px;          /* the island hangs at clip x = 540, not in the middle of the frame */
  transform-origin: 270px 0;
  background: url("assets/ch-open.webp") 0 0 / 100% 100% no-repeat;   /* until the first frame is drawn */
  z-index: 35;
  pointer-events: none;
  will-change: transform;
}
/* The videos are only frame sources — Safari composites a <video> layer with its own colour handling
   and, on iOS, won't show a frame it hasn't played — so each frame is drawn into a canvas instead.
   Two canvases: the current frame, and the last frame of the previous chapter fading out under it. */
.ch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}
.frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.frame.prev { opacity: 0; transition: opacity .28s linear; }
.frame.prev.is-on { opacity: 1; transition: none; }

.cursor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
  will-change: transform, opacity;
}
.cursor svg { display: block; }
.cursor .ring {
  position: absolute;
  left: -14px;
  top: -14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid rgba(245, 240, 230, 0.8);
  opacity: 0;
  transform: scale(0.2);
}

.hero {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  top: 33vh;
  z-index: 36;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: auto;
  will-change: transform, opacity;
}
.hero .lede { margin-top: 22px; max-width: 44ch; }
.cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 34px;
}

/* Captions sit in the column beside the island, so the island never has to move out of their way. */
.beats {
  position: absolute;
  left: var(--gutter);
  bottom: 13vh;
  width: min(460px, calc(50vw - 270px));
  z-index: 36;
  pointer-events: none;
}
.beat {
  position: absolute;
  left: 0;
  bottom: 0;
  margin: 0;
  width: 100%;
  font-family: var(--serif);
  font-size: clamp(32px, 3.4vw, 50px);
  line-height: 1.06;
  letter-spacing: -0.5px;
  text-wrap: balance;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .45s cubic-bezier(.2,.7,.2,1), transform .45s cubic-bezier(.2,.7,.2,1);
}
.beat.is-on { opacity: 1; transform: none; }
.beat small {
  display: block;
  margin-top: 14px;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--dim);
}

.cue {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 36;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  letter-spacing: 2.6px;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--faint);
  transition: opacity .4s;
}
.cue-line { width: 30px; height: 1px; background: var(--faint); }
.cue.is-gone { opacity: 0; }

/* ---------- why a tree: the seedling grows beside the rules ---------- */

.growth { height: 380vh; position: relative; background: linear-gradient(180deg, var(--wall), var(--ink) 50vh); }  /* the desktop gives way to the page */
.growth-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--bar) var(--gutter) 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 40px;
}
.tree { display: flex; flex-direction: column; align-items: center; gap: 2px; }
#grow {
  width: min(100%, 520px, 62vh);
  aspect-ratio: 1 / 1;
  -webkit-mask-image: radial-gradient(circle at 50% 52%, #000 46%, transparent 72%);
  mask-image: radial-gradient(circle at 50% 52%, #000 46%, transparent 72%);
}
.count {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: -10px 0 0;
  font-family: var(--serif);
  font-size: 28px;
  color: var(--moss);
  font-variant-numeric: tabular-nums;
}
.count .unit {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: var(--faint);
}
.rules { max-width: 460px; }
.rules ol {
  list-style: none;
  margin: 36px 0 0;
  padding: 0;
  border-top: 1px solid var(--hairline);
}
.rules li {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid var(--hairline);
  opacity: 0.28;
  transform: translateX(6px);
  transition: opacity .5s, transform .5s cubic-bezier(.2,.7,.2,1);
}
.rules li.is-on { opacity: 1; transform: none; }
.rules li.is-past { opacity: 0.62; transform: none; }
.rules strong { font-family: var(--serif); font-weight: 400; font-size: 22px; line-height: 1.2; }
.rules span { font-size: 15px; line-height: 1.55; color: var(--dim); }
.rules li.is-on span { color: var(--washi); }

/* ---------- the species: seven trees, floating ---------- */

.species {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--rhythm) var(--gutter) 0;
}
.species-head { max-width: 560px; margin-bottom: 40px; }
.species-head p { color: var(--dim); margin: 16px 0 0; }
.species ul {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 20px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.species li { text-align: center; }
/* Renders sit on black; masking the corners floats them on the page instead of boxing them. */
.species img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  -webkit-mask-image: radial-gradient(circle at 50% 52%, #000 45%, transparent 72%);
  mask-image: radial-gradient(circle at 50% 52%, #000 45%, transparent 72%);
}
.species h3 { font-size: 21px; margin-top: -4px; }
.species li p {
  margin: 3px 0 0;
  font-size: 10px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---------- quiet by design ---------- */

.quiet {
  max-width: 1000px;
  margin: 0 auto;
  padding: var(--rhythm) var(--gutter) 0;
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 60px;
  align-items: start;
}
.quiet dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 40px 48px;
  margin: 0;
}
.quiet dt { font-family: var(--serif); font-size: 23px; line-height: 1.2; }
.quiet dd { margin: 8px 0 0; font-size: 15.5px; color: var(--dim); }

/* ---------- film ---------- */

.film {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--rhythm) var(--gutter) 0;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 64px;
  align-items: center;
}
.film-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 22px;
  overflow: hidden;
  background: #000;
}
.film-frame video { width: 100%; height: 100%; object-fit: cover; }
.film-copy p { color: var(--dim); margin: 18px 0 0; max-width: 40ch; }
.play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1px solid rgba(245, 240, 230, 0.45);
  background: rgba(10, 10, 9, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--washi);
  font-size: 16px;
  cursor: pointer;
  transition: border-color .25s, background .25s;
}
.play:hover { border-color: var(--washi); background: rgba(10, 10, 9, 0.5); }
.film-frame.playing .play { opacity: 0; pointer-events: none; }

/* ---------- faq ---------- */

.faq {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--rhythm) var(--gutter) 0;
}
.faq dl { margin: 0; }
.faq dt { font-family: var(--serif); font-size: 22px; margin-top: 34px; }
.faq dt:first-child { margin-top: 0; }
.faq dd { margin: 6px 0 0; color: var(--dim); }

/* ---------- closing ---------- */

.closing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  text-align: center;
  padding: var(--rhythm) var(--gutter);
}
.closing h2 { font-size: clamp(38px, 5vw, 64px); margin-bottom: 6px; }

/* ---------- footer ---------- */

.footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px var(--gutter) 56px;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  font-size: 13.5px;
  color: var(--faint);
}
.footer-brand { display: inline-flex; align-items: center; gap: 9px; font-family: var(--serif); font-size: 19px; color: var(--washi); }
.footer nav { display: flex; gap: 22px; margin-left: auto; }
.footer a { text-decoration: none; color: var(--dim); transition: color .25s; }
.footer a:hover { color: var(--washi); }
.footer p { margin: 0; }

/* ---------- legal pages ---------- */

.legal { max-width: 680px; margin: 0 auto; padding: calc(var(--bar) + 40px) var(--gutter) 40px; }
.legal h1 { font-size: clamp(36px, 5vw, 52px); }
.legal .updated { color: var(--faint); font-size: 13.5px; margin-top: 10px; }
.legal h2 { font-size: 25px; margin-top: 44px; }
.legal p, .legal li { color: var(--dim); }
.legal ul { padding-left: 20px; }
.legal a { color: var(--moss); }
.legal .back { display: inline-block; margin-top: 50px; font-size: 14.5px; color: var(--dim); text-decoration: none; }
.legal .back:hover { color: var(--washi); }

/* The page for agents: a legal-style column with code in it. */
.agents pre {
  margin: 14px 0 0;
  padding: 16px 18px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.55;
  color: var(--washi);
}
.agents pre code { font-family: inherit; }
.agents .updated { font-size: 17px; color: var(--dim); line-height: 1.62; max-width: 62ch; }
.agents li { margin-top: 8px; }
.agents .eyebrow { margin-bottom: 10px; }

/* ---------- reveal ---------- */

.reveal { opacity: 0; transform: translateY(22px); transition: opacity .8s cubic-bezier(.2,.7,.2,1), transform .8s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .beat, .frame.prev, .rules li { transition: none; }
}

/* Narrower than the island plus a column of captions: captions move under the island. */
@media (max-width: 1180px) {
  .beats {
    left: var(--gutter);
    right: var(--gutter);
    width: auto;
    bottom: 9vh;
    text-align: center;
  }
  .beat { font-size: clamp(28px, 4.2vw, 40px); }
  .beat small { max-width: 44ch; margin-left: auto; margin-right: auto; }
  .hero { top: 30vh; }
}

@media (max-width: 900px) {
  :root { --rhythm: 110px; }
  .growth { height: 320vh; }
  .growth-stage {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 18px;
    padding-top: calc(var(--bar) + 10px);
  }
  #grow { width: min(100%, 260px, 30vh); }
  .rules { max-width: none; }
  .rules .lede { display: none; }
  .rules ol { margin-top: 20px; }
  .rules li { grid-template-columns: 110px 1fr; padding: 11px 0; }
  .rules strong { font-size: 19px; }
  .rules span { font-size: 14px; }
  .species ul { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .quiet { grid-template-columns: 1fr; gap: 36px; }
  .quiet dl { grid-template-columns: 1fr; gap: 28px; }
  .film { grid-template-columns: 1fr; gap: 34px; justify-items: center; text-align: center; }
  .film-frame { max-width: 280px; }
  .film-copy p { margin-left: auto; margin-right: auto; }
}

@media (max-width: 620px) {
  :root { --gutter: 18px; --rhythm: 88px; --bar: 34px; }
  body { font-size: 16px; }
  .story { height: 680vh; }
  .get { display: none; }   /* the island needs the bar to itself; the hero has the button */
  .hero { top: 28vh; }
  .hero .lede { font-size: 16px; }
  .beat { font-size: 27px; }
  /* Seven trees don't grid on a phone: a strip you swipe through, one tree per snap. */
  .species { padding-left: 0; padding-right: 0; }
  .species-head { padding: 0 var(--gutter); }
  .species ul {
    display: flex;
    gap: 6px;
    padding: 0 var(--gutter);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }
  .species ul::-webkit-scrollbar { display: none; }
  .species li { flex: 0 0 46%; scroll-snap-align: center; }
  .species h3 { font-size: 18px; }
  .species li p { font-size: 9px; letter-spacing: 1.4px; }
  .closing h2 { font-size: 36px; }
}

/* Short windows: the captions win, the island gives up height (see fit() in main.js). */
@media (max-height: 640px) {
  .hero { top: 26vh; }
  .hero .lede { display: none; }
  .beat { font-size: 26px; }
}
