:root {
  --night: #1a1b3a;
  --night-deep: #10112b;
  --plum: #3b2a52;
  --lavender: #9b87c9;
  --lavender-soft: #c9bce3;
  --gold: #e7b75f;
  --coral: #e38b76;
  --cream: #f6f1e7;
  --cream-dim: rgba(246, 241, 231, 0.72);

  --font-display: "Fraunces", serif;
  --font-body: "Work Sans", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at 20% 0%, var(--plum) 0%, var(--night) 45%, var(--night-deep) 100%);
  color: var(--cream);
  font-family: var(--font-body);
  overflow-x: hidden;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  pointer-events: none;
  display: none;
}

/* ---------- Chapitres (progression) ---------- */
.chapters {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 20;
}

.chapter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(246, 241, 231, 0.25);
  transition: background 0.4s ease, transform 0.4s ease;
}

.chapter-dot.done {
  background: var(--gold);
}

.chapter-dot.current {
  background: var(--coral);
  transform: scale(1.4);
}

/* ---------- Layout ---------- */
#app {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 100px 24px 64px;
}

.scene {
  display: none;
  max-width: 640px;
  width: 100%;
  text-align: center;
  animation: rise 0.7s ease both;
}

.scene.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

.eyebrow {
  font-family: var(--font-body);
  font-size: 0.8rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--lavender-soft);
  margin: 0 0 14px;
}

.scene-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.9rem, 4.6vw, 3.1rem);
  line-height: 1.15;
  margin: 0 0 20px;
  color: var(--cream);
}

.scene-title .dot {
  color: var(--coral);
}

.scene-text {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--cream-dim);
  margin: 0 0 14px;
  max-width: 520px;
}

.scene-text strong {
  color: var(--gold);
  font-weight: 600;
}

/* ---------- Boutons ---------- */
.btn-next, .btn-replay {
  margin-top: 32px;
  padding: 14px 30px;
  border-radius: 999px;
  border: 1px solid rgba(231, 183, 95, 0.5);
  background: transparent;
  color: var(--gold);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.btn-next:hover, .btn-replay:hover {
  background: var(--gold);
  color: var(--night-deep);
  transform: translateY(-2px);
}

.btn-next:focus-visible, .btn-replay:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 3px;
}

/* ---------- Compte à rebours ---------- */
.countdown {
  display: flex;
  gap: 20px;
  margin: 28px 0 8px;
}

.countdown-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 76px;
  padding: 14px 10px;
  background: rgba(246, 241, 231, 0.06);
  border: 1px solid rgba(246, 241, 231, 0.12);
  border-radius: 14px;
}

.countdown-number {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
}

.countdown-label {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream-dim);
  margin-top: 6px;
}

.countdown-final .countdown-unit {
  border-color: rgba(227, 139, 118, 0.4);
}
.countdown-final .countdown-number {
  color: var(--coral);
}

/* ---------- Badges (Chapitre II) ---------- */
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}

.badge {
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(155, 135, 201, 0.15);
  border: 1px solid rgba(155, 135, 201, 0.35);
  font-size: 0.9rem;
  color: var(--lavender-soft);
}

/* ---------- Polaroid (Chapitre III) ---------- */
.polaroid {
  margin-top: 26px;
  background: var(--cream);
  padding: 16px 16px 22px;
  border-radius: 6px;
  box-shadow: 0 20px 45px rgba(0,0,0,0.35);
  transform: rotate(-2deg);
  transition: transform 0.4s ease;
}

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

.polaroid-photo {
  width: min(320px, 70vw);
  aspect-ratio: 4 / 5;
  background: #d8d2c4;
  position: relative;
  overflow: hidden;
  border-radius: 2px;
}

.polaroid-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-placeholder {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: #7d7460;
  font-size: 0.82rem;
  text-align: center;
  padding: 12px;
}

.polaroid-photo.photo-missing .photo-placeholder {
  display: flex;
}
.polaroid-photo.photo-missing img {
  display: none;
}

.photo-placeholder span {
  font-size: 2rem;
}

.photo-placeholder code {
  background: rgba(0,0,0,0.06);
  padding: 2px 6px;
  border-radius: 4px;
}

.polaroid-caption {
  font-family: var(--font-display);
  font-style: italic;
  color: #3a3428;
  margin: 14px 4px 2px;
  font-size: 0.95rem;
}

/* ---------- Carte (Chapitre IV) ---------- */
.map-wrap {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin-top: 24px;
}

.route-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

#route-path {
  stroke-dashoffset: 620;
  animation: draw-route 2.4s ease forwards 0.3s;
}

@keyframes draw-route {
  to { stroke-dashoffset: 0; }
}

#van-marker {
  offset-path: path('M 90 70 C 220 40, 280 190, 500 190');
  offset-rotate: 0deg;
  animation: drive 2.4s ease forwards 0.3s;
  opacity: 0;
}

@keyframes drive {
  0% { offset-distance: 0%; opacity: 1; }
  95% { opacity: 1; }
  100% { offset-distance: 100%; opacity: 1; }
}

.map-label {
  position: absolute;
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--cream-dim);
  top: 2%;
}

.map-label-start { left: 8%; }
.map-label-end { right: 10%; top: 76%; }

/* ---------- Révélation (Chapitre V) ---------- */
.baby-icon {
  font-size: 3rem;
  margin: 6px 0 4px;
  animation: pop-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both 0.2s;
}

@keyframes pop-in {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.reveal-sub {
  font-size: 1.2rem;
  color: var(--cream);
}

.final-note {
  margin-top: 22px;
  font-style: italic;
  color: var(--lavender-soft);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  #app { padding: 88px 18px 56px; }
  .countdown { gap: 12px; }
  .countdown-unit { min-width: 64px; padding: 10px 6px; }
  .map-label-end { right: 4%; }
  .map-label-start { left: 2%; }
}

@media (prefers-reduced-motion: reduce) {
  .scene, #route-path, #van-marker, .baby-icon {
    animation: none !important;
  }
  #route-path { stroke-dashoffset: 0; }
  #van-marker { offset-distance: 100%; opacity: 1; }
}
