/* Number-themed decoration and easter eggs for the public pages. Uses each page's own tokens; pairs with fun.js.
   Everything that moves by itself is inside the no-preference block at the bottom, so reduced-motion visitors get a still page. */
:root { --add: #E7C34A; --sub: #6E93A8; --mul: #E8C4C2; --div: #A9C24D; --turkey: #8A5A3B; }

/* drifting numbers behind the first screen */
.fun-sky { position: absolute; inset: 0 0 auto; height: min(100vh, 900px); overflow: hidden; pointer-events: none; z-index: -1; }
.fun-sky i { position: absolute; font: 700 var(--s, 120px)/1 "JetBrains Mono", ui-monospace, Menlo, monospace; font-style: normal; opacity: .42; user-select: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fun-sky i { opacity: .2; } }
:root[data-theme="dark"] .fun-sky i { opacity: .2; }
/* phones: the hero is all text, so the numbers sit fainter behind it */
@media (max-width: 760px) { .fun-sky i:nth-child(n) { font-size: calc(var(--s, 120px) * .6); opacity: .22; } .fun-sky i:nth-child(n+6) { display: none; } }

/* no stray digits behind a lesson, a quiz or a live arcade round: fun.js sets data-fun-quiet off a course's home view */
:root[data-fun-quiet] .fun-sky, body:has(#game:not([hidden])) .fun-sky { display: none; }

/* hand-drawn underline under the headline's accent words */
h1 em { position: relative; }
.fun-swash { position: absolute; left: -2%; bottom: -.16em; width: 104%; height: .22em; overflow: visible; pointer-events: none; }
.fun-swash path { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; vector-effect: non-scaling-stroke; stroke-dasharray: 1; }

/* number-line scroll progress */
.fun-line { position: fixed; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: 4px; z-index: 20; pointer-events: none;
  background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 10%); }
.fun-line b { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }

/* the 3 with eyes: watches the pointer, winks when clicked */
.fun-host { position: relative; }
.fun-three { position: absolute; top: 14px; right: 3%; width: 54px; padding: 0; border: 0; background: none; color: var(--ink); cursor: pointer; z-index: 1; }
.fun-three svg { display: block; width: 100%; height: auto; overflow: visible; }
.fun-three .eye { fill: #FFFFFF; stroke: currentColor; stroke-width: 2; }
.fun-three .pupil { fill: #0E0E0E; }
.fun-three .lids { transform-origin: 50% 27px; }
.fun-three.wink .lids { transform: scaleY(.1); }
@media (max-width: 760px) {
  .fun-three { top: auto; bottom: 0; right: 8px; width: 30px; }
  .fun-host:has(.facts) .fun-three { bottom: -46px; }  /* heroes that end in the stats box: sit just below it, not on its text */
}

/* turkey */
.fun-turkey { display: inline-flex; align-items: center; gap: 8px; padding: 0 4px; min-height: 44px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.fun-turkey svg { width: 40px; height: 40px; overflow: visible; }
.fun-turkey .fan { transform-origin: 32px 40px; }

/* digit rain from the logo dot */
.fun-rain { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 30; }
.fun-rain i { position: absolute; top: -60px; font: 700 28px/1 "JetBrains Mono", ui-monospace, Menlo, monospace; font-style: normal; }

.art i { transition: translate .18s ease, scale .18s ease; }
/* the shine runs on each page's one main button only */
.hero-actions .btn, .btn.hot { position: relative; overflow: hidden; }

@media (prefers-reduced-motion: no-preference) {
  .fun-sky i { animation: fun-drift var(--d, 18s) ease-in-out infinite alternate; }
  @keyframes fun-drift { to { transform: translate(var(--x, 20px), var(--y, -26px)) rotate(var(--r, 8deg)); } }

  .fun-swash path { animation: fun-draw .7s .35s cubic-bezier(.16, 1, .3, 1) both; }
  @keyframes fun-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

  .fun-rise { opacity: 0; transform: translateY(18px); transition: opacity .5s ease, transform .5s cubic-bezier(.16, 1, .3, 1); }
  .fun-rise.in { opacity: 1; transform: none; }

  .hero-actions .btn::after, .btn.hot::after { content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, .28); transform: translateX(-130%) skewX(-20deg); animation: fun-shine 6s 2s ease-in-out infinite; pointer-events: none; }
  @keyframes fun-shine { 0%, 82% { transform: translateX(-130%) skewX(-20deg); } 100% { transform: translateX(130%) skewX(-20deg); } }

  .art i:hover { translate: 0 -6px; scale: 1.06; }
  .fun-three .lids { transition: transform .1s ease; }
  .fun-three .pupil { transition: transform .12s ease-out; }

  .fun-turkey.dance svg { animation: fun-hop .45s ease-in-out 7; }
  .fun-turkey.dance .fan { animation: fun-fan .45s ease-in-out 7; }
  @keyframes fun-hop { 0%, 100% { transform: translateY(0) rotate(-10deg); } 50% { transform: translateY(-9px) rotate(10deg); } }
  @keyframes fun-fan { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18) rotate(6deg); } }

  .fun-rain i { animation: fun-fall var(--d, 2s) var(--w, 0s) cubic-bezier(.4, 0, .9, .6) forwards; }
  @keyframes fun-fall { to { transform: translateY(calc(100vh + 80px)) rotate(var(--r, 90deg)); } }
}
