/* --- Base & tokens --- */
:root {
  --bg-top: #fff5f7;
  --bg-mid: #fceee9;
  --bg-bottom: #f5e6dc;
  --ink: #4a3f45;
  --ink-soft: #6d5f66;
  --rose: #e8a4b8;
  --rose-deep: #c77b94;
  --card: rgba(255, 255, 255, 0.72);
  --shadow-soft: 0 18px 50px rgba(74, 63, 69, 0.12);
  --shadow-polaroid: 0 14px 28px rgba(45, 35, 40, 0.22), 0 6px 10px rgba(45, 35, 40, 0.12);
  --font-display: "Dancing Script", cursive;
  --font-accent: "Pacifico", cursive;
  --font-body: "Nunito", system-ui, sans-serif;
}

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

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(165deg, var(--bg-top) 0%, var(--bg-mid) 42%, var(--bg-bottom) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- Floating hearts (subtle) --- */
.hearts-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.heart {
  position: absolute;
  bottom: -10%;
  font-size: clamp(10px, 2.2vw, 18px);
  opacity: 0;
  animation: heart-rise linear infinite;
  filter: blur(0.2px);
}

@keyframes heart-rise {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 0;
  }
  8% {
    opacity: 0.35;
  }
  85% {
    opacity: 0.28;
  }
  100% {
    transform: translate3d(var(--drift), -120vh, 0) rotate(360deg);
    opacity: 0;
  }
}

/* --- Page shell --- */
.page {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2rem) 6rem;
  opacity: 0;
  animation: page-in 1.35s ease forwards 0.15s;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Hero --- */
.hero {
  text-align: center;
  margin-bottom: clamp(1.5rem, 4vw, 2.25rem);
}

.hero-eyebrow {
  font-family: var(--font-body);
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rose-deep);
  margin: 0 0 0.5rem;
  opacity: 0.85;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.75rem, 10vw, 4.5rem);
  line-height: 1.05;
  margin: 0 0 0.65rem;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.6), 0 10px 30px rgba(199, 123, 148, 0.25);
}

.heart-inline {
  display: inline-block;
  animation: pulse-heart 2.2s ease-in-out infinite;
}

@keyframes pulse-heart {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

.hero-sub {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0 auto;
  max-width: 28ch;
  line-height: 1.35;
}

/* --- Message card --- */
.message {
  background: var(--card);
  backdrop-filter: blur(10px);
  border-radius: 22px;
  padding: clamp(1.25rem, 4vw, 2rem);
  margin-bottom: clamp(1.5rem, 4vw, 2rem);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-soft);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.card-glow:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 55px rgba(199, 123, 148, 0.18), var(--shadow-soft);
}

.message-heading {
  font-family: var(--font-accent);
  font-size: clamp(1.35rem, 4.5vw, 1.85rem);
  font-weight: 400;
  margin: 0 0 1rem;
  color: var(--rose-deep);
}

.message-text {
  margin: 0 0 1rem;
  font-size: clamp(0.95rem, 2.8vw, 1.05rem);
  line-height: 1.65;
  color: var(--ink-soft);
}

.message-text:last-child {
  margin-bottom: 0;
}

.message-accent {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 3.5vw, 1.45rem);
  font-weight: 600;
  color: var(--ink);
}

/* --- Memory lane intro --- */
.lane-intro {
  text-align: center;
  margin: 0 auto clamp(1.25rem, 4vw, 2rem);
  max-width: 36rem;
  padding: 0 0.25rem;
}

.lane-heading {
  font-family: var(--font-accent);
  font-size: clamp(1.5rem, 5vw, 2.1rem);
  font-weight: 400;
  color: var(--rose-deep);
  margin: 0 0 0.5rem;
  line-height: 1.2;
}

.lane-sub {
  margin: 0;
  font-size: clamp(0.88rem, 2.6vw, 1rem);
  line-height: 1.55;
  color: var(--ink-soft);
}

/* --- Scrapbook / memory lane --- */
.scrapbook {
  position: relative;
  margin: 0 auto 2rem;
  touch-action: pan-y;
}

.scrapbook--lane {
  min-height: 0;
}

.memory-lane {
  position: relative;
  max-width: 28rem;
  margin: 0 auto;
  padding: 0.35rem 0 1.5rem;
}

/* Sketchy “thread” down the middle */
.memory-lane::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0.5rem;
  bottom: 0.75rem;
  width: 0;
  border-left: 2px dashed rgba(199, 123, 148, 0.45);
  transform: translateX(-50%);
  border-radius: 2px;
  pointer-events: none;
  z-index: 0;
}

.memory-lane__step {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr minmax(2.25rem, 3rem) 1fr;
  gap: 0.35rem 0.45rem;
  align-items: start;
  margin-bottom: clamp(1.6rem, 5.5vw, 2.75rem);
}

.memory-lane__step--right .memory-lane__marker {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}

.memory-lane__step--right .polaroid-slot {
  grid-column: 3;
  grid-row: 1;
  justify-self: start;
}

.memory-lane__step--left .memory-lane__marker {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}

.memory-lane__step--left .polaroid-slot {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
}

/* Washi / paper scrap behind every other frame */
.memory-lane__step::after {
  content: "";
  position: absolute;
  top: -0.35rem;
  left: -4%;
  right: -4%;
  height: calc(100% + 0.5rem);
  border-radius: 10px;
  background: linear-gradient(
    118deg,
    rgba(255, 248, 240, 0.55) 0%,
    rgba(252, 232, 236, 0.35) 50%,
    rgba(255, 252, 248, 0.5) 100%
  );
  box-shadow: 0 8px 24px rgba(74, 63, 69, 0.06);
  z-index: -1;
  pointer-events: none;
}

.memory-lane__step:nth-child(even)::after {
  transform: rotate(-0.6deg);
  background: linear-gradient(
    125deg,
    rgba(255, 252, 248, 0.5) 0%,
    rgba(240, 248, 255, 0.3) 45%,
    rgba(255, 245, 248, 0.45) 100%
  );
}

.memory-lane__marker {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 0.65rem;
}

.memory-lane__marker-num {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.65rem;
  height: 1.65rem;
  padding: 0 0.25rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--rose-deep);
  background: radial-gradient(circle at 30% 25%, #fffefb, #fce4ec);
  border: 1.5px solid rgba(199, 123, 148, 0.35);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(199, 123, 148, 0.2);
}

.polaroid-slot {
  position: relative;
  left: auto;
  top: auto;
  width: min(78vw, 268px);
  max-width: 268px;
  cursor: pointer;
  touch-action: manipulation;
  z-index: 2;
  transition: filter 0.25s ease;
}

@media (hover: hover) {
  .polaroid-slot:hover .polaroid {
    transform: rotate(var(--tilt, 0deg)) scale(1.04);
    box-shadow: 0 22px 40px rgba(45, 35, 40, 0.26), 0 8px 14px rgba(45, 35, 40, 0.12);
  }
}

.polaroid-slot:active .polaroid {
  transform: rotate(var(--tilt, 0deg)) scale(0.99);
}

.polaroid-float {
  animation: polaroid-float-lane 7s ease-in-out infinite;
  animation-delay: var(--float-delay, 0s);
}

@keyframes polaroid-float-lane {
  0%,
  100% {
    transform: translateY(0) rotate(var(--wobble, 0deg));
  }
  50% {
    transform: translateY(-4px) rotate(calc(var(--wobble, 0deg) * -1));
  }
}

@media (prefers-reduced-motion: reduce) {
  .polaroid-float {
    animation: none;
  }
}

.polaroid {
  background: #fffef9;
  padding: 10px 10px 28px;
  border-radius: 3px;
  box-shadow: var(--shadow-polaroid);
  transform: rotate(var(--tilt, 0deg));
  transition: box-shadow 0.35s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.polaroid--compact {
  padding: 8px 8px 22px;
}

.polaroid--compact .polaroid-caption {
  font-size: 0.88rem;
  margin-top: 6px;
}

/* “Taped into the book” */
.polaroid--scrap {
  position: relative;
  background: linear-gradient(152deg, #fffefb 0%, #fff9f2 42%, #fffef9 100%);
}

.polaroid--scrap::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  width: 46%;
  max-width: 7.5rem;
  height: 13px;
  transform: translateX(-50%) rotate(var(--tape-rot, -1.5deg));
  border-radius: 2px;
  opacity: 0.88;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.1),
    rgba(248, 210, 224, 0.75) 20%,
    rgba(255, 236, 244, 0.9) 50%,
    rgba(230, 236, 252, 0.55) 80%,
    rgba(255, 255, 255, 0.05)
  );
  box-shadow: 0 1px 2px rgba(45, 35, 40, 0.12);
}

.memory-lane__step:nth-child(3n) .polaroid--scrap::before {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.08),
    rgba(220, 236, 255, 0.65) 35%,
    rgba(255, 245, 250, 0.85) 70%,
    rgba(255, 255, 255, 0.06)
  );
}

.polaroid--scrap::after {
  content: "";
  position: absolute;
  bottom: 10px;
  right: 6px;
  width: 22px;
  height: 8px;
  border-radius: 1px;
  opacity: 0.35;
  pointer-events: none;
  transform: rotate(-18deg);
  background: linear-gradient(90deg, rgba(199, 123, 148, 0.2), rgba(199, 123, 148, 0.45));
}

.polaroid-media {
  width: 100%;
  /* Default; JS adjusts to each media's natural aspect ratio. */
  aspect-ratio: 4 / 5;
  border-radius: 1px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.55);
}

.polaroid-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.05) contrast(0.98);
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.polaroid-media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.05) contrast(0.98);
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Ensure a poster is visible even when autoplay is blocked */
.polaroid-media video[poster] {
  background: #000;
}

.polaroid-caption {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  margin: 8px 0 0;
  color: var(--ink-soft);
  line-height: 1.2;
  pointer-events: none;
}

.gallery-empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.95rem;
  padding: 2rem 1rem;
}

/* --- Footer --- */
.site-footer {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--rose-deep);
  padding-top: 0.5rem;
}

/* --- Audio dock --- */
.audio-dock {
  position: fixed;
  z-index: 200;
  right: clamp(0.75rem, 3vw, 1.25rem);
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  left: auto;
}

.audio-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(74, 63, 69, 0.15);
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  max-width: min(92vw, 280px);
}

.audio-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 36px rgba(199, 123, 148, 0.22);
}

.audio-btn:active {
  transform: scale(0.98);
}

.audio-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.audio-label {
  text-align: left;
  line-height: 1.25;
}

@media (max-width: 380px) {
  .audio-label {
    display: none;
  }
  .audio-btn {
    padding: 0.65rem;
    border-radius: 50%;
  }
}

/* --- Full-size lightbox --- */
body.lightbox-open {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}

.lightbox.is-open {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
  transition: opacity 0.35s ease, visibility 0s linear 0s;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: radial-gradient(ellipse at 50% 40%, rgba(60, 45, 52, 0.55), rgba(30, 22, 28, 0.78));
  backdrop-filter: blur(6px);
}

.lightbox-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}

.lightbox-x {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  z-index: 2;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
  background: rgba(255, 250, 252, 0.95);
  box-shadow: 0 6px 20px rgba(45, 35, 40, 0.2);
  transition: transform 0.2s ease, background 0.2s ease;
}

.lightbox-x:hover {
  transform: scale(1.06);
  background: #fff;
}

.lightbox-stage {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: min(100vw, 1400px);
  max-height: min(92dvh, 92vh, 1200px);
}

.lightbox-img {
  display: block;
  max-width: min(98vw, 1400px);
  max-height: min(88dvh, 88vh, 1100px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(20, 12, 18, 0.45), 0 8px 24px rgba(20, 12, 18, 0.25);
  transform-origin: center center;
  will-change: transform;
}

.lightbox-video {
  display: block;
  max-width: min(98vw, 1400px);
  max-height: min(88dvh, 88vh, 1100px);
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(20, 12, 18, 0.45), 0 8px 24px rgba(20, 12, 18, 0.25);
  background: #000;
}

.lightbox:fullscreen,
.lightbox:-webkit-full-screen {
  padding: max(0.5rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-right))
    max(0.5rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
  background: #1a1216;
}

.lightbox:fullscreen .lightbox-stage,
.lightbox:-webkit-full-screen .lightbox-stage {
  max-width: 100%;
  max-height: 100%;
}

.lightbox:fullscreen .lightbox-img,
.lightbox:-webkit-full-screen .lightbox-img {
  max-width: 100%;
  max-height: min(100dvh, 100vh);
  border-radius: 8px;
}

.lightbox-caption {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 3.5vw, 1.5rem);
  font-weight: 600;
  color: #fffef9;
  text-align: center;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  max-width: 40ch;
  line-height: 1.3;
}

.lightbox-caption[hidden] {
  display: none;
}
