/* KUNG FU FUNGI - ANIMATIONS, SOUND SWITCH AND EASTER EGGS
   Rules from the style guide (section 13): motion is used sparingly, every move plays ONCE and stops
   (nothing loops forever), nothing slows shopping, and people who turned motion off get none of it.
   js/fx.js puts "fx" on the page when motion is allowed; js/eggs.js builds the easter eggs.
   Colors come from tokens.css. */

/* ====================================================================== ANIMATIONS */
@media (prefers-reduced-motion: no-preference) {

  /* 1. Ink-stamp slam: "Not on sale yet" thumps down when it scrolls into view */
  .fx .card__status { opacity: 0; }
  .fx .card__status.is-stamped { animation: fx-stamp 0.42s cubic-bezier(0.2, 1.4, 0.4, 1) both; }

  /* 3. Title card: the hero comes in like opening credits (once per visit) */
  .fx-intro .hero__credit { animation: fx-fade 0.5s ease-out both; }
  .fx-intro .hero__title span,
  .fx-intro .atop__title span { animation: fx-slam 0.45s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
  .fx-intro .hero__title span:nth-child(1), .fx-intro .atop__title span:nth-child(1) { animation-delay: 0.35s; }
  .fx-intro .hero__title span:nth-child(2), .fx-intro .atop__title span:nth-child(2) { animation-delay: 0.6s; }
  .fx-intro .hero__title span:nth-child(3) { animation-delay: 0.85s; }
  .fx-intro .hero__line, .fx-intro .hero__sells, .fx-intro .atop__lead { animation: fx-fade 0.5s 1.2s ease-out both; }
  .fx-intro .hero .btn { animation: fx-fade 0.5s 1.2s ease-out both; }
  .fx-intro .hero__poster { animation: fx-poster 0.7s 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) both; }

  /* 5. Marquee bulbs: the header lights run across twice on page load, then stop */
  .fx-bulbs .marquee::after { opacity: 1; animation: fx-chase 0.9s steps(22, jump-none) 2 both; }
}

/* 2. Punch on hover: buttons, product cards and category panels jab, with speed lines and a spore burst */
.btn, .card, .marquee, .aenemy__poster { position: relative; }
.btn::before, .card::before {
  content: ""; position: absolute; right: 100%; top: 16%; width: 3.25rem; height: 68%; margin-right: 10px;
  pointer-events: none; opacity: 0;
  background: repeating-linear-gradient(180deg, var(--c-ink) 0 3px, transparent 3px 15px);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000); mask-image: linear-gradient(90deg, transparent, #000);
}
.btn::after, .card::after {
  content: ""; position: absolute; right: -22px; top: -22px; width: 64px; height: 64px;
  pointer-events: none; opacity: 0;
  background:
    radial-gradient(circle at 50% 8%, var(--c-cream) 0 3px, var(--c-ink) 3.5px 5px, transparent 5.5px),
    radial-gradient(circle at 86% 22%, var(--c-yellow) 0 4px, var(--c-ink) 4.5px 6px, transparent 6.5px),
    radial-gradient(circle at 93% 58%, var(--c-cream) 0 3px, var(--c-ink) 3.5px 5px, transparent 5.5px),
    radial-gradient(circle at 70% 88%, var(--c-yellow) 0 3px, var(--c-ink) 3.5px 5px, transparent 5.5px),
    radial-gradient(circle at 30% 90%, var(--c-cream) 0 4px, var(--c-ink) 4.5px 6px, transparent 6.5px),
    radial-gradient(circle at 8% 60%, var(--c-yellow) 0 3px, var(--c-ink) 3.5px 5px, transparent 5.5px),
    radial-gradient(circle at 15% 22%, var(--c-cream) 0 3px, var(--c-ink) 3.5px 5px, transparent 5.5px);
}
.hero .btn::before { background: repeating-linear-gradient(180deg, var(--c-cream) 0 3px, transparent 3px 15px); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .card:hover, .cat:hover { animation: fx-jab 0.26s ease-out 1; }
  .btn:hover::before, .card:hover::before { animation: fx-lines 0.32s ease-out 1; }
  .btn:hover::after, .card:hover::after { animation: fx-burst 0.45s ease-out 1; }

  /* 4. Projector flicker: a short flicker and scratch lines when the mouse lands on a poster */
  .aenemy__poster:hover::after { animation: fx-scratch 0.9s steps(5, jump-none) 1; }
  .aenemy__poster:hover img { animation: fx-flicker 0.9s steps(6, jump-none) 1; }
}
.aenemy__poster::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg,
    transparent 22%, rgba(242, 222, 180, 0.6) 22% 22.5%, transparent 22.5% 61%,
    rgba(24, 23, 19, 0.5) 61% 61.4%, transparent 61.4% 83%, rgba(242, 222, 180, 0.45) 83% 83.4%, transparent 83.4%);
}
/* the lit bulbs that run along the header (same spacing as the bulbs in site.css) */
.marquee::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 14px; pointer-events: none; opacity: 0;
  background-image: radial-gradient(circle, var(--c-cream) 0 3.5px, var(--c-red) 4px 6px, transparent 6.5px);
  background-size: 26px 14px; background-repeat: repeat-x; background-position: 4px 100%;
}

@keyframes fx-stamp {
  0% { opacity: 0; transform: rotate(-14deg) scale(2.8); }
  55% { opacity: 1; transform: rotate(-2deg) scale(0.92); }
  78% { transform: rotate(-2deg) scale(1.06); }
  100% { opacity: 1; transform: rotate(-2deg) scale(1); }
}
@keyframes fx-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fx-slam { from { opacity: 0; translate: -70px 0; scale: 1.25; } to { opacity: 1; translate: 0 0; scale: 1; } }
@keyframes fx-poster { from { opacity: 0; translate: 90px 30px; rotate: 8deg; } to { opacity: 1; translate: 0 0; rotate: 0deg; } }
@keyframes fx-chase {
  0% { clip-path: inset(0 100% 0 0); }
  22% { clip-path: inset(0 78% 0 0); }
  78% { clip-path: inset(0 0 0 78%); }
  100% { clip-path: inset(0 0 0 100%); }
}
@keyframes fx-jab { 0% { translate: 0 0; } 30% { translate: 10px 0; } 62% { translate: -3px 0; } 100% { translate: 0 0; } }
@keyframes fx-lines {
  0% { opacity: 0; transform: translateX(16px) scaleX(0.3); }
  30% { opacity: 0.9; transform: none; }
  100% { opacity: 0; transform: translateX(-14px); }
}
@keyframes fx-burst { 0% { opacity: 0; transform: scale(0.3); } 25% { opacity: 1; } 100% { opacity: 0; transform: scale(1.5) rotate(25deg); } }
@keyframes fx-flicker {
  0%, 100% { filter: none; }
  15% { filter: brightness(1.12) sepia(0.25); }
  35% { filter: brightness(0.9) sepia(0.2); }
  55% { filter: brightness(1.08) sepia(0.25); }
  80% { filter: brightness(0.95) sepia(0.15); }
}
@keyframes fx-scratch {
  0%, 100% { opacity: 0; transform: none; }
  20% { opacity: 0.9; transform: translateX(-6%); }
  40% { opacity: 0.5; transform: translateX(9%); }
  60% { opacity: 0.9; transform: translateX(-3%); }
  80% { opacity: 0.6; transform: translateX(4%); }
}

/* ====================================================================== SOUND SWITCH (ticket stub) */
/* Sits at the end of the header row (it used to float bottom-left and covered page text). */
.soundstub {
  flex: none; cursor: pointer;
  font: 700 1rem/1 var(--f-second); text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--c-cream); color: var(--c-ink);
  border: var(--line); border-left: 3px dashed var(--c-ink);
  padding: 0.45rem 0.7rem 0.4rem 0.85rem; box-shadow: 3px 3px 0 var(--c-ink); transform: rotate(-2deg);
}
.soundstub[aria-pressed="true"] { background: var(--c-yellow); }
.soundstub:hover { background: var(--c-ink); color: var(--c-yellow); }

/* ====================================================================== EASTER EGGS */
/* the hidden "badly dubbed" switch: reads like a plain line of footer text */
.dubswitch { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; opacity: 0.75; }
.dubswitch:hover, .dubswitch[aria-pressed="true"] { opacity: 1; text-decoration: underline; color: var(--c-yellow); }

.toast {
  position: fixed; left: 50%; bottom: 4.5rem; z-index: 56; translate: -50% 0; width: max-content; max-width: calc(100% - 2rem);
  background: var(--c-ink); color: var(--c-yellow); border: 3px solid var(--c-yellow); box-shadow: 5px 5px 0 var(--c-red);
  font: 700 1.3rem/1.2 var(--f-second); text-transform: uppercase; letter-spacing: 0.04em; text-align: center;
  padding: 0.7rem 1.1rem 0.6rem;
}
.egg-layer { position: fixed; inset: 0; z-index: 45; overflow: hidden; pointer-events: none; }

/* secret code: mold minions (little green caps with a pale rim) */
.minion {
  position: absolute; left: 0; top: 0; width: 58px; height: 46px; scale: var(--size, 1);
  background: var(--c-green); border: 3px solid var(--c-ink); border-bottom: 7px solid var(--c-cream);
  border-radius: 50% 50% 44% 44% / 68% 68% 32% 32%;
  background-image: radial-gradient(circle at 34% 58%, var(--c-ink) 0 4px, transparent 4.5px), radial-gradient(circle at 66% 58%, var(--c-ink) 0 4px, transparent 4.5px);
  animation: fx-swarm 3.1s cubic-bezier(0.3, 0, 0.3, 1) both;
}
.minion::after { content: ""; position: absolute; left: 34%; top: 100%; width: 32%; height: 16px; margin-top: 7px; background: var(--c-cream); border: 3px solid var(--c-ink); border-top: 0; }
/* the Ninja: a purple blur with a headband tail (he gets real art once his character sheet exists) */
.kick {
  position: absolute; left: 0; top: 34vh; width: 75vw; height: 9rem; transform: skewX(-24deg);
  background: linear-gradient(90deg, transparent, var(--c-magenta) 30%, var(--c-purple) 62%, var(--c-yellow) 62% 70%, var(--c-purple) 70% 88%, var(--c-cream) 88%);
  -webkit-mask-image: repeating-linear-gradient(180deg, #000 0 20px, transparent 20px 26px); mask-image: repeating-linear-gradient(180deg, #000 0 20px, transparent 20px 26px);
  animation: fx-kick 0.5s 1.5s cubic-bezier(0.5, 0, 0.2, 1) both;
}
.pow {
  position: absolute; left: 50%; top: 42vh; translate: -50% -50%;
  font: 400 clamp(4rem, 14vw, 10rem)/1 var(--f-display); text-transform: uppercase; white-space: nowrap;
  color: var(--c-yellow); text-shadow: 5px 5px 0 var(--c-red), 10px 10px 0 var(--c-ink); -webkit-text-stroke: 2px var(--c-ink);
  animation: fx-pow 1.5s 1.65s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
@keyframes fx-swarm {
  0% { translate: var(--x0) var(--y0); rotate: 0deg; }
  38% { translate: var(--x1) var(--y1); rotate: -8deg; }
  44% { rotate: 8deg; }
  52% { translate: var(--x1) var(--y1); rotate: -6deg; }
  100% { translate: var(--x2) var(--y2); rotate: 900deg; }
}
@keyframes fx-kick { 0% { translate: -80vw 0; opacity: 1; } 100% { translate: 130vw 0; opacity: 1; } }
@keyframes fx-pow {
  0% { opacity: 0; scale: 0.2; rotate: -14deg; }
  18% { opacity: 1; scale: 1; rotate: -6deg; }
  75% { opacity: 1; scale: 1.04; rotate: -6deg; }
  100% { opacity: 0; scale: 1.25; rotate: -6deg; }
}

/* contamination: green fuzz creeps in from the edges; the Sterilize button clears it */
.egg-layer--fuzz { transition: opacity 0.7s, background-color 0.25s; }
.fuzz {
  position: absolute; translate: -50% -50%; border-radius: 47% 53% 51% 49% / 52% 46% 54% 48%;
  background:
    radial-gradient(circle, rgba(24, 23, 19, 0.28) 1.5px, transparent 2px) 0 0 / 9px 9px,
    radial-gradient(circle, var(--c-green) 0 52%, rgba(101, 184, 62, 0.75) 60%, rgba(242, 222, 180, 0.7) 66%, transparent 71%);
  animation: fx-creep 4.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.is-still .fuzz { animation: none; }
.fuzz__warning {
  position: absolute; left: 50%; top: 1rem; translate: -50% 0; width: max-content; max-width: calc(100% - 2rem);
  background: var(--c-ink); color: var(--c-green); border: 3px solid var(--c-green);
  font: 400 clamp(1.3rem, 3.2vw, 2.2rem)/1.1 var(--f-display); text-transform: uppercase; text-align: center; padding: 0.7rem 1.1rem;
}
.fuzz__button { position: absolute; left: 50%; bottom: 4.5rem; translate: -50% 0; pointer-events: auto; cursor: pointer; }
.egg-layer--fuzz.is-clean { opacity: 0; background-color: var(--c-cream); }
@keyframes fx-creep { from { scale: 0.02; opacity: 0.4; } to { scale: 1; opacity: 1; } }

/* 420: a slow drift of spores */
.spore {
  position: absolute; top: -4vh; border-radius: 50%; background: var(--c-cream); border: 2px solid var(--c-ink);
  animation: fx-drift 7s linear both;
}
.spore:nth-child(3n) { background: var(--c-yellow); }
@keyframes fx-drift { from { translate: 0 0; } to { translate: var(--drift, 0) 112vh; } }

/* the "page not found" page */
.lost { background-color: var(--c-navy); color: var(--c-cream); background-image: radial-gradient(circle, rgba(242, 222, 180, 0.09) 1.6px, transparent 2px); background-size: 11px 11px; }
.lost__box { padding: var(--s-5) 0 var(--s-6); }
.lost__reel { font: 600 1.15rem/1.2 var(--f-second); text-transform: uppercase; letter-spacing: 0.22em; }
.lost__title { font-size: clamp(2.8rem, 8.5vw, 7rem); }
.lost__line { font-size: var(--t-lead); line-height: 1.4; max-width: 30em; margin-bottom: var(--s-4); }

@media (max-width: 760px) {
  .soundstub { font-size: 0.9rem; }
}

/* ---------- people who turned off motion: nothing moves ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}
