/* =========================================================
   A Little Surprise — stylesheet
   Palette: warm cream, soft pink, charcoal/brown, subtle gold
   Mobile-first, system font stack (fully offline)
   ========================================================= */

:root {
  --cream:      #fdf6ef;
  --cream-2:    #f7ebe0;
  --pink:       #e9b7b0;
  --pink-soft:  #f6dfda;
  --pink-deep:  #d98b83;
  --gold:       #c9a86a;
  --gold-soft:  #e7d3a8;
  --ink:        #3a2f2a;
  --ink-soft:   #6b5d54;
  --charcoal:   #2a2622;
  --white:      #fffdfb;

  --shadow-sm: 0 4px 16px rgba(90, 60, 45, 0.08);
  --shadow-md: 0 12px 40px rgba(90, 60, 45, 0.12);
  --shadow-lg: 0 24px 70px rgba(90, 60, 45, 0.18);

  --radius:    22px;
  --radius-lg: 30px;

  --ease:      cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;

  --maxw: 640px;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

/* The [hidden] attribute must always win over display rules below
   (.modal, .music-toggle, .progress-rail all set display). */
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.65;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- focus ---------- */
:focus-visible {
  outline: 3px solid var(--pink-deep);
  outline-offset: 3px;
  border-radius: 6px;
}

/* =========================================================
   Background wash
   ========================================================= */
#app {
  position: relative;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--pink-soft) 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 100%, #f3e6d6 0%, transparent 55%),
    var(--cream);
  background-attachment: fixed;
}

/* =========================================================
   Scenes
   ========================================================= */
.scene {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(2rem, 8vh, 6rem) clamp(1.2rem, 5vw, 2.5rem);
  align-items: center;
  justify-content: center;
  position: relative;
}
.scene.is-active { display: flex; }

.scene__inner {
  width: 100%;
  max-width: var(--maxw);
  text-align: center;
  animation: sceneIn 0.9s var(--ease) both;
}
.scene__inner--wide { max-width: 1000px; }

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

.scene__eyebrow {
  font-size: 0.82rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 0.9rem;
}

.scene__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.7rem, 5.5vw, 2.8rem);
  line-height: 1.2;
  color: var(--charcoal);
  margin-bottom: 1.6rem;
  letter-spacing: -0.01em;
}

.scene__advance {
  margin-top: 2.6rem;
}

/* =========================================================
   Cards & buttons
   ========================================================= */
.card {
  background: var(--white);
  border: 1px solid rgba(201, 168, 106, 0.18);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: clamp(1.8rem, 6vw, 3rem);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.95em 1.8em;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }

.btn--primary {
  background: linear-gradient(135deg, var(--pink) 0%, var(--pink-deep) 100%);
  color: #fff;
  box-shadow: 0 10px 28px rgba(217, 139, 131, 0.4);
}
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(217, 139, 131, 0.48); }

.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid rgba(106, 93, 84, 0.25);
  font-weight: 500;
}
.btn--ghost:hover { background: rgba(255,255,255,0.6); color: var(--ink); }

/* =========================================================
   1. Opening
   ========================================================= */
.scene--opening {
  background:
    radial-gradient(1000px 700px at 50% 20%, #fbe8e2 0%, transparent 65%),
    linear-gradient(180deg, var(--cream) 0%, var(--cream-2) 100%);
}
.opening__inner { max-width: 560px; }

.opening__eyebrow {
  font-family: var(--serif);
  font-size: clamp(1.1rem, 4vw, 1.4rem);
  color: var(--pink-deep);
  margin-bottom: 1rem;
  font-style: italic;
}
.opening__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 7vw, 3.4rem);
  line-height: 1.15;
  color: var(--charcoal);
  letter-spacing: -0.015em;
  margin-bottom: 1.2rem;
}
.opening__sub {
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin-bottom: 2.4rem;
}

/* particles */
.particles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.particle {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(233,183,176,0.9) 0%, rgba(233,183,176,0) 70%);
  opacity: 0;
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  0%   { transform: translateY(20px) scale(0.6); opacity: 0; }
  10%  { opacity: 0.7; }
  90%  { opacity: 0.5; }
  100% { transform: translateY(-110vh) scale(1.1); opacity: 0; }
}

/* reveal on enter */
.reveal { opacity: 0; transform: translateY(18px); }
.reveal.in {
  animation: revealIn 0.85s var(--ease) forwards;
}
.reveal[data-delay="0"].in { animation-delay: 0.05s; }
.reveal[data-delay="1"].in { animation-delay: 0.35s; }
.reveal[data-delay="2"].in { animation-delay: 0.65s; }
.reveal[data-delay="3"].in { animation-delay: 0.95s; }
@keyframes revealIn { to { opacity: 1; transform: none; } }

/* =========================================================
   2. Secret question
   ========================================================= */
.secret__card { max-width: 500px; margin: 0 auto; }
.secret__form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 1.4rem;
}
.secret__input {
  font-family: inherit;
  font-size: 1.05rem;
  padding: 0.95em 1.2em;
  border-radius: 16px;
  border: 1.5px solid rgba(201,168,106,0.35);
  background: var(--cream);
  color: var(--ink);
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.secret__input:focus {
  outline: none;
  border-color: var(--pink-deep);
  box-shadow: 0 0 0 4px rgba(217,139,131,0.15);
}
.secret__hint {
  min-height: 1.4rem;
  margin-top: 1rem;
  font-size: 0.95rem;
  color: var(--pink-deep);
  transition: opacity 0.2s;
}
.secret__hint.success { color: #4b9b7a; }
.shake { animation: shake 0.4s var(--ease-soft); }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* =========================================================
   3. Slideshow
   ========================================================= */
.slideshow { margin: 1.5rem auto 0; max-width: 560px; }
.slideshow__stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: var(--cream-2);
  touch-action: pan-y;
}
.slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1s var(--ease);
  display: flex;
  align-items: flex-end;
}
.slide.is-current { opacity: 1; z-index: 2; }
.slide img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.slide.is-current img { animation: kenburns 6s ease-out both; }
@keyframes kenburns {
  from { transform: scale(1.08); }
  to   { transform: scale(1); }
}
.slide__caption {
  position: relative;
  z-index: 3;
  width: 100%;
  padding: 2.2rem 1.4rem 1.3rem;
  color: #fff;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.02rem;
  text-align: center;
  background: linear-gradient(180deg, transparent 0%, rgba(42,38,34,0.72) 100%);
}
.slide__fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); font-size: 2.4rem;
  background: linear-gradient(135deg, var(--pink-soft), var(--cream-2));
}

.slideshow__progress {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 1.1rem 0 0.4rem;
  flex-wrap: wrap;
}
.dot {
  width: 26px; height: 4px;
  border-radius: 4px;
  background: rgba(201,168,106,0.3);
  overflow: hidden;
  position: relative;
}
.dot.active { background: rgba(201,168,106,0.35); }
.dot .fill {
  position: absolute; inset: 0;
  width: 0;
  background: var(--pink-deep);
  border-radius: 4px;
}
.dot.active .fill.run { animation: fillbar linear forwards; }
@keyframes fillbar { from { width: 0; } to { width: 100%; } }
.dot.done .fill { width: 100%; }

.slideshow__controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 0.9rem;
}
.round-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(201,168,106,0.3);
  background: var(--white);
  color: var(--ink);
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, background 0.2s;
}
.round-btn svg { width: 22px; height: 22px; }
.round-btn:hover { transform: translateY(-2px); background: var(--pink-soft); }
.round-btn .ico-play { display: none; }
.round-btn.paused .ico-pause { display: none; }
.round-btn.paused .ico-play { display: block; }

/* =========================================================
   4. Timeline
   ========================================================= */
.timeline {
  list-style: none;
  position: relative;
  margin: 2rem auto 0;
  max-width: 900px;
  padding: 1rem 0;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, transparent, var(--gold-soft) 8%, var(--gold-soft) 92%, transparent);
}
.tl-item {
  position: relative;
  padding: 0 0 2.6rem 3.4rem;
  opacity: 0;
  transform: translateY(26px);
}
.tl-item.in { animation: tlIn 0.8s var(--ease) forwards; }
@keyframes tlIn { to { opacity: 1; transform: none; } }
.tl-node {
  position: absolute;
  left: 10px; top: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--white);
  border: 3px solid var(--pink);
  box-shadow: 0 0 0 4px rgba(246,223,218,0.6);
  z-index: 2;
}
.tl-item.in .tl-node { animation: nodePop 0.5s var(--ease) 0.15s both; }
@keyframes nodePop { from { transform: scale(0); } to { transform: scale(1); } }

.tl-date {
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.tl-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  color: var(--charcoal);
  margin-bottom: 0.4rem;
  font-weight: 500;
}
.tl-desc { color: var(--ink-soft); font-size: 1rem; }
.tl-photos {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}
.tl-photos img {
  width: 100px; height: 100px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transform: scale(0.96);
  transition: transform 0.5s var(--ease);
}
.tl-item.in .tl-photos img { transform: scale(1); }
.tl-item.in .tl-photos img:hover { transform: scale(1.04); }

.tl-item--birthday .tl-node {
  border-color: var(--gold);
  background: var(--gold-soft);
  box-shadow: 0 0 0 5px rgba(231,211,168,0.5), 0 0 18px rgba(201,168,106,0.6);
}
.tl-item--birthday .tl-title { color: var(--pink-deep); }

/* Desktop: alternating layout */
@media (min-width: 780px) {
  .timeline::before { left: 50%; transform: translateX(-1px); }
  .tl-item {
    width: 50%;
    padding: 0 3rem 3rem 3rem;
    text-align: right;
  }
  .tl-item:nth-child(odd) {
    left: 0;
  }
  .tl-item:nth-child(even) {
    left: 50%;
    text-align: left;
  }
  .tl-node { left: auto; }
  .tl-item:nth-child(odd) .tl-node { right: -9px; left: auto; }
  .tl-item:nth-child(even) .tl-node { left: -9px; }
  .tl-item:nth-child(odd) .tl-photos { justify-content: flex-end; }
}

/* =========================================================
   5. Letter
   ========================================================= */
.letter__card { max-width: 560px; margin: 0 auto; }
.letter__paper {
  margin-top: 1.8rem;
  padding: 1.8rem 1.5rem;
  background:
    linear-gradient(180deg, #fffdf8, #fbf3e8);
  border: 1px solid rgba(201,168,106,0.25);
  border-radius: 18px;
  box-shadow: inset 0 0 40px rgba(201,168,106,0.08);
  text-align: left;
}
.letter__text {
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.9;
  color: var(--ink);
  white-space: pre-wrap;
  min-height: 3rem;
}
.letter__text .cursor {
  display: inline-block;
  width: 2px;
  background: var(--pink-deep);
  animation: blink 0.9s steps(1) infinite;
  margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* =========================================================
   6. Video
   ========================================================= */
.video-wrap {
  margin: 1.5rem auto 0;
  max-width: 640px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: #000;
}
.video-wrap video { width: 100%; display: block; border-radius: var(--radius); }
.video-missing {
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 2rem;
  text-align: center;
  color: var(--ink-soft);
  background: linear-gradient(135deg, var(--pink-soft), var(--cream-2));
}
.video-missing .vm-icon { font-size: 2.6rem; }
.video-missing code {
  font-size: 0.85rem;
  background: rgba(255,255,255,0.6);
  padding: 0.2em 0.5em;
  border-radius: 6px;
  color: var(--ink);
}

/* =========================================================
   7. Final reveal
   ========================================================= */
.scene--final {
  background:
    radial-gradient(900px 700px at 50% 30%, #f7ddd6 0%, transparent 60%),
    linear-gradient(180deg, #fbeee7 0%, #f3e0d1 100%);
  overflow: hidden;
}
.final__glow {
  position: absolute;
  width: 130vmax; height: 130vmax;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(233,183,176,0.5) 0%, transparent 55%);
  animation: pulseGlow 6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pulseGlow {
  0%,100% { opacity: 0.55; transform: translate(-50%,-50%) scale(1); }
  50% { opacity: 0.85; transform: translate(-50%,-50%) scale(1.06); }
}
.confetti { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.hearts { position: absolute; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; }
.floating-heart {
  position: absolute;
  bottom: -40px;
  font-size: 1.2rem;
  opacity: 0;
  animation: heartRise linear forwards;
}
@keyframes heartRise {
  0% { transform: translateY(0) scale(0.7); opacity: 0; }
  15% { opacity: 0.85; }
  100% { transform: translateY(-108vh) scale(1.1); opacity: 0; }
}

.final__inner { position: relative; z-index: 3; max-width: 560px; }
.final__photo {
  width: 130px; height: 130px;
  margin: 0 auto 1.6rem;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 4px solid #fff;
  box-shadow: var(--shadow-md);
}
.final__photo.empty { display: none; }
.final__pre {
  font-family: var(--serif);
  font-style: italic;
  color: var(--pink-deep);
  font-size: 1.1rem;
  margin-bottom: 0.8rem;
}
.final__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.2rem, 9vw, 3.8rem);
  line-height: 1.12;
  color: var(--charcoal);
  margin-bottom: 1.2rem;
  letter-spacing: -0.015em;
}
.final__msg {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.15rem;
  margin-bottom: 2.4rem;
}

/* =========================================================
   Music control
   ========================================================= */
.music-toggle {
  position: fixed;
  bottom: max(1.1rem, env(safe-area-inset-bottom));
  right: 1.1rem;
  z-index: 60;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(201,168,106,0.3);
  background: var(--white);
  box-shadow: var(--shadow-md);
  display: grid; place-items: center;
  transition: transform 0.2s, background 0.2s;
}
.music-toggle:hover { transform: translateY(-2px); background: var(--pink-soft); }
.music-icon {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 20px;
}
.music-icon .bar {
  width: 3px;
  height: 6px;
  background: var(--pink-deep);
  border-radius: 2px;
}
.music-toggle.playing .music-icon .bar { animation: eq 0.9s ease-in-out infinite; }
.music-icon .bar:nth-child(1) { animation-delay: 0s; }
.music-icon .bar:nth-child(2) { animation-delay: 0.2s; }
.music-icon .bar:nth-child(3) { animation-delay: 0.4s; }
.music-icon .bar:nth-child(4) { animation-delay: 0.15s; }
@keyframes eq {
  0%,100% { height: 6px; }
  50% { height: 18px; }
}

/* =========================================================
   Progress rail (scene dots)
   ========================================================= */
.progress-rail {
  position: fixed;
  top: 50%;
  left: 0.9rem;
  transform: translateY(-50%);
  z-index: 55;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.progress-rail button {
  width: 9px; height: 9px;
  border-radius: 50%;
  border: none;
  background: rgba(201,168,106,0.3);
  padding: 0;
  transition: transform 0.2s, background 0.2s;
}
.progress-rail button.active { background: var(--pink-deep); transform: scale(1.4); }
.progress-rail button:hover { background: var(--pink); }
@media (max-width: 640px) {
  .progress-rail { left: auto; right: 0.7rem; top: auto; bottom: 5.2rem; transform: none; }
}

/* =========================================================
   Modal
   ========================================================= */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 1.4rem;
}
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(42,38,34,0.4);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.3s ease;
}
.modal__box {
  position: relative;
  max-width: 400px;
  text-align: center;
  animation: modalPop 0.4s var(--ease);
}
.modal__title { font-family: var(--serif); font-size: 1.4rem; margin-bottom: 0.8rem; color: var(--charcoal); }
.modal__body { color: var(--ink-soft); margin-bottom: 1.4rem; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop { from { opacity: 0; transform: scale(0.9) translateY(10px); } to { opacity: 1; transform: none; } }

/* =========================================================
   Reduced motion
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
  .tl-item { opacity: 1; transform: none; }
  .particle, .floating-heart, .final__glow { display: none; }
  .slide.is-current img { animation: none; }
}
