@font-face {
  font-family: "Public Sans";
  src: url("../fonts/public-sans-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Public Sans";
  src: url("../fonts/public-sans-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: light;
  --desk: #dde3e8;
  --desk-deep: #cfd7de;
  --paper: #fbfbf9;
  --paper-back: #eef0ef;
  --ink: #15191d;
  --muted: #34414d;
  --line: #c4ccd3;
  --dept: #183a66;
  --amber: #8a5200;
  --amber-wash: #f6e3c2;
  --green: #235c42;
  --red: #a33a2c;
  --gutter: clamp(16px, 4.5vw, 56px);
  --sheet-shadow: 0 1px 2px rgba(21, 31, 41, 0.10), 0 16px 44px rgba(21, 31, 41, 0.12);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--desk); }

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 400 18px/1.55 "Public Sans", system-ui, sans-serif;
  font-kerning: normal;
}

a { color: inherit; text-underline-offset: 0.18em; }

:focus-visible { outline: 3px solid var(--dept); outline-offset: 3px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- top line: scrolls away with the page ---- */

.top {
  display: flex;
  gap: 0.7em;
  align-items: baseline;
  padding: 18px var(--gutter) 0;
  font-size: 15px;
  color: var(--muted);
}

.top strong { color: var(--ink); font-weight: 650; }

/* ---- opening frame ---- */

.opening {
  height: calc(100svh - 44px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(16px, 4vw, 64px);
  padding: 0 var(--gutter);
  overflow: hidden;
}

.opening h1 {
  margin: 0;
  font-size: clamp(2.1rem, min(6.4vw, 11svh), 5.4rem);
  font-weight: 720;
  line-height: 1.02;
  letter-spacing: -0.022em;
}

.opening .lede {
  max-width: 26em;
  margin: 0.9em 0 0;
  font-size: clamp(1rem, min(1.5vw, 2.8svh), 1.3rem);
  color: var(--muted);
}

.opening .envelope {
  width: 100%;
  max-height: 62svh;
  height: auto;
  justify-self: center;
  filter: drop-shadow(0 14px 26px rgba(21, 31, 41, 0.16));
}

@media (max-aspect-ratio: 4 / 5) {
  .opening {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    align-content: center;
  }
  .opening .envelope { max-height: 30svh; width: auto; max-width: 100%; }
}

/* ---- pinned scenes ---- */

.scene { position: relative; margin: 0; }
.scene[data-scene="arrives"] { height: 330svh; }
.scene[data-scene="review"] { height: 240svh; }
.scene[data-scene="rule"] { height: 185svh; }

/* 2px short of the viewport, so the stage stays pinned through the last
   fraction of a pixel of its scene's travel and the final frame holds exactly. */
.stage {
  position: sticky;
  top: 0;
  height: calc(100svh - 2px);
  overflow: hidden;
}

.world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

/* Reduced motion: the scenes become rows of stills. */
.stills {
  display: grid;
  gap: 18px;
  padding: 6svh var(--gutter);
}

.still {
  position: relative;
  overflow: hidden;
  background: var(--desk);
  border-top: 1px solid var(--line);
}

/* ---- things in the scenes (logical pixels inside a world) ---- */

.w-el { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform, opacity; }

.caption {
  font-weight: 620;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
}

.sheet {
  background: var(--paper);
  box-shadow: var(--sheet-shadow);
  color: var(--ink);
}

.paper-slip {
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(21, 31, 41, 0.12), 0 8px 22px rgba(21, 31, 41, 0.12);
  padding: 22px 26px;
}

.slip-label { color: var(--muted); font-size: 0.82em; font-weight: 560; }
.slip-figure { font-weight: 700; letter-spacing: -0.01em; }

.hl { transition: none; border-radius: 2px; box-shadow: inset 0 -0.42em 0 var(--hl, transparent); }

.flying { font-weight: 700; color: var(--dept); white-space: nowrap; }

.rule-card { border-top: 6px solid var(--dept); }
.rule-card .slot { border-bottom: 1px dashed var(--line); min-height: 1.6em; }
.stamp-version {
  display: inline-block;
  border: 2px solid var(--dept);
  color: var(--dept);
  font-weight: 700;
  padding: 0.05em 0.45em;
}

.estimate-tag {
  display: inline-block;
  font-size: 0.72em;
  font-weight: 650;
  color: var(--amber);
  border: 1.5px solid var(--amber);
  padding: 0 0.35em;
  line-height: 1.35;
  vertical-align: 0.12em;
}

.mark-estimate { background: var(--amber-wash); color: var(--amber); font-weight: 650; }

/* The letter, drawn in the scenes. */
.mini { position: absolute; inset: 0; padding: 40px 44px; font-size: 16px; line-height: 1.42; }
.mini .lh { display: flex; align-items: center; gap: 10px; color: var(--dept); font-weight: 700; font-size: 17px; }
.mini .emblem { width: 26px; height: 26px; flex: none; }
.mini .addr { margin-top: 26px; font-size: 15px; line-height: 1.35; }
.mini .meta { display: flex; justify-content: space-between; margin: 22px 0 18px; font-size: 13.5px; color: var(--muted); }
.mini .ln { margin: 0 0 9px; }
.mini .big { font-size: 20px; font-weight: 650; margin-bottom: 16px; }
.mini .h { margin: 16px 0 6px; font-weight: 700; color: var(--dept); font-size: 15px; }
.mini .box { display: inline-block; width: 15px; height: 15px; border: 1.5px solid var(--ink); vertical-align: -2px; margin-right: 6px; position: relative; }
.mini .sign { margin-top: 18px; font-style: italic; }
.mini .draft { color: #8a96a2; }
.mini .strike { position: relative; }

.panel { position: absolute; left: 0; width: 100%; }
.panel .face { position: absolute; inset: 0; overflow: hidden; background: var(--paper); }
.panel .back { background: var(--paper-back); }
.panel .shade { pointer-events: none; }
.panel .face-inner { position: absolute; left: 0; width: 100%; }

.env {
  transform-style: preserve-3d;
}
.env .face { position: absolute; inset: 0; backface-visibility: hidden; }
.env .front { background: #f7f8f7; box-shadow: var(--sheet-shadow); }
.env .front .window {
  position: absolute;
  left: 7%; top: 30%;
  width: 46%; height: 36%;
  border: 1px solid #c9d0d6;
  border-radius: 6px;
  background: #ffffff;
  padding: 12px 16px;
  font-size: 18px;
  line-height: 1.35;
}
.env .front .frank { position: absolute; right: 7%; top: 12%; width: 14%; height: 26%; border: 2px solid var(--dept); color: var(--dept); font-size: 13px; font-weight: 700; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.env .rear { background: #eff1f0; transform: rotateY(180deg); box-shadow: var(--sheet-shadow); }
.env .pocket {
  position: absolute; inset: 0;
  background: #f5f6f5;
  clip-path: polygon(0 0, 50% 46%, 100% 0, 100% 100%, 0 100%);
  backface-visibility: hidden;
  transform: rotateY(180deg);
}
.env .flap {
  position: absolute; left: 0; top: 0; width: 100%; height: 56%;
  background: #e9ecea;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  backface-visibility: visible;
}

.other-window { position: absolute; left: 7%; top: 32%; width: 46%; height: 34%; border: 1px solid #c9d0d6; border-radius: 6px; background: #fff; }
.other-window i { display: block; height: 10px; margin: 14px 16px 0; background: #d5dbe0; border-radius: 2px; }

.stamp {
  border: 3px solid var(--red);
  color: var(--red);
  font-weight: 760;
  letter-spacing: 0.02em;
  padding: 8px 14px;
  line-height: 1.15;
  background: rgba(251, 251, 249, 0.93);
  text-align: center;
}

.green { color: var(--green); font-weight: 650; }
.strike-line { height: 3px; background: var(--green); }

.reg-row { border-top: 1px solid var(--line); padding: 16px 0; }
.reg-row .ver { font-weight: 700; }
.reg-row .state { color: var(--muted); }
.flag { color: var(--red); border-left: 4px solid var(--red); padding: 6px 0 6px 14px; font-weight: 560; }
.cells { display: grid; gap: 3px; }
.cells i { display: block; aspect-ratio: 1; background: var(--amber-wash); outline: 1px solid #e3c79a; }

.note-mini { color: var(--muted); font-size: 17px; line-height: 1.35; border-left: 3px solid var(--line); padding-left: 12px; }
.note-mini b { color: var(--ink); font-weight: 650; }
.note-mini.estimate { border-left-color: var(--amber); }
.leader { position: absolute; height: 1px; background: var(--muted); transform-origin: 0 50%; }

.endcard { text-align: center; }

/* ---- the letter, readable ---- */

.letter-wrap {
  padding: 12svh var(--gutter) 12svh;
  display: grid;
  justify-items: center;
}

.composition {
  width: min(100%, 640px);
  position: relative;
}

@media (min-width: 1180px) {
  .composition { width: 1020px; padding-right: 380px; }
}

.letter {
  background: var(--paper);
  box-shadow: var(--sheet-shadow);
  padding: clamp(22px, 5.5vw, 56px) clamp(20px, 5.5vw, 60px) clamp(28px, 6vw, 60px);
  position: relative;
}

.letter .lh { display: flex; align-items: center; gap: 12px; color: var(--dept); font-weight: 720; font-size: 1.05rem; }
.letter .lh svg { width: 34px; height: 34px; flex: none; }
.letter .addr { margin-top: 22px; font-size: 0.95rem; line-height: 1.4; }

.letter .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 28px;
  margin: 20px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.letter .meta dt { display: inline; }
.letter .meta dd { display: inline; margin: 0 0 0 0.35em; color: var(--ink); font-weight: 560; }

.tick {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 0 30px;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  font-weight: 560;
  cursor: pointer;
}

.tick input {
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 2px solid var(--ink);
  background: var(--paper);
  display: grid;
  place-items: center;
  flex: none;
  cursor: pointer;
}

.tick input::after {
  content: "";
  width: 12px;
  height: 7px;
  border-left: 3px solid var(--dept);
  border-bottom: 3px solid var(--dept);
  transform: translateY(-2px) rotate(-45deg) scale(0);
  transform-origin: center;
  transition: transform 180ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.tick input:checked::after { transform: translateY(-2px) rotate(-45deg) scale(1); }

.letter h3 {
  margin: 30px 0 8px;
  font-size: 1rem;
  font-weight: 720;
  color: var(--dept);
}

.letter p { margin: 0 0 10px; }
.letter .amount { font-size: 1.3rem; font-weight: 680; line-height: 1.35; margin-bottom: 4px; }
.letter .sign { margin-top: 30px; font-style: italic; }

.letter mark.estimate {
  background: var(--amber-wash);
  color: var(--amber);
  font-weight: 650;
  padding: 0 0.15em;
}

.letter .estimate-tag { margin-left: 0.3em; }
.letter .together { white-space: nowrap; }

.letter a.ask { font-weight: 650; color: var(--dept); }

.row { position: relative; }

/* The work: notes in the margin (wide) or under each sentence (narrow). */
.note {
  display: none;
  margin: 2px 0 14px;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.note p { margin: 0; }
.note b { color: var(--ink); font-weight: 650; }
.note.estimate { border-left-color: var(--amber); }

.shows-work .note { display: block; }

@media (min-width: 1180px) {
  .shows-work .note {
    position: absolute;
    top: 2px;
    left: calc(100% + 60px + clamp(20px, 5.5vw, 60px));
    width: 320px;
    margin: 0;
  }
  .shows-work .note::before {
    content: "";
    position: absolute;
    right: calc(100% + 4px);
    top: 0.72em;
    width: calc(60px + clamp(20px, 5.5vw, 60px) - 8px);
    border-top: 1px solid #8793a0;
    transform-origin: 100% 50%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .shows-work .note { animation: note-in 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: calc(var(--i, 0) * 70ms); }
  .shows-work .note::before { animation: leader-in 300ms cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: calc(var(--i, 0) * 70ms + 80ms); }
}

@keyframes note-in {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: none; }
}

@keyframes leader-in {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ---- close ---- */

.close {
  padding: 10svh var(--gutter) 12svh;
  display: grid;
  justify-items: center;
}

.close-inner { width: min(100%, 720px); }

.close h2 {
  margin: 0 0 0.5em;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 720;
  line-height: 1.15;
  letter-spacing: -0.015em;
}

.close p { margin: 0 0 1em; }
.close .closing { margin-top: 2.2em; padding-top: 1.2em; border-top: 1px solid var(--line); color: var(--muted); }

.film { margin: 2.4em 0 1.6em; }
.film video { display: block; width: 100%; height: auto; background: #10151a; }
.film figcaption { margin-top: 0.6em; font-size: 0.92rem; color: var(--muted); }

.cite { font-size: 0.9rem; color: var(--muted); }
.back { margin-top: 2em; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .scene[data-scene] { height: auto; }
}
