:root {
  color-scheme: light;
  --cream: #fff3df;
  --gold: #603b00;
  --wine: #741819;
  --invitation-width: 556px;
  font-family: "Trebuchet MS", Arial, sans-serif;
  background: #120a06;
  color: var(--gold);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid #a45618; outline-offset: 4px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  z-index: 15;
  inset: 1rem auto auto 1rem;
  padding: .7rem 1rem;
  border-radius: 2rem;
  background: var(--cream);
  color: var(--wine);
  translate: 0 -180%;
}
.skip-link:focus { translate: 0; }

.invitation {
  width: min(100%, var(--invitation-width));
  margin: 0 auto;
  background: #ffe4c7;
  box-shadow: 0 0 65px #0009;
  container-type: inline-size;
  isolation: isolate;
}

.panel {
  position: relative;
  width: 100%;
  aspect-ratio: var(--paper-width) / var(--panel-height);
}
.art, .hero video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.art {
  object-fit: fill;
  pointer-events: none;
  user-select: none;
}
.hero {
  background: #f5b98e url("assets/peacock-poster.webp") center top / cover no-repeat;
}
.hero video {
  object-fit: cover;
  object-position: center top;
}
.hero .art { z-index: 1; }

.opening-active { overflow: hidden; }
.opening-active .skip-link { visibility: hidden; }
#opening {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  background: #231006;
}
.opening-frame {
  width: min(100%, var(--invitation-width), 56.25svh);
  height: 100%;
}
#envelope-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
#open-envelope {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 0 16px max(32px, 7svh);
  border: 0;
  background: transparent;
  color: var(--cream);
  touch-action: manipulation;
}
#open-envelope:focus-visible { outline-offset: -7px; }
#open-envelope span {
  padding: 12px 26px;
  border: 1px solid #f1c891a5;
  border-radius: 2rem;
  background: #45230ede;
  box-shadow: 0 6px 20px #1c0a0870;
  font: 400 clamp(16px, 4vw, 20px)/1.25 Georgia, serif;
}
#music-toggle {
  position: fixed;
  z-index: 8;
  right: max(12px, calc((100vw - var(--invitation-width)) / 2 + 12px));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #ffdfb8a0;
  border-radius: 50%;
  background: #432609d8;
  color: var(--cream);
  font-size: 23px;
  line-height: 1;
}
#music-toggle.is-paused span { opacity: .63; }
.invitation:focus { outline: none; }

#motion-toggle {
  position: absolute;
  z-index: 2;
  inset: auto 12px 12px auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #ffdfb8a0;
  background: #432609d8;
  color: var(--cream);
  display: grid;
  place-items: center;
}
#motion-toggle span {
  display: block;
  width: 11px;
  height: 13px;
  border-inline: 3px solid currentColor;
}
#motion-toggle[aria-pressed="true"] span {
  width: 0;
  height: 0;
  border: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid currentColor;
  translate: 1px 0;
}

.overlay {
  position: absolute;
  left: var(--left);
  top: var(--top);
  width: var(--width);
  height: var(--height);
}
.scratch-heart {
  z-index: 2;
  padding: 0;
  border: 0;
  background: transparent;
  touch-action: none;
  user-select: none;
  cursor: crosshair;
}
.scratch-art, .scratch-canvas, .heart-fill, .heart-date, .scratch-label {
  position: absolute;
  inset: 0;
}
.scratch-art, .scratch-canvas { width: 100%; height: 100%; }
.scratch-art, .scratch-label, .heart-fill, .heart-date, .scratch-canvas { pointer-events: none; }
.scratch-art { display: block; }
.scratch-label {
  display: grid;
  place-items: center;
  padding-bottom: 12%;
  color: #fff2d9;
  font: italic 600 clamp(22px, 6.2cqw, 38px)/1 Georgia, serif;
  text-shadow: 0 2px 7px #320004;
}
.scratch-canvas {
  visibility: hidden;
  transition: opacity .55s ease;
}
.scratch-heart.is-ready .scratch-canvas { visibility: visible; }
.scratch-heart.is-ready .scratch-art,
.scratch-heart.is-ready .scratch-label,
.scratch-heart.is-revealed .scratch-art,
.scratch-heart.is-revealed .scratch-label { visibility: hidden; }
.scratch-heart.is-ready .heart-fill {
  background: radial-gradient(ellipse at 50% 35%, #fff9e9 5%, #ffe3be 50%, #e5a370 94%);
  mask: var(--heart-mask) center / 100% 100% no-repeat;
}
.heart-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 13%;
  color: var(--wine);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.04;
  letter-spacing: -.025em;
}
.heart-date strong { font-size: clamp(37px, 12cqw, 70px); font-weight: 400; }
.heart-date span { font-size: clamp(14px, 4cqw, 24px); }
.scratch-heart.is-revealed { cursor: default; }
.scratch-heart.is-revealed:focus-visible { outline: none; }
.scratch-heart.is-revealed .scratch-canvas { opacity: 0; }

.countdown {
  display: grid;
  align-content: center;
  text-align: center;
  color: var(--wine);
}
.countdown h2 {
  margin: 0 0 1.5cqw;
  font: 600 clamp(11px, 2.65cqw, 16px)/1.1 "Trebuchet MS", Arial, sans-serif;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.countdown dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.55cqw;
  margin: 0;
}
.countdown dl div {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 1.1cqw 0 1.4cqw;
  border: 1px solid #b67f4560;
  border-radius: 2.3cqw;
  background: linear-gradient(150deg, #fff7e8dc, #ffecd1b8);
  box-shadow: 0 4px 12px #713b0d0c;
}
.countdown dd {
  margin: 0;
  font: clamp(21px, 6.1cqw, 36px)/1.09 Georgia, serif;
  font-variant-numeric: lining-nums tabular-nums;
}
.countdown dt {
  margin-top: .5cqw;
  color: var(--gold);
  font-size: clamp(9px, 2.25cqw, 13px);
  line-height: 1.1;
}

.directions {
  display: grid;
  place-items: center;
  border-radius: 9cqw;
  color: #fff;
  text-decoration: none;
  font-size: clamp(12px, 3.5cqw, 21px);
  line-height: 1;
  letter-spacing: .045em;
  transition: background .2s ease;
}
.directions:hover, .directions:focus-visible { background: #4d2b05; }

.story-panel {
  display: flow-root;
  aspect-ratio: auto;
  min-height: calc(var(--panel-height) / var(--paper-width) * 100cqw);
}
.story-carousel {
  position: relative;
  width: 86%;
  margin: 40cqw auto 4cqw;
  color: var(--wine);
  text-align: center;
}
.story-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3cqw;
  margin: 0 auto 6cqw;
}
.story-divider::before, .story-divider::after {
  content: "";
  width: 16cqw;
  height: 1px;
  background: #b47c3d80;
}
.story-divider span {
  width: 6px;
  height: 6px;
  rotate: 45deg;
  background: #ae7535;
}
.story-deck { position: relative; }
.story-stack {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 79%;
  margin-inline: auto;
  touch-action: pan-y;
}
.story-stack::before, .story-stack::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 1.6cqw 0 .6cqw 0;
  border: 1px solid #c9a3754f;
  border-radius: 2px;
  box-shadow: 0 8px 16px #71451e2c;
  background: #f5e9d6;
  transform: translate(3cqw, 1.6cqw) rotate(5deg);
}
.story-stack::after {
  background: #fff7e9;
  transform: translate(1.7cqw, .8cqw) rotate(2.8deg);
}
.story-slide {
  grid-area: 1 / 1;
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 1.65cqw 1.65cqw 0;
  border: 1px solid #c9a37550;
  border-radius: 2px;
  background: #fffaee;
  box-shadow: 0 12px 25px #603a263b;
  transform: rotate(-1.7deg);
  transition: opacity .22s ease, transform .22s ease;
}
.story-slide[aria-hidden="true"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(2cqw) rotate(0);
}
.story-photo {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  aspect-ratio: 1.18;
  background: #d9c3b1;
}
.story-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 26%;
  user-select: none;
}
.story-photo-01 img {
  position: relative;
  width: 83%;
  margin-inline: auto;
  object-position: 50% 21%;
}
.story-photo-02 img, .story-photo-03 img {
  position: relative;
  object-fit: contain;
  object-position: center;
}
.story-photo-01::before, .story-photo-02::before, .story-photo-03::before {
  content: "";
  position: absolute;
  inset: -14px;
  background: var(--photo) center / cover;
  filter: blur(14px) brightness(.78) saturate(.68);
}
.story-photo-04 img { object-position: center 38%; }
.story-photo-05 img { object-position: 58% 70%; }
.story-slide figcaption {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  padding: 2.7cqw 1.65cqw 3.4cqw;
}
.story-chapter {
  margin: 0;
  color: #805322;
  font-weight: 600;
  font-size: clamp(10px, 2.25cqw, 13px);
  letter-spacing: .21em;
  text-transform: uppercase;
}
.story-slide h3 {
  margin: .7cqw 0 1.3cqw;
  font: italic 400 clamp(17px, 4.8cqw, 29px)/1.12 Georgia, serif;
  text-wrap: balance;
}
.story-copy {
  margin: 0;
  color: #663e22;
  font: clamp(12px, 3.05cqw, 17px)/1.38 Georgia, serif;
  text-wrap: pretty;
}
.story-slide time {
  margin-top: 1.6cqw;
  color: #805322;
  font: 600 clamp(10px, 2.55cqw, 14px)/1.2 "Trebuchet MS", Arial, sans-serif;
  letter-spacing: .04em;
}
.story-arrow {
  position: absolute;
  z-index: 2;
  top: 46%;
  display: grid;
  place-items: center;
  width: clamp(36px, 9.4cqw, 49px);
  aspect-ratio: 1;
  transform: translateY(-50%);
  padding: 0;
  border: 1px solid #a9694f45;
  border-radius: 50%;
  background: #fff9ee;
  color: var(--wine);
  box-shadow: 0 4px 12px #71451e25;
  font-size: clamp(22px, 5.4cqw, 30px);
  line-height: 1;
  touch-action: manipulation;
}
.story-arrow:hover { background: #ffe7d0; }
.story-prev { left: 2%; }
.story-next { right: 2%; }
.story-arrow span { translate: 0 -1px; }
.story-dots {
  display: flex;
  justify-content: center;
  margin-top: 4cqw;
}
.story-dots button {
  display: grid;
  place-items: center;
  width: clamp(27px, 7.5cqw, 40px);
  height: 27px;
  padding: 0;
  border: 0;
  border-radius: 1rem;
  background: transparent;
  touch-action: manipulation;
}
.story-dots button::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #bd7959a5;
}
.story-dots button[aria-current="true"]::before {
  background: #8e263d;
  scale: 1.25;
}

.memory-card {
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: 29.7%;
  perspective: 600px;
  touch-action: manipulation;
}
.card-inner {
  display: block;
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .37s cubic-bezier(.25, .75, .35, 1);
}
.card-front, .card-back {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 29.7%;
  backface-visibility: hidden;
}
.card-front {
  background: var(--gold);
  color: #fff;
  transition: background .2s ease;
}
.memory-card:hover .card-front { background: #754708; }
.card-heart {
  display: block;
  font: clamp(24px, 10.4cqw, 59px)/1 "Segoe UI Symbol", Georgia, serif;
}
.card-back {
  transform: rotateY(180deg);
  border: 1px solid #b97b33;
  background: #fff1d8;
  box-shadow: inset 0 0 0 2px #fff9edb0;
  font-size: clamp(22px, 8.2cqw, 45px);
}
.memory-card.is-flipped .card-inner { transform: rotateY(180deg); }
.memory-card.is-matched .card-back { background: #ffdfa5; border-color: #946017; }
.memory-card:disabled { cursor: default; opacity: 1; }
#memory-feedback {
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--wine);
  text-align: center;
  font-size: clamp(11px, 2.6cqw, 15px);
  font-weight: 600;
}
#play-again {
  padding: 0;
  border: 0;
  border-radius: 5cqw;
  background: transparent;
  touch-action: manipulation;
}
#play-again:hover { box-shadow: inset 0 0 0 2px #fff1d7a6; }

#ambience {
  position: fixed;
  z-index: 6;
  top: 0;
  bottom: 0;
  left: 50%;
  width: min(100%, var(--invitation-width));
  transform: translateX(-50%);
  overflow: hidden;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.petal {
  position: absolute;
  top: -16px;
  left: var(--x);
  width: var(--size);
  height: calc(var(--size) * 1.25);
  border-radius: 62% 38% 65% 45% / 70% 50% 66% 25%;
  background: radial-gradient(ellipse at 30% 18%, #ffb1b7, #ed5977 53%, #a2224e 96%);
  box-shadow: 0 1px 1px #69294a24;
  animation: fall var(--fall) var(--delay) linear infinite;
}
.petal:nth-child(3n) {
  background: radial-gradient(ellipse at 25% 22%, #ffd0c9, #ed8097 56%, #b92457 95%);
}
@keyframes fall {
  0% { opacity: 0; transform: translate3d(0, 0, 0) rotate(0) rotateY(0); }
  6% { opacity: .85; }
  32% { transform: translate3d(var(--sway), 34dvh, 0) rotate(110deg) rotateY(105deg); }
  68% { transform: translate3d(var(--drift), 72dvh, 0) rotate(235deg) rotateY(220deg); }
  94% { opacity: .8; }
  100% { opacity: 0; transform: translate3d(var(--sway), 107dvh, 0) rotate(390deg) rotateY(360deg); }
}
.butterfly {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  aspect-ratio: 523 / 369;
  perspective: 55px;
  animation: flight var(--flight) var(--delay) ease-in-out infinite alternate;
}
.wing {
  position: absolute;
  inset: 0 auto 0 0;
  width: 50%;
  background: url("assets/monarch.png") 8% 58% / 217% 142.3% no-repeat;
  transform-origin: right center;
  animation: flap var(--flap) ease-in-out infinite alternate;
  --wing-angle: -70deg;
}
.wing + .wing {
  inset-inline: auto 0;
  background-position: 93% 58%;
  transform-origin: left center;
  --wing-angle: 70deg;
}
@keyframes flight {
  0% { transform: translate3d(0, 10px, 0) rotate(-25deg); }
  34% { transform: translate3d(var(--drift), -8dvh, 0) rotate(16deg); }
  68% { transform: translate3d(var(--sway), -3dvh, 0) rotate(-14deg); }
  100% { transform: translate3d(var(--sway), 5dvh, 0) rotate(26deg); }
}
@keyframes flap { to { transform: rotateY(var(--wing-angle)); } }
.motion-paused #ambience { visibility: hidden; }
.motion-paused #ambience * { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .scratch-canvas, .card-inner, .directions, .story-slide { transition: none; }
}
