/* /later/ — Letters for later (UX run-07). A v2 page on the css/toys.css tokens (DESIGN.md):
   putty surface, one lemon accent (the envelope, the chosen chips, the Seal key and a letter
   that is ready to open), physical depth, springy motion, light and dark. Type is Geist + Geist
   Mono (--t-display swapped, like /links, the blog and /versions/). Paper objects (the letter,
   the reading sheet) stay paper in dark mode: off-white #f7f6f2 with #141414 ink. The shared
   header floats fixed over the page; the body clears its height. */
body.later {
  --t-display: "Geist", ui-sans-serif, system-ui, sans-serif;
  --l-gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --l-paper: #fff;
  --l-env-in: #e2b21f;
  --l-env-flap: #f4c62f;
  padding-top: var(--header-h);
  font-family: var(--t-display);
  font-variation-settings: normal;
}
@media (prefers-color-scheme: dark) { body.later { --l-paper: #f7f6f2; } }
html:has(body.later) { scroll-padding-top: calc(var(--header-h) + 18px); }
body.later .t-wrap,
body.later .container-wide { width: min(100% - 2 * var(--l-gutter), 1240px); }
.l-vh { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- masthead ---------- */
.l-main { padding-bottom: 40px; }
.l-mast { padding: 36px 0 26px; }
.l-kicker { margin: 0 0 14px; color: var(--t-ink-2); }
.l-mast h1 {
  margin: 0; max-width: 12ch;
  font-size: 2.5rem; line-height: .92; font-weight: 800; letter-spacing: -.02em; text-wrap: balance;
  animation: l-rise .7s var(--t-spring) both;
}
.l-lede { margin: 20px 0 0; max-width: 46ch; font-size: 1.125rem; line-height: 1.42; color: var(--t-ink-2); text-wrap: pretty; }
.l-lede strong { color: var(--t-ink); font-weight: 600; }
@media (min-width: 380px) { .l-mast h1 { font-size: 2.75rem; } }
@media (min-width: 600px) { .l-mast h1 { font-size: 4.5rem; } .l-lede { font-size: 1.3125rem; } }
@media (min-width: 1100px) { .l-mast { padding-top: 56px; } .l-mast h1 { font-size: 6rem; } }
@keyframes l-rise { from { transform: translateY(28px) scale(.97); } }

.l-h2 { margin: 0 0 12px; font-size: 1.5rem; line-height: 1.05; font-weight: 800; letter-spacing: -.015em; }
@media (min-width: 900px) { .l-h2 { font-size: 1.875rem; } }

/* ---------- keys (DESIGN.md: --t-r-btn, >= 48 px, flat face, inset outline, bottom lip) ---------- */
.l-keys { display: flex; flex-wrap: wrap; gap: 10px; }
.l-key {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px 3px; border: 0;
  border-radius: var(--t-r-btn); background: var(--t-surface); color: var(--t-ink);
  font: 700 .9375rem/1.1 var(--t-display); text-decoration: none; text-align: center; cursor: pointer;
  box-shadow: inset 0 0 0 1.5px var(--t-line), inset 0 -4px 0 rgba(0,0,0,.08);
  transition: transform var(--t-slow) var(--t-spring), box-shadow var(--t-base) var(--t-out);
  -webkit-tap-highlight-color: transparent;
}
body.v2 a.l-key { color: var(--t-ink); }
body.v2 .l-key-ink { background: var(--t-ink); color: var(--t-surface); box-shadow: inset 0 -4px 0 rgba(127,127,127,.35); }
@media (hover: hover) { .l-key:hover { transform: translateY(-3px); } }
.l-key:active { transform: translateY(2px) scale(.97); transition-duration: var(--t-fast); }
.l-key-quiet { background: transparent; box-shadow: none; padding-inline: 4px; text-decoration: underline; text-underline-offset: .22em; }
@media (hover: hover) { .l-key-quiet:hover { transform: none; } }
.l-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--t-ink-2); font: 500 .9375rem/1.2 var(--t-display); text-decoration: underline; text-underline-offset: .22em;
}
/* body.v2 resets every button to `font: inherit` (css/toys.css); the keys set their own type. */
body.v2 button.l-key { font: 700 .9375rem/1.1 var(--t-display); }
body.v2 button.l-link { font: 500 .9375rem/1.2 var(--t-display); }

/* ---------- the shelf ---------- */
.l-kept { padding: 8px 0 30px; }
.l-status { margin: 0 0 16px; font-size: 1.0625rem; line-height: 1.4; color: var(--t-ink-2); }
.l-status:focus { outline: none; }
.l-shelf { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 760px) { .l-shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .l-shelf { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.l-letter {
  display: flex; gap: 16px; align-items: flex-start; min-width: 0; padding: 20px;
  border-radius: var(--t-r-l); background: var(--t-card); color: var(--t-ink);
  box-shadow: inset 0 0 0 2px var(--t-line);
  animation: l-rise .6s var(--t-spring) both; animation-delay: calc(var(--i, 0) * 70ms);
}
.l-letter.is-ready {
  background: var(--t-lemon); color: #141414;
  box-shadow: inset 0 -8px 0 rgba(0,0,0,.16), 0 20px 40px -24px rgba(0,0,0,.45);
}
.l-letter-body { display: grid; gap: 6px; min-width: 0; flex: 1; }
.l-letter-meta { margin: 0; font: 500 .75rem/1.4 var(--t-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--t-ink-2); }
.l-letter-title { margin: 0; font-size: 1.375rem; line-height: 1.08; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.l-letter-when { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: .9375rem; line-height: 1.35; color: var(--t-ink-2); }
.l-letter.is-ready .l-letter-meta, .l-letter.is-ready .l-letter-when { color: #141414; }
.l-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--t-lemon-deep); }
.l-letter.is-ready .l-dot { background: #141414; box-shadow: 0 0 0 3px #fff; animation: t-ping 1.5s var(--t-out) 3; }
.l-letter.is-opened .l-dot { background: var(--t-ink-2); }
body.v2 .l-letter.is-ready .l-key { background: #fff; color: #141414; box-shadow: inset 0 -4px 0 rgba(0,0,0,.12); }
body.v2 .l-letter.is-ready .l-key-ink { background: #141414; color: #fff; box-shadow: inset 0 -4px 0 rgba(255,255,255,.18); }
.l-letter.is-ready :focus-visible { outline-color: #141414; }
.l-confirm { display: grid; gap: 10px; }
.l-confirm p { margin: 0; font-weight: 600; line-height: 1.35; }

/* The shelf's small envelope: lemon with a closed flap; an opened one lies open and quiet. */
.l-mini {
  position: relative; flex: none; width: 60px; height: 42px; margin-top: 2px; border-radius: 8px;
  background: var(--t-lemon); box-shadow: inset 0 -4px 0 rgba(0,0,0,.16);
}
.l-mini i { position: absolute; inset: 0 0 auto; height: 62%; border-radius: 8px 8px 0 0; background: var(--l-env-flap); clip-path: polygon(0 0, 100% 0, 50% 100%); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.l-mini::after { content: ""; position: absolute; left: 50%; top: 62%; width: 12px; height: 12px; border-radius: 50%; background: #141414; transform: translate(-50%, -50%); }
.l-letter.is-ready .l-mini { background: #fff; }
.l-letter.is-ready .l-mini i { background: #f2efe6; }
.l-letter.is-opened .l-mini { background: var(--t-surface-2); box-shadow: none; }
.l-letter.is-opened .l-mini i { transform: scaleY(-1); transform-origin: top; background: var(--t-surface-2); box-shadow: inset 0 0 0 1.5px var(--t-line); }
.l-letter.is-opened .l-mini::after { display: none; }

.l-forget { margin-top: 14px; }
.l-forget .l-confirm { max-width: 520px; padding: 16px; border-radius: var(--t-r-m); background: var(--t-surface-2); }

.l-arrived { margin: 0 0 30px; padding: 22px; border-radius: var(--t-r-l); background: var(--t-card); box-shadow: inset 0 0 0 2px var(--t-line); }
.l-arrived p { margin: 0; max-width: 62ch; line-height: 1.45; color: var(--t-ink-2); }

/* ---------- the stage: the writing desk and the envelope ---------- */
.l-write { padding: 8px 0 34px; }
.l-stage { display: grid; gap: 16px; align-items: start; }
.l-object { order: -1; }
@media (min-width: 900px) {
  .l-stage { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 22px; align-items: stretch; }
  .l-object { order: 0; }
}
.l-desk {
  min-width: 0; padding: 22px; border-radius: var(--t-r-l);
  background: var(--t-card); box-shadow: inset 0 0 0 2px var(--t-line);
}
@media (min-width: 600px) { .l-desk { padding: 28px; } }
.l-form { display: grid; gap: 20px; }

.l-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.l-chips legend { margin: 0 0 10px; padding: 0; color: var(--t-ink-2); }
.l-chip { position: relative; display: inline-flex; }
.l-chip input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.l-chip span {
  display: inline-flex; flex-direction: column; justify-content: center; min-height: 48px; padding: 8px 16px 10px;
  border-radius: var(--t-r-btn); background: var(--t-surface); color: var(--t-ink);
  font: 700 .9375rem/1.15 var(--t-display);
  box-shadow: inset 0 0 0 1.5px var(--t-line), inset 0 -4px 0 rgba(0,0,0,.08);
  transition: transform var(--t-slow) var(--t-spring), background var(--t-base) var(--t-out);
}
.l-chip small { margin-top: 3px; font: 500 .75rem/1.2 var(--t-mono); font-variant-numeric: tabular-nums; color: var(--t-ink-2); }
.l-chip input:checked + span { background: var(--t-lemon); color: #141414; box-shadow: inset 0 -4px 0 rgba(0,0,0,.16); }
.l-chip input:checked + span small { color: #141414; }
.l-chip input:focus-visible + span { outline: 4px solid var(--t-ink); outline-offset: 3px; }
@media (hover: hover) { .l-chip:hover span { transform: translateY(-2px); } }
.l-chip:active span { transform: translateY(2px) scale(.97); transition-duration: var(--t-fast); }
.l-when .l-chip-date { flex: 1 1 calc(50% - 8px); }
.l-when .l-chip-date span { width: 100%; }
@media (min-width: 600px) { .l-when .l-chip-date { flex: 0 1 auto; } }

.l-pick { flex-basis: 100%; display: grid; gap: 6px; margin-top: 4px; }
.l-pick label { font-weight: 600; font-size: .9375rem; }
.l-pick input {
  min-height: 48px; max-width: 260px; padding: 0 14px; border: 0; border-radius: var(--t-r-s);
  background: var(--l-paper); color: #141414; color-scheme: light;
  box-shadow: inset 0 0 0 1.5px rgba(20,20,20,.18);
}

.l-paper { display: grid; gap: 8px; }
.l-paper > .t-label { color: var(--t-ink-2); }
.l-paper textarea {
  width: 100%; min-height: 188px; resize: vertical; box-sizing: border-box; padding: 16px 18px; border: 0;
  border-radius: var(--t-r-m); background: var(--l-paper); color: #141414; color-scheme: light;
  font: 400 1.0625rem/1.55 var(--t-display);
  box-shadow: inset 0 0 0 1.5px rgba(20,20,20,.14), 0 14px 30px -24px rgba(0,0,0,.5);
}
.l-paper textarea::placeholder { color: #5d5b55; opacity: 1; }
.l-count { margin: 0; justify-self: end; font: 500 .75rem/1.3 var(--t-mono); font-variant-numeric: tabular-nums; color: var(--t-ink-2); }
.l-error { margin: 0; font-weight: 600; line-height: 1.35; }
.l-error:empty { display: none; }
.l-error:not(:empty) { padding: 10px 14px; border-radius: var(--t-r-s); background: var(--t-surface-2); box-shadow: inset 4px 0 0 var(--t-ink); }

.l-seal-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
body.v2 button.l-key-seal {
  min-height: 58px; padding: 0 30px 5px; background: var(--t-lemon); color: #141414;
  font-size: 1.1875rem; font-weight: 800;
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.18), 0 16px 30px -20px rgba(0,0,0,.55);
}
.l-note { margin: 0; flex: 1 1 200px; font-size: .875rem; line-height: 1.4; color: var(--t-ink-2); }

/* After sealing */
.l-done { display: grid; gap: 12px; }
.l-done:focus { outline: none; }
.l-done-k { margin: 0; color: var(--t-ink-2); }
.l-done-title { margin: 0; font-size: 1.875rem; line-height: 1.02; font-weight: 800; letter-spacing: -.015em; text-wrap: balance; }
.l-done-sub { margin: 0; max-width: 46ch; line-height: 1.45; color: var(--t-ink-2); }
.l-check { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; padding: 10px 0; line-height: 1.35; cursor: pointer; }
.l-check input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: #141414; }
.l-fine { margin: 0; font-size: .8125rem; line-height: 1.4; color: var(--t-ink-2); }
.l-done .l-key-quiet { justify-self: start; }

/* The envelope: back, letter, front pocket (with the address and the postmark), flap and seal,
   stacked. Open: the flap stands up behind the letter, which sticks out of the pocket. Sealed:
   the letter slides in, the flap folds down over it, the seal presses on. */
.l-object {
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 14px; margin: 0; padding: 22px 16px 20px;
  border-radius: var(--t-r-l); background: var(--t-surface-2);
}
@media (min-width: 900px) { .l-object { align-content: center; padding: 40px 28px 30px; } }
.l-env { position: relative; width: min(100%, 290px); aspect-ratio: 3 / 2; margin-top: 30%; perspective: 900px; }
@media (min-width: 600px) { .l-env { width: min(100%, 420px); } }
@media (min-width: 1100px) { .l-env { width: min(100%, 470px); } }
.l-env > * { position: absolute; }
.l-env-back {
  inset: 0; z-index: 0; border-radius: 18px; background: var(--l-env-in);
  box-shadow: 0 26px 44px -26px rgba(0,0,0,.55);
}
.l-env-paper {
  left: 8%; right: 8%; top: 7%; height: 82%; z-index: 2; box-sizing: border-box; padding: 7% 7% 0;
  border-radius: 10px; background: var(--l-paper); color: #141414;
  box-shadow: 0 0 0 1px rgba(20,20,20,.08);
  transform: translateY(-48%);
  transition: transform .62s var(--t-spring) .42s, opacity 0s linear 0s;
}
.l-env-paper p { margin: 0 0 6%; font: 700 clamp(.8125rem, 3.2vw, 1.0625rem)/1.2 var(--t-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.l-env-paper i { display: block; height: 7px; margin-top: 4.5%; border-radius: 4px; background: #e1dfd8; }
.l-env-paper i:nth-of-type(1) { width: 92%; }
.l-env-paper i:nth-of-type(2) { width: 80%; }
.l-env-paper i:nth-of-type(3) { width: 58%; }
.l-env-front {
  inset: 0; z-index: 3; border-radius: 18px; background: var(--t-lemon); color: #141414;
  clip-path: polygon(0 0, 50% 60%, 100% 0, 100% 100%, 0 100%);
  box-shadow: inset 0 -8px 0 rgba(0,0,0,.16);
}
.l-env-to { left: 7%; bottom: 13%; margin: 0; position: absolute; display: grid; gap: 2px; }
.l-env-to span { font: 500 .6875rem/1 var(--t-mono); letter-spacing: .1em; text-transform: uppercase; }
.l-env-to strong { font-size: clamp(1rem, 4.4vw, 1.5rem); line-height: 1.05; font-weight: 800; }
.l-env-stamp {
  position: absolute; right: 6%; bottom: 10%; margin: 0; width: 31%; aspect-ratio: 1; box-sizing: border-box;
  display: grid; place-content: center; gap: 3px; text-align: center;
  border: 2px dashed #141414; border-radius: 50%; transform: rotate(-9deg);
}
.l-env-stamp span { font: 600 .625rem/1 var(--t-mono); letter-spacing: .12em; text-transform: uppercase; }
.l-env-stamp strong { font: 600 clamp(.625rem, 2.3vw, .8125rem)/1.1 var(--t-mono); font-variant-numeric: tabular-nums; }
.l-env-flap {
  left: 0; right: 0; top: 0; height: 60%; z-index: 1; border-radius: 18px 18px 0 0;
  background: var(--l-env-flap); clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0; transform: rotateX(180deg);
  transition: transform .5s var(--t-out), z-index 0s linear .25s;
}
.l-env-seal {
  left: 50%; top: 60%; z-index: 5; width: 17%; aspect-ratio: 1; display: grid; place-items: center;
  border-radius: 50%; background: #141414; color: var(--t-lemon);
  font: 800 clamp(1rem, 4.6vw, 1.75rem)/1 var(--t-display);
  box-shadow: inset 0 -4px 0 rgba(255,255,255,.16), 0 6px 12px -6px rgba(0,0,0,.6);
  transform: translate(-50%, -50%) scale(0);
  transition: transform .3s var(--t-out);
}
/* Once the flap is down the letter is out of sight; hiding it keeps it from showing through the seams. */
.l-env.is-sealed .l-env-paper { transform: translateY(0); opacity: 0; transition: transform .5s var(--t-out) 0s, opacity 0s linear 1s; }
.l-env.is-sealed .l-env-flap { z-index: 4; transform: rotateX(0deg); transition: transform .55s var(--t-spring) .42s, z-index 0s linear .5s; }
.l-env.is-sealed .l-env-seal { transform: translate(-50%, -50%) scale(1); transition: transform .5s var(--t-spring) .95s; }
.l-caption { margin: 0; text-align: center; font: 500 .875rem/1.4 var(--t-mono); font-variant-numeric: tabular-nums; color: var(--t-ink-2); text-wrap: balance; }

/* ---------- how it works ---------- */
.l-how { padding: 10px 0 10px; }
.l-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 900px) { .l-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.l-steps li { padding: 20px; border-radius: var(--t-r-l); background: var(--t-card); box-shadow: inset 0 0 0 2px var(--t-line); }
.l-step-n {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--t-lemon); color: #141414; font: 600 .9375rem/1 var(--t-mono); box-shadow: inset 0 -3px 0 rgba(0,0,0,.16);
}
.l-steps h3 { margin: 14px 0 6px; font-size: 1.25rem; line-height: 1.1; font-weight: 800; }
.l-steps p { margin: 0; line-height: 1.45; color: var(--t-ink-2); }
.l-honest { margin: 18px 0 0; max-width: 70ch; line-height: 1.45; color: var(--t-ink-2); }

/* ---------- reading a letter ---------- */
.l-read {
  width: min(640px, 100% - 2 * var(--l-gutter)); max-width: none; max-height: calc(100dvh - 32px); margin: auto; padding: 0; border: 0;
  background: transparent; color: #141414; overflow: visible;
}
.l-read::backdrop { background: rgba(20,20,20,.62); }
.l-read-sheet {
  box-sizing: border-box; max-height: calc(100dvh - 32px); overflow-y: auto; padding: 26px 22px 24px;
  border-radius: var(--t-r-l); background: var(--l-paper); color: #141414;
  box-shadow: inset 0 -8px 0 rgba(0,0,0,.08), 0 30px 60px -30px rgba(0,0,0,.6);
}
@media (min-width: 600px) { .l-read-sheet { padding: 34px 36px 30px; } }
.l-read.is-rising .l-read-sheet { animation: l-unfold .65s var(--t-spring) both; }
@keyframes l-unfold { from { transform: translateY(40px) scale(.94); } }
.l-read-k { margin: 0 0 10px; color: #5d5b55; }
.l-read-title { margin: 0 0 18px; font-size: 1.875rem; line-height: 1.02; font-weight: 800; letter-spacing: -.015em; text-wrap: balance; }
.l-read-text { font-size: 1.125rem; line-height: 1.6; overflow-wrap: anywhere; }
.l-read-text p { margin: 0 0 1em; }
.l-read-foot { margin: 18px 0 20px; padding-top: 14px; border-top: 1.5px dashed rgba(20,20,20,.2); font: 500 .8125rem/1.45 var(--t-mono); color: #5d5b55; }
body.v2 .l-read .l-key { background: #f2efe6; color: #141414; box-shadow: inset 0 0 0 1.5px rgba(20,20,20,.14), inset 0 -4px 0 rgba(0,0,0,.08); }
body.v2 .l-read .l-key-ink { background: #141414; color: #fff; box-shadow: inset 0 -4px 0 rgba(255,255,255,.18); }
.l-read :focus-visible { outline-color: #141414; }

.l-noscript { padding: 16px 0; color: var(--t-ink-2); }
@media (scripting: none) { #write, #kept { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .l-mast h1, .l-letter, .l-read.is-rising .l-read-sheet, .l-letter.is-ready .l-dot { animation: none !important; }
  .l-key, .l-key:hover, .l-key:active, .l-chip span, .l-chip:hover span, .l-chip:active span { transform: none !important; transition: none !important; }
  .l-env-paper, .l-env-flap, .l-env-seal,
  .l-env.is-sealed .l-env-paper, .l-env.is-sealed .l-env-flap, .l-env.is-sealed .l-env-seal { transition: none !important; }
}
