/* =========================================================
   Dear Engaged v3: notes on the left, a pile of reference
   paperwork on the right (layout idea from rectangles.fm).
   Loads after ../styles.css, which supplies the base, the
   sign-up form and the reduced-motion rule.
   ========================================================= */

:root {
  --hand: "Caveat", "Bradley Hand", cursive;
  --script: "Homemade Apple", "Caveat", cursive;
  --type: "Special Elite", "Courier New", monospace;
  --kraft: #C9A27A;
  --sheet: #FCFBF7;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.desk {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  background: #FFFFFF;
}

/* ---------- The pile ---------- */
.pile {
  position: absolute;
  aspect-ratio: 1 / 1.05;
  container-type: inline-size;
  pointer-events: none;
  z-index: 0;
}
.pc {
  position: absolute;
  height: auto;
  transform: rotate(var(--r, 0deg));
  animation: drop .75s var(--ease) backwards calc(.15s + var(--i, 0) * .07s);
}
img.pc { display: block; }
.pc.o { filter: drop-shadow(0 .8cqw 1.2cqw rgb(0 0 0 / .2)); }
.pc.k { filter: drop-shadow(0 .7cqw 1cqw rgb(0 0 0 / .22)); }
.pc.t { filter: drop-shadow(0 1px 1px rgb(0 0 0 / .08)); animation-name: tape; animation-duration: .5s; animation-timing-function: ease-out; }
.pc.d { opacity: .9; animation-name: tape; }
.pc.clip { height: auto; filter: drop-shadow(1px 2px 1px rgb(0 0 0 / .25)); }

/* kraft folder with a tab */
.folder {
  border-radius: 1.2cqw;
  background: var(--grain), linear-gradient(160deg, #D3AE86, var(--kraft) 60%, #BE9569);
  box-shadow: 0 1.4cqw 3cqw -1cqw rgb(60 40 20 / .35);
}
.folder::before {
  content: "";
  position: absolute;
  left: 4%; top: -5.5%;
  width: 30%; height: 7%;
  border-radius: 1.2cqw 1.2cqw 0 0;
  background: inherit;
}

/* the typed planning sheet, hole-punched */
.sheet {
  padding: 4.4cqw 5cqw 0 9cqw;
  background: var(--grain), var(--sheet);
  box-shadow: 0 .6cqw 2cqw -.4cqw rgb(0 0 0 / .22);
  font-family: var(--type);
  color: #2A2A2A;
}
.sheet::before {
  content: "";
  position: absolute;
  left: 3.5%; top: 18%;
  width: 3.2cqw; height: 64%;
  background: radial-gradient(circle, #fff 0 42%, #D8D4CC 44% 50%, transparent 52%) center top / 100% 33.4% repeat-y;
}
.sheet__head { display: flex; justify-content: space-between; align-items: flex-start; }
.sheet__title {
  font: 400 6.4cqw/.92 var(--type);
  text-transform: uppercase;
  letter-spacing: -.02em;
}
.sheet__no { font-size: 2.2cqw; line-height: 1.3; text-align: right; }
.sheet__no span { font-size: 4.6cqw; }
.sheet__kicker {
  margin-top: 4%;
  padding: 1.6% 0;
  border-block: 1px dashed #9C978E;
  font-size: 1.9cqw;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.sheet__list { list-style: none; margin: 5% 0 0; padding: 0; font-size: 2.6cqw; line-height: 1.85; }
.sheet__list li::before {
  content: "";
  display: inline-block;
  width: .8em; height: .8em;
  margin-right: .7em;
  border: 1.5px solid #2A2A2A;
  vertical-align: -.05em;
  font: 700 1.5em/.5 var(--hand);
  color: var(--rose);
  text-indent: -.05em;
}
.sheet__list li.ok { text-decoration: line-through; text-decoration-color: var(--rose); text-decoration-thickness: .16em; }
.sheet__list li.ok::before { content: "✓"; }

/* receipt with a zig-zag tear */
.receipt {
  padding: 2cqw 1.6cqw 0;
  background: var(--grain), #FAF9F5;
  font: 400 1.55cqw/1.9 var(--type);
  color: #3A3A3A;
  box-shadow: 0 .6cqw 1.6cqw -.4cqw rgb(0 0 0 / .22);
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 1.6cqw 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 1.6cqw 100%;
}
.receipt p { display: flex; justify-content: space-between; gap: .4em; }
.receipt hr { border: 0; border-top: 1px dashed #999; margin: 8% 0; }
.receipt__love { justify-content: center !important; margin-top: 10%; font: 700 2.6cqw/1 var(--hand); color: var(--rose); }

/* torn spiral-pad note */
.note {
  padding: 2cqw 2.4cqw 2.4cqw 6.4cqw;
  background:
    repeating-linear-gradient(transparent 0 5.4cqw, #D6E0EA 5.4cqw calc(5.4cqw + 1px)),
    #FFFFFF;
  background-position: 0 3.6cqw;
  box-shadow: 0 .8cqw 2cqw -.6cqw rgb(0 0 0 / .28);
  font: 600 3cqw/5.4cqw var(--hand);
  color: #2B2B2B;
  text-align: left;
}
.note::before {
  content: "";
  position: absolute;
  left: 3%; top: 6%; bottom: 6%;
  width: 2.6cqw;
  background: radial-gradient(circle, #1E1E1E 0 46%, transparent 50%) center top / 100% 2.6cqw repeat-y;
  background-size: 2.6cqw 5.4cqw;
}
.note__who { color: var(--rose); }
.note mark {
  background: linear-gradient(transparent 30%, #F8EC7A 30% 88%, transparent 88%);
  color: inherit;
  padding: 0 .15em;
}

/* ---------- The notes (letter) ---------- */
.letter {
  position: relative;
  z-index: 2;
  text-align: left;
}
.letter h1.dear {
  margin: 0 0 0 -4px;
  font: 400 clamp(1.8rem, 8vw, 2.3rem)/1.5 var(--script);
  letter-spacing: 0;
  color: var(--rose);
  transform: rotate(-3deg);
  transform-origin: left center;
  animation: write 1.1s linear backwards .5s;
}
.letter .body {
  margin-top: .3rem;
  font: 300 clamp(1.1rem, 4.9vw, 1.3rem)/1.4 var(--serif);
  font-optical-sizing: auto;
  letter-spacing: -.01em;
  text-wrap: pretty;
  animation: rise .9s var(--ease) .9s backwards;
}
/* marker highlight: an uneven hand-swiped stroke behind key words */
.letter .body .hl {
  padding: .06em .22em .02em;
  margin: 0 -.12em;
  color: #1A1013;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 40' preserveAspectRatio='none'%3E%3Cpath fill='%23F29BB8' fill-opacity='.92' d='M7 6 C 50 3, 120 5, 193 2 C 199 6, 200 30, 196 35 C 140 37, 70 34, 4 38 C 0 30, 1 12, 7 6 Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  background-position: left center;
  /* swiped on left to right once the letter has appeared; the words stay light until the marker reaches them */
  animation: marker .55s cubic-bezier(.5,.1,.3,1) backwards var(--hl-delay, 1.6s);
}
.letter .body .hl--2 { --hl-delay: 2s; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 40' preserveAspectRatio='none'%3E%3Cpath fill='%23F29BB8' fill-opacity='.92' d='M4 4 C 70 6, 140 2, 195 5 C 200 12, 199 31, 194 37 C 120 34, 60 38, 6 35 C 1 27, 0 9, 4 4 Z'/%3E%3C/svg%3E"); }
.letter .body .hl--3 { --hl-delay: 2.4s; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 40' preserveAspectRatio='none'%3E%3Cpath fill='%23F29BB8' fill-opacity='.92' d='M6 3 C 60 5, 130 1, 196 4 C 200 12, 198 30, 195 36 C 130 38, 60 35, 3 37 C 0 28, 2 10, 6 3 Z'/%3E%3C/svg%3E"); }
@keyframes marker {
  from { background-size: 0% 100%; color: var(--cream, #F3EEE6); }
  70% { color: var(--cream, #F3EEE6); }
}
.letter .signoff {
  margin-top: .7rem;
  font: 700 1.4rem/1.1 var(--hand);
  transform: rotate(-2deg);
  transform-origin: left center;
  animation: write .8s linear backwards 1.4s;
}
.letter .signoff span { color: var(--rose); }
.letter .signup { margin: clamp(14px, 2.6svh, 28px) 0 0; max-width: none; animation: rise .9s var(--ease) 1.6s backwards; }
.letter .signup__fine { text-align: left; padding-left: 4px; font-size: .85rem; }
.ps { font: 700 1.15rem/1 var(--hand); color: var(--rose); margin-right: .15em; }

/* ---------- Phones: the letter up top, the pile spills off the bottom ---------- */
.desk { display: flex; flex-direction: column; height: 100vh; height: 100svh; }
.letter { padding: max(5svh, 28px) 24px 0; }
.pile {
  position: relative;
  order: 2;
  flex: none;
  width: 124vw;
  margin: max(3.5svh, 18px) 0 0 -10vw;
}

@media (max-height: 700px) and (max-width: 899px) {
  .letter { padding-top: 22px; }
  .letter h1.dear { font-size: 1.7rem; }
  .letter .body { font-size: 1.05rem; }
  .letter .signoff { font-size: 1.25rem; margin-top: .4rem; }
  .pile { margin-top: 14px; }
}

/* ---------- Laptops: notes left, pile right ---------- */
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .desk { flex-direction: row; align-items: center; height: auto; }
  .pile { position: absolute; order: 0; margin: 0; right: -2vw; top: 2svh; width: min(59vw, 104svh); }
  .letter {
    position: relative;
    left: auto; right: auto; bottom: auto;
    width: min(37vw, 600px);
    margin-left: 6vw;
    padding: 0;
    background: none;
    box-shadow: none;
    transform: none;
    animation: none;
  }
  .letter::before { content: none; }
  .letter h1.dear { font-size: clamp(2.6rem, min(3.7vw, 7svh), 4.4rem); }
  .letter .body { font-size: clamp(1.3rem, min(1.7vw, 3.6svh), 2rem); }
  .letter .signoff { font-size: clamp(1.6rem, 2.1vw, 2.3rem); margin-top: 1rem; }
  .letter .signup { margin-top: clamp(22px, 4svh, 40px); max-width: 470px; }
  .signup input[type="email"] { height: 50px; }
}

/* ---------- Motion ---------- */
/* each piece is dropped onto the pile and settles */
@keyframes drop {
  from { opacity: 0; translate: 0 -3cqw; scale: 1.04; }
  60%  { opacity: 1; }
}
@keyframes tape  { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes write { from { clip-path: inset(-150% 100% -150% -60px); } to { clip-path: inset(-150% -60px -150% -60px); } }

/* ---------- Guest list counter (P.S.) ---------- */
.guests b { font-weight: 600; color: var(--ink); }
.guests .signup__fine { text-wrap: pretty; }

/* ---------- Guest list bar: a hand-drawn aisle that fills up to a heart at 100 ---------- */
.aisle { display: block; width: min(100%, 330px); height: auto; overflow: visible; }
.aisle[hidden] { display: none; }
.aisle__line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .75;
}
.aisle__ink { fill: var(--rose); opacity: .9; }
.aisle__scribble {
  fill: none;
  stroke: color-mix(in srgb, var(--rose) 60%, white);
  stroke-width: 1.4;
  stroke-linecap: round;
  opacity: .55;
}
.aisle__progress {
  transform: scaleX(var(--p, 0));
  transform-origin: 0 0;
  animation: aisle-fill 1.6s cubic-bezier(.3, .7, .2, 1) backwards var(--aisle-delay, 1.9s);
}
.aisle__heart {
  fill: none;
  stroke: var(--rose);
  stroke-width: 1.8;
  stroke-linejoin: round;
  transform-box: fill-box;
  transform-origin: center;
  rotate: 10deg;
}
.aisle.is-full .aisle__heart { fill: var(--rose); animation: heart-beat .5s var(--spring) backwards calc(var(--aisle-delay, 1.9s) + 1.5s); }
@keyframes aisle-fill { from { transform: scaleX(0); } }
@keyframes heart-beat { from { scale: .2; } }

/* equal space: sign-off -> email box -> P.S. */
.letter { --gap: clamp(16px, 3svh, 26px); }
.letter .signup { margin-top: var(--gap); }
.letter .guests { margin-top: var(--gap); }
.letter .guests .signup__fine { margin-top: 0; }
.letter .guests .aisle { margin-top: 8px; }
@media (max-height: 700px) and (max-width: 899px) { .letter { --gap: 14px; } }
@media (min-width: 900px) and (min-aspect-ratio: 1/1) { .letter { --gap: clamp(22px, 4svh, 38px); } }
.aisle__line--echo { opacity: .3; stroke-width: 1.1; }

/* ---------- Phones: no P.S., just the bar with a handwritten caption under it ---------- */
.guests__ps { display: none; }
.letter .guests .aisle { margin-top: 0; }
.guests__caption {
  margin: 2px 0 0 4px;
  font: 600 1.1rem/1.2 var(--hand);
  color: var(--grey);
  rotate: -.6deg;
  transform-origin: left center;
}
.guests__caption b { font-weight: 700; color: var(--rose); }
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .guests__ps { display: block; }
  .guests__caption { display: none; }
  .letter .guests .aisle { margin-top: 8px; }
}
