/* Hausbuch – effects (static/js/effekte.js, docs/PILOT.md 2.6 and 3.5).

   Rules: silent, short, never in the way. Only transform and opacity are animated, nothing
   in .fx-layer ever catches a tap (pointer-events: none) and the layer is aria-hidden.
   Colours come from the tokens below (light and dark); the pixel cat is our own drawing in
   static/img/effekte/katze.svg and katze-2.svg (second frame for the legs and the tail).

   Sizes the script relies on: .fx-cat 105 × 60 px (35 × 20 pixels of 3 px),
   .fx-rainbow__seg 18 × 42 px. */

:root {
  /* confetti, sparks and stars – deeper tones so they read on light paper */
  --fx-confetti-0: #E9AE00;
  --fx-confetti-1: #2E7552;
  --fx-confetti-2: #3FAE7A;
  --fx-confetti-3: #E2579C;
  --fx-confetti-4: #3D8ED6;
  --fx-confetti-5: #EE8A3A;
  --fx-spark-0: #E9AE00;
  --fx-spark-1: var(--green);
  --fx-spark-2: #E2579C;
  --fx-star-0: #E2A400;
  --fx-star-1: #DD4A9E;
  --fx-star-2: #2F8FDB;
  --fx-crumb-0: #F7CB95;
  --fx-crumb-1: #F9A3D3;
  --fx-crumb-2: #E3A866;
  --fx-crumb-edge: rgba(36, 32, 46, .55);
  --fx-bite-shadow: drop-shadow(-2px 0 0 rgba(28, 39, 51, .28)) drop-shadow(0 8px 14px rgba(28, 39, 51, .2));
  /* standard style */
  --fx-ring: var(--green);
  --fx-stamp: var(--green);
  --fx-stamp-paper: color-mix(in srgb, var(--surface) 82%, transparent);
  --fx-glow: var(--marker);
  --fx-bubble-edge: var(--ink);
  /* nyan style: six stripes, red to violet */
  --fx-rainbow-1: #F0434D;
  --fx-rainbow-2: #F7952B;
  --fx-rainbow-3: #F8D83A;
  --fx-rainbow-4: #4FBF5A;
  --fx-rainbow-5: #3A9FEF;
  --fx-rainbow-6: #7B5AD6;
  --fx-rainbow: linear-gradient(to bottom,
    var(--fx-rainbow-1) 0 16.67%, var(--fx-rainbow-2) 16.67% 33.33%, var(--fx-rainbow-3) 33.33% 50%,
    var(--fx-rainbow-4) 50% 66.67%, var(--fx-rainbow-5) 66.67% 83.33%, var(--fx-rainbow-6) 83.33% 100%);
  --fx-cat-halo: none;
  --fx-shadow: 0 10px 30px rgba(28, 39, 51, .18);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fx-confetti-0: #FFE15A;
    --fx-confetti-1: #7FCBA2;
    --fx-confetti-2: #4FD1A0;
    --fx-confetti-3: #F59BD0;
    --fx-confetti-4: #8CC4F2;
    --fx-confetti-5: #F6B26B;
    --fx-spark-0: #FFE15A;
    --fx-spark-2: #F59BD0;
    --fx-star-0: #FFE15A;
    --fx-star-1: #FF9ED8;
    --fx-star-2: #9AD4FF;
    --fx-crumb-edge: rgba(0, 0, 0, .45);
    --fx-bite-shadow: drop-shadow(-2px 0 0 rgba(236, 238, 233, .35)) drop-shadow(0 8px 14px rgba(0, 0, 0, .5));
    --fx-rainbow-6: #9373E8;
    --fx-cat-halo: drop-shadow(0 0 1px rgba(236, 238, 233, .55));
    --fx-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  }
}
:root[data-theme="dark"] {
  --fx-confetti-0: #FFE15A;
  --fx-confetti-1: #7FCBA2;
  --fx-confetti-2: #4FD1A0;
  --fx-confetti-3: #F59BD0;
  --fx-confetti-4: #8CC4F2;
  --fx-confetti-5: #F6B26B;
  --fx-spark-0: #FFE15A;
  --fx-spark-2: #F59BD0;
  --fx-star-0: #FFE15A;
  --fx-star-1: #FF9ED8;
  --fx-star-2: #9AD4FF;
  --fx-crumb-edge: rgba(0, 0, 0, .45);
  --fx-bite-shadow: drop-shadow(-2px 0 0 rgba(236, 238, 233, .35)) drop-shadow(0 8px 14px rgba(0, 0, 0, .5));
  --fx-rainbow-6: #9373E8;
  --fx-cat-halo: drop-shadow(0 0 1px rgba(236, 238, 233, .55));
  --fx-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

/* ---------------------------------------------------------------- layer */
.fx-layer {
  position: fixed; inset: 0; z-index: 60;
  overflow: hidden; contain: strict;
  pointer-events: none; user-select: none; -webkit-user-select: none;
}
.fx-layer * { pointer-events: none !important; }

/* ------------------------------------------------------------- standard */
/* login: greeting bubble below the top bar */
.fx-hello {
  position: absolute; left: 50%; top: calc(72px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 12px;
  width: max-content; max-width: min(92vw, 420px); padding: 10px 20px 10px 14px;
  border-radius: 20px; border: 2px solid var(--fx-bubble-edge);
  background: var(--surface); color: var(--ink); box-shadow: 0 5px 0 -1px var(--marker), var(--fx-shadow);
  opacity: 0;
}
.fx-hello::before {
  content: ""; position: absolute; top: -9px; left: calc(50% - 8px); width: 14px; height: 14px;
  background: var(--surface); border-left: 2px solid var(--fx-bubble-edge); border-top: 2px solid var(--fx-bubble-edge);
  border-top-left-radius: 3px; transform: rotate(45deg);
}
.fx-hello__hand { flex: none; font-size: 2rem; line-height: 1; transform-origin: 70% 85%; }
.fx-hello__lines { display: grid; gap: 2px; min-width: 0; }
.fx-hello__title {
  font-family: var(--font-head); font-weight: 800; font-size: 1.55rem; line-height: 1;
  text-transform: uppercase; letter-spacing: .02em;
}
.fx-hello__text { color: var(--ink-soft); font-weight: 700; font-size: .98rem; line-height: 1.25; }

/* eingetragen: a ring around the card ("plopp") or a round check, plus sparks */
.fx-ring {
  position: absolute; border: 3px solid var(--fx-ring); border-radius: var(--radius-lg);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--fx-ring) 22%, transparent); opacity: 0;
}
.fx-pop {
  position: absolute; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 7px color-mix(in srgb, var(--green) 24%, transparent), var(--fx-shadow);
  opacity: 0;
}
.fx-pop::after {
  content: ""; position: absolute; left: 23px; top: 13px; width: 14px; height: 27px;
  border-right: 6px solid var(--green-ink); border-bottom: 6px solid var(--green-ink); border-radius: 0 0 3px 0;
  transform: rotate(45deg);
}
.fx-spark {
  position: absolute; width: 16px; height: 16px; background: var(--fx-spark-0); opacity: 0;
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
}
.fx-spark--1 { background: var(--fx-spark-1); }
.fx-spark--2 { background: var(--fx-spark-2); }
.fx-spark--small { width: 11px; height: 11px; }
.fx-spark--big { width: 22px; height: 22px; }

/* confetti: four shapes, six colours */
.fx-confetti { position: absolute; width: 9px; height: 14px; border-radius: 2px; opacity: 0; }
.fx-confetti--round { width: 10px; height: 10px; border-radius: 50%; }
.fx-confetti--strip { width: 5px; height: 17px; border-radius: 3px; }
.fx-confetti--square { width: 10px; height: 10px; border-radius: 1px; }
.fx-confetti--0 { background: var(--fx-confetti-0); }
.fx-confetti--1 { background: var(--fx-confetti-1); }
.fx-confetti--2 { background: var(--fx-confetti-2); }
.fx-confetti--3 { background: var(--fx-confetti-3); }
.fx-confetti--4 { background: var(--fx-confetti-4); }
.fx-confetti--5 { background: var(--fx-confetti-5); }

/* erledigt: tilted stamp with a double frame */
.fx-stamp {
  position: absolute; z-index: 2; display: block; padding: 8px 20px 5px;
  border: 5px solid var(--fx-stamp); border-radius: 12px;
  box-shadow: inset 0 0 0 3px var(--fx-stamp-paper), inset 0 0 0 5px var(--fx-stamp);
  background: var(--fx-stamp-paper); color: var(--fx-stamp);
  font-family: var(--font-head); font-weight: 800; font-size: clamp(2.3rem, 11vw, 3.1rem);
  line-height: 1; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  opacity: 0;
}
.fx-impact {
  position: absolute; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%;
  border: 4px solid var(--fx-stamp); opacity: 0;
}

/* quest: badge with a glowing medal */
.fx-badge {
  position: absolute; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 14px;
  width: max-content; max-width: min(92vw, 440px); padding: 12px 22px 12px 12px;
  border-radius: var(--radius-lg); border: 2px solid var(--fx-bubble-edge);
  background: var(--surface); color: var(--ink); box-shadow: var(--fx-shadow);
  opacity: 0;
}
.fx-badge__medal { position: relative; flex: none; width: 56px; height: 56px; }
.fx-badge__rays {
  position: absolute; inset: -26px; border-radius: 50%; opacity: 0;
  background: repeating-conic-gradient(from 0deg,
    color-mix(in srgb, var(--fx-glow) 90%, transparent) 0deg 9deg, transparent 9deg 30deg);
  -webkit-mask-image: radial-gradient(circle, #000 32%, transparent 70%);
  mask-image: radial-gradient(circle, #000 32%, transparent 70%);
}
.fx-badge__glow {
  position: absolute; inset: -16px; border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, color-mix(in srgb, var(--fx-glow) 95%, transparent) 0, transparent 70%);
}
.fx-badge__star {
  position: absolute; inset: 0; border-radius: 50%;
  background: var(--marker); box-shadow: inset 0 0 0 3px var(--marker-ink);
}
.fx-badge__star::before {
  content: ""; position: absolute; inset: 12px; background: var(--marker-ink);
  clip-path: polygon(50% 0, 61.8% 35%, 98% 35%, 68.6% 56.6%, 79.4% 91%, 50% 70%, 20.6% 91%, 31.4% 56.6%, 2% 35%, 38.2% 35%);
}
.fx-badge__text { display: grid; gap: 2px; min-width: 0; }
.fx-badge__eyebrow {
  font-size: .85rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft);
}
.fx-badge__title { font-weight: 700; font-size: 1.05rem; line-height: 1.25; overflow-wrap: anywhere; }
.fx-badge .fx-badge__cat { position: absolute; right: 18px; top: -27px; }

/* finale: the big title card */
.fx-finale {
  position: absolute; z-index: 3; left: 50%; top: 44%;
  display: grid; justify-items: center; gap: 4px;
  width: max-content; max-width: 92vw; padding: 16px 28px 14px;
  border-radius: var(--radius-lg); background: var(--marker); color: var(--marker-ink);
  box-shadow: 0 6px 0 -1px var(--marker-ink), var(--fx-shadow); text-align: center;
  opacity: 0;
}
.fx-finale__title {
  font-family: var(--font-head); font-weight: 800; font-size: clamp(2.2rem, 10vw, 3.6rem);
  line-height: 1; text-transform: uppercase; white-space: nowrap;
}
.fx-finale__text { font-weight: 700; }

/* ----------------------------------------------------------------- nyan */
/* A flying cat: .fx-nyan holds the rainbow trail and the cat side by side. */
.fx-nyan {
  position: absolute; left: 0; top: 0;
  z-index: 2; display: flex; align-items: flex-start; will-change: transform;
}
.fx-cat { position: relative; flex: none; width: 105px; height: 60px; }
.fx-cat__sprite {
  position: absolute; inset: 0; filter: var(--fx-cat-halo);
  animation: fx-bob 360ms steps(1, end) infinite;
}
.fx-cat__frame { position: absolute; inset: 0; background: no-repeat center / 100% 100%; }
.fx-cat__frame--a {
  background-image: url("../img/effekte/katze.276a206e3ae1.svg");
  animation: fx-frame-a 360ms steps(1, end) infinite;
}
.fx-cat__frame--b {
  background-image: url("../img/effekte/katze-2.7508077fde1e.svg"); opacity: 0;
  animation: fx-frame-b 360ms steps(1, end) infinite;
}
.fx-cat--small { width: 52px; height: 30px; }
.fx-cat--flip .fx-cat__sprite { transform: scaleX(-1); animation-name: fx-bob-flip; }

.fx-rainbow {
  display: flex; flex: none; margin-top: 4px; margin-right: -15px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 45%);
  mask-image: linear-gradient(to right, transparent 0, #000 45%);
}
.fx-rainbow__seg {
  display: block; flex: none; width: 18px; height: 42px; background: var(--fx-rainbow);
  animation: fx-wave 360ms steps(1, end) infinite;
}
.fx-rainbow__seg:nth-child(even) { animation-delay: -180ms; }

/* twinkling pixel star: two bars that grow and shrink */
.fx-star { position: absolute; width: 21px; height: 21px; color: var(--fx-star-0); opacity: 0; }
.fx-star::before, .fx-star::after {
  content: ""; position: absolute; background: currentColor;
  animation: fx-twinkle-y 520ms steps(1, end) infinite; animation-delay: var(--fx-twinkle-delay, 0ms);
}
.fx-star::before { left: 9px; top: 0; width: 3px; height: 21px; }
.fx-star::after { left: 0; top: 9px; width: 21px; height: 3px; animation-name: fx-twinkle-x; }
.fx-star--1 { color: var(--fx-star-1); }
.fx-star--2 { color: var(--fx-star-2); }
.fx-star--small { width: 15px; height: 15px; }
.fx-star--small::before { left: 6px; height: 15px; }
.fx-star--small::after { top: 6px; width: 15px; }

/* eingetragen: the cat peeks out from behind the bottom bar, bottom right */
.fx-peek {
  position: absolute; right: 0; bottom: calc(65px + env(safe-area-inset-bottom));
  width: 170px; height: 120px; overflow: hidden;
}
.fx-peek .fx-cat { position: absolute; right: -16px; bottom: -4px; }

/* erledigt: a stand-in of the card that the cat eats (the real one rests meanwhile).
   .fx-munch is the window that moves right bite by bite (scalloped left edge), the plate
   inside moves back so the card stays where it was. */
.fx-munch-shell { position: absolute; left: 0; top: 0; filter: var(--fx-bite-shadow); }
.fx-munch {
  position: absolute; overflow: hidden;
  -webkit-mask-image: radial-gradient(circle at 0 50%, transparent 10px, #000 11px), linear-gradient(#000, #000);
  -webkit-mask-size: 22px 30px, calc(100% - 10px) 100%;
  -webkit-mask-position: 0 0, 100% 0;
  -webkit-mask-repeat: repeat-y, no-repeat;
  mask-image: radial-gradient(circle at 0 50%, transparent 10px, #000 11px), linear-gradient(#000, #000);
  mask-size: 22px 30px, calc(100% - 10px) 100%;
  mask-position: 0 0, 100% 0;
  mask-repeat: repeat-y, no-repeat;
}
.fx-munch__plate { position: absolute; inset: 0; }
.fx-ghost { position: absolute; margin: 0 !important; box-sizing: border-box; }
.fx-munch-hidden { opacity: 0 !important; }
.fx-crumb {
  position: absolute; width: 6px; height: 6px; background: var(--fx-crumb-0);
  box-shadow: 0 0 0 1px var(--fx-crumb-edge); opacity: 0;
}
.fx-crumb--1 { background: var(--fx-crumb-1); }
.fx-crumb--2 { background: var(--fx-crumb-2); width: 4px; height: 4px; }

/* ------------------------------------------------ calm (reduced motion) */
.fx-check {
  position: absolute; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; padding: 8px 18px 8px 8px;
  border-radius: 999px; border: 2px solid var(--green); background: var(--green-soft); color: var(--ink);
  font-weight: 700; white-space: nowrap; transform: translateX(-50%); opacity: 0;
}
.fx-check__mark { position: relative; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--green); }
.fx-check__mark::after {
  content: ""; position: absolute; left: 10px; top: 5px; width: 7px; height: 14px;
  border-right: 3px solid var(--green-ink); border-bottom: 3px solid var(--green-ink); transform: rotate(45deg);
}

@media (min-width: 900px) {
  .fx-badge, .fx-check { bottom: 48px; }
  .fx-peek { bottom: 0; }
}

/* ------------------------------------------------------------ keyframes */
@keyframes fx-bob { 0% { transform: translateY(0); } 50% { transform: translateY(-3px); } 100% { transform: translateY(-3px); } }
@keyframes fx-bob-flip {
  0% { transform: scaleX(-1) translateY(0); } 50% { transform: scaleX(-1) translateY(-3px); }
  100% { transform: scaleX(-1) translateY(-3px); }
}
@keyframes fx-frame-a { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 0; } }
@keyframes fx-frame-b { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 1; } }
@keyframes fx-wave { 0% { transform: translateY(0); } 50% { transform: translateY(3px); } 100% { transform: translateY(3px); } }
@keyframes fx-twinkle-y {
  0% { transform: scaleY(.15); } 25% { transform: scaleY(.43); } 50% { transform: scaleY(1); }
  75% { transform: scaleY(.43); } 100% { transform: scaleY(.43); }
}
@keyframes fx-twinkle-x {
  0% { transform: scaleX(.15); } 25% { transform: scaleX(.43); } 50% { transform: scaleX(1); }
  75% { transform: scaleX(.43); } 100% { transform: scaleX(.43); }
}
/* Movement off: no stepping, no bobbing (the script plays calm checks anyway). */
@media (prefers-reduced-motion: reduce) {
  .fx-cat__sprite, .fx-cat__frame, .fx-rainbow__seg, .fx-star::before, .fx-star::after {
    animation: none !important;
  }
}

/* Fetch the cat early for people who chose it, so the first flight is never empty. */
@media (prefers-reduced-motion: no-preference) {
  body[data-effekte="nyan"]::after {
    content: ""; position: fixed; left: 0; top: 0; width: 1px; height: 1px;
    opacity: 0; pointer-events: none;
    background-image: url("../img/effekte/katze.276a206e3ae1.svg"), url("../img/effekte/katze-2.7508077fde1e.svg");
  }
}

@media print {
  .fx-layer { display: none !important; }
}
