/* ===========================================================
   Nia's Learning Villa — fun.css
   Extra animations and play pages (bonus, not part of the
   graded HTML lessons). Uses the colors from styles.css.
   =========================================================== */

/* ---- Unicorn parade that runs across the screen ---- */
.runner {
  position: fixed;
  left: -160px;
  font-size: 3.4rem;
  z-index: 90;
  pointer-events: none;
  white-space: nowrap;
  animation: run-across 4s linear forwards;
}
.runner .bounce { display: inline-block; animation: hop .35s ease-in-out infinite alternate; }
.runner.flip .bounce { transform: scaleX(-1); }
@keyframes run-across { to { left: 110vw; } }
@keyframes hop { from { transform: translateY(0); } to { transform: translateY(-14px); } }

/* ---- Balloons that float up ---- */
.balloon-float {
  position: fixed;
  bottom: -80px;
  font-size: 2.8rem;
  z-index: 85;
  pointer-events: none;
  animation: float-up 6s ease-in forwards;
}
@keyframes float-up {
  50% { transform: translateX(20px); }
  to { transform: translate(-10px, -115vh); }
}

/* ---- Slow-drifting friends in the background ---- */
.drifter {
  position: fixed;
  font-size: 2.2rem;
  opacity: .22;
  z-index: 0;
  pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate(0, 0) rotate(-8deg); }
  to { transform: translate(40px, -30px) rotate(8deg); }
}
main, .site-header, footer { position: relative; z-index: 1; }
.site-header { position: sticky; z-index: 10; }

/* ---- Sparkles wherever she taps ---- */
.sparkle {
  position: fixed;
  font-size: 1.3rem;
  pointer-events: none;
  z-index: 120;
  animation: sparkle-out .7s ease-out forwards;
}
@keyframes sparkle-out { to { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; } }

/* ---- Big "Great job!" pop ---- */
.great-job {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 130;
  font-size: 3rem;
  font-weight: 700;
  color: var(--white);
  background: linear-gradient(135deg, var(--pink), var(--purple));
  padding: 18px 34px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  pointer-events: none;
  animation: great-pop 1.8s ease-out forwards;
  white-space: nowrap;
}
@keyframes great-pop {
  0% { transform: translate(-50%, -50%) scale(.2) rotate(-10deg); opacity: 0; }
  20% { transform: translate(-50%, -50%) scale(1.15) rotate(3deg); opacity: 1; }
  35% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -70%) scale(1); opacity: 0; }
}

/* ---- Emoji "doors": tap a unicorn, it whooshes you there ---- */
.fly-link {
  display: inline-block;
  cursor: pointer;
  text-decoration: none;
  transition: transform .2s;
}
.fly-link:hover { transform: scale(1.25) rotate(-8deg); }
.fly-link.whoosh { animation: whoosh .6s ease-in forwards; }
@keyframes whoosh {
  30% { transform: scale(1.6) rotate(-20deg); }
  100% { transform: translate(60vw, -40vh) scale(.3) rotate(360deg); opacity: 0; }
}
.door-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; margin: 10px 0 18px; }
.door-row .fly-link { font-size: 3rem; text-align: center; color: var(--purple); }
.door-row .fly-link small { display: block; font-size: .9rem; font-weight: 700; }
.wiggle { animation: wiggle 2.2s ease-in-out infinite; }
.wiggle:nth-child(2) { animation-delay: .3s; }
.wiggle:nth-child(3) { animation-delay: .6s; }
.wiggle:nth-child(4) { animation-delay: .9s; }
.wiggle:nth-child(5) { animation-delay: 1.2s; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 10% { transform: rotate(-10deg); } 20% { transform: rotate(10deg); } 30% { transform: rotate(0); } }

/* ---- Sound button in the header ---- */
.sound-btn {
  font: inherit;
  border: 3px solid var(--white);
  box-shadow: 0 0 0 2px var(--blue-soft), var(--shadow);
  background: var(--blue-soft);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  font-size: 1.15rem;
  flex: none;
}

/* ---- Parent PIN lock ---- */
.lock-box {
  max-width: 340px;
  margin: 20px auto;
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 4px dashed var(--purple);
}
.pin-dots { font-size: 2rem; letter-spacing: 10px; min-height: 1.5em; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.pin-pad button {
  font: inherit;
  font-size: 1.6rem;
  font-weight: 700;
  padding: 14px 0;
  border: none;
  border-radius: 16px;
  background: var(--purple-soft);
  color: var(--purple);
  cursor: pointer;
}
.pin-pad button:active { background: var(--pink); color: var(--white); }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }
.hidden { display: none !important; }

/* ---- Game picker ---- */
.game-tabs { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 16px 0; }
.game-panel {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

/* Memory match */
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; max-width: 460px; margin: 16px auto; }
.mem-card {
  font-size: 2.6rem;
  aspect-ratio: 1;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  box-shadow: var(--shadow);
  transition: transform .3s, background .3s;
}
.mem-card.open, .mem-card.matched { background: var(--yellow-soft); transform: scale(1.05); }
.mem-card.matched { outline: 4px solid var(--yellow); }

/* Balloon pop */
.sky {
  position: relative;
  height: 360px;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(180deg, var(--blue-soft), var(--pink-soft));
  margin-top: 12px;
}
.pop-balloon { position: absolute; font-size: 3rem; cursor: pointer; user-select: none; }
.pop-balloon.popped { animation: popped .25s forwards; }
@keyframes popped { to { transform: scale(1.8); opacity: 0; } }

/* Color hunt */
.color-dots { display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; margin: 18px 0; }
.color-dot {
  width: 96px; height: 96px;
  border-radius: 50%;
  border: 6px solid var(--white);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s;
}
.color-dot:hover { transform: scale(1.1); }

/* ---- Play page: unicorn dress-up ---- */
.studio { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(240px, 1fr); gap: 20px; align-items: start; }
.stage {
  position: relative;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  transition: background .4s;
}
.stage svg { width: 100%; height: auto; display: block; }
.accessory {
  position: absolute;
  font-size: 3rem;
  transition: transform .3s;
  pointer-events: none;
}
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.swatch {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 4px solid var(--white);
  box-shadow: 0 0 0 2px var(--ink);
  cursor: pointer;
}
.toggle.on { background: var(--yellow); color: var(--ink); }

/* Sparkle drawing pad */
.draw-wrap { background: var(--white); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
#draw-pad {
  width: 100%;
  height: 380px;
  border-radius: 16px;
  background: var(--white);
  border: 3px dashed var(--purple);
  touch-action: none;
  cursor: crosshair;
  display: block;
}

@media (max-width: 700px) {
  .studio { grid-template-columns: 1fr; }
  .memory-grid { gap: 8px; }
  .mem-card { font-size: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .runner, .balloon-float, .drifter, .wiggle { animation: none; display: none; }
}

/* ===========================================================
   MORE FUN (bonus): daily love note, bubbles, peekaboo,
   wishing star, gift + dance buttons, bouncy titles
   =========================================================== */

/* ---- Unicorn holding Daddy's daily note (bottom-left) ---- */
.love-note {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.love-unicorn {
  position: relative;
  font-size: 3.4rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  animation: uni-bob 1.6s ease-in-out infinite alternate;
}
.love-unicorn::before { content: ""; }
.love-envelope {
  position: absolute;
  right: -10px;
  top: -6px;
  font-size: 1.6rem;
  animation: wiggle-env 1.2s ease-in-out infinite;
}
.love-note.open .love-envelope { display: none; }
@keyframes uni-bob { from { transform: translateY(0) scaleX(-1); } to { transform: translateY(-8px) scaleX(-1); } }
@keyframes wiggle-env { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }

.love-paper {
  position: relative;
  width: 230px;
  margin: 0 0 6px 30px;
  padding: 20px 16px 14px;
  background: var(--pink-soft);
  border: 3px dashed var(--pink);
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 4px 8px 14px rgba(0, 0, 0, .2);
  transform: rotate(-4deg) scale(0);
  transform-origin: bottom left;
  transition: transform .45s cubic-bezier(.3, 1.6, .5, 1);
  cursor: pointer;
  display: none;
}
.love-note.open .love-paper { display: block; transform: rotate(-4deg) scale(1); animation: pop .5s ease-out; }
.love-paper::before {               /* tape, like the birthday note */
  content: "";
  position: absolute;
  top: -12px; left: 50%;
  width: 80px; height: 24px;
  transform: translateX(-50%) rotate(3deg);
  background: rgba(255, 255, 255, .7);
}
.love-paper::after {                /* the unicorn's "string" holding the note */
  content: "";
  position: absolute;
  left: 18px; bottom: -14px;
  border: 10px solid transparent;
  border-top-color: var(--pink);
}
.love-sign { margin-top: 8px; text-align: right; color: var(--purple); font-size: 1rem; }
.love-close { float: right; border: none; background: none; font-size: 1.1rem; cursor: pointer; color: var(--ink); }
.love-heart {
  position: absolute;
  bottom: 10px;
  font-size: 1.3rem;
  pointer-events: none;
  animation: heart-up 2s ease-out forwards;
}
@keyframes heart-up { to { transform: translateY(-140px) scale(1.4); opacity: 0; } }

/* ---- Bubbles with friends inside ---- */
.bubble {
  position: fixed;
  bottom: -100px;
  width: 78px; height: 78px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .9);
  background: radial-gradient(circle at 30% 28%, rgba(255,255,255,.95) 0 10%, rgba(255,111,181,.25) 40%, rgba(155,93,229,.3) 75%, rgba(76,201,240,.35));
  box-shadow: 0 0 18px rgba(155, 93, 229, .35);
  font-size: 2.2rem;
  cursor: pointer;
  z-index: 80;
  animation: bubble-up 10s linear forwards;
}
@keyframes bubble-up {
  25% { transform: translate(25px, -30vh); }
  50% { transform: translate(-20px, -60vh); }
  75% { transform: translate(20px, -90vh); }
  to  { transform: translate(0, -125vh); }
}
.big-sparkle { font-size: 1.8rem; }

/* ---- Peekaboo friends ---- */
.peeker {
  position: fixed;
  font-size: 4rem;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 80;
  padding: 0;
  transition: transform .5s;
}
.peeker.left  { left: -20px;  animation: peek-left 1s ease-out; }
.peeker.right { right: -20px; animation: peek-right 1s ease-out; }
@keyframes peek-left  { from { transform: translateX(-120%) rotate(30deg); } to { transform: translateX(0) rotate(20deg); } }
@keyframes peek-right { from { transform: translateX(120%) rotate(-30deg); } to { transform: translateX(0) rotate(-20deg); } }
.peeker.left  { transform: rotate(20deg); }
.peeker.right { transform: rotate(-20deg); }
.peeker.hide.left  { transform: translateX(-130%); }
.peeker.hide.right { transform: translateX(130%); }
.peeker.found { animation: found-spin .7s ease-in forwards; }
@keyframes found-spin { to { transform: scale(2) rotate(360deg); opacity: 0; } }

/* ---- Wishing star ---- */
.wish-star {
  position: fixed;
  left: 105vw;
  font-size: 3rem;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 80;
  padding: 10px;              /* bigger target for little fingers */
  animation: shoot 7s linear forwards;
  filter: drop-shadow(0 0 10px var(--yellow));
}
.wish-star span { display: inline-block; animation: twinkle .5s ease-in-out infinite alternate; }
@keyframes shoot { to { left: -15vw; transform: translateY(18vh); } }
@keyframes twinkle { from { transform: scale(1); } to { transform: scale(1.25); } }

/* ---- Gift + dance buttons on the right side ---- */
.fun-dock {
  position: fixed;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 60;
}
.dock-btn {
  width: 62px; height: 62px;
  border-radius: 50%;
  border: 4px solid var(--white);
  background: linear-gradient(135deg, var(--pink), var(--purple));
  box-shadow: var(--shadow);
  font-size: 2rem;
  cursor: pointer;
  animation: dock-pulse 2.4s ease-in-out infinite;
}
.dock-btn:nth-child(2) { background: linear-gradient(135deg, var(--blue), var(--purple)); animation-delay: 1.2s; }
.dock-btn:active { transform: scale(.9); }
@keyframes dock-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.dock-btn.shake { animation: gift-shake .6s; }
@keyframes gift-shake {
  20% { transform: rotate(-20deg) scale(1.15); } 40% { transform: rotate(18deg) scale(1.15); }
  60% { transform: rotate(-12deg); } 80% { transform: rotate(8deg); }
}

/* ---- Giant rainbow surprise ---- */
.rainbow-sweep {
  position: fixed;
  left: 50%; bottom: -50vmin;
  width: 100vmin; height: 100vmin;
  margin-left: -50vmin;
  border-radius: 50%;
  background: radial-gradient(circle, transparent 38%, var(--purple) 38% 43%, var(--blue) 43% 48%, #6ee7a8 48% 53%, var(--yellow) 53% 58%, #ffa94d 58% 63%, var(--true-red) 63% 68%, transparent 68%);
  pointer-events: none;
  z-index: 70;
  animation: rainbow-in 2.6s ease-out forwards;
}
@keyframes rainbow-in { 0% { transform: scale(0); opacity: 0; } 30% { transform: scale(1); opacity: .9; } 80% { opacity: .9; } to { opacity: 0; } }

/* ---- Dance party: colors change and the page dances ---- */
body.disco { animation: disco-bg 1.2s linear infinite; }
body.disco main > * { animation: sway .6s ease-in-out infinite alternate; }
@keyframes disco-bg {
  0% { background-color: var(--pink-soft); } 25% { background-color: var(--purple-soft); }
  50% { background-color: var(--blue-soft); } 75% { background-color: var(--yellow-soft); } 100% { background-color: var(--pink-soft); }
}
@keyframes sway { from { transform: rotate(-2deg); } to { transform: rotate(2deg) translateY(-6px); } }

/* ---- Bouncy page titles ---- */
.jump-letter { display: inline-block; white-space: pre; }
h1.jumping .jump-letter { animation: letter-jump .6s ease-out; animation-delay: calc(var(--i) * 40ms); }
@keyframes letter-jump {
  40% { transform: translateY(-22px) rotate(-8deg); color: var(--pink); }
  70% { color: var(--purple); }
}
.star-counter.spin { animation: star-spin .7s ease-out; }
@keyframes star-spin { 50% { transform: scale(1.3) rotate(10deg); } }

@media (max-width: 640px) {
  .love-paper { width: 180px; font-size: 1rem; margin-left: 20px; }
  .love-unicorn { font-size: 2.8rem; }
  .dock-btn { width: 52px; height: 52px; font-size: 1.6rem; }
  .bubble { width: 64px; height: 64px; font-size: 1.8rem; }
  .great-job { font-size: 1.7rem; padding: 14px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .bubble, .peeker, .wish-star, .love-unicorn, .dock-btn, body.disco, body.disco main > * { animation: none; }
  .bubble, .peeker, .wish-star { display: none; }
}
