/* Gnist-manden: animeret maskot bygget direkte på figuren fra det originale logo
   (tegnet af Mettes datter). Figuren er delt i hoved, to ben og hofte, så hver del
   kan animeres. Tilstand styres med data-state på .gnist-host. */

.gnist-host {
  --g-fill: #f8d648;
  --g-edge: #e2b417;
  --g-ink: #14233a;
  position: relative;
  display: inline-block;
  width: 9rem;
  aspect-ratio: 1;
  line-height: 0;
}

.gnist {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.gnist .g-part {
  fill: var(--g-fill);
}

.gnist .g-shadow {
  fill: rgb(20 35 58 / 0.13);
  transform-origin: 70px 135px;
}

.gnist .g-eye {
  fill: var(--g-ink);
}

.gnist .g-smile {
  fill: none;
  stroke: var(--g-ink);
  stroke-width: 2.3;
  stroke-linecap: round;
}

.gnist .g-cheek {
  fill: #f2967b;
  opacity: 0.55;
}

.gnist-host[data-face="off"] .g-face {
  display: none;
}

.gnist .g-spark {
  fill: var(--g-fill);
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
}

/* Omdrejningspunkter (i viewBox-enheder, 0 0 140 140) */
.gnist .g-body { transform-origin: 69px 134px; filter: drop-shadow(0 1px 0 var(--g-edge)) drop-shadow(0 6px 10px rgb(226 180 23 / 0.25)); }
.gnist .g-head { transform-origin: 70px 50px; }
.gnist .g-leg-l { transform-origin: 64px 61px; }
.gnist .g-leg-r { transform-origin: 73px 65px; }
.gnist .g-eyes { transform-origin: 70px 48px; }
.gnist .g-look { transition: translate 0.25s ease-out; }

/* ---------- Tilstande ---------- */

/* Hvile: vugger, blinker, gnister glimter */
.gnist-host[data-state="idle"] .g-body { animation: g-bob 2.8s ease-in-out infinite; }
.gnist-host[data-state="idle"] .g-head { animation: g-wobble 5s ease-in-out infinite; }
.gnist-host .g-eyes { animation: g-blink 5.5s infinite; }
.gnist-host[data-state="idle"] .g-spark,
.gnist-host[data-state="climb"] .g-spark { animation: g-twinkle 3s ease-in-out infinite; }
.gnist-host .g-spark:nth-child(2) { animation-delay: -1s; }
.gnist-host .g-spark:nth-child(3) { animation-delay: -2s; }
.gnist-host .g-spark:nth-child(4) { animation-delay: -0.5s; }

/* Hop */
.gnist-host[data-state="hop"] .g-body { animation: g-hop 1.1s cubic-bezier(.3,.7,.4,1) infinite; }
.gnist-host[data-state="hop"] .g-leg-l { animation: g-tuck-l 1.1s ease-in-out infinite; }
.gnist-host[data-state="hop"] .g-leg-r { animation: g-tuck-r 1.1s ease-in-out infinite; }
.gnist-host[data-state="hop"] .g-shadow { animation: g-shadow 1.1s cubic-bezier(.3,.7,.4,1) infinite; }

/* Hilser (vinker med foden) */
.gnist-host[data-state="wave"] .g-body { animation: g-lean 1.6s ease-in-out infinite; }
.gnist-host[data-state="wave"] .g-leg-r { animation: g-kick 0.8s ease-in-out infinite alternate; }
.gnist-host[data-state="wave"] .g-head { animation: g-nod 1.6s ease-in-out infinite; }

/* Tænker */
.gnist-host[data-state="think"] .g-head { rotate: 12deg; transition: rotate 0.4s; }
.gnist-host[data-state="think"] .g-body { animation: g-bob 3.6s ease-in-out infinite; }
.gnist-host[data-state="think"] .g-dots { opacity: 1; }
.gnist .g-dots { opacity: 0; transition: opacity 0.3s; }
.gnist .g-dots circle { fill: var(--g-ink); animation: g-dot 1.2s ease-in-out infinite; }
.gnist .g-dots circle:nth-child(2) { animation-delay: 0.15s; }
.gnist .g-dots circle:nth-child(3) { animation-delay: 0.3s; }

/* Jubler */
.gnist-host[data-state="cheer"] .g-body { animation: g-hop 0.9s cubic-bezier(.3,.7,.4,1) infinite; }
.gnist-host[data-state="cheer"] .g-head { animation: g-spin 1.8s cubic-bezier(.6,0,.3,1) infinite; }
.gnist-host[data-state="cheer"] .g-spark { animation: g-burst 0.9s ease-out infinite; }
.gnist-host[data-state="cheer"] .g-shadow { animation: g-shadow 0.9s cubic-bezier(.3,.7,.4,1) infinite; }

/* Klatrer (bruges på læsetrappen) */
.gnist-host[data-state="climb"] .g-body { animation: g-step 0.7s ease-in-out infinite; }
.gnist-host[data-state="climb"] .g-leg-l { animation: g-swing 0.7s ease-in-out infinite; }
.gnist-host[data-state="climb"] .g-leg-r { animation: g-swing 0.7s ease-in-out infinite reverse; }

/* Sover */
.gnist-host[data-state="sleep"] .g-head { rotate: 22deg; transition: rotate 0.6s; }
.gnist-host[data-state="sleep"] .g-body { animation: g-breathe 3.4s ease-in-out infinite; }
.gnist-host[data-state="sleep"] .g-eyes { animation: none; scale: 1 0.12; }
.gnist-host[data-state="sleep"] .g-zzz { opacity: 1; }
.gnist .g-zzz { opacity: 0; font: 700 13px/1 "Fraunces", serif; fill: var(--g-ink); }
.gnist .g-zzz text { animation: g-zzz 2.4s ease-in infinite; transform-box: fill-box; }
.gnist .g-zzz text:nth-child(2) { animation-delay: 0.8s; }
.gnist .g-zzz text:nth-child(3) { animation-delay: 1.6s; }

/* Tændes (intro) */
.gnist-host.is-igniting .g-body { animation: g-ignite 1.1s cubic-bezier(.2,1.4,.4,1) both; }
.gnist-host.is-igniting .g-spark { animation: g-burst 1.1s ease-out both; }

@keyframes g-bob { 50% { translate: 0 -3px; } }
@keyframes g-wobble { 25% { rotate: -5deg; } 75% { rotate: 5deg; } }
@keyframes g-nod { 50% { rotate: -8deg; } }
@keyframes g-blink { 0%, 93%, 100% { scale: 1 1; } 95% { scale: 1 0.1; } }
@keyframes g-twinkle { 0%, 100% { opacity: 0; scale: 0.4; rotate: 0deg; } 50% { opacity: 1; scale: 1; rotate: 45deg; } }
@keyframes g-hop {
  0%, 100% { translate: 0 0; scale: 1 1; }
  12% { translate: 0 0; scale: 1.1 0.88; }
  45% { translate: 0 -24px; scale: 0.95 1.07; }
  72% { translate: 0 0; scale: 1.08 0.9; }
  86% { scale: 0.98 1.02; }
}
@keyframes g-shadow { 0%, 100% { scale: 1; opacity: 1; } 45% { scale: 0.6; opacity: 0.5; } }
@keyframes g-tuck-l { 45% { rotate: 14deg; } }
@keyframes g-tuck-r { 45% { rotate: -14deg; } }
@keyframes g-lean { 50% { rotate: -4deg; } }
@keyframes g-kick { from { rotate: 0deg; } to { rotate: -38deg; } }
@keyframes g-dot { 50% { translate: 0 -3px; opacity: 0.4; } }
@keyframes g-spin { 0%, 30% { rotate: 0deg; } 70%, 100% { rotate: 360deg; } }
@keyframes g-burst {
  0% { opacity: 0; scale: 0.2; translate: 0 0; }
  30% { opacity: 1; scale: 1.1; }
  100% { opacity: 0; scale: 0.6; translate: var(--bx, 0) var(--by, -14px); }
}
@keyframes g-step { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }
@keyframes g-swing { 0%, 100% { rotate: -16deg; } 50% { rotate: 16deg; } }
@keyframes g-breathe { 50% { scale: 1.02 0.98; } }
@keyframes g-zzz {
  0% { opacity: 0; translate: 0 0; scale: 0.6; }
  30% { opacity: 1; }
  100% { opacity: 0; translate: 10px -22px; scale: 1.2; }
}
@keyframes g-ignite {
  0% { scale: 0; rotate: -160deg; filter: drop-shadow(0 0 0 rgb(248 214 72 / 0)); }
  60% { scale: 1.15; rotate: 10deg; filter: drop-shadow(0 0 16px rgb(248 214 72 / 0.95)); }
  100% { scale: 1; rotate: 0deg; filter: drop-shadow(0 0 0 rgb(248 214 72 / 0)); }
}


/* Taler (bruges når gnist-manden læser højt) */
.gnist .g-smile { transform-box: fill-box; transform-origin: center; }
.gnist-host[data-state="talk"] .g-body { animation: g-bob 1.6s ease-in-out infinite; }
.gnist-host[data-state="talk"] .g-head { animation: g-nod 2.4s ease-in-out infinite; }
.gnist-host[data-state="talk"] .g-smile { animation: g-talk 0.32s ease-in-out infinite alternate; }
.gnist-host[data-state="talk"] .g-spark { animation: g-twinkle 2s ease-in-out infinite; }
@keyframes g-talk { from { scale: 1 0.5; } to { scale: 1.08 1.6; } }
/* Taleboble */
.g-bubble {
  position: absolute;
  bottom: 88%;
  right: 62%;
  z-index: 2;
  width: max-content;
  max-width: 17rem;
  padding: 0.75rem 1rem;
  border-radius: 18px 18px 4px 18px;
  background: #fff;
  box-shadow: 0 14px 34px -14px rgb(20 35 58 / 0.4);
  color: #14233a;
  font: 500 1rem/1.45 "Lexend", system-ui, sans-serif;
  text-align: left;
  opacity: 0;
  scale: 0.85;
  transform-origin: 100% 100%;
  transition: opacity 0.25s, scale 0.35s cubic-bezier(.3,1.5,.5,1);
  pointer-events: none;
}

.g-bubble.is-open {
  opacity: 1;
  scale: 1;
}

@media (prefers-reduced-motion: reduce) {
  .gnist-host *, .gnist-host.is-igniting * { animation: none !important; transition: none !important; }
  .gnist .g-spark { opacity: 1; }
}

html[data-motion="off"] .gnist-host * { animation: none !important; transition: none !important; }
