:root {
  --wax-burgundy: #7A1734;
  --letter-cream: #FFF1E6;
  --robin-glass: #A7E8E1;
  --cobalt-ink: #214C9A;
  --petal-blush: #F6A6B2;
  --sour-chartreuse: #C8FF6E;
  --bruised-plum: #251625;
  --title: "Fraunces", serif;
  --lyric: "Cormorant Garamond", serif;
  --tag: "Hanken Grotesk", sans-serif;
  --scribble: "Caveat", cursive;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--bruised-plum);
  background: var(--letter-cream);
  font-family: var(--lyric);
  overflow-x: hidden;
}

.paper-grain {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: .32;
  background:
    radial-gradient(circle at 18% 12%, rgba(122, 23, 52, .09) 0 1px, transparent 1.5px),
    radial-gradient(circle at 77% 31%, rgba(33, 76, 154, .08) 0 1px, transparent 1.7px),
    radial-gradient(circle at 44% 82%, rgba(37, 22, 37, .07) 0 1px, transparent 1.6px);
  background-size: 38px 42px, 54px 46px, 31px 35px;
  mix-blend-mode: multiply;
}

.cursor-vapor {
  position: fixed;
  width: 120px;
  height: 120px;
  left: -200px;
  top: -200px;
  z-index: 9;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(167, 232, 225, .42), rgba(255, 241, 230, 0) 68%);
  filter: blur(12px);
  transform: translate(-50%, -50%);
  transition: opacity .3s ease;
}

.love-observatory { position: relative; }

.chapter {
  --chapter-bg: var(--letter-cream);
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: var(--chapter-bg);
}

.chapter-meta {
  position: absolute;
  top: 28px;
  left: 34px;
  z-index: 3;
  font-family: var(--tag);
  font-size: 12px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--cobalt-ink);
}

.affection-barometer {
  position: fixed;
  right: 22px;
  top: 50%;
  z-index: 20;
  width: 76px;
  height: min(72vh, 640px);
  transform: translateY(-50%);
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  color: var(--wax-burgundy);
}

.barometer-ribbon {
  border-left: 1px solid currentColor;
  border-right: 1px solid rgba(122, 23, 52, .35);
  background: linear-gradient(var(--petal-blush), var(--letter-cream) 45%, var(--robin-glass));
  box-shadow: 0 10px 28px rgba(37, 22, 37, .18);
}

.barometer-ribbon a {
  display: block;
  height: 25%;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  text-decoration: none;
  color: inherit;
  font-family: var(--tag);
  font-size: 10px;
  letter-spacing: .12em;
  text-align: center;
  padding: 14px 0;
  border-bottom: 1px dashed rgba(122, 23, 52, .35);
}

.instrument { position: relative; }

.glass-tube {
  position: absolute;
  left: 18px;
  top: 16px;
  bottom: 16px;
  width: 16px;
  border: 1px solid rgba(33, 76, 154, .52);
  border-radius: 999px;
  background: rgba(255, 241, 230, .4);
  overflow: hidden;
}

.reading {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 2px;
  height: 22%;
  border-radius: 999px;
  background: linear-gradient(to top, var(--wax-burgundy), var(--petal-blush), var(--sour-chartreuse));
  transition: height .75s cubic-bezier(.2,.8,.2,1), background .75s ease;
}

.bar-label {
  position: absolute;
  left: 39px;
  font-family: var(--scribble);
  font-size: 18px;
  white-space: nowrap;
  transform: rotate(-6deg);
}
.bar-label.top { top: 2%; }
.bar-label.mid { top: 39%; color: var(--cobalt-ink); }
.bar-label.low { top: 67%; }
.bar-label.base { bottom: 0; color: var(--bruised-plum); }

.chapter-blush {
  --chapter-bg: radial-gradient(circle at 12% 18%, rgba(246, 166, 178, .46), transparent 34%), var(--letter-cream);
}

.envelope-stage {
  position: absolute;
  width: min(1040px, 92vw);
  height: min(720px, 72vh);
  left: 2vw;
  top: 15vh;
  transform: rotate(-12deg);
  transform-style: preserve-3d;
  filter: drop-shadow(0 34px 55px rgba(37, 22, 37, .25));
}

.envelope-back,
.envelope-flap,
.envelope-fold {
  position: absolute;
  inset: 0;
  background: var(--letter-cream);
  border: 1px solid rgba(122, 23, 52, .22);
}

.envelope-back {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  background:
    linear-gradient(115deg, rgba(246, 166, 178, .28), transparent 45%),
    var(--letter-cream);
}

.envelope-flap {
  clip-path: polygon(0 0, 100% 0, 50% 56%);
  transform-origin: top center;
  animation: flapBreath 4.8s ease-in-out infinite;
  background: linear-gradient(180deg, #FFF1E6, rgba(167, 232, 225, .3));
}

.envelope-stage.opened .envelope-flap { transform: rotateX(54deg); }

.fold-left { clip-path: polygon(0 0, 50% 56%, 0 100%); opacity: .62; }
.fold-right { clip-path: polygon(100% 0, 50% 56%, 100% 100%); opacity: .45; }

.wax-seal {
  position: absolute;
  left: 47%;
  top: 43%;
  width: 164px;
  height: 164px;
  border: 0;
  border-radius: 43% 55% 48% 52%;
  background: radial-gradient(circle at 38% 32%, #F6A6B2 0 4%, var(--wax-burgundy) 28%, #4c0f25 100%);
  color: var(--letter-cream);
  font-family: var(--tag);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  box-shadow: 0 0 42px rgba(122, 23, 52, .46), inset 0 -9px 20px rgba(37, 22, 37, .35);
  cursor: pointer;
  animation: waxGlow 2.9s ease-in-out infinite;
}

.wax-seal::before,
.wax-seal::after {
  content: "";
  position: absolute;
  background: rgba(255, 241, 230, .4);
  transform: scaleX(0);
  transition: transform .45s ease;
}
.wax-seal::before { width: 70%; height: 1px; left: 15%; top: 48%; rotate: 31deg; }
.wax-seal::after { width: 58%; height: 1px; left: 20%; top: 54%; rotate: -22deg; }
.wax-seal.cracked::before,
.wax-seal.cracked::after { transform: scaleX(1); }
.wax-seal span { position: relative; z-index: 1; display: block; padding: 0 18px; }

.postal-stamp {
  position: absolute;
  right: 10%;
  top: 20%;
  padding: 18px 20px;
  border: 2px solid var(--cobalt-ink);
  color: var(--cobalt-ink);
  font-family: var(--title);
  font-size: clamp(32px, 6vw, 78px);
  line-height: .88;
  transform: rotate(8deg);
  text-transform: lowercase;
  background-image: radial-gradient(var(--cobalt-ink) 1px, transparent 1px);
  background-size: 8px 8px;
  background-color: rgba(255, 241, 230, .64);
}
.postal-stamp i { display: block; margin-top: 9px; font-family: var(--tag); font-style: normal; font-size: 10px; letter-spacing: .22em; text-transform: uppercase; }

.cancellation { position: absolute; right: 6%; top: 35%; width: 310px; fill: none; stroke: var(--cobalt-ink); stroke-width: 3; opacity: .68; }
.cancellation path { stroke-dasharray: 420; stroke-dashoffset: 420; animation: drawPath 4s 1s ease forwards; }

.lyric-note {
  position: absolute;
  left: 9vw;
  bottom: 7vh;
  width: min(430px, 72vw);
  padding: 24px 28px;
  background: rgba(255, 241, 230, .75);
  border-left: 3px solid var(--sour-chartreuse);
  box-shadow: 0 16px 38px rgba(37, 22, 37, .11);
}
.lyric-note p { margin: 0; font-size: clamp(24px, 3vw, 38px); line-height: 1.04; font-style: italic; }
.lyric-note small { display: block; margin-top: 12px; color: var(--cobalt-ink); font-family: var(--tag); letter-spacing: .12em; text-transform: uppercase; }

.chapter-noon {
  --chapter-bg: radial-gradient(circle, rgba(200, 255, 110, .2), transparent 28%), linear-gradient(135deg, #FFF1E6 0%, #F6A6B2 100%);
  min-height: 112vh;
}

.heart-clock {
  position: relative;
  width: min(760px, 86vw);
  height: min(760px, 86vw);
  margin: 12vh auto 0;
}

.orbit-lines { position: absolute; inset: 0; overflow: visible; fill: none; stroke: var(--cobalt-ink); stroke-width: 1.5; opacity: .78; }
.orbit-lines text { fill: var(--wax-burgundy); stroke: none; font-family: var(--tag); font-size: 13px; letter-spacing: .16em; text-transform: uppercase; }

.clock-core {
  position: absolute;
  inset: 33%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, var(--letter-cream), rgba(167, 232, 225, .64));
  border: 1px solid var(--cobalt-ink);
  box-shadow: 0 0 0 16px rgba(255, 241, 230, .28);
}
.clock-core strong { font-family: var(--title); font-size: clamp(34px, 6vw, 62px); color: var(--wax-burgundy); }
.clock-core em { font-family: var(--tag); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; font-style: normal; color: var(--cobalt-ink); }
.second-hand { position: absolute; left: 50%; top: 50%; width: 2px; height: 44%; background: var(--sour-chartreuse); transform-origin: 50% 0; animation: clockSweep 8s linear infinite; }

.petal-panel {
  position: absolute;
  width: 188px;
  height: 246px;
  padding: 40px 24px;
  border-radius: 72% 28% 66% 34% / 56% 42% 58% 44%;
  background: linear-gradient(145deg, rgba(255, 241, 230, .82), rgba(167, 232, 225, .62));
  border: 1px solid rgba(122, 23, 52, .22);
  text-align: center;
  box-shadow: 0 20px 40px rgba(122, 23, 52, .14);
  animation: petalFloat 5s ease-in-out infinite;
}
.petal-panel span { font-family: var(--tag); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--cobalt-ink); }
.petal-panel p { margin: 26px 0 0; font-size: 28px; line-height: .95; font-style: italic; }
.p1 { left: 50%; top: -1%; transform: translateX(-50%) rotate(-8deg); }
.p2 { right: -1%; top: 44%; transform: translateY(-50%) rotate(72deg); animation-delay: -.8s; }
.p3 { left: 50%; bottom: -4%; transform: translateX(-50%) rotate(184deg); animation-delay: -1.4s; }
.p4 { left: -2%; top: 44%; transform: translateY(-50%) rotate(-74deg); animation-delay: -2s; }

.margin-annotation { position: absolute; right: -7vw; bottom: 10%; width: 210px; font-family: var(--scribble); color: var(--wax-burgundy); font-size: 28px; transform: rotate(9deg); }

.chapter-dusk { --chapter-bg: linear-gradient(90deg, #FFF1E6 0 49%, #A7E8E1 49% 51%, rgba(246,166,178,.55) 51% 100%); }
.torn-desk { min-height: 100vh; display: grid; grid-template-columns: 1fr 74px 1fr; }
.unsent-side, .keepsake-side { position: relative; padding: 12vh 7vw; }
.unsent-side h2, .pinned-note h2 { margin: 0; font-family: var(--title); font-size: clamp(70px, 12vw, 168px); line-height: .76; color: var(--wax-burgundy); }
.sentence { position: absolute; max-width: 410px; font-size: clamp(25px, 3vw, 42px); line-height: 1; font-style: italic; color: var(--bruised-plum); opacity: .86; animation: sentenceDrift 8s ease-in-out infinite; }
.drift-one { left: 12vw; top: 42vh; }
.drift-two { left: 5vw; top: 62vh; animation-delay: -2s; }
.drift-three { left: 20vw; top: 73vh; animation-delay: -4s; color: var(--cobalt-ink); }
.artifact-action { position: absolute; left: 8vw; bottom: 8vh; padding: 13px 18px; border: 1px solid var(--wax-burgundy); background: transparent; color: var(--wax-burgundy); font-family: var(--tag); letter-spacing: .18em; text-transform: uppercase; cursor: pointer; }
.torn-seam { position: relative; background: var(--letter-cream); filter: drop-shadow(0 0 20px rgba(37, 22, 37, .14)); }
.torn-seam svg { width: 100%; height: 100%; }
#tearPath { fill: none; stroke: var(--wax-burgundy); stroke-width: 2; stroke-dasharray: 12 13; }
.ticket, .matchbook, .locket { position: absolute; box-shadow: 0 20px 34px rgba(37, 22, 37, .18); }
.ticket { left: 12%; top: 18%; width: 290px; height: 120px; padding: 22px; background: var(--letter-cream); clip-path: polygon(0 0, 100% 0, 96% 50%, 100% 100%, 0 100%, 4% 50%); border: 1px dashed var(--cobalt-ink); font-family: var(--tag); text-transform: uppercase; letter-spacing: .14em; color: var(--cobalt-ink); transform: rotate(-8deg); }
.ticket b { display: block; margin-top: 12px; font-family: var(--title); font-size: 38px; color: var(--wax-burgundy); }
.matchbook { right: 10%; top: 38%; width: 178px; height: 222px; padding: 34px 22px; background: var(--wax-burgundy); color: var(--letter-cream); font-family: var(--title); font-size: 33px; line-height: .92; transform: rotate(12deg); }
.matchbook i { font-family: var(--tag); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; font-style: normal; color: var(--sour-chartreuse); }
.locket { left: 24%; bottom: 13%; width: 208px; height: 208px; border-radius: 50%; background: radial-gradient(circle at 40% 38%, var(--petal-blush), var(--wax-burgundy)); border: 8px double var(--letter-cream); transform-origin: left center; transition: transform .65s cubic-bezier(.2,.8,.2,1); }
.locket.open { transform: rotateY(48deg) rotate(-8deg); }
.locket span { position: absolute; left: 50%; top: 20px; bottom: 20px; border-left: 1px solid rgba(255,241,230,.5); }
.locket em { position: absolute; left: 36px; bottom: 39px; color: var(--letter-cream); font-family: var(--scribble); font-size: 28px; font-style: normal; }
.ink-pool { position: absolute; right: 24%; bottom: 15%; width: 190px; height: 76px; border-radius: 50%; background: radial-gradient(ellipse, rgba(33,76,154,.75), rgba(33,76,154,0) 72%); filter: blur(2px); }
.scribble { position: absolute; right: 20%; top: 22%; font-family: var(--scribble); font-size: 46px; color: var(--cobalt-ink); transform: rotate(-14deg); }

.chapter-night { --chapter-bg: radial-gradient(circle at 25% 35%, rgba(33,76,154,.55), transparent 28%), linear-gradient(160deg, #251625, #214C9A 120%); color: var(--letter-cream); }
.chapter-night .chapter-meta { color: var(--robin-glass); }
.night-letter { position: relative; min-height: 100vh; }
.pinned-note { position: absolute; left: 7vw; top: 16vh; width: min(420px, 78vw); padding: 46px 42px 38px; background: rgba(255, 241, 230, .93); color: var(--bruised-plum); box-shadow: 0 30px 70px rgba(0,0,0,.32); transform: rotate(-4deg); }
.pin { position: absolute; right: 34px; top: 24px; width: 18px; height: 18px; border-radius: 50%; background: var(--sour-chartreuse); box-shadow: 0 0 18px var(--sour-chartreuse); }
.pinned-note h2 { font-size: clamp(56px, 8vw, 102px); color: var(--cobalt-ink); }
.pinned-note p { font-size: 30px; line-height: 1.05; font-style: italic; }
.constellation { position: absolute; right: 2vw; top: 8vh; width: min(900px, 80vw); height: 80vh; overflow: visible; }
.star-line { fill: none; stroke: var(--robin-glass); stroke-width: 2; stroke-dasharray: 1200; stroke-dashoffset: 1200; filter: drop-shadow(0 0 8px var(--robin-glass)); }
.chapter-night.in-view .star-line { animation: drawPath 3.8s ease forwards; }
.star-line.secondary { stroke: var(--petal-blush); animation-delay: .45s; }
.stars circle { fill: var(--letter-cream); filter: drop-shadow(0 0 10px #FFF1E6); transform-origin: center; animation: starPulse 2.8s ease-in-out infinite; }
.stars circle:nth-child(3n) { fill: var(--sour-chartreuse); animation-delay: -.7s; }
.constellation text { fill: var(--letter-cream); font-family: var(--scribble); font-size: 32px; }
.blue-hour-fragment { position: absolute; right: 8vw; bottom: 7vh; max-width: 360px; color: var(--robin-glass); font-family: var(--tag); text-transform: uppercase; letter-spacing: .18em; font-size: 12px; }

.artifact-tilt { transition: transform .22s ease; }
.is-warmed { color: var(--wax-burgundy); text-shadow: 0 0 18px rgba(200, 255, 110, .55); }
.note-turned .sentence { color: var(--cobalt-ink); }
.note-turned .keepsake-side { background: radial-gradient(circle at 60% 50%, rgba(200,255,110,.16), transparent 34%); }

@keyframes flapBreath { 0%,100% { transform: rotateX(0deg) translateY(0); } 50% { transform: rotateX(8deg) translateY(-8px); } }
@keyframes waxGlow { 0%,100% { box-shadow: 0 0 34px rgba(122,23,52,.38), inset 0 -9px 20px rgba(37,22,37,.35); } 50% { box-shadow: 0 0 62px rgba(122,23,52,.68), inset 0 -9px 20px rgba(37,22,37,.35); } }
@keyframes drawPath { to { stroke-dashoffset: 0; } }
@keyframes clockSweep { to { transform: rotate(360deg); } }
@keyframes petalFloat { 0%,100% { margin-top: 0; } 50% { margin-top: -18px; } }
@keyframes sentenceDrift { 0%,100% { transform: translate(0,0) rotate(-1deg); } 50% { transform: translate(18px,-16px) rotate(2deg); } }
@keyframes starPulse { 0%,100% { opacity: .72; } 50% { opacity: 1; } }

@media (max-width: 820px) {
  .affection-barometer { right: 8px; width: 54px; height: 64vh; }
  .bar-label { display: none; }
  .envelope-stage { left: -22vw; width: 118vw; top: 18vh; }
  .wax-seal { width: 124px; height: 124px; left: 42%; }
  .postal-stamp { right: 8%; font-size: 40px; }
  .heart-clock { margin-top: 18vh; }
  .petal-panel { width: 132px; height: 176px; padding: 28px 16px; }
  .petal-panel p { font-size: 21px; }
  .margin-annotation { right: 12vw; bottom: -11vh; }
  .torn-desk { grid-template-columns: 1fr; }
  .torn-seam { display: none; }
  .unsent-side, .keepsake-side { min-height: 100vh; padding-right: 74px; }
  .constellation { width: 112vw; right: -38vw; opacity: .86; }
}
