:root {
  --ink: #4a3a30;
  --dim: rgba(74, 58, 48, 0.58);
  --wine: #c2485e;
  --gold: #d99a3d;
  --paper: #faf3e1;
  --wall: #eddcc0;
  --wall-deep: #e3cda8;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: auto;
}

body {
  background: linear-gradient(180deg, var(--wall) 0%, var(--wall-deep) 100%);
  color: var(--ink);
  font-family: "Outfit", system-ui, sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  /* soft lined-paper texture for the wall */
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    repeating-linear-gradient(0deg, rgba(74, 58, 48, 0.035) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(90deg, rgba(74, 58, 48, 0.02) 0 1px, transparent 1px 42px);
  pointer-events: none;
}

/* ---------------- cover ---------------- */
.cover {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.5rem 1.5rem;
  overflow: hidden;
  background:
    radial-gradient(110% 70% at 50% 18%, rgba(255, 245, 224, 0.85) 0%, rgba(237, 220, 192, 0) 70%),
    linear-gradient(180deg, var(--wall) 0%, var(--wall-deep) 100%);
}
.cover-wash {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.cover-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 300;
  font-size: clamp(64px, 19vw, 220px);
  letter-spacing: 0.3em;
  margin-left: 0.3em;
  display: flex;
  transition: letter-spacing 1.2s ease;
}
.title span {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.5em);
  animation: rise 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.title span:nth-child(1) { animation-delay: 0.1s; }
.title span:nth-child(2) { animation-delay: 0.25s; }
.title span:nth-child(3) { animation-delay: 0.4s; }
.title span:nth-child(4) { animation-delay: 0.55s; }
@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}
.sub {
  margin-top: 1rem;
  font-family: "Caveat", cursive;
  font-size: clamp(20px, 4.5vw, 34px);
  color: var(--dim);
}
.stanza {
  margin-top: 1.6rem;
  font-family: "Caveat", cursive;
  font-weight: 600;
  font-size: clamp(22px, 4vw, 36px);
  line-height: 1.18;
  color: var(--ink);
}
.stanza span {
  display: block;
  opacity: 0;
  transform: translateY(0.5em);
  animation: rise 1.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.stanza span:nth-child(1) { animation-delay: 0.8s; }
.stanza span:nth-child(2) { animation-delay: 1.05s; }
.brush-under {
  margin-top: 0.65rem;
  width: min(300px, 76vw);
  height: 20px;
  pointer-events: none;
}

/* ---------------- memory wall ---------------- */
.wall {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(2.5rem, 7vw, 6rem) 1.25rem 3rem;
}
.wall-title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 300;
  font-style: italic;
  font-size: clamp(22px, 4vw, 38px);
  text-align: center;
  letter-spacing: 0.04em;
  color: rgba(74, 58, 48, 0.72);
  margin-bottom: clamp(2rem, 5vw, 4rem);
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1.4rem, 3vw, 2.6rem) clamp(1.2rem, 2.6vw, 2.4rem);
}

figure.card {
  display: block;
  margin: 0;
  break-inside: avoid;
  filter: drop-shadow(0 12px 22px rgba(74, 50, 30, 0.18));
  content-visibility: auto;
  contain-intrinsic-size: auto 400px;
}
figure.card:nth-child(3n + 1) { transform: rotate(-1.7deg); }
figure.card:nth-child(3n + 2) { transform: rotate(1.1deg); }
figure.card:nth-child(3n + 3) { transform: rotate(-0.6deg); }
figure.card:nth-child(5n + 2) { transform: translateY(10px); }
figure.card:nth-child(5n + 4) { transform: translateY(-8px); }

.polaroid {
  background: var(--paper);
  padding: 12px 12px 18px;
  border-radius: 3px;
  position: relative;
}
.polaroid::before {
  /* washi tape */
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  width: 92px;
  height: 26px;
  margin-left: -46px;
  border-radius: 2px;
  box-shadow: 0 2px 6px rgba(74, 58, 48, 0.18);
  opacity: 0.92;
}
figure.card:nth-child(3n + 1) .polaroid::before { background: rgba(246, 222, 146, 0.85); transform: rotate(-2deg); }
figure.card:nth-child(3n + 2) .polaroid::before { background: rgba(240, 205, 178, 0.85); transform: rotate(2.5deg); }
figure.card:nth-child(3n + 3) .polaroid::before { background: rgba(214, 222, 190, 0.85); transform: rotate(-1deg); }

.polaroid img,
.polaroid video {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
  background: #e9ddc6;
  object-fit: cover;
}
.caption {
  font-family: "Caveat", cursive;
  font-weight: 600;
  font-size: clamp(1.25rem, 2.1vw, 1.55rem);
  text-align: center;
  margin-top: 10px;
  line-height: 1.15;
  color: var(--ink);
}

/* cards start hidden, GSAP reveals them */
figure.card .polaroid {
  opacity: 0;
}

/* ---------------- bands (message / finale) ---------------- */
.band {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  scroll-margin-top: 10vh;
}
.message {
  background:
    radial-gradient(90% 70% at 50% 30%, rgba(255, 246, 228, 0.9) 0%, rgba(237, 220, 192, 0) 75%),
    linear-gradient(180deg, var(--wall-deep) 0%, var(--wall) 100%);
}
.msg-line {
  font-family: "Caveat", cursive;
  font-weight: 600;
  font-size: clamp(32px, 6vw, 60px);
  line-height: 1.15;
  color: var(--ink);
  opacity: 0;
  transform: translateY(24px);
  margin: 0.3em 0;
  transition: opacity 1.2s ease, transform 1.2s ease;
}
.msg-line.show {
  opacity: 1;
  transform: translateY(0);
}
.msg-line.heart {
  color: var(--wine);
}
.msg-line.small {
  font-size: clamp(22px, 3.6vw, 38px);
  color: var(--dim);
}

.finale {
  background:
    radial-gradient(90% 75% at 50% 35%, rgba(255, 244, 220, 0.95) 0%, rgba(232, 202, 158, 0) 78%),
    linear-gradient(180deg, var(--wall) 0%, var(--wall-deep) 100%);
}
.fin-title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 300;
  letter-spacing: 0.3em;
  font-size: clamp(30px, 7vw, 84px);
  line-height: 1.1;
  color: var(--ink);
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 1.4s ease, transform 1.4s ease;
}
.fin-title span {
  display: block;
}
.fin-name {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: clamp(72px, 17vw, 200px);
  letter-spacing: 0.18em;
  margin-left: 0.18em;
  color: var(--wine);
  opacity: 0;
  transform: translateY(30px) scale(0.96);
  transition: opacity 1.4s ease, transform 1.4s ease;
  margin: 0.12em 0 0 0.18em;
}
.fin-wish,
.fin-love {
  font-style: italic;
  font-weight: 300;
  font-size: clamp(16px, 3.4vw, 30px);
  margin: 0.3em 0;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1.4s ease, transform 1.4s ease;
}
.finalize .fin-title,
.finalize .fin-name,
.finalize .fin-wish,
.finalize .fin-love {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.fin-love {
  color: var(--wine);
}

/* ---------------- UI chrome ---------------- */
#ui-corner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: 20px 26px;
  pointer-events: none;
}
#ui-corner .logo {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: 0.4em;
  color: rgba(74, 58, 48, 0.7);
}
#ui-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 16px 26px;
  display: flex;
  align-items: center;
  gap: 18px;
  pointer-events: none;
}
#sound {
  pointer-events: auto;
  background: rgba(250, 243, 225, 0.55);
  border: 1px solid rgba(74, 58, 48, 0.28);
  color: var(--ink);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
  transition: color 0.4s ease, border-color 0.4s ease, background 0.4s ease;
}
#sound.on {
  color: var(--wine);
  border-color: rgba(194, 72, 94, 0.6);
  background: rgba(250, 243, 225, 0.85);
}
#progress {
  flex: 1;
  height: 2px;
  background: rgba(74, 58, 48, 0.18);
  border-radius: 2px;
  overflow: hidden;
}
#progress i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--wine), var(--gold));
  transform-origin: left;
  transform: scaleX(0);
}
#scroll-hint {
  font-size: 0.66rem;
  letter-spacing: 0.34em;
  color: var(--dim);
  text-transform: uppercase;
  white-space: nowrap;
  transition: opacity 0.6s ease;
}
#scroll-hint.hidden {
  opacity: 0;
}

/* ---------------- loader ---------------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--wall);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 1.2s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.loader-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 50% at 50% 38%, rgba(255, 245, 224, 0.55) 0%, rgba(237, 220, 192, 0) 70%);
  opacity: 0;
  transition: opacity 1.2s ease;
}
#loader.ready .loader-sheen {
  opacity: 1;
}
#loader.gone {
  opacity: 0;
  pointer-events: none;
}
#loader h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 300;
  font-size: clamp(40px, 10vw, 90px);
  letter-spacing: 0.4em;
  margin-left: 0.4em;
}
#loader p {
  margin-top: 1.4rem;
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--dim);
}
#loaderBar {
  margin-top: 1.6rem;
  width: min(320px, 70vw);
  height: 2px;
  background: rgba(74, 58, 48, 0.18);
  border-radius: 2px;
  overflow: hidden;
}
#loaderBar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--wine), var(--gold));
  transform-origin: left;
  transform: scaleX(0);
}

/* hide loading chrome once the tap-to-open prompt shows */
#loader.ready #loaderMsg,
#loader.ready #loaderBar {
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* ---------------- ribbon banner ---------------- */
.ribbon {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-top: 2.4rem;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.9s ease, transform 0.9s ease;
}
#loader.ready .ribbon {
  opacity: 1;
  transform: translateY(0);
}
.rb-band {
  position: relative;
  z-index: 1;
  display: inline-block;
  padding: 0.62em 1.7em;
  font-family: "Outfit", system-ui, sans-serif;
  font-weight: 500;
  font-size: clamp(0.8rem, 2.6vw, 0.95rem);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #fdf3e6;
  background: linear-gradient(180deg, #ce5a72 0%, #c2485e 45%, #a93c52 100%);
  border-radius: 3px;
  box-shadow:
    inset 0 0 0 1px rgba(253, 243, 230, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 6px 14px rgba(74, 40, 20, 0.25);
  white-space: nowrap;
}
.rb-band::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 4px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(217, 154, 61, 0.9), transparent);
}
.rb-tail {
  position: relative;
  z-index: 0;
  width: 0;
  height: 0;
  border-style: solid;
  filter: drop-shadow(0 4px 4px rgba(74, 40, 20, 0.18));
}
.rb-left {
  border-width: 15px 0 15px 15px;
  border-color: transparent transparent transparent #8f3449;
  transform: translateX(-6px) rotate(3deg);
}
.rb-right {
  border-width: 15px 15px 15px 0;
  border-color: transparent #8f3449 transparent transparent;
  transform: translateX(6px) rotate(-3deg);
}
/* fold creases on the tails */
.rb-tail::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: rgba(74, 40, 20, 0.18);
}

@media (max-width: 900px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .cards {
    grid-template-columns: 1fr;
    max-width: 420px;
    margin: 0 auto;
  }
}
@media (max-width: 640px) {
  #ui-corner {
    padding: calc(14px + env(safe-area-inset-top, 0px))
      calc(18px + env(safe-area-inset-right, 0px));
  }
  #ui-bar {
    padding: 12px
      calc(26px + env(safe-area-inset-right, 0px))
      calc(16px + env(safe-area-inset-bottom, 0px))
      calc(18px + env(safe-area-inset-left, 0px));
  }
  #scroll-hint { display: none; }
}

/* large touch targets / no double-tap-zoom delay on touch screens */
@media (hover: none) {
  #sound {
    width: 48px;
    height: 48px;
    font-size: 1.15rem;
  }
}

/* mobile keepsake stack — cards pin and pile on top of each other */
@media (max-width: 767px) {
  .cards {
    display: block;
    max-width: 430px;
    margin: 0 auto;
    padding: 6vh 0 8vh;
  }
  figure.card {
    position: sticky;
    top: calc(12vh + min(var(--i, 0), 6) * 1.6vh);
    content-visibility: visible;
  }
  figure.card:nth-child(1) { --i: 0; }
  figure.card:nth-child(2) { --i: 1; }
  figure.card:nth-child(3) { --i: 2; }
  figure.card:nth-child(4) { --i: 3; }
  figure.card:nth-child(5) { --i: 4; }
  figure.card:nth-child(6) { --i: 5; }
  figure.card:nth-child(7) { --i: 6; }
  figure.card:nth-child(8) { --i: 7; }
  figure.card:nth-child(9) { --i: 8; }
  figure.card:nth-child(10) { --i: 9; }
  figure.card:nth-child(11) { --i: 10; }
  figure.card:nth-child(12) { --i: 11; }
  figure.card:nth-child(13) { --i: 12; }
  figure.card:nth-child(14) { --i: 13; }
  figure.card:nth-child(15) { --i: 14; }
  figure.card:nth-child(16) { --i: 15; }
  .polaroid img,
  .polaroid video {
    width: 100%;
    height: auto;
    max-height: 52vh;
    object-fit: cover;
  }
}

/* reduced motion: show everything statically, honor the visitor's OS */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .title span,
  .stanza span {
    animation: none;
    opacity: 1;
    transform: none;
  }
  figure.card .polaroid,
  .msg-line,
  .fin-title,
  .fin-name,
  .fin-wish,
  .fin-love {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  #loader.ready .ribbon,
  #loader.ready .loader-sheen {
    transition: none;
    opacity: 1;
    transform: none;
  }
}