/* ═══ Ida 11 · Geburtstagskarte ═══ */

:root {
  --paper: #fdfbf7;
  --ink: #574f6b;
  --ink-soft: #8a80a5;
  --blush: #f7c9d4;
  --mint: #c5e8d6;
  --butter: #fce3a8;
  --sky: #c3ddf5;
  --lilac: #dccbf0;
  --gold: #f0b84c;
  --indigo: #8087c9;
  --card-shadow: 0 6px 22px rgba(122, 108, 160, 0.16);
  --font-fun: "Segoe Print", "Chalkboard SE", "Comic Sans MS", "Comic Neue", cursive;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-fun);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: pan-y;
}

/* ── Hintergrund-Kleckse ── */
#bgBlobs { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.blob {
  position: absolute;
  border-radius: 46% 54% 52% 48% / 55% 45% 55% 45%;
  opacity: 0.5;
  filter: blur(2px);
  transition: transform 0.6s ease-out;
}
.b1 { width: 42vw; height: 42vw; background: var(--blush); top: -12vw; left: -14vw; }
.b2 { width: 36vw; height: 36vw; background: var(--sky); bottom: 8vh; right: -14vw; }
.b3 { width: 28vw; height: 28vw; background: var(--butter); bottom: -10vw; left: -8vw; }
.b4 { width: 22vw; height: 22vw; background: var(--mint); top: 16vh; right: -6vw; }

/* ── Buch & Seiten ── */
#book {
  display: flex;
  height: 100dvh;
  transition: transform 0.55s cubic-bezier(0.33, 1, 0.45, 1);
  position: relative;
  z-index: 1;
}
.page {
  flex: 0 0 100vw;
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(64px + env(safe-area-inset-top)) 18px calc(126px + env(safe-area-inset-bottom));
  overflow-y: auto;
  overflow-x: hidden;
  gap: 12px;
  text-align: center;
}
/* Wichtig: Karten duerfen nicht zusammengequetscht werden, Seite soll scrollen */
.page > * { flex-shrink: 0; }

h1 {
  font-size: clamp(1.5rem, 6.4vw, 2.3rem);
  line-height: 1.25;
  color: var(--ink);
}
h1 .ida { color: #e2738f; }
h2 {
  font-size: clamp(1.25rem, 5.4vw, 1.8rem);
  color: var(--ink);
}
.nowrap { white-space: nowrap; }

.card {
  background: #fff;
  border-radius: 26px 30px 24px 32px;
  padding: 0.9rem 1.15rem;
  box-shadow: var(--card-shadow);
  border: 3px solid #fff;
  font-size: clamp(0.95rem, 4vw, 1.1rem);
  line-height: 1.5;
  max-width: 480px;
}

.prompt {
  font-size: clamp(0.9rem, 3.8vw, 1.05rem);
  color: var(--ink-soft);
  animation: bob 2.4s ease-in-out infinite;
}
.prompt.light { color: #cfd4f5; }
.prompt.done { display: none; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ── Hinweis-Karten (Zettel) ── */
.clue {
  background: #fff7de;
  border-color: #fff;
  transform: scale(0.7) rotate(-4deg);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: -12px;
  overflow: hidden;
}
.clue.revealed {
  transform: scale(1) rotate(-1deg);
  opacity: 1;
  max-height: 400px;
  padding: 0.9rem 1.15rem;
  margin-top: 0;
}

/* ── Cover ── */
/* kein justify-center: bei Ueberlauf wuerde der Titel oben abgeschnitten;
   auto-Margins zentrieren nur, wenn Platz ist, sonst wird gescrollt */
.p-cover > :first-child { margin-top: auto; }
.p-cover > :last-child { margin-bottom: auto; }
.cover-art { width: min(62vw, 270px); }
.cover-art svg { width: 100%; height: auto; overflow: visible; }

.big-btn {
  font-family: var(--font-fun);
  font-size: clamp(1rem, 4.4vw, 1.2rem);
  color: #fff;
  background: linear-gradient(135deg, #eb8fa8, #e2738f);
  border: 3px solid #fff;
  border-radius: 999px;
  padding: 0.85rem 1.5rem;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  animation: bob 2.4s ease-in-out infinite;
  margin-top: 6px;
}
.big-btn:active { transform: scale(0.95); }

.float-slow { animation: floaty 5s ease-in-out infinite; }
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

/* ── Seite 2 · Ballon ── */
/* feste Hoehe wie auf den Seiten 5 und 6: die Zone schrumpft nicht,
   wenn der Hinweis erscheint, und der Ballon landet komplett darin */
.balloon-zone {
  height: 330px;
  width: 100%;
  max-width: 520px;
  position: relative;
}
#balloonWrap {
  position: absolute;
  left: 50%;
  top: 0;
  width: min(38vw, 150px);
  margin-left: calc(min(38vw, 150px) / -2);
  cursor: grab;
  animation: floaty 4s ease-in-out infinite;
  touch-action: none;
}
#balloonWrap svg { width: 100%; height: auto; overflow: visible; }
#balloonWrap.grab { animation: none; cursor: grabbing; }
#balloonWrap.landed { animation: none; transition: transform 0.5s ease; }
#balloonWrap.landed .note { animation: notewiggle 0.7s ease; }
@keyframes notewiggle {
  0% { transform: rotate(0); } 30% { transform: rotate(-7deg); }
  60% { transform: rotate(5deg); } 100% { transform: rotate(0); }
}

/* ── Seite 3 · Nacht ── */
.p-night {
  background: linear-gradient(180deg, #3d4166 0%, #565d94 70%, #6a6f9e 100%);
  color: #f3f1fb;
  border-radius: 0 0 34px 34px;
}
.p-night h2 { color: #fff; }
.p-night .card { background: rgba(255, 255, 255, 0.14); border-color: rgba(255,255,255,0.35); color: #f3f1fb; }
.p-night .clue { background: #fff7de; color: var(--ink); border-color: #fff; }
#sky {
  height: 300px;
  width: 100%;
  position: relative;
  max-width: 520px;
}
.star {
  position: absolute;
  color: #ffffff;
  cursor: pointer;
  animation: twinkle 2.6s ease-in-out infinite;
  line-height: 1;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}
.star.wiggle { animation: starwiggle 0.5s ease; }
@keyframes starwiggle {
  0%,100% { transform: rotate(0) scale(1); }
  30% { transform: rotate(-18deg) scale(1.25); }
  70% { transform: rotate(14deg) scale(1.1); }
}
@keyframes twinkle {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}
.star.big {
  color: #ffe58a;
  font-size: 3.2rem;
  text-shadow: 0 0 14px rgba(255, 229, 138, 0.95), 0 0 34px rgba(255, 229, 138, 0.7);
  animation: bigtwinkle 1.8s ease-in-out infinite;
  z-index: 2;
}
@keyframes bigtwinkle {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.14) rotate(6deg); }
}
.star.big.fall {
  animation: none;
  transition: top 1s cubic-bezier(0.45, 0, 0.7, 1), left 1s ease, transform 1s ease, opacity 0.4s ease 0.9s;
  opacity: 0;
  transform: rotate(200deg) scale(0.5);
}

/* ── Seite 4 · Seifenblasen ── */
#bubbleBox {
  flex: 1;
  min-height: 250px;
  width: 100%;
  max-width: 520px;
  position: relative;
}
.bubble {
  position: absolute;
  border-radius: 50%;
  cursor: pointer;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.25) 22%, rgba(255,255,255,0) 40%),
    radial-gradient(circle at 70% 75%, rgba(195, 221, 245, 0.55), rgba(220, 203, 240, 0.35) 60%, rgba(247, 201, 212, 0.3));
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 0 14px rgba(255, 255, 255, 0.5), 0 4px 10px rgba(122, 108, 160, 0.12);
  animation: bubblebob 3.4s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}
@keyframes bubblebob {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(4px, -9px); }
  66% { transform: translate(-5px, -3px); }
}
.bubble.pop {
  animation: pop 0.35s ease forwards;
  pointer-events: none;
}
@keyframes pop {
  0% { transform: scale(1); opacity: 1; }
  55% { transform: scale(1.32); opacity: 0.85; }
  100% { transform: scale(0.15); opacity: 0; }
}
.bubble .keyglint {
  font-size: 1.35rem;
  filter: drop-shadow(0 0 5px rgba(240, 184, 76, 0.9));
  animation: twinkle 1.6s ease-in-out infinite;
}
#freeKey {
  position: absolute;
  font-size: 3rem;
  filter: drop-shadow(0 0 10px rgba(240, 184, 76, 0.9));
  transform: scale(0);
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  z-index: 3;
}
#freeKey.shown { transform: scale(1) rotate(-12deg); }

/* ── Seite 5 · Lichtung ── */
.meadow-zone { width: min(92vw, 400px); }
#meadowSvg { width: 100%; height: auto; overflow: visible; }
#fritzi { transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
#meadowSvg.found #fritzi { transform: translateY(-52px); }
#fritziHit { cursor: pointer; }
.sway { transform-origin: bottom center; transform-box: fill-box; animation: sway 3.4s ease-in-out infinite; }
.sway.s2 { animation-delay: -1.7s; }
@keyframes sway {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}
#bush { animation: rustle 4s ease-in-out infinite; transform-origin: center bottom; transform-box: fill-box; }
#meadowSvg.found #bush { animation: none; }
@keyframes rustle {
  0%, 86%, 100% { transform: rotate(0); }
  90% { transform: rotate(1.6deg); }
  94% { transform: rotate(-1.6deg); }
  98% { transform: rotate(0.8deg); }
}
.speech { position: relative; }

/* ── Seite 6 · Kerzen ── */
.cake-zone { width: min(92vw, 380px); }
#cakeSvg { width: 100%; height: auto; overflow: visible; }
.counter { padding: 0.5rem 1rem; font-size: 0.95rem; color: var(--ink-soft); }
.flame { animation: flicker 0.55s ease-in-out infinite alternate; transform-origin: center bottom; transform-box: fill-box; }
@keyframes flicker {
  from { transform: scaleY(1) skewX(-3deg); }
  to { transform: scaleY(0.82) skewX(4deg); }
}
.candle.out .flame { display: none; }
.candle .hit { cursor: pointer; }
.candle.out .hit { cursor: default; }
.smokepuff {
  animation: smoke 1.1s ease-out forwards;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes smoke {
  0% { opacity: 0.8; transform: translateY(0) scale(0.6); }
  100% { opacity: 0; transform: translateY(-30px) scale(1.6); }
}
#boxLid { transition: transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1); transform-box: fill-box; transform-origin: left bottom; }
#cakeSvg.open #boxLid { transform: rotate(-9deg) translateY(-8px); }

/* ── Seite 7 · Geschenk ── */
.openbox-art { width: min(66vw, 260px); }
.openbox-art svg { width: 100%; height: auto; overflow: visible; }

.swatches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(88vw, 380px);
}
.swatch {
  font-family: var(--font-fun);
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow: var(--card-shadow);
  padding: 8px 14px;
  cursor: pointer;
  color: var(--ink);
  font-size: 1.05rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.swatch:active { transform: scale(0.94); }
.swatch.chosen {
  transform: scale(1.05);
  box-shadow: 0 0 0 4px var(--gold), 0 10px 26px rgba(240, 184, 76, 0.45);
  animation: chosenbounce 0.5s ease;
}
@keyframes chosenbounce {
  0% { transform: scale(0.9); }
  55% { transform: scale(1.12); }
  100% { transform: scale(1.05); }
}
.chip {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(122, 108, 160, 0.3);
  flex: 0 0 auto;
}
.chip-silver { background: linear-gradient(135deg, #eceef1, #cfd3d9); }
.chip-blush { background: linear-gradient(135deg, #fadde3, #f1b9c4); }
.chip-citrus { background: linear-gradient(135deg, #fde4a0, #f4c65e); }
.chip-indigo { background: linear-gradient(135deg, #9ba3e0, #7079c2); }

.gold-card { background: #fff7de; }
.reveal-sub { font-size: 1.05rem; color: var(--ink-soft); }

/* ── Geschenkspur ── */
.trail { background: #f1e9ff; font-size: 0.92em; }

/* ── Seite 8 · Foto & Video ── */
.photo-frame {
  width: min(88vw, 420px);
  background: #fff;
  border: 4px solid #fff;
  border-radius: 24px 28px 22px 30px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  cursor: pointer;
}
.photo-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  object-position: center;
  border-radius: 18px;
}
#neoImg.pos-silver { object-position: 62% 50%; }
.photo-frame.small { width: min(78vw, 340px); cursor: default; }
#videoOverlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(24, 21, 38, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
}
#videoOverlay[hidden] { display: none; }
.video-box {
  width: min(94vw, 640px);
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  background: #000;
}
#ytFrame { width: 100%; height: 100%; border: 0; display: block; }
#videoClose {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 14px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
}

.letter { text-align: left; }
.letter p { margin-bottom: 0.7rem; }
.letter p:last-child { margin-bottom: 0; }

/* fliegende Funkel */
.sparkle {
  position: fixed;
  pointer-events: none;
  font-size: 1.1rem;
  z-index: 40;
  animation: sparklefly 0.8s ease-out forwards;
}
@keyframes sparklefly {
  0% { transform: translate(0, 0) scale(0.5); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.25) rotate(120deg); opacity: 0; }
}

/* ── Navigation ── */
#nav {
  position: fixed;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 8px 12px;
  box-shadow: var(--card-shadow);
  z-index: 20;
}
#prevBtn, #nextBtn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--lilac);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font-fun);
  transition: opacity 0.3s ease, background 0.3s ease;
}
#prevBtn:active, #nextBtn:active { transform: scale(0.92); }
#prevBtn.off, #nextBtn.locked { opacity: 0.35; }
#nextBtn.ready { background: var(--gold); animation: bob 1.4s ease-in-out infinite; }
#nextBtn.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
#dots { display: flex; gap: 7px; }
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ddd5ec;
  transition: background 0.3s ease, transform 0.3s ease;
}
.dot.open { background: var(--lilac); cursor: pointer; }
.dot.here { background: #e2738f; transform: scale(1.35); }

/* ── Musik ── */
#musicBtn {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: 12px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--card-shadow);
  font-size: 1.25rem;
  cursor: pointer;
  z-index: 25;
}
#musicBtn.on { background: var(--butter); animation: bob 1.6s ease-in-out infinite; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(14px);
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 0.92rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 30;
  white-space: nowrap;
  max-width: 92vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Konfetti ── */
#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.5s ease;
}
#confetti.on { opacity: 1; }

/* ── Zauberwort ── */
#lockOverlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: opacity 0.5s ease;
}
#lockOverlay.unlocked { opacity: 0; pointer-events: none; }
.lock-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 1.6rem 1.4rem;
  width: min(88vw, 340px);
  text-align: center;
}
.lock-card.shake { animation: shake 0.4s ease; }
.lock-emoji { font-size: 2.6rem; }
.lock-sub { color: var(--ink-soft); }
#pwInput {
  font-family: var(--font-fun);
  font-size: 1.1rem;
  text-align: center;
  color: var(--ink);
  background: #f6f2fc;
  border: 3px solid var(--lilac);
  border-radius: 999px;
  padding: 10px 16px;
  width: 100%;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
#pwInput:focus { border-color: var(--gold); }
#lockMsg { color: #d9748f; font-size: 0.95rem; min-height: 1.3em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.15s !important; }
}
