/* ---------- Palette & type ---------- */
:root {
  --cream: #fbf5ec;
  --paper: #ffffff;
  --ink: #221c17;
  --ink-soft: #4a4038;
  --muted: #9a8c7e;
  --pink: #ff5c8a;
  --butter: #ffd166;
  --sky: #7cc6fe;
  --mint: #7ed9b4;
  --lilac: #b8a1ff;

  --serif: "Fraunces", ui-serif, Georgia, serif;
  --sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --gap: 14px;
  --bleed: 70px;
  --radius: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- Photo wall ---------- */
.wall {
  position: fixed;
  /* bleed past both edges so the wall feels endless */
  inset: 0 calc(var(--bleed, 70px) * -1);
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), 1fr);
  gap: var(--gap);
  overflow: hidden;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.wall.ready { opacity: 1; }

.col {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  will-change: transform;
  animation: drift-up var(--dur, 140s) linear infinite;
  animation-delay: var(--delay, 0s);
}
.col.down { animation-name: drift-down; }

@keyframes drift-up   { from { transform: translateY(0); }    to { transform: translateY(-50%); } }
@keyframes drift-down { from { transform: translateY(-50%); } to { transform: translateY(0); } }

body.paused .col { animation-play-state: paused; }

.tile {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #ecdfcf;
  box-shadow: 0 1px 2px rgba(60, 35, 15, .08), 0 6px 18px -8px rgba(60, 35, 15, .25);
  transform: translateZ(0);
  transition: transform .35s cubic-bezier(.2, .8, .2, 1.2), box-shadow .35s ease;
}
.tile img,
.tile video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tile video {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .25s ease;
}
.tile.playing video { opacity: 1; }
.tile img { opacity: 0; transition: opacity .6s ease; }
.tile img.loaded { opacity: 1; }

@media (hover: hover) {
  .tile:hover {
    transform: scale(1.035) rotate(var(--tilt, 1deg));
    box-shadow: 0 2px 4px rgba(60, 35, 15, .1), 0 18px 36px -12px rgba(60, 35, 15, .45);
    z-index: 2;
  }
}
.tile:focus-visible { outline: 3px solid var(--pink); outline-offset: 3px; }

/* little badges for live photos + the video */
.badge {
  position: absolute;
  left: 10px;
  top: 10px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
  color: var(--ink);
  pointer-events: none;
}
.badge svg { width: 14px; height: 14px; }
.badge.play { left: 50%; top: 50%; width: 52px; height: 52px; transform: translate(-50%, -50%); }
.badge.play svg { width: 20px; height: 20px; margin-left: 3px; }

/* soft cream glow behind the card so the note stays the hero */
.wash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 46% 58% at 50% 50%, rgba(251, 245, 236, .78) 0%, rgba(251, 245, 236, .35) 55%, rgba(251, 245, 236, 0) 100%);
  transition: opacity .6s ease;
}
body.peeking .wash { opacity: 0; }

/* ---------- The card ---------- */
.card {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 10;
  width: min(560px, calc(100vw - 40px));
  max-height: calc(100svh - 56px);
  overflow: visible;
  padding: 56px 60px 40px;
  border-radius: 30px;
  background: var(--paper);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .9) inset,
    0 2px 6px rgba(60, 35, 15, .06),
    0 40px 90px -30px rgba(60, 35, 15, .45),
    0 0 0 1px rgba(60, 35, 15, .04);
  transform: translate(-50%, -50%);
  opacity: 0;
  animation: card-in 1s cubic-bezier(.2, .9, .25, 1.15) .35s forwards;
  transition: transform .7s cubic-bezier(.6, -0.25, .3, 1), opacity .5s ease;
  display: flex;
  flex-direction: column;
}
@keyframes card-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 28px)) scale(.96); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
body.peeking .card {
  animation: none;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(50vh + 40px)) rotate(-4deg);
}
body.returning .card {
  animation: none;
  opacity: 1;
  transition: transform .8s cubic-bezier(.2, .9, .25, 1.15), opacity .4s ease;
}

/* washi tape */
.card::before {
  content: "";
  position: absolute;
  top: -15px;
  left: 50%;
  width: 132px;
  height: 32px;
  transform: translateX(-50%) rotate(-3deg);
  background:
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, .35) 0 6px, transparent 6px 12px),
    rgba(255, 209, 102, .85);
  border-radius: 3px;
  box-shadow: 0 2px 6px rgba(120, 80, 20, .15);
  clip-path: polygon(3% 0, 97% 0, 100% 18%, 98% 40%, 100% 62%, 97% 100%, 3% 100%, 0 80%, 2% 55%, 0 30%);
}

.name {
  position: relative;
  margin: 0 0 34px;
  font-family: var(--serif);
  font-weight: 500;
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144;
  font-size: clamp(76px, 15vw, 124px);
  line-height: .92;
  letter-spacing: -.035em;
  text-align: center;
  color: var(--ink);
}

.squiggle {
  position: absolute;
  left: 50%;
  bottom: -16px;
  width: 64%;
  height: 16px;
  transform: translateX(-50%);
  color: var(--pink);
  overflow: visible;
}
.squiggle path {
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  animation: draw 1.1s cubic-bezier(.6, 0, .3, 1) 1.1s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.message {
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  margin: 0 -8px;
  padding: 0 8px;
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink-soft);
  scrollbar-width: thin;
  scrollbar-color: #ffb3c8 transparent;
}
.message p { margin: 0 0 1em; }
.message p:last-child { margin-bottom: 0; }
.message em { font-style: italic; color: var(--ink); }

/* the gift: a little book, tucked in like a polaroid */
.gift {
  display: flex;
  justify-content: center;
  margin: 22px 0 26px;
}
.book-photo {
  display: block;
  width: 150px;
  height: auto;
  aspect-ratio: 312 / 420;
  border-radius: 3px 6px 6px 3px;
  transform: rotate(-3deg);
  box-shadow:
    inset 4px 0 0 rgba(0, 0, 0, .08),
    0 2px 4px rgba(60, 35, 15, .12),
    0 20px 34px -14px rgba(60, 35, 15, .5);
  transition: transform .4s cubic-bezier(.3, 1.6, .5, 1);
}
.gift:hover .book-photo { transform: rotate(1deg) translateY(-3px); }

/* scroll affordance: soft fade + bouncing pill while there's more below */
.message-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.message {
  --fade-top: 0px;
  --fade-bottom: 0px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent 100%);
}
.message.more-above { --fade-top: 36px; }
.message.more-below { --fade-bottom: 90px; padding-bottom: 8px; }
.message:focus-visible { outline: none; }

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 8px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  box-shadow: 0 8px 20px -6px rgba(255, 92, 138, .7);
  transform: translate(-50%, 0);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.scroll-hint svg { width: 14px; height: 14px; animation: nudge 1.4s ease-in-out infinite; }
.scroll-hint.show { opacity: 1; pointer-events: auto; }
.scroll-hint:hover { filter: brightness(1.05); }
@keyframes nudge { 0%, 100% { transform: translateY(-1px); } 50% { transform: translateY(3px); } }

.signoff {
  margin: 26px 0 0;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 10px;
  font-family: var(--serif);
  font-style: italic;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}
.signoff-love { font-size: 17px; color: var(--muted); }
.signoff-name {
  font-size: 30px;
  font-weight: 500;
  color: var(--pink);
  letter-spacing: -.01em;
}

.peek {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 30px;
  padding: 10px 18px 10px 20px;
  border: 0;
  border-radius: 999px;
  background: #f6efe5;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  transition: background .2s ease, transform .2s ease;
}
.peek svg { width: 14px; height: 14px; transition: transform .3s cubic-bezier(.3, 1.6, .5, 1); }
.peek:hover { background: #f0e6d8; }
.peek:hover svg { transform: translateY(2px); }
.peek:focus-visible { outline: 2px solid var(--pink); outline-offset: 3px; }

/* pill to bring the card back */
.return {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 11;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px 14px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 14px 40px -10px rgba(60, 35, 15, .45), 0 0 0 1px rgba(60, 35, 15, .05);
  font-size: 15px;
  font-weight: 600;
  transform: translate(-50%, 0);
  animation: pop-in .5s cubic-bezier(.3, 1.6, .5, 1) both;
}
.return[hidden] { display: none; }
.return:hover { transform: translate(-50%, -2px); }
.return-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 0 4px rgba(255, 92, 138, .18);
}
@keyframes pop-in {
  from { opacity: 0; transform: translate(-50%, 20px) scale(.9); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  background: rgba(251, 245, 236, .82);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  backdrop-filter: blur(22px) saturate(1.2);
  animation: fade-in .25s ease both;
}
.lightbox[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.lb-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-width: 0;
}
.lb-media {
  display: grid;
  place-items: center;
}
.lb-media img,
.lb-media video {
  display: block;
  max-width: min(100%, 1100px);
  max-height: calc(100svh - 160px);
  border-radius: 18px;
  background: #eadccb;
  box-shadow: 0 30px 80px -24px rgba(60, 35, 15, .55);
  animation: lb-in .4s cubic-bezier(.2, .9, .25, 1.1) both;
}
@keyframes lb-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }

.lb-caption {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-family: var(--serif);
  font-style: italic;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-size: 28px;
  font-weight: 500;
  color: var(--ink);
}
.lb-count {
  font-family: var(--sans);
  font-style: normal;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .08em;
  color: var(--muted);
}

.lb-nav,
.lb-close {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 8px 24px -8px rgba(60, 35, 15, .35);
  transition: transform .2s ease;
}
.lb-nav:hover, .lb-close:hover { transform: scale(1.08); }
.lb-nav svg, .lb-close svg { width: 22px; height: 22px; }
.lb-close { position: absolute; top: 20px; right: 20px; margin: 0; }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  :root { --gap: 10px; --radius: 12px; }
  .card {
    padding: 52px 28px 28px;
    border-radius: 24px;
    max-height: calc(100svh - 72px);
  }
  .name { margin-bottom: 28px; }
  :root { --bleed: 40px; }
  .squiggle {
  position: absolute;
  left: 50%;
  bottom: -16px;
  width: 64%;
  height: 16px;
  transform: translateX(-50%);
  color: var(--pink);
  overflow: visible;
}
.squiggle path {
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  animation: draw 1.1s cubic-bezier(.6, 0, .3, 1) 1.1s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.message { font-size: 16px; }
  .lightbox { grid-template-columns: 1fr; padding: 16px; }
  .lb-nav { position: absolute; bottom: 24px; }
  .lb-prev { left: calc(50% - 64px); }
  .lb-next { right: calc(50% - 64px); }
  .lb-media img, .lb-media video { max-height: calc(100svh - 220px); }
  .lb-figure { margin-bottom: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  .col { animation: none; }
  .card { animation-duration: .01s; animation-delay: 0s; }
}
