:root {
  --page-bg: #faf7f6;
  --sheet-bg: #ffffff;
  --polaroid-paper: #f3f4f6;
  --polaroid-border: #e5e7eb;
  --ink: #252224;
  --ink-soft: #756c70;
  --pink: #eb7aa3;
  --pink-soft: #fdecf3;
  --font-hand: "Caveat", cursive;
  --font-ui: "Quicksand", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

.hidden {
  display: none !important;
}

.page-wrap {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: clamp(1rem, 3vw, 2.4rem) 0.85rem 3rem;
}

/* White Polaroid Scrapbook Sheet matching the exact proportions of the template */
.scrapbook-sheet {
  width: min(500px, 100%);
  background: var(--sheet-bg);
  border-radius: 26px;
  border: 1px solid #f0e6ea;
  box-shadow: 0 18px 50px rgba(45, 25, 34, 0.08);
  padding: 1.4rem clamp(0.9rem, 3.5vw, 1.65rem) 1.8rem;
  position: relative;
  overflow: hidden;
}

/* Top Progress Hint */
.top-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 1.1rem;
  text-align: center;
}

.hint-text {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--ink-soft);
  line-height: 1.15;
}

.progress-dots {
  display: inline-flex;
  gap: 0.45rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e9dce2;
  transition: background 0.35s ease, transform 0.35s ease;
}

.dot.active {
  background: var(--pink);
  transform: scale(1.22);
}

/* Alternating 3-Row Collage Layout matching reference image */
.collage-row {
  display: grid;
  align-items: center;
  gap: 0.6rem;
  position: relative;
}

.row-1 {
  grid-template-columns: 0.92fr 1.08fr;
  margin-bottom: 1.35rem;
}

.row-2 {
  grid-template-columns: 1.08fr 0.92fr;
  margin-bottom: 1.45rem;
}

.row-3 {
  grid-template-columns: 0.92fr 1.08fr;
  margin-bottom: 1.4rem;
}

/* Cat Stickers */
.sticker-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.25rem;
}

.cat-sticker {
  width: min(172px, 100%);
  height: auto;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.05));
  transition: transform 0.35s ease;
}

.cat-sticker:hover {
  transform: scale(1.05) rotate(-2deg);
}

.sway-a {
  animation: gentleSwayA 5.5s ease-in-out infinite;
}

.sway-b {
  animation: gentleSwayB 6s ease-in-out infinite;
}

@keyframes gentleSwayA {
  0%, 100% { transform: rotate(-1.5deg) translateY(0px); }
  50% { transform: rotate(1.5deg) translateY(-3px); }
}

@keyframes gentleSwayB {
  0%, 100% { transform: rotate(1.8deg) translateY(0px); }
  50% { transform: rotate(-1.8deg) translateY(-3px); }
}

/* Polaroid Container & Overlapping Stickers */
.polaroid-slot {
  position: relative;
  display: flex;
  justify-content: center;
  padding: 0.65rem 0.35rem;
}

.heart-sticker {
  position: absolute;
  width: 66px;
  height: auto;
  z-index: 5;
  pointer-events: none;
  filter: drop-shadow(0 3px 6px rgba(235, 122, 163, 0.22));
}

.heart-p1 {
  top: -12px;
  right: -10px;
  transform: rotate(14deg);
}

.heart-p2 {
  top: -18px;
  left: -6px;
  transform: rotate(-12deg);
}

.heart-p3 {
  top: -22px;
  left: 50%;
  transform: translateX(-55%) rotate(-4deg);
}

.heart-cats-sticker {
  position: absolute;
  bottom: -6px;
  left: -14px;
  width: 88px;
  height: auto;
  z-index: 6;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

/* Polaroid Frame */
.polaroid {
  appearance: none;
  border: 1px solid var(--polaroid-border);
  background: linear-gradient(165deg, #f8f9fa 0%, #eceef1 100%);
  padding: 11px 11px 0 11px;
  width: min(215px, 100%);
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 2px 5px rgba(0, 0, 0, 0.08),
    0 12px 24px rgba(28, 22, 26, 0.13);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease;
  -webkit-tap-highlight-color: transparent;
}

.tilt-1 { transform: rotate(1.8deg); }
.tilt-2 { transform: rotate(-4.5deg); }
.tilt-3 { transform: rotate(2.8deg); }

.polaroid:hover {
  box-shadow:
    0 6px 12px rgba(0, 0, 0, 0.1),
    0 18px 34px rgba(28, 22, 26, 0.18);
}

.tilt-1:hover { transform: rotate(0.4deg) scale(1.025); }
.tilt-2:hover { transform: rotate(-2.5deg) scale(1.025); }
.tilt-3:hover { transform: rotate(1.2deg) scale(1.025); }

.polaroid:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 4px;
}

/* Inner Photo Window (black before click -> smooth gradient reveal!) */
.photo-window {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 4.45;
  background: #050505;
  overflow: hidden;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.25);
}

.real-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.14) contrast(1.35) saturate(0.2) blur(4px);
  transform: scale(1.06);
  transition:
    filter 1.75s cubic-bezier(0.22, 1, 0.36, 1),
    transform 1.75s cubic-bezier(0.22, 1, 0.36, 1);
}

.pos-1 { object-position: center 35%; }
.pos-2 { object-position: center 26%; }
.pos-3 { object-position: center 58%; }

/* Solid black Polaroid film veil */
.black-veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, #121214 0%, #050505 78%);
  display: grid;
  place-items: center;
  opacity: 1;
  transition: opacity 1.35s cubic-bezier(0.25, 0.85, 0.35, 1);
  z-index: 2;
}

.tap-label {
  font-family: var(--font-hand);
  font-size: 1.32rem;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: 0.03em;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  animation: pulseSoft 2.4s ease-in-out infinite;
}

@keyframes pulseSoft {
  0%, 100% { opacity: 0.52; transform: scale(0.98); }
  50% { opacity: 0.95; transform: scale(1.02); }
}

/* Black-to-transparent sweeping gradient layer for the developing reveal */
.gradient-sweep {
  position: absolute;
  inset: -40% 0 0 0;
  background: linear-gradient(
    180deg,
    rgba(5, 5, 5, 0) 0%,
    rgba(5, 5, 5, 0.72) 28%,
    rgba(5, 5, 5, 0.97) 58%,
    rgba(5, 5, 5, 1) 100%
  );
  transform: translateY(-25%);
  opacity: 1;
  pointer-events: none;
  z-index: 3;
  transition:
    transform 1.75s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 1.65s ease;
}

/* Revealed State */
.polaroid.revealed .real-photo {
  filter: brightness(1) contrast(1) saturate(1) blur(0px);
  transform: scale(1);
}

.polaroid.revealed .black-veil {
  opacity: 0;
  pointer-events: none;
}

.polaroid.revealed .gradient-sweep {
  transform: translateY(125%);
  opacity: 0;
}

/* Bottom white chin of the Polaroid */
.polaroid-chin {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chin-caption {
  font-family: var(--font-hand);
  font-size: 1.18rem;
  color: #5f565a;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.9s ease 0.7s, transform 0.9s ease 0.7s;
}

.polaroid.revealed .chin-caption {
  opacity: 1;
  transform: translateY(0);
}

/* Floating Heart Burst on Reveal */
.burst-heart {
  position: absolute;
  pointer-events: none;
  z-index: 12;
  width: 16px;
  height: 16px;
  color: var(--pink);
  animation: floatUpHeart 1.3s ease-out forwards;
}

@keyframes floatUpHeart {
  0% { opacity: 0; transform: translate(0, 0) scale(0.5); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.15); }
}

/* Sheet Controls */
.sheet-controls {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.mini-pill {
  border: 1px solid #f0cddb;
  background: var(--pink-soft);
  color: #9e3d65;
  padding: 0.45rem 1.05rem;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.mini-pill:hover {
  background: #fbd9e8;
  transform: translateY(-1px);
}

.mini-pill.ghost {
  background: #f6f4f5;
  border-color: #e4dfe2;
  color: var(--ink-soft);
}

/* Spotify Music Card */
.spotify-card {
  margin-top: 0.5rem;
  padding: 1.05rem 1.05rem 0.95rem;
  background: #fdf9fb;
  border: 1px solid #f1dfe7;
  border-radius: 18px;
}

.spotify-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
  padding: 0 0.2rem;
}

.spotify-note {
  font-family: var(--font-hand);
  font-size: 1.42rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

.spotify-ext-link {
  font-size: 0.76rem;
  font-weight: 700;
  color: #168a44;
  text-decoration: none;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: #eaf8ef;
  border: 1px solid #cdecd7;
}

.spotify-ext-link:hover {
  background: #daf2e3;
}

.spotify-embed-wrap {
  border-radius: 12px;
  overflow: hidden;
  background: #121212;
}

.spotify-embed-wrap iframe {
  display: block;
  border-radius: 12px;
}

.spotify-tip {
  margin: 0.65rem 0 0;
  font-size: 0.73rem;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.4;
}

/* Fullscreen Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(16, 13, 15, 0.88);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.lb-close {
  position: fixed;
  top: 1rem;
  right: 1.15rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.lb-frame {
  background: #f8f9fa;
  padding: 12px 12px 14px;
  border-radius: 4px;
  max-width: min(520px, 94vw);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.lb-frame img {
  max-height: 76vh;
  max-width: 100%;
  margin: 0 auto;
  object-fit: contain;
}

.lb-caption {
  margin: 0.7rem 0 0;
  font-family: var(--font-hand);
  font-size: 1.6rem;
  color: #3a3337;
}

@media (max-width: 440px) {
  .scrapbook-sheet {
    padding: 1.15rem 0.75rem 1.4rem;
    border-radius: 20px;
  }
  .heart-sticker { width: 54px; }
  .heart-cats-sticker { width: 74px; left: -10px; }
  .polaroid { padding: 9px 9px 0 9px; }
  .polaroid-chin { height: 30px; }
  .chin-caption { font-size: 1.05rem; }
}
