:root {
  --diary-ink: #30271f;
  --diary-soft: rgba(48, 39, 31, .62);
  --diary-faint: rgba(48, 39, 31, .36);
  --diary-paper: #f4eddf;
  --diary-paper-light: #fbf8f0;
  --diary-leather: #5a3324;
  --diary-accent: #8b4b36;
  --diary-serif: "Cormorant Garamond", Georgia, serif;
  --diary-sans: "Geist", system-ui, sans-serif;
  --diary-hand: "Caveat", "Segoe Script", cursive;
  --diary-pen: #3d332a;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body.diary-home {
  color: var(--diary-ink);
  background: #f1ede4;
  font-family: var(--diary-serif);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button, a { color: inherit; }
a { text-decoration: none; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.diary-wash {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, rgba(252, 250, 245, .46), rgba(244, 239, 229, .58)),
    url("../images/diary/memory-wash.webp") center / cover no-repeat;
}
.diary-wash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 46%, rgba(255,255,255,.48), rgba(255,255,255,.12) 52%, transparent 74%);
  pointer-events: none;
}

.diary-nav {
  position: fixed;
  z-index: 100;
  top: 0; left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 56px;
  background: linear-gradient(180deg, rgba(242,234,216,.92), rgba(242,234,216,.58) 50%, transparent);
  pointer-events: none;
}
/* Content scrolling under the mast blurs into a soft cloud instead of
   meeting a hard edge. */
.diary-nav::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  -webkit-mask-image: linear-gradient(180deg, #000 44%, transparent 96%);
  mask-image: linear-gradient(180deg, #000 44%, transparent 96%);
  pointer-events: none;
}
.diary-nav > * { pointer-events: auto; }
.diary-brand {
  font-size: clamp(25px, 2.6vw, 32px);
  font-weight: 600;
  letter-spacing: .025em;
  line-height: 1;
}
.diary-nav nav { display: flex; gap: 28px; font-family: var(--diary-sans); }
.diary-nav nav a {
  color: var(--diary-soft);
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  transition: color .2s ease;
}
.diary-nav nav a:hover, .diary-nav nav a:focus-visible { color: var(--diary-ink); }

.diary-hero {
  min-height: 100svh;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: clamp(116px, 14svh, 150px) 18px 54px;
  position: relative;
}
.diary-kicker {
  margin: 0 0 clamp(18px, 3svh, 34px);
  color: var(--diary-soft);
  font-family: var(--diary-sans);
  font-size: 10px;
  letter-spacing: .28em;
  text-transform: uppercase;
}

.diary-home-quote {
  width: min(780px, 82vw);
  margin: 0;
  color: rgba(48, 39, 31, .72);
  font-size: clamp(15px, 1.45vw, 20px);
  font-style: italic;
  font-weight: 400;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
}
.diary-home-quote--above { margin-bottom: clamp(18px, 2.8vh, 30px); }
.diary-home-quote--below { margin-top: clamp(17px, 2.6vh, 28px); }

.diary-shell {
  width: min(1120px, 96vw);
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  align-items: center;
  gap: clamp(2px, 1.3vw, 16px);
}
.diary-stage {
  min-width: 0;
  position: relative;
  perspective: 1800px;
  perspective-origin: 50% 42%;
  touch-action: pan-y;
}
.diary-book {
  position: relative;
  width: 100%;
  aspect-ratio: 1.62 / 1;
  transform-style: preserve-3d;
  transform: rotateX(calc(2.2deg + var(--lean-x, 0deg))) rotateY(var(--lean-y, 0deg));
  transition: transform .16s ease-out;
  will-change: transform;
  --page-pad: clamp(18px, 3.1vw, 48px);
  --span: .481;
  --strips: 18;
  --leaf-w: calc(var(--book-w, 1000px) * var(--span));
  --strip-w: calc(var(--leaf-w) / var(--strips));
}

/* The book sits on a surface, so the shadow is a pool underneath it rather
   than a filter on the artwork. Each pool fades to nothing well inside its
   own bounds, and all three ease off while a leaf is in the air. */
.diary-cast {
  position: absolute;
  z-index: -1;
  pointer-events: none;
}
.diary-cast--ambient {
  left: 3%; right: 3%; top: 26%; bottom: -6%;
  background: radial-gradient(50% 50% at 50% 58%,
    rgba(58, 44, 26, .34) 0%, rgba(58, 44, 26, .18) 40%, rgba(58, 44, 26, 0) 74%);
  filter: blur(26px);
  opacity: calc(1 - var(--turn-shade, 0) * .42);
}
.diary-cast--contact {
  left: 7%; right: 7%; top: 60%; bottom: -3%;
  background: radial-gradient(50% 44% at 50% 42%,
    rgba(44, 32, 14, .42) 0%, rgba(44, 32, 14, .17) 48%, rgba(44, 32, 14, 0) 78%);
  filter: blur(11px);
  opacity: calc(1 - var(--turn-shade, 0) * .5);
}
.diary-cast--hair {
  left: 10%; right: 10%; top: 72%; bottom: 2%;
  background: radial-gradient(50% 52% at 50% 40%,
    rgba(40, 28, 10, .36) 0%, rgba(40, 28, 10, 0) 76%);
  filter: blur(4px);
  opacity: calc(1 - var(--turn-shade, 0) * .62);
}
.diary-book::after {
  content: "";
  position: absolute;
  z-index: 47;
  inset: 3.3% 1.9% 3%;
  background: linear-gradient(90deg, transparent 39%, rgba(55,36,20,.28) 49.5%, rgba(255,255,255,.08) 50.5%, transparent 61%);
  opacity: calc(var(--turn-shade, 0) * .72);
  pointer-events: none;
}
.diary-cover {
  position: absolute;
  inset: 2.7% 1.2% 1.2%;
  border-radius: 15px 18px 17px 15px;
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,.09), transparent 19%),
    radial-gradient(circle at 82% 76%, rgba(0,0,0,.17), transparent 26%),
    repeating-linear-gradient(97deg, rgba(255,255,255,.025) 0 1px, transparent 1px 4px),
    #603a28;
  border: 1px solid #3a2119;
  box-shadow: inset 0 0 0 4px rgba(161,105,69,.22), inset 0 0 30px rgba(27,15,10,.5);
  transform: translateZ(-7px);
}
.diary-page-stack {
  position: absolute;
  top: 4.1%; bottom: 2.2%;
  width: 48.9%;
  background: repeating-linear-gradient(180deg, #ddcfb2 0 2px, #b7a586 2px 3px, #eadfc8 3px 5px);
  box-shadow: 0 10px 12px rgba(58,36,19,.26), inset 0 -3px 5px rgba(70,45,22,.22);
  transform: translateZ(-3px);
}
.diary-page-stack--left { left: 1.8%; border-radius: 12px 2px 4px 12px; }
.diary-page-stack--right { right: 1.8%; border-radius: 2px 12px 12px 4px; }

.diary-spread {
  position: absolute;
  inset: 3.3% 1.9% 3%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  transform-style: preserve-3d;
}
/* Each zone covers a whole half of the spread, so a page can be picked up
   anywhere on it and dragged. A press that never moves is a click: near the
   outer edge it turns the page, and anywhere else it opens the essay. */
.diary-turn-zone {
  position: absolute;
  z-index: 48;
  top: 3.3%;
  bottom: 3%;
  width: 48.1%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}
.diary-turn-zone:active { cursor: grabbing; }
.diary-turn-zone:disabled { cursor: pointer; }
.diary-turn-zone--left { left: 1.9%; }
.diary-turn-zone--right { right: 1.9%; }
.diary-turn-zone::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 62px;
  height: 62px;
  opacity: 0;
  transition: opacity .25s ease;
}
.diary-turn-zone--left::after {
  left: 0;
  background: linear-gradient(45deg, rgba(96,74,48,.22), rgba(117,91,61,.06) 46%, transparent 62%);
  border-radius: 0 100% 0 0;
}
.diary-turn-zone--right::after {
  right: 0;
  background: linear-gradient(-45deg, rgba(96,74,48,.22), rgba(117,91,61,.06) 46%, transparent 62%);
  border-radius: 100% 0 0;
}
.diary-turn-zone:hover::after,
.diary-turn-zone:focus-visible::after { opacity: 1; }
.diary-turn-zone:disabled::after { opacity: 0; }
.memory-page {
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  color: var(--diary-ink);
  background-color: var(--diary-paper);
  background-image:
    radial-gradient(circle at 13% 16%, rgba(110,64,36,.045) 0 1px, transparent 2px),
    radial-gradient(circle at 88% 77%, rgba(130,76,39,.05) 0 1px, transparent 2.4px),
    radial-gradient(ellipse at 50% 12%, rgba(255,255,255,.24), transparent 50%),
    repeating-linear-gradient(0deg, rgba(89,62,38,.018) 0 1px, transparent 1px 4px);
  background-size: 47px 43px, 59px 61px, 100% 100%, 100% 4px;
  cursor: pointer;
  isolation: isolate;
}
.memory-page::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  box-shadow: inset 0 0 28px rgba(88,57,29,.16);
  opacity: .68;
}
.memory-page::after {
  content: "";
  position: absolute;
  width: 90px; height: 70px;
  border: 2px solid rgba(115,68,34,.06);
  border-radius: 50%;
  right: 3%; bottom: 5%;
  transform: rotate(-16deg);
  pointer-events: none;
}
.memory-page--left { border-radius: 9px 1px 2px 9px; box-shadow: inset -18px 0 22px -20px rgba(38,22,12,.9); }
.memory-page--right { border-radius: 1px 9px 9px 2px; box-shadow: inset 18px 0 22px -20px rgba(38,22,12,.9); }
.memory-page--left .memory-page__inner { padding-right: calc(var(--page-pad) * 1.15); }
.memory-page--right .memory-page__inner { padding-left: calc(var(--page-pad) * 1.15); }
.memory-page__inner {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: var(--page-pad);
}
.memory-page__eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 clamp(9px, 1.6vw, 20px);
  color: var(--diary-soft);
  font-family: var(--diary-hand);
  font-size: clamp(11px, 1.15vw, 16px);
  letter-spacing: .04em;
}
.memory-page__number { font-variant-numeric: tabular-nums; }
/* A photograph is a print laid on the page and held by a strip of tape on
   its top edge, the way a real diary keeps one. */
.memory-page__photo {
  position: relative;
  display: block;
  margin: 6px 0 clamp(10px, 1.5vw, 19px);
  transform: rotate(-.45deg);
}
.memory-page__image {
  display: block;
  width: 100%;
  height: clamp(105px, 17vw, 225px);
  object-fit: cover;
  filter: sepia(.1) saturate(.9) contrast(.97);
  border: 7px solid rgba(249,242,222,.8);
  box-shadow: 0 3px 7px rgba(65,40,20,.22);
}
.memory-page__tape {
  position: absolute;
  z-index: 3;
  top: clamp(-9px, -.7vw, -6px);
  left: 50%;
  width: clamp(48px, 24%, 104px);
  height: clamp(14px, 1.8vw, 24px);
  transform: translateX(-50%) rotate(-2.2deg);
  background:
    linear-gradient(90deg, rgba(255,255,255,.24), transparent 18%, transparent 82%, rgba(255,255,255,.2)),
    linear-gradient(180deg, rgba(243,234,206,.66), rgba(232,220,188,.5));
  border-left: 1px dashed rgba(120,90,55,.22);
  border-right: 1px dashed rgba(120,90,55,.22);
  box-shadow: 0 1px 3px rgba(70,45,20,.2), inset 0 0 8px rgba(255,255,255,.4);
}
.memory-page__mark {
  width: 100%;
  height: clamp(64px, 11vw, 142px);
  margin-bottom: clamp(10px, 1.5vw, 19px);
  display: grid;
  place-items: center;
  border-top: 1px solid rgba(73,51,32,.2);
  border-bottom: 1px solid rgba(73,51,32,.2);
  color: rgba(75,50,31,.28);
  font-size: clamp(36px, 6vw, 72px);
  font-style: italic;
}
.memory-page__title {
  margin: 0;
  color: var(--diary-pen);
  font-family: var(--diary-hand);
  font-size: clamp(17px, 2vw, 31px);
  font-weight: 600;
  line-height: .96;
  letter-spacing: .005em;
  text-wrap: balance;
}
.memory-page__rule {
  width: 54px;
  height: 1px;
  margin: clamp(10px, 1.5vw, 18px) 0;
  background: var(--diary-accent);
  opacity: .58;
}
.memory-page__excerpt {
  margin: 0;
  color: rgba(61, 51, 42, .82);
  font-family: var(--diary-hand);
  font-size: clamp(11px, 1.25vw, 18px);
  font-weight: 400;
  line-height: 1.34;
  display: -webkit-box;
  -webkit-line-clamp: var(--clamp-feature, 4);
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.memory-page__read {
  margin: auto 0 0;
  padding-top: 12px;
  color: var(--diary-accent);
  font-family: var(--diary-hand);
  font-size: clamp(11px, 1.1vw, 16px);
  font-weight: 600;
  letter-spacing: .05em;
}

.memory-page--feature .memory-page__title { font-size: clamp(16px, 1.95vw, 29px); }
/* The feature photo: the plain polaroid, just a touch taller than the
   panorama's natural height. */
.memory-page--feature .memory-page__image {
  height: clamp(100px, 13vw, 175px);
  object-fit: cover;
  /* the couple sits at the right edge of the panorama; crop from the left */
  object-position: right center;
}
.memory-page--feature .memory-page__photo { margin-bottom: clamp(16px, 2.4vw, 30px); }
.memory-page--feature-continuation .memory-page__inner { justify-content: center; }

/* A post owns its whole spread, so the right page is all writing. */
.memory-page--body .memory-page__excerpt {
  margin-top: clamp(8px, 1.4vw, 18px);
  font-size: clamp(11px, 1.3vw, 19px);
  -webkit-line-clamp: var(--clamp-body, 10);
}
.memory-page:not(.memory-page--feature):not(.memory-page--body):not(.memory-page--feature-continuation) .memory-page__title {
  font-size: clamp(18px, 2.3vw, 33px);
}
/* The few lines that follow the headline on a post's left page. */
.memory-page__excerpt--lead {
  margin-top: 2px;
  -webkit-line-clamp: 3;
}
.memory-page__excerpt--lead:empty { display: none; }
/* The lead-in line of a bulleted feature page, separated from the byline
   by a blank line the way the post itself is set. */
.memory-page__excerpt--leadin {
  margin-top: clamp(10px, 1.5vw, 20px);
  -webkit-line-clamp: 2;
}
/* The written lines never get squeezed into half-height slices; when space
   runs out, whole bullets are dropped instead (see tuneClamp). */
.memory-page__excerpt--lead,
.memory-page__excerpt--leadin,
.memory-page__list { flex-shrink: 0; }
/* One or two more bullets written under the landing page's pull quote. */
.memory-page__list--continuation {
  margin: clamp(14px, 2vw, 26px) auto 0;
  max-width: 36ch;
}
.memory-page--feature .memory-page__list { margin-top: clamp(8px, 1.2vw, 16px); }

/* A line worth keeping, copied out across the lower part of the page. */
.memory-page__quote--pull {
  margin: clamp(12px, 1.9vw, 24px) 4% 0;
  font-size: clamp(13px, 1.5vw, 22px);
  transform: rotate(-.8deg);
}

/* A post written as bullets keeps its bullets in the diary. */
.memory-page__list {
  margin: clamp(6px, 1vw, 12px) 0 0;
  padding: 0;
  list-style: none;
  color: rgba(61, 51, 42, .82);
  font-family: var(--diary-hand);
  font-size: clamp(11px, 1.3vw, 19px);
  line-height: 1.34;
  overflow: hidden;
}
.memory-page__list li {
  position: relative;
  margin: 0 0 .38em;
  padding-left: 1.05em;
}
.memory-page__list li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: rgba(61, 51, 42, .55);
}
.memory-page__quote {
  position: relative;
  margin: 0;
  padding: 0 2%;
  color: var(--diary-pen);
  font-family: var(--diary-hand);
  font-size: clamp(16px, 2vw, 30px);
  font-weight: 600;
  line-height: 1.12;
  text-align: center;
  transform: rotate(-1.1deg);
}
.memory-page__quote::before {
  content: "“";
  display: block;
  height: .6em;
  color: rgba(139,75,54,.35);
  font-size: 2.5em;
  line-height: .65;
}
.memory-page__continuation {
  margin: clamp(14px, 2.2vw, 28px) auto 0;
  max-width: 34ch;
  color: rgba(61, 51, 42, .76);
  font-family: var(--diary-hand);
  font-size: clamp(12px, 1.32vw, 19px);
  line-height: 1.36;
  text-align: center;
}

.diary-gutter {
  position: absolute;
  z-index: 40;
  top: 4%; bottom: 4%; left: 50%;
  width: 26px;
  transform: translateX(-50%) translateZ(5px);
  background: linear-gradient(90deg, transparent, rgba(49,29,15,.19) 43%, rgba(255,255,255,.12) 52%, transparent);
  pointer-events: none;
}
.diary-gutter i {
  position: absolute;
  left: 50%;
  width: 13px; height: 4px;
  border: 1px solid rgba(84,55,33,.4);
  border-width: 1px 0;
  border-radius: 50%;
  transform: translateX(-50%) rotate(6deg);
}
.diary-gutter i:nth-child(1) { top: 12%; }
.diary-gutter i:nth-child(2) { top: 31%; }
.diary-gutter i:nth-child(3) { top: 50%; }
.diary-gutter i:nth-child(4) { top: 69%; }
.diary-gutter i:nth-child(5) { top: 88%; }

.diary-arrow {
  width: 42px; height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(247,239,219,.38);
  color: var(--diary-faint);
  font: 22px/1 var(--diary-serif);
  cursor: pointer;
  transition: color .2s ease, background .2s ease, transform .2s ease;
}
.diary-arrow:hover, .diary-arrow:focus-visible { color: var(--diary-ink); background: rgba(247,239,219,.78); transform: scale(1.05); }
.diary-arrow:disabled { opacity: .2; cursor: default; transform: none; }

/* The turning leaf is a chain of nested strips whose tangent sweeps through
   an arc, so the paper bends instead of pivoting like a flat door. Every
   width here is an absolute length derived from --book-w. A percentage would
   resolve against the parent strip, and because the strips are nested each
   one would end up a fraction of the strip above it. */
.diary-leaf {
  position: absolute;
  z-index: 55;
  top: 3.3%;
  height: 93.7%;
  width: var(--leaf-w);
  transform-style: preserve-3d;
  pointer-events: none;
  --turn: 0deg;
  --step: 0deg;
}
.diary-leaf--next { left: 50%; transform-origin: left center; transform: rotateY(calc(-1 * var(--turn))); }
.diary-leaf--prev { right: 50%; transform-origin: right center; transform: rotateY(var(--turn)); }
.diary-strip {
  position: absolute;
  top: 0;
  height: 100%;
  width: var(--strip-w);
  transform-style: preserve-3d;
}
.diary-leaf--next > .diary-strip { left: 0; transform-origin: left center; }
.diary-leaf--prev > .diary-strip { right: 0; left: auto; transform-origin: right center; }
.diary-leaf--next .diary-strip > .diary-strip { left: 100%; transform-origin: left center; transform: rotateY(var(--step)); }
.diary-leaf--prev .diary-strip > .diary-strip { right: 100%; left: auto; transform-origin: right center; transform: rotateY(calc(-1 * var(--step))); }
.diary-face {
  position: absolute;
  inset: 0 -1.1px 0 0;
  overflow: hidden;
  background: var(--diary-paper);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.diary-face--back { transform: rotateY(180deg); }
.diary-face__page {
  position: absolute;
  top: 0;
  height: 100%;
  width: var(--leaf-w);
  pointer-events: none;
}
/* A back face is pre-rotated 180°, so when the leaf lands the strips read in
   the opposite order. Its offsets count from the far edge, or the landed page
   comes out with its slices reversed. */
.diary-leaf--next .diary-face--front .diary-face__page { left: calc(-1 * var(--strip-w) * var(--strip-index)); }
.diary-leaf--next .diary-face--back .diary-face__page { left: calc(-1 * var(--strip-w) * (var(--strips) - 1 - var(--strip-index))); }
.diary-leaf--prev .diary-face--front .diary-face__page { right: calc(-1 * var(--strip-w) * var(--strip-index)); left: auto; }
.diary-leaf--prev .diary-face--back .diary-face__page { right: calc(-1 * var(--strip-w) * (var(--strips) - 1 - var(--strip-index))); left: auto; }
/* Leaf faces render exactly like settled pages, so a page held mid-turn
   (the bent stop page in the opening) is indistinguishable from a real one. */
.diary-face::before,
.diary-face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.diary-face::before {
  z-index: 2;
  background: #fffaf0;
  opacity: calc(var(--shade, 0) * var(--lit, 1) * var(--lit, 1) * .2);
}
.diary-face::after { z-index: 3; }
.diary-leaf--next .diary-face--front::after,
.diary-leaf--prev .diary-face--back::after {
  background: linear-gradient(90deg, rgba(51,35,20,var(--a1,0)), rgba(51,35,20,var(--a2,0)));
}
.diary-leaf--next .diary-face--back::after,
.diary-leaf--prev .diary-face--front::after {
  background: linear-gradient(90deg, rgba(51,35,20,var(--a2,0)), rgba(51,35,20,var(--a1,0)));
}

/* The riffle leaves are rotated frame by frame from diary.js with a plain
   transform. Deliberately absent here: CSS animations, filters, preserve-3d
   and backface-visibility. That combination made iOS Safari's compositor
   rasterize the page content at the wrong scale. */
.diary-riffle { position: absolute; inset: 3.3% 1.9% 3%; z-index: 65; pointer-events: none; perspective: 1600px; }
.diary-riffle__leaf {
  position: absolute;
  top: 0; right: 0;
  width: 50%; height: 100%;
  transform-origin: left center;
  border-radius: 1px 9px 9px 2px;
  background-color: #e9ddc4;
  background-image: repeating-linear-gradient(0deg, rgba(89,62,38,.025) 0 1px, transparent 1px 4px);
  box-shadow: inset 14px 0 18px -18px #2c1c10, 3px 5px 7px rgba(58,37,20,.16);
}
/* Each riffle leaf carries a written page on its face. diary.js fades the
   page out once the leaf turns past edge-on, so the flipped side reads as
   plain paper instead of mirrored writing. */
.diary-riffle__page {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.diary-riffle__page .memory-page {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}
.diary-riffle__page .memory-page::before,
.diary-riffle__page .memory-page::after { display: none; }
.diary-riffle__leaf::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(67,39,20,.22), transparent 28%, rgba(255,255,255,.16));
}

/* The feather is driven frame by frame from diary.js, so the only things
   set here are its size and the shadow it drops on the paper. --h is how
   far it is above the page, from 1 in the air to 0 lying on it. */
.diary-feather {
  position: absolute;
  left: 0; top: 0;
  z-index: 74;
  width: 24%;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  transform-origin: 76% 60%;
  will-change: transform, opacity;
}
/* While the feather slips in under the lifted page, it renders beneath the
   book so its tip disappears under the paper's edge. */
.diary-feather--under { z-index: -1; }
.diary-feather__quill {
  display: block;
  width: 100%;
  height: auto;
  filter: sepia(.2) saturate(.92) contrast(1.32) brightness(.6);
  -webkit-user-drag: none;
}
/* The source image has wispy half-transparent barbs. A real feather lying on
   the page hides the ink under it, so the same image is stacked once more to
   bring the body up to full opacity. */
.diary-feather::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../images/diary/memory-feather.webp") center / 100% 100% no-repeat;
  filter: sepia(.2) saturate(.92) contrast(1.32) brightness(.6);
}
.diary-feather__shadow {
  position: absolute;
  z-index: -1;
  left: 7%; right: 7%; top: 17%; bottom: 17%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(50,34,16,.55), rgba(50,34,16,0) 76%);
  filter: blur(calc(3px + 15px * var(--h, 0)));
  opacity: calc(.52 - var(--h, 0) * .32);
  transform: translate(calc(var(--h, 0) * 24%), calc(var(--h, 0) * 32%)) scale(calc(1 + var(--h, 0) * .45));
}

.diary-meta {
  width: min(500px, 75vw);
  margin-top: clamp(18px, 2.8vh, 30px);
  text-align: center;
}
.diary-meta > p:first-child {
  margin: 0;
  min-height: 20px;
  font-size: 13px;
  letter-spacing: .15em;
  text-transform: uppercase;
}
.diary-progress {
  width: 150px;
  height: 1px;
  margin: 11px auto;
  overflow: hidden;
  background: rgba(48,39,31,.15);
}
.diary-progress span { display: block; width: 100%; height: 100%; background: var(--diary-ink); transform: scaleX(0); transform-origin: left; transition: transform .35s ease; }
.diary-hint {
  margin: 0;
  color: var(--diary-faint);
  font-family: var(--diary-sans);
  font-size: 9px;
  letter-spacing: .13em;
  text-transform: uppercase;
  transition: opacity .4s ease;
}
.diary-hint.is-gone { opacity: 0; }
.diary-noscript { font-family: var(--diary-sans); font-size: 13px; }
.diary-noscript a { text-decoration: underline; }

@media (max-width: 720px) {
  .diary-nav { padding-top: 14px; }
  .diary-nav nav { gap: 18px; }
  .diary-hero { padding-inline: 0; }
  .diary-shell { width: 100vw; grid-template-columns: 24px minmax(0, 1fr) 24px; gap: 0; }
  .diary-arrow { position: relative; z-index: 80; width: 30px; height: 46px; padding: 0; background: transparent; }
  .diary-book { --page-pad: clamp(11px, 3vw, 18px); }
  .memory-page__image { border-width: 3px; }
  .memory-page__excerpt { -webkit-line-clamp: 4; }
  .memory-page__read { display: none; }
  .diary-gutter { width: 14px; }
  .diary-turn-zone { width: 23%; }
  .diary-feather { width: 30%; }
}

@media (max-width: 480px) {
  .diary-hero { min-height: 92svh; padding-top: 108px; }
  .diary-kicker { margin-bottom: 15px; }
  .diary-home-quote { width: 86vw; font-size: 12px; }
  .diary-home-quote--above { margin-bottom: 14px; }
  .diary-home-quote--below { margin-top: 14px; }
  .memory-page__eyebrow { margin-bottom: 5px; letter-spacing: .06em; }
  .memory-page__image, .memory-page__mark { height: 58px; margin-bottom: 7px; }
  .memory-page__title { font-size: 12px; line-height: 1.02; }
  .memory-page--feature .memory-page__title { font-size: 16px; }
  .memory-page__rule { margin: 6px 0; width: 28px; }
  .memory-page__excerpt { font-size: 7px; line-height: 1.32; -webkit-line-clamp: 3; }
  .memory-page__quote { font-size: 12px; }
  .memory-page__continuation { margin-top: 8px; font-size: 7px; }
  .diary-meta { margin-top: 14px; }
}

/* ---- the lamp: tap it and the room goes dark, leaving the diary in a
       warm pool of light ---- */
.lamp-toggle {
  position: fixed;
  top: 0;
  right: clamp(12px, 2.5vw, 30px);
  z-index: 130;
  width: 46px;
  height: 96px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* The wind brushes the lantern: it swings gently on its cord and settles. */
.lamp-toggle { transform-origin: 50% 0; }
.lamp-toggle.is-swaying { animation: lantern-sway 3s ease-in-out; }
/* While the opening wind is turning pages, the lantern swings with it and
   only comes to rest when the diary does, just before the feather. */
body.is-wind-blowing .lamp-toggle { animation: lantern-sway 2.6s ease-in-out infinite; }
@keyframes lantern-sway {
  0% { transform: rotate(0deg); }
  18% { transform: rotate(2.7deg); }
  38% { transform: rotate(-2.2deg); }
  58% { transform: rotate(1.3deg); }
  78% { transform: rotate(-.6deg); }
  100% { transform: rotate(0deg); }
}
.lamp-toggle svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(2px 4px 3px rgba(58, 38, 18, .32));
}
/* A lit lantern is the light source, so at night it casts no shadow of
   its own and the glow stays exactly as before. */
body.is-night .lamp-toggle svg { filter: none; }
.lamp-cord { stroke: #5a4632; stroke-width: 1.6; }
.lamp-shade { fill: #6b4a2f; stroke: #3f2c1a; stroke-width: 1; }
.lamp-bulb {
  fill: rgba(120, 95, 60, .18);
  stroke: #6b543a;
  stroke-width: 1.2;
  transition: fill .5s ease, stroke .5s ease;
}
.lamp-flame { fill: transparent; transition: fill .5s ease; }
.lamp-glow {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 130px;
  height: 130px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 199, 112, .5), rgba(255, 180, 80, .16) 46%, transparent 72%);
  opacity: 0;
  transition: opacity .6s ease;
  pointer-events: none;
}
body.is-night .lamp-bulb { fill: rgba(255, 214, 122, .35); stroke: #c9a050; }
body.is-night .lamp-flame { fill: #ffd67a; animation: lamp-flame-sway 2.6s ease-in-out infinite; transform-origin: 50% 88%; }
body.is-night .lamp-glow { opacity: 1; animation: lamp-flicker 3.4s ease-in-out infinite; }
@keyframes lamp-flicker {
  0%, 100% { opacity: .95; }
  46% { opacity: .72; }
  58% { opacity: 1; }
  74% { opacity: .84; }
}
@keyframes lamp-flame-sway {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(.9) rotate(1.6deg); }
}

/* Night in the room. The desk and its clutter go dark, and a soft warm
   pool stays over the book, as if the lamp were burning beside it. */
body.diary-home { transition: background .7s ease; }
body.diary-home.is-night { background: #191309; }
.diary-wash { transition: filter .7s ease; }
.is-night .diary-wash { filter: brightness(.25) saturate(.62) sepia(.14); }
body.diary-home::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 88;
  pointer-events: none;
  opacity: 0;
  transition: opacity .8s ease;
  background:
    radial-gradient(ellipse 60% 56% at 50% 52%, rgba(255, 191, 105, .07), transparent 62%),
    radial-gradient(ellipse 78% 72% at 50% 50%, transparent 40%, rgba(12, 8, 3, .5) 74%, rgba(8, 5, 2, .78) 100%);
}
body.diary-home.is-night::after { opacity: 1; }
.is-night .diary-nav { background: linear-gradient(180deg, rgba(21, 16, 9, .93), rgba(21, 16, 9, .55) 50%, transparent); }
.is-night .diary-brand,
.is-night .diary-nav nav a:hover,
.is-night .diary-nav nav a:focus-visible { color: rgba(240, 227, 200, .92); }
.is-night .diary-nav nav a { color: rgba(226, 210, 180, .6); }
.is-night .diary-kicker,
.is-night .diary-home-quote,
.is-night .diary-hint,
.is-night .diary-meta > p:first-child { color: rgba(233, 219, 190, .58); }
.is-night .diary-progress { background: rgba(238, 224, 198, .18); }
.is-night .diary-progress span { background: #e6d3ac; }
.is-night .diary-arrow { color: rgba(238, 225, 198, .5); background: rgba(42, 31, 18, .42); }
.is-night .diary-arrow:hover,
.is-night .diary-arrow:focus-visible { color: #f3e7cd; background: rgba(58, 43, 25, .6); }
.is-night .diary-cast--ambient,
.is-night .diary-cast--contact,
.is-night .diary-cast--hair { opacity: .25; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .diary-riffle { display: none; }
  .diary-feather { animation: none !important; }
}

/* The one-time margin note pointing at the lantern, written in the same
   hand as the diary. */
.lantern-note {
  position: fixed;
  top: 100px;
  right: clamp(14px, 2.6vw, 34px);
  z-index: 129;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  color: rgba(96, 70, 42, .85);
  font-family: var(--diary-hand);
  font-size: clamp(16px, 1.5vw, 20px);
  transform: rotate(-3deg);
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
}
.lantern-note.is-visible { opacity: 1; }
.lantern-note svg { width: 26px; height: auto; margin-right: 14px; }
.is-night .lantern-note { color: rgba(235, 216, 182, .8); }
