/* ── Variables ── */
:root {
  --cream: #fdfbf7;
  --olive: #6b7c5e;
  --olive-light: #8a9e7a;
  --burgundy: #722f37;
  --brown: #5c4033;
  --gold: #d4af37;
  --pink: #e8a0b4;
  --blue-muted: #8faabe;
  --pink-muted: #d4a0ac;
  --font-heading: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Montserrat', 'Helvetica Neue', sans-serif;
}

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--brown);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* ── Phase 1: Poll ── */
#poll-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  animation: fadeIn 0.8s ease;
}

.poll-content {
  text-align: center;
  max-width: 500px;
}

#poll-screen h1 {
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 600;
  color: var(--brown);
  margin-bottom: 1.5rem;
  letter-spacing: 0.02em;
}

.quran-verse {
  margin: 0 auto 2rem;
  padding: 0 1rem;
  max-width: 420px;
  border: none;
}

.quran-verse .arabic {
  font-size: clamp(1.3rem, 3.5vw, 1.7rem);
  line-height: 1.8;
  color: var(--brown);
  margin-bottom: 0.75rem;
}

.quran-verse .translation {
  font-family: var(--font-heading);
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  font-style: italic;
  line-height: 1.6;
  color: var(--olive);
  margin-bottom: 0.5rem;
}

.quran-verse cite {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-style: normal;
  color: var(--gold);
  letter-spacing: 0.05em;
}

.subtitle {
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-style: italic;
  color: var(--olive);
  margin-bottom: 2.5rem;
  font-weight: 400;
}

.poll-buttons {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.vote-btn {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  padding: 1rem 3rem;
  border: 2px solid;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.05em;
  min-width: 150px;
}

.boy-btn {
  background: transparent;
  border-color: var(--blue-muted);
  color: var(--blue-muted);
}

.boy-btn:hover {
  background: var(--blue-muted);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(143, 170, 190, 0.4);
}

.girl-btn {
  background: transparent;
  border-color: var(--pink-muted);
  color: var(--pink-muted);
}

.girl-btn:hover {
  background: var(--pink-muted);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(212, 160, 172, 0.4);
}

/* ── Phase 2: Envelope ── */
#envelope-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  animation: fadeIn 0.8s ease;
}

.envelope-wrapper {
  text-align: center;
  cursor: pointer;
}

.envelope {
  position: relative;
  width: min(360px, 80vw);
  height: min(240px, 53vw);
  margin: 0 auto 2rem;
  perspective: 800px;
}

.envelope-back {
  position: absolute;
  inset: 0;
  background: var(--olive);
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 55%;
  background: var(--olive-light);
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  transform-origin: top center;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 3;
}

.envelope.opening .envelope-flap {
  transform: rotateX(180deg);
}

.envelope-front {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60%;
  background: var(--olive);
  border-radius: 0 0 4px 4px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wax-seal {
  width: 56px;
  height: 56px;
  background: var(--burgundy);
  border-radius: 50%;
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.2),
    0 2px 8px rgba(0, 0, 0, 0.3);
  position: relative;
  margin-top: -16px;
}

.wax-seal::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
}

.cta {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-style: italic;
  color: var(--olive);
  animation: pulse 2s ease-in-out infinite;
}

/* ── Phase 3-5: Reveal Screen ── */
#reveal-screen {
  min-height: 100vh;
  padding: 3rem 1.5rem;
  animation: fadeIn 0.6s ease;
}

/* Reveal Header */
.reveal-header {
  text-align: center;
  margin-bottom: 1.5rem;
  animation: revealIn 1s ease;
}

.reveal-header h2 {
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-weight: 700;
  color: var(--pink);
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

/* Poll Results */
.poll-results {
  max-width: 400px;
  margin: 0 auto 2.5rem;
  animation: revealIn 1s ease 0.3s both;
}

.result-bar {
  display: flex;
  height: 40px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.result-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 1s ease;
  min-width: 0;
}

.result-label {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  padding: 0 0.75rem;
}

.boy-segment {
  background: var(--blue-muted);
}

.girl-segment {
  background: var(--pink-muted);
}

/* Collage Grid */
.collage {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  max-width: 1000px;
  margin: 0 auto 3rem;
  padding: 0 1rem;
}

/* Polaroid Cards */
.polaroid {
  background: #fff;
  padding: 0.75rem 0.75rem 2.5rem;
  border-radius: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transform: rotate(calc((var(--i) - 3.5) * 1.2deg));
  transition: transform 0.3s ease;
  opacity: 0;
  animation: cascadeIn 0.6s ease forwards;
  animation-delay: calc(var(--i) * 0.1s);
}

.polaroid:hover {
  transform: rotate(0deg) translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.polaroid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  filter: grayscale(100%);
  transition: filter 1.5s ease;
}

.color-revealed .polaroid img {
  filter: grayscale(0%);
}

.color-revealed .polaroid:nth-child(1) img { transition-delay: 0s; }
.color-revealed .polaroid:nth-child(2) img { transition-delay: 0.15s; }
.color-revealed .polaroid:nth-child(3) img { transition-delay: 0.3s; }
.color-revealed .polaroid:nth-child(4) img { transition-delay: 0.45s; }
/* video-card is child 5, skip */
.color-revealed .polaroid:nth-child(6) img { transition-delay: 0.6s; }
.color-revealed .polaroid:nth-child(7) img { transition-delay: 0.75s; }
.color-revealed .polaroid:nth-child(8) img { transition-delay: 0.9s; }
.color-revealed .polaroid:nth-child(9) img { transition-delay: 1.05s; }

/* Video Card */
.video-card {
  position: relative;
  background: #fff;
  padding: 0.75rem;
  border-radius: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  opacity: 0;
  animation: cascadeIn 0.6s ease forwards;
  animation-delay: 0.4s;
}

.video-card video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  border-radius: 1px;
  background: #000;
}

.play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
  z-index: 2;
}

.play-btn:hover {
  transform: translate(-50%, -50%) scale(1.1);
}

.rewatch-btn {
  display: block;
  margin: 0.75rem auto 0;
  padding: 0.5rem 1.5rem;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--olive);
  background: transparent;
  border: 2px solid var(--olive);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.rewatch-btn:hover {
  background: var(--olive);
  color: #fff;
}

/* Registry Link */
.registry-link {
  text-align: center;
  margin-bottom: 3rem;
  animation: revealIn 0.8s ease;
}

.registry-link a {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  color: #fff;
  background: var(--burgundy);
  padding: 0.85rem 2.5rem;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.3s ease;
  letter-spacing: 0.03em;
}

.registry-link a:hover {
  background: var(--brown);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes revealIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cascadeIn {
  from {
    opacity: 0;
    transform: translateY(-40px) rotate(calc((var(--i, 0) - 3.5) * 1.2deg)) scale(0.9);
  }
  to {
    opacity: 1;
    transform: rotate(calc((var(--i, 0) - 3.5) * 1.2deg)) scale(1);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .collage {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .video-card {
    grid-column: span 2;
  }

  .polaroid {
    padding: 0.5rem 0.5rem 1.75rem;
  }
}

@media (max-width: 480px) {
  .collage {
    grid-template-columns: 1fr;
    gap: 1rem;
    max-width: 360px;
  }

  .video-card {
    grid-column: span 1;
  }

  .poll-buttons {
    flex-direction: column;
    align-items: center;
  }

  .vote-btn {
    width: 100%;
    max-width: 240px;
  }

  .polaroid {
    transform: rotate(0deg);
  }
}
