:root {
  --desk: #cbc8c1;
  --paper: #cbb487;
  --ink: #242321;
  --soft-ink: #615748;
  --red: #6f4333;
  --machine: #efeee9;
  --machine-shadow: #c9c8c3;
  --mono: "Courier New", "Songti SC", "STSong", monospace;
}

* { box-sizing: border-box; }
html { background: var(--desk); }

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -8%, rgba(255,255,255,.48), transparent 42%),
    repeating-linear-gradient(90deg, rgba(53,48,41,.018) 0 1px, transparent 1px 7px),
    var(--desk);
  font-family: var(--mono);
}

body::before {
  content: "";
  position: fixed;
  z-index: 50;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

button, a { -webkit-tap-highlight-color: transparent; }

.encore-header {
  position: fixed;
  z-index: 60;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  justify-content: space-between;
  padding: calc(17px + env(safe-area-inset-top)) calc(22px + env(safe-area-inset-right)) 12px calc(22px + env(safe-area-inset-left));
  color: #34322f;
  font: 8px/1 var(--mono);
  letter-spacing: .17em;
}

.encore-header a {
  border-bottom: 1px solid transparent;
  color: inherit;
  text-decoration: none;
}

.encore-header a:hover,
.encore-header a:focus-visible { border-bottom-color: currentColor; }

.letter-stage {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  padding: clamp(54px, 7vh, 82px) 18px max(22vh, 160px);
}

.letter {
  position: relative;
  z-index: 1;
  width: min(790px, calc(100% - 18px));
  min-height: 1120px;
  margin: 0 auto;
  padding: clamp(58px, 8vw, 96px) clamp(34px, 8vw, 88px) 138px;
  border: 1px solid rgba(56,51,44,.14);
  background:
    repeating-linear-gradient(87deg, rgba(89,68,42,.018) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(1deg, rgba(255,255,255,.02) 0 1px, transparent 1px 9px),
    radial-gradient(circle at 14% 3%, rgba(255,255,255,.22), transparent 34%),
    var(--paper);
  box-shadow: 0 7px 24px rgba(48,42,34,.14);
  opacity: 0;
  transform: translateY(34px);
  transition: opacity .55s ease, transform 1.1s cubic-bezier(.18,.75,.18,1);
}

.letter::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .14;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.56' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='.15'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.is-ready .letter { opacity: 1; transform: translateY(0); }

.letter-mark {
  position: absolute;
  z-index: 2;
  top: 27px;
  right: 32px;
  color: var(--soft-ink);
  font-size: 7px;
  letter-spacing: .18em;
}

.letter-heading,
.letter-grid,
.film-gift,
.letter-closing,
.letter-folio { position: relative; z-index: 1; }

.letter-heading {
  width: 100%;
  margin-bottom: 52px;
  border-bottom: 1px dashed rgba(45,43,39,.24);
  padding-bottom: 28px;
}

.letter-heading > p:first-child,
.section-index {
  margin: 0;
  color: var(--red);
  font-size: 8px;
  line-height: 1.5;
  letter-spacing: .12em;
}

.letter-heading h1 {
  margin: 18px 0 9px;
  font: 700 clamp(28px, 5vw, 44px)/1 var(--mono);
  letter-spacing: .12em;
  text-shadow: .7px 0 rgba(36,35,33,.28), -.25px .4px rgba(36,35,33,.18);
}

.letter-heading h1 span { color: var(--red); }

.letter-date {
  margin: 0;
  color: var(--soft-ink);
  font-size: 10px;
  letter-spacing: .08em;
}

.letter-grid { display: block; }

.letter-copy {
  font-size: clamp(13px, 1.5vw, 15px);
  line-height: 2.12;
  letter-spacing: .018em;
  text-shadow: .28px 0 rgba(30,29,27,.22);
}

.letter-copy p { margin: 0 0 1.55em; }
.letter-copy p:nth-child(2) { opacity: .92; }
.letter-copy p:nth-child(3) { opacity: .97; }
.letter-copy p:nth-child(4) { opacity: .88; }
.letter-copy .salutation { margin-bottom: 2.25em; }

.memory-photos {
  display: grid;
  grid-template-columns: 1fr;
  align-items: end;
  margin: 46px 0 64px;
  padding: 10px;
  border: 1px dashed rgba(49,47,43,.22);
}

.memory-frame {
  margin: 0;
  padding: 7px;
  border: 1px solid rgba(50,47,42,.22);
  background: rgba(220,202,166,.54);
}

.memory-photo {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: #b9a47e;
  cursor: zoom-in;
}

.memory-photo img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: saturate(.76) contrast(.98) sepia(.08);
  transition: filter .2s ease;
}

.memory-photo:hover img,
.memory-photo:focus-visible img { filter: saturate(1) contrast(1); }
.memory-photo:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

.memory-frame figcaption {
  margin-top: 8px;
  color: var(--soft-ink);
  font-size: 7px;
  line-height: 1.4;
  letter-spacing: .07em;
}

.film-gift {
  margin-top: 30px;
  border-top: 1px dashed rgba(45,43,39,.25);
  padding-top: 38px;
}

.film-gift-intro h2 {
  margin: 18px 0 24px;
  font: 700 clamp(20px, 3vw, 27px)/1.45 var(--mono);
  letter-spacing: .03em;
}

.film-gift-intro h2 em { color: var(--red); font-style: normal; }

.film-gift-intro > p:last-child {
  margin: 0;
  color: #3e3b37;
  font-size: 13px;
  line-height: 2;
}

.app-link {
  color: var(--red);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid rgba(111,67,51,.48);
  text-shadow: .35px 0 rgba(80,45,35,.18);
  transition: color .18s ease, border-color .18s ease;
}

.app-link:hover,
.app-link:focus-visible {
  color: #442a21;
  border-bottom-color: currentColor;
}

.app-link:focus-visible { outline: 1px dashed currentColor; outline-offset: 3px; }

.darkroom-note {
  margin-top: 34px;
  border: 1px solid rgba(43,42,38,.28);
  padding: 0 25px 24px;
  background: rgba(223,205,170,.5);
}

.darkroom-note::before {
  content: "COLOR NEGATIVE / VIEWING NOTE";
  display: inline-block;
  margin-top: -1px;
  padding: 6px 9px;
  background: #2a2a27;
  color: #efebdf;
  font-size: 7px;
  letter-spacing: .12em;
}

.darkroom-note summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 0 18px;
  border-bottom: 1px dashed rgba(46,44,40,.25);
  font-size: 11px;
  line-height: 1.6;
  cursor: pointer;
  list-style: none;
}

.darkroom-note summary::-webkit-details-marker { display: none; }
.app-link-summary { margin: 0 .22em; }
.summary-label { min-width: 0; }
.darkroom-note summary .summary-plus { flex: 0 0 auto; font-size: 15px; transition: transform .2s ease; }
.darkroom-note[open] summary .summary-plus { transform: rotate(45deg); }

.darkroom-note ol { margin: 24px 0 0; padding: 0; list-style: none; }

.darkroom-note li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 9px;
  margin-bottom: 17px;
  color: #41403b;
  font-size: 11px;
  line-height: 1.8;
}

.darkroom-note li strong { color: var(--red); font-weight: 700; }

.darkroom-tip {
  margin: 24px 0 0;
  padding-top: 13px;
  border-top: 1px dashed rgba(46,44,40,.22);
  color: var(--soft-ink);
  font-size: 8px;
  line-height: 1.6;
  letter-spacing: .05em;
}

.letter-closing {
  margin: 65px 0 42px;
  font-size: 12px;
  line-height: 1.9;
}

.letter-closing > p { margin: 0 0 5px; }
.signature { margin-top: 29px; text-align: right; }
.signature span { display: block; color: var(--soft-ink); font-size: 9px; }

.signature strong {
  display: inline-block;
  margin-top: 8px;
  color: var(--red);
  font: 700 14px/1 var(--mono);
  letter-spacing: .08em;
}

.letter-folio {
  margin: 0;
  color: #77716a;
  font-size: 7px;
  letter-spacing: .14em;
  text-align: center;
}

/* The lower fifth of the viewport: a compact, dimensional white typewriter. */
.typewriter {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  width: min(1040px, 100%);
  height: 20vh;
  min-height: 142px;
  max-height: 215px;
  margin: 0 auto;
  filter: drop-shadow(0 -5px 12px rgba(39,35,29,.16)) drop-shadow(0 17px 18px rgba(35,32,27,.26));
  pointer-events: none;
  transform: translateY(18px);
  transition: transform .85s cubic-bezier(.18,.75,.18,1);
}

.typewriter::before {
  content: "";
  position: absolute;
  z-index: 0;
  right: 7%;
  bottom: -9px;
  left: 7%;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(37,34,30,.38), rgba(37,34,30,0) 70%);
  filter: blur(7px);
}

.is-ready .typewriter { transform: translateY(0); }

.carriage {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 50%;
  width: min(1050px, 108vw);
  height: 24px;
  transform: translateX(-50%);
}

.carriage-rail {
  position: absolute;
  top: 6px;
  right: 18px;
  left: 18px;
  height: 10px;
  border: 1px solid #858783;
  border-radius: 5px;
  background: linear-gradient(180deg, #f3f4ef 0, #8b8d89 34%, #d8d9d4 52%, #696b68 76%, #b9bbb6 100%);
  box-shadow: 0 2px 2px rgba(28,28,27,.38), inset 0 1px 0 rgba(255,255,255,.8);
}

.carriage-scale {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 56%;
  height: 10px;
  background: repeating-linear-gradient(90deg, transparent 0 8px, rgba(42,42,40,.65) 8px 9px);
  transform: translateX(-50%);
}

.carriage-knob {
  position: absolute;
  z-index: 2;
  top: 2px;
  width: 33px;
  height: 19px;
  border-radius: 5px;
  background: linear-gradient(180deg, #41423f, #11120f 62%, #31322f);
  box-shadow: inset 0 0 0 3px #151614, 0 3px 4px rgba(0,0,0,.3);
}

.carriage-knob-left { left: 0; }
.carriage-knob-right { right: 0; }

.paper-mouth {
  position: absolute;
  z-index: 9;
  top: 18px;
  left: 50%;
  width: min(650px, 72vw);
  height: 13px;
  border-radius: 8px;
  background: linear-gradient(#171816, #4b4b47 45%, #11120f 48%, #292a27);
  transform: translateX(-50%);
  box-shadow: 0 3px 0 rgba(233,231,221,.92), 0 7px 7px rgba(24,24,22,.28);
}

.ribbon-deck {
  position: absolute;
  z-index: 5;
  top: 29px;
  left: 50%;
  width: min(560px, 67vw);
  height: 54px;
  border-radius: 50% 50% 22% 22%;
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(205,204,199,.88));
  box-shadow: 0 7px 9px rgba(33,31,27,.22), inset 0 1px 0 #fff;
  transform: translateX(-50%) perspective(300px) rotateX(42deg);
  transform-origin: top center;
}

.ribbon-spool {
  position: absolute;
  top: 1px;
  width: 46px;
  height: 34px;
  border: 5px solid #282927;
  border-radius: 50%;
  background: radial-gradient(circle, #999a96 0 10%, #20211f 11% 28%, #777874 29% 32%, #1e1f1d 33%);
  box-shadow: 0 5px 5px rgba(25,25,23,.35), inset 0 2px 2px rgba(255,255,255,.14);
}

.ribbon-spool-left { left: 9%; }
.ribbon-spool-right { right: 9%; }

.ink-ribbon {
  position: absolute;
  top: 16px;
  right: 15%;
  left: 15%;
  height: 8px;
  background: #28201d;
  box-shadow: 0 3px 0 #743327;
  transform: perspective(140px) rotateX(12deg);
}

.type-basket {
  position: absolute;
  z-index: 3;
  top: 46px;
  left: 50%;
  width: min(420px, 56vw);
  height: 75px;
  border-radius: 50% 50% 12px 12px;
  background:
    radial-gradient(ellipse at 50% 4%, transparent 0 23%, #272825 24% 30%, transparent 31%),
    repeating-conic-gradient(from -42deg at 50% 4%, #373835 0 2deg, transparent 2deg 6deg),
    #11120f;
  clip-path: polygon(4% 0, 96% 0, 82% 100%, 18% 100%);
  transform: translateX(-50%);
  box-shadow: inset 0 9px 13px #050604, 0 7px 9px rgba(26,25,22,.26);
}

.typewriter-wing {
  position: absolute;
  z-index: 5;
  top: 47px;
  width: 37%;
  height: 49px;
  border-top: 1px solid rgba(255,255,255,.82);
  background: linear-gradient(180deg, #fff 0, #f1f0eb 35%, #c8c7c2 100%);
  box-shadow: inset 0 4px 8px rgba(255,255,255,.8), 0 6px 8px rgba(38,36,31,.22);
}

.typewriter-wing-left { left: 0; border-radius: 0 50px 10px 0; transform: skewX(-8deg); }
.typewriter-wing-right { right: 0; border-radius: 50px 0 0 10px; transform: skewX(8deg); }

.typewriter-shell {
  position: absolute;
  z-index: 6;
  right: 4%;
  bottom: 0;
  left: 4%;
  height: 62%;
  min-height: 88px;
  border: 1px solid rgba(81,80,75,.42);
  border-radius: 26px 26px 8px 8px;
  background:
    linear-gradient(105deg, rgba(255,255,255,.55), transparent 22% 78%, rgba(117,115,108,.13)),
    linear-gradient(180deg, #fff 0, var(--machine) 30%, #d3d2cd 75%, #bbb9b3 100%);
  box-shadow:
    inset 0 10px 13px rgba(255,255,255,.88),
    inset 0 -16px 18px rgba(73,71,66,.18),
    0 10px 12px rgba(41,38,33,.3);
  clip-path: polygon(9% 0, 91% 0, 100% 94%, 97% 100%, 3% 100%, 0 94%);
}

.shell-ridge {
  position: absolute;
  z-index: 1;
  top: 7px;
  right: 12%;
  left: 12%;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(150,149,144,.28));
  box-shadow: 0 3px 5px rgba(50,48,43,.16);
}

.keyboard-well {
  position: absolute;
  z-index: 2;
  top: 18px;
  right: 12%;
  bottom: -16px;
  left: 12%;
  border: 1px solid rgba(36,36,33,.68);
  border-radius: 11px 11px 18px 18px;
  background: linear-gradient(180deg, #252622 0, #0d0e0c 60%, #30312e 100%);
  box-shadow: inset 0 8px 12px rgba(0,0,0,.75), inset 0 -4px 3px rgba(255,255,255,.06), 0 2px 0 rgba(255,255,255,.7);
  transform: perspective(360px) rotateX(21deg);
  transform-origin: bottom center;
}

.key-row {
  position: absolute;
  right: 4%;
  left: 4%;
  display: grid;
  gap: clamp(2px, .45vw, 6px);
}

.key-row-one { top: 7%; grid-template-columns: repeat(10, 1fr); }
.key-row-two { top: 37%; right: 8%; left: 8%; grid-template-columns: repeat(9, 1fr); }
.key-row-three { top: 67%; right: 17%; left: 17%; grid-template-columns: repeat(7, 1fr); }

.key-row span {
  display: grid;
  place-items: center;
  min-height: clamp(17px, 2.6vh, 29px);
  border: 1px solid #0a0b09;
  border-radius: 50%;
  background: radial-gradient(circle at 42% 30%, rgba(255,255,255,.18), transparent 28%), linear-gradient(145deg, #444541, #11120f 68%);
  color: #e6e0d1;
  font: clamp(5px, .65vw, 8px)/1 var(--mono);
  text-shadow: 0 -1px #000;
  box-shadow: inset 0 2px 1px rgba(255,255,255,.17), inset 0 -3px 2px rgba(0,0,0,.52), 0 4px 0 #090a08, 0 5px 4px rgba(0,0,0,.62);
  transform: translateY(-2px);
}

.spacebar {
  position: absolute;
  right: 29%;
  bottom: -4px;
  left: 29%;
  height: 9px;
  border: 1px solid #0c0d0b;
  border-radius: 3px 3px 6px 6px;
  background: linear-gradient(#3c3d39, #141512);
  box-shadow: 0 4px 0 #080907, 0 5px 4px rgba(0,0,0,.6), inset 0 1px rgba(255,255,255,.14);
}

.typewriter-base {
  position: absolute;
  z-index: 5;
  right: 2%;
  bottom: -8px;
  left: 2%;
  height: 21px;
  border-radius: 4px 4px 16px 16px;
  background: linear-gradient(180deg, #cecdc8, #8f8e89 55%, #deddd8 58%, #9b9a94);
  box-shadow: 0 7px 8px rgba(35,33,29,.35), inset 0 1px rgba(255,255,255,.78);
}

.encore-lightbox {
  width: min(94vw, 1160px);
  max-width: none;
  height: min(90vh, 820px);
  max-height: none;
  border: 0;
  padding: 42px;
  background: rgba(24,24,22,.97);
  color: #efebdf;
}

.encore-lightbox::backdrop { background: rgba(25,23,20,.8); backdrop-filter: blur(5px); }
.encore-lightbox figure { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; margin: 0; }
.encore-lightbox img { display: block; max-width: 100%; max-height: calc(100% - 40px); object-fit: contain; }
.encore-lightbox figcaption { margin-top: 15px; font-size: 8px; letter-spacing: .08em; }

.lightbox-close {
  position: absolute;
  top: 12px;
  right: 15px;
  border: 0;
  background: none;
  color: inherit;
  font: 22px/1 var(--mono);
  cursor: pointer;
}

@media (max-width: 620px) {
  .encore-header { padding: calc(13px + env(safe-area-inset-top)) 12px 10px; font-size: 6px; }
  .letter-stage { padding: 46px 6px max(23vh, 145px); }
  .letter { width: 100%; min-height: 1050px; padding: 51px 24px 122px; }
  .letter-mark { top: 20px; right: 21px; font-size: 6px; }
  .letter-heading { margin-bottom: 41px; padding-bottom: 22px; }
  .letter-heading h1 { font-size: 27px; }
  .letter-copy { font-size: 12px; line-height: 2.05; }
  .memory-photos { grid-template-columns: 1fr; margin: 38px 0 52px; }
  .memory-photo img { height: auto; max-height: none; object-fit: contain; }
  .film-gift-intro > p:last-child { font-size: 12px; }
  .darkroom-note { padding-right: 17px; padding-left: 17px; }
  .darkroom-note li { grid-template-columns: 26px 1fr; font-size: 10px; }
  .typewriter { height: 21vh; min-height: 138px; }
  .carriage { width: 104vw; }
  .typewriter-shell { right: 0; left: 0; border-radius: 12px 12px 0 0; }
  .typewriter-wing { width: 33%; }
  .ribbon-deck { width: 76vw; }
  .type-basket { width: 64vw; }
  .keyboard-well { right: 8%; bottom: -11px; left: 8%; }
  .key-row { gap: 2px; }
  .key-row-one { right: 4%; left: 4%; }
  .key-row-two { right: 8%; left: 8%; }
  .key-row-three { right: 17%; left: 17%; }
  .key-row span { min-height: 20px; }
  .spacebar { right: 27%; left: 27%; }
  .typewriter-base { right: 0; left: 0; }
  .encore-lightbox { width: 100vw; height: 100dvh; padding: 42px 12px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .letter,
  .typewriter { opacity: 1; transform: none; transition: none; }
  .memory-photo img,
  .darkroom-note summary .summary-plus { transition: none; }
}
