/* ============================================
   BIRTHDAY WEBSITE — styles.css
   Tema: Romantic Elegant | Pink Blush & Gold
   ============================================ */

:root {
  --blush: #fbe9e6;
  --blush-deep: #f3d6d2;
  --cream: #fffaf5;
  --rose: #c98a93;
  --rose-deep: #a85d68;
  --wine: #5b2a33;
  --gold: #c6a15b;
  --gold-light: #ecdcae;
  --font-display: 'Playfair Display', serif;
  --font-script: 'Dancing Script', cursive;
  --font-body: 'Lora', serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: linear-gradient(180deg, var(--blush) 0%, var(--cream) 35%, var(--blush) 100%);
  color: var(--wine);
  overflow-x: hidden;
  position: relative;
}

/* ---------- Ambient floating petals ---------- */
.petal {
  position: fixed;
  top: -8vh;
  width: 12px;
  height: 12px;
  background: radial-gradient(circle at 30% 30%, var(--gold-light), var(--rose) 80%);
  border-radius: 0 100% 0 100%;
  opacity: .5;
  pointer-events: none;
  z-index: 1;
  animation: fall linear infinite;
  will-change: transform;
}

@keyframes fall {
  to {
    transform: translateY(115vh) translateX(var(--drift, 40px)) rotate(360deg);
  }
}

section {
  position: relative;
  z-index: 2;
}

.eyebrow {
  font-family: var(--font-body);
  letter-spacing: .25em;
  text-transform: uppercase;
  font-size: .7rem;
  color: var(--rose-deep);
  font-style: italic;
}

/* ---------- Landing / envelope ---------- */
#landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.5rem;
}

.envelope-wrap {
  position: relative;
  width: 280px;
  height: 190px;
  margin-bottom: 2.5rem;
  /* No overflow:hidden here — we need letter-card to exit upward */
  /* Flap overflow handled by clip-path instead */
}

/* Clip only the TOP portion to prevent flap from overflowing above the envelope */
.envelope-flap-clip {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  z-index: 3;
}

.envelope-body {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, var(--cream), #fff);
  border: 1px solid var(--gold-light);
  border-radius: 6px;
  box-shadow: 0 18px 40px -12px rgba(91, 42, 51, .35);
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 140px solid transparent;
  border-right: 140px solid transparent;
  border-top: 100px solid var(--rose-deep);
  transform-origin: top center;
  transition: transform 1.1s cubic-bezier(.6, .1, .3, 1);
  /* z-index managed by parent .envelope-flap-clip */
  filter: drop-shadow(0 6px 10px rgba(91, 42, 51, .25));
}

/* Seal — glow kilau elegan */
.seal {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, var(--gold-light), var(--gold) 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-script);
  font-size: 1.5rem;
  color: var(--wine);
  cursor: pointer;
  z-index: 5;
  transition: transform .5s ease, opacity .5s ease;
  animation: sealGlow 2.4s ease-in-out infinite;
}

@keyframes sealGlow {

  0%,
  100% {
    box-shadow:
      0 3px 8px rgba(0, 0, 0, .28),
      0 0 0 0 rgba(198, 161, 91, .45),
      0 0 12px 0 rgba(198, 161, 91, 0);
  }

  50% {
    box-shadow:
      0 3px 8px rgba(0, 0, 0, .28),
      0 0 0 12px rgba(198, 161, 91, 0),
      0 0 28px 8px rgba(198, 161, 91, .38);
  }
}

.letter-card {
  position: absolute;
  bottom: 8px;
  left: 50%;
  width: 82%;
  transform: translate(-50%, 0px);
  /* resting at bottom of envelope */
  background: var(--cream);
  border: 1px solid var(--gold-light);
  border-radius: 4px;
  padding: 1rem .8rem;
  opacity: 0;
  z-index: 2;
  transition: transform 1s .5s cubic-bezier(.2, .7, .3, 1), opacity 1s .5s;
  font-family: var(--font-display);
  font-size: .82rem;
  color: var(--rose-deep);
  text-align: center;
}

/* Flap folds into itself (clipped by .envelope-flap-clip wrapper) */
.envelope-wrap.open .envelope-flap {
  transform: rotateX(180deg);
}

.envelope-wrap.open .seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(.3) rotate(25deg);
  animation: none;
}

/* Letter card slides up to be visible inside the open envelope body */
.envelope-wrap.open .letter-card {
  transform: translate(-50%, -72px);
  opacity: 1;
}

.tap-hint {
  font-size: .8rem;
  letter-spacing: .1em;
  color: var(--rose-deep);
  font-style: italic;
  animation: hintFade 2.4s ease-in-out infinite;
  transition: opacity .6s ease;
}

@keyframes hintFade {

  0%,
  100% {
    opacity: .5;
  }

  50% {
    opacity: 1;
  }
}

.reveal-message {
  margin-top: 2rem;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 1s .9s, transform 1s .9s;
}

.envelope-wrap.open~.reveal-message {
  opacity: 1;
  transform: translateY(0);
}

.reveal-message .headline {
  font-family: var(--font-display);
  font-weight: 600;
  font-style: italic;
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  color: var(--wine);
  margin-bottom: .3rem;
}

.reveal-message .name-script {
  font-family: var(--font-script);
  font-size: clamp(3rem, 10vw, 5rem);
  color: var(--rose-deep);
  line-height: 1;
  margin: .4rem 0;
}

.scroll-cue {
  margin-top: 2.2rem;
  font-size: .75rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--rose-deep);
  cursor: pointer;
}

.scroll-cue span {
  display: block;
  margin-top: .4rem;
  animation: bob 1.8s ease-in-out infinite;
}

@keyframes bob {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(6px);
  }
}

/* ---------- Section shared ---------- */
.section-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 6rem 1.5rem;
}

.section-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  text-align: center;
  margin: .4rem 0 3rem;
}

.divider {
  width: 70px;
  height: 1px;
  background: var(--gold);
  margin: 1rem auto 0;
  position: relative;
}

.divider::after {
  content: '\276E';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--cream);
  color: var(--gold);
  font-size: .7rem;
  padding: 0 .4rem;
}

/* ============================================
   CALENDAR — Birthday Date Highlight
   ============================================ */
#calendar {
  background: linear-gradient(180deg, var(--blush) 0%, var(--cream) 100%);
}

.calendar-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 4.5vw, 2.3rem);
  color: var(--wine);
  margin-top: .4rem;
  margin-bottom: 2.8rem;
}

.calendar-card-wrap {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.calendar-month-script {
  position: absolute;
  top: -36px;
  right: -8px;
  font-family: var(--font-script);
  font-size: clamp(3.2rem, 9vw, 4.2rem);
  color: var(--wine);
  z-index: 10;
  transform: rotate(-7deg);
  text-shadow: 2px 2px 0px var(--cream), 0 0 14px var(--gold-light);
  pointer-events: none;
}

.calendar-card {
  background: linear-gradient(145deg, var(--wine) 0%, #3e1c23 100%);
  color: var(--cream);
  border-radius: 28px;
  padding: 2.6rem 1.6rem 2.2rem;
  box-shadow: 0 20px 45px -12px rgba(91, 42, 51, 0.45);
  border: 1.5px solid var(--gold);
  position: relative;
  overflow: hidden;
}

.calendar-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
  opacity: 0.8;
}

.calendar-days-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--gold-light);
  margin-bottom: 1.3rem;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 0.8rem;
  column-gap: 0.2rem;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  align-items: center;
  justify-items: center;
  color: var(--cream);
}

.calendar-grid span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
}

.calendar-grid span.empty {
  pointer-events: none;
}

.calendar-grid span.birthday-date {
  position: relative;
  overflow: visible;
}

.heart-badge {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wine) !important;
  font-weight: 800;
  font-size: 1rem;
  z-index: 2;
  animation: heartPulse 2.2s ease-in-out infinite;
}

.heart-badge::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23fffaf5'%3E%3Cpath d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E") center / contain no-repeat;
  z-index: -1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

@keyframes heartPulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.12);
  }
}

/* ============================================
   GALLERY — Stacked Card Style
   ============================================ */
#gallery {
  background: var(--cream);
}

/* Outer wrapper — centers the stack */
.card-stack-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.8rem;
  padding: 1rem 0 2.5rem;
  user-select: none;
  -webkit-user-select: none;
}

/* The stack container — sized to the top card */
.card-stack {
  position: relative;
  width: 240px;
  height: 295px;
  /* 240 × 1.18 ≈ 283px + room for tilt */
  margin: 0 auto;
  cursor: grab;
}

.card-stack.is-dragging {
  cursor: grabbing;
}

/* Individual polaroid photo frame */
.photo-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 240px;
  aspect-ratio: 1 / 1.18;
  background: var(--blush);
  border: 10px solid #fff;
  border-bottom-width: 38px;
  /* thick polaroid bottom */
  box-shadow: 0 14px 30px -10px rgba(91, 42, 51, .35);
  overflow: hidden;
  transform-origin: center 110%;
  /* rotate from below center for natural stack feel */
  transition:
    transform 0.55s cubic-bezier(.4, 0, .2, 1),
    opacity 0.45s ease,
    box-shadow 0.3s ease;
  will-change: transform, opacity;
  touch-action: none;
}

/* Active top card gets pointer events */
.photo-frame.stack-pos-0 {
  cursor: grab;
  box-shadow: 0 20px 40px -10px rgba(91, 42, 51, .45);
}

.photo-frame.stack-pos-0:active {
  cursor: grabbing;
}

/* Fly-out animation classes (added by JS on swipe) */
.photo-frame.fly-left {
  transform: translateX(-130%) rotate(-22deg) scale(0.9) !important;
  opacity: 0 !important;
  transition: transform 0.45s cubic-bezier(.4, 0, .6, 1), opacity 0.35s ease !important;
}

.photo-frame.fly-right {
  transform: translateX(130%) rotate(22deg) scale(0.9) !important;
  opacity: 0 !important;
  transition: transform 0.45s cubic-bezier(.4, 0, .6, 1), opacity 0.35s ease !important;
}

.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.photo-frame.no-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(150deg, var(--blush-deep), var(--gold-light));
  color: var(--wine);
  text-align: center;
  padding: 1rem;
}

.photo-frame.no-photo .no-photo-heart {
  font-size: 2.2rem;
  color: var(--rose-deep);
  opacity: .85;
  margin-bottom: 0.4rem;
}

.photo-frame.no-photo .no-photo-text {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-style: italic;
  color: var(--wine);
  opacity: 0.85;
  letter-spacing: 0.05em;
}

.photo-caption {
  position: absolute;
  bottom: -32px;
  left: 0;
  width: 100%;
  text-align: center;
  font-family: var(--font-script);
  font-size: 1.15rem;
  color: var(--wine);
  pointer-events: none;
  line-height: 1;
}

/* Numeric Counter */
.stack-counter {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  color: var(--rose-deep);
  margin-top: 0.2rem;
}

/* Dot indicators */
.stack-dots {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 280px;
  margin: 0 auto;
}

.stack-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  padding: 6px;
  /* expands touch area for mobile */
  border-radius: 50%;
  background: var(--blush-deep);
  border: 1.5px solid var(--rose);
  background-clip: content-box;
  box-sizing: content-box;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
}

.stack-dot:hover {
  border-color: var(--gold);
  transform: scale(1.2);
}

.stack-dot.active {
  background: var(--gold);
  border-color: var(--gold);
  transform: scale(1.4);
}

/* Swipe hint text */
.stack-hint {
  font-family: var(--font-body);
  font-style: italic;
  font-size: .75rem;
  letter-spacing: .08em;
  color: var(--rose-deep);
  opacity: .6;
  text-align: center;
}

@media (max-width: 640px) {
  .card-stack {
    width: 200px;
    height: 246px;
  }

  .photo-frame {
    width: 200px;
  }

  .photo-caption {
    font-size: 1rem;
    bottom: -28px;
  }
}


/* ============================================
   LETTER — "Unfold" animation on scroll
   ============================================ */
#letter {
  background: var(--blush);
}

.letter-paper {
  background: var(--cream);
  border: 1px solid var(--gold-light);
  box-shadow: 0 20px 50px -20px rgba(91, 42, 51, .35);
  padding: 3rem 2.4rem;
  border-radius: 2px;
  /* Unfold: starts as a thin sliver — IO can still detect it at threshold:0 */
  transform-origin: top center;
  transform: scaleY(0.05);
  opacity: 0;
  /* Do NOT use max-height:0 — it makes element undetectable by IO */
  overflow: hidden;
  transition:
    transform 1.0s cubic-bezier(.22, .8, .3, 1),
    opacity .8s ease .15s;
}

.letter-paper.visible {
  transform: scaleY(1);
  opacity: 1;
}

.letter-paper p {
  font-family: var(--font-body);
  font-size: 1.02rem;
  line-height: 1.9;
  margin-bottom: 1.3rem;
}

.letter-paper .placeholder-note {
  color: var(--rose-deep);
  font-style: italic;
  font-size: .92rem;
}

.signature {
  font-family: var(--font-script);
  font-size: 2rem;
  color: var(--rose-deep);
  margin-top: 1.5rem;
  text-align: right;
}

@media (max-width: 640px) {
  .letter-paper {
    padding: 2rem 1.3rem;
  }
}

/* ============================================
   CLOSING — floating mini hearts
   ============================================ */
#closing {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5rem 1.5rem;
  background: linear-gradient(180deg, var(--cream), var(--blush));
  position: relative;
  overflow: hidden;
}

#closing .name-script {
  font-family: var(--font-script);
  font-size: clamp(2.6rem, 8vw, 4rem);
  color: var(--rose-deep);
  margin: .6rem 0 1.4rem;
}

#closing>p {
  max-width: 460px;
  font-size: .95rem;
  color: var(--wine);
  opacity: .8;
  position: relative;
  z-index: 2;
}

#closing .eyebrow,
#closing .headline {
  position: relative;
  z-index: 2;
}

#closing .name-script {
  position: relative;
  z-index: 2;
}

/* Floating hearts */
.floating-heart {
  position: absolute;
  font-size: .9rem;
  color: var(--rose);
  opacity: 0;
  pointer-events: none;
  animation: floatHeart linear forwards;
  will-change: transform, opacity;
  z-index: 1;
}

@keyframes floatHeart {
  0% {
    transform: translateY(0) scale(1) rotate(0deg);
    opacity: 0;
  }

  8% {
    opacity: .7;
  }

  88% {
    opacity: .45;
  }

  100% {
    transform: translateY(-72vh) scale(1.2) rotate(18deg);
    opacity: 0;
  }
}

footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: .72rem;
  letter-spacing: .08em;
  color: var(--rose-deep);
  opacity: .6;
}

/* ============================================
   ACCESSIBILITY — prefers-reduced-motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {

  .petal,
  .seal,
  .tap-hint,
  .scroll-cue span,
  .floating-heart {
    animation: none !important;
  }

  .letter-paper {
    transform: none !important;
    transition: opacity .3s ease !important;
  }

  * {
    transition-duration: .2s !important;
  }
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}