/* =========================================
   HOME PAGE SCROLL FUN (just for entertainment)
   1. A caterpillar walks along the grass as you scroll,
      and turns into a butterfly at the bottom of the page.
   2. A rocket "back to top" button that blasts off.
   3. Game cards bounce in as they scroll into view.
========================================= */

/* ---------- 1. Grass + caterpillar ---------- */

.fun-ground {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 30px;
    z-index: 40;
    pointer-events: none;
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.fun-ground.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* wavy grass strip */
.fun-grass {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 7px;
    background:
        radial-gradient(circle at 6px 0, transparent 5px, #7ccc4a 5.5px) 0 0 / 12px 7px repeat-x;
    filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, 0.06));
}

/* a few flowers on the grass */
.fun-flower {
    position: absolute;
    bottom: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffd23f;
    box-shadow:
        0 -5px 0 -1px #ff8fb1, 0 5px 0 -1px #ff8fb1,
        -5px 0 0 -1px #ff8fb1, 5px 0 0 -1px #ff8fb1;
}

.fun-flower.f1 { left: 12%; }
.fun-flower.f2 { left: 47%; background: #fff; box-shadow: 0 -5px 0 -1px #8fd3ff, 0 5px 0 -1px #8fd3ff, -5px 0 0 -1px #8fd3ff, 5px 0 0 -1px #8fd3ff; }
.fun-flower.f3 { left: 83%; }

/* the walker */
.fun-cat {
    position: absolute;
    left: 0;
    bottom: 6px;
    width: 64px;
    height: 22px;
    will-change: transform;
}

.fun-cat-inner {
    position: absolute;
    inset: 0;
    transition: transform 0.3s ease;
}

.fun-cat.face-left .fun-cat-inner {
    transform: scaleX(-1);
}

.fun-seg {
    position: absolute;
    bottom: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #b6f07a, #5fbf2a);
    box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.12);
}

.fun-seg:nth-child(1) { left: 0; }
.fun-seg:nth-child(2) { left: 10px; }
.fun-seg:nth-child(3) { left: 20px; }
.fun-seg:nth-child(4) { left: 30px; }

/* little legs */
.fun-seg::after {
    content: "";
    position: absolute;
    left: 5px;
    bottom: -3px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #3f8f19;
}

.fun-head {
    position: absolute;
    left: 39px;
    bottom: 3px;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #c4f58c, #6ccf33);
    box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.12);
}

/* eyes */
.fun-head::before {
    content: "";
    position: absolute;
    top: 5px;
    left: 9px;
    width: 4px;
    height: 5px;
    border-radius: 50%;
    background: #222;
    box-shadow: 4px 0 0 #222;
}

/* smile */
.fun-head::after {
    content: "";
    position: absolute;
    left: 9px;
    top: 10px;
    width: 7px;
    height: 4px;
    border: 2px solid #2b5d12;
    border-top: none;
    border-radius: 0 0 6px 6px;
}

/* antennae */
.fun-antenna {
    position: absolute;
    bottom: 19px;
    width: 2px;
    height: 8px;
    background: #3f8f19;
    border-radius: 2px;
    transform-origin: bottom center;
}

.fun-antenna::after {
    content: "";
    position: absolute;
    top: -3px;
    left: -2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ff6f61;
}

.fun-antenna.a1 { left: 46px; transform: rotate(-20deg); }
.fun-antenna.a2 { left: 52px; transform: rotate(18deg); }

/* wiggle while walking */
.fun-cat.is-walking .fun-seg {
    animation: fun-hump 0.35s ease-in-out infinite alternate;
}

.fun-cat.is-walking .fun-seg:nth-child(2) { animation-delay: 0.08s; }
.fun-cat.is-walking .fun-seg:nth-child(3) { animation-delay: 0.16s; }
.fun-cat.is-walking .fun-seg:nth-child(4) { animation-delay: 0.24s; }

.fun-cat.is-walking .fun-antenna {
    animation: fun-boing 0.35s ease-in-out infinite alternate;
}

@keyframes fun-hump {
    from { transform: translateY(0); }
    to   { transform: translateY(-5px); }
}

@keyframes fun-boing {
    from { transform: rotate(-22deg); }
    to   { transform: rotate(22deg); }
}

/* speech bubble */
.fun-bubble {
    position: absolute;
    bottom: 30px;
    left: 30px;
    padding: 4px 9px;
    border-radius: 12px;
    background: #fff;
    color: #2b3a47;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(6px) scale(0.8);
    transform-origin: bottom left;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fun-bubble::after {
    content: "";
    position: absolute;
    left: 12px;
    bottom: -5px;
    border: 5px solid transparent;
    border-top-color: #fff;
    border-bottom: none;
}

.fun-bubble.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.fun-cat.face-left .fun-bubble {
    /* keep text readable when the caterpillar turns around */
    transform: scaleX(-1) translateY(6px) scale(0.8);
}

.fun-cat.face-left .fun-bubble.show {
    transform: scaleX(-1) translateY(0) scale(1);
}

/* butterfly (appears at the end of the page) */
.fun-butterfly {
    position: absolute;
    left: 20px;
    bottom: 4px;
    width: 30px;
    height: 24px;
    opacity: 0;
    transform: scale(0.2);
    transition: opacity 0.4s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fun-wing {
    position: absolute;
    top: 0;
    width: 15px;
    height: 20px;
    border-radius: 60% 60% 40% 40%;
    background: radial-gradient(circle at 50% 40%, #fff3a0 0 3px, #ff8fb1 4px, #b06cf0 100%);
}

.fun-wing.l { left: 0;  transform-origin: right center; }
.fun-wing.r { right: 0; transform-origin: left center; }

.fun-butterfly::after {
    content: "";
    position: absolute;
    left: 13px;
    top: 2px;
    width: 4px;
    height: 20px;
    border-radius: 3px;
    background: #4b2a6b;
}

.fun-cat.is-butterfly .fun-seg,
.fun-cat.is-butterfly .fun-head,
.fun-cat.is-butterfly .fun-antenna {
    opacity: 0;
    transform: scale(0.3);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.fun-cat.is-butterfly .fun-butterfly {
    opacity: 1;
    transform: scale(1);
    animation: fun-flutter-up 2.4s ease-in-out infinite;
}

.fun-cat.is-butterfly .fun-wing.l { animation: fun-flap-l 0.25s ease-in-out infinite alternate; }
.fun-cat.is-butterfly .fun-wing.r { animation: fun-flap-r 0.25s ease-in-out infinite alternate; }

@keyframes fun-flap-l { from { transform: scaleX(1); } to { transform: scaleX(0.25); } }
@keyframes fun-flap-r { from { transform: scaleX(1); } to { transform: scaleX(0.25); } }

@keyframes fun-flutter-up {
    0%, 100% { translate: 0 0; }
    50%      { translate: 4px -10px; }
}

/* ---------- 2. Rocket back-to-top ---------- */

.fun-rocket {
    position: fixed;
    right: 16px;
    bottom: 40px;
    z-index: 45;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(145deg, #1e88d0, #005d91);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 5px 0 #00446b, 0 8px 18px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(30px) scale(0.6);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}

.fun-rocket.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.fun-rocket:hover {
    box-shadow: 0 7px 0 #00446b, 0 12px 22px rgba(0, 0, 0, 0.3);
}

.fun-rocket:hover .fun-rocket-icon {
    animation: fun-shake 0.3s linear infinite;
}

.fun-rocket:focus-visible {
    outline: 3px solid #ffb400;
    outline-offset: 3px;
}

.fun-rocket-icon {
    position: relative;
    display: block;
    transform: rotate(-45deg);
}

/* flame */
.fun-rocket-flame {
    position: absolute;
    left: 50%;
    top: 100%;
    width: 12px;
    height: 0;
    margin-left: -6px;
    border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
    background: linear-gradient(#ffd23f, #ff6f00 70%, transparent);
    transition: height 0.2s ease;
}

.fun-rocket:hover .fun-rocket-flame { height: 10px; }

.fun-rocket.is-launching {
    pointer-events: none;
    animation: fun-launch 1s cubic-bezier(0.55, 0, 0.85, 0.35) forwards;
}

.fun-rocket.is-launching .fun-rocket-flame {
    height: 30px;
    animation: fun-flame 0.08s linear infinite alternate;
}

@keyframes fun-shake {
    0%, 100% { transform: rotate(-45deg) translate(0, 0); }
    25%      { transform: rotate(-45deg) translate(1px, -1px); }
    75%      { transform: rotate(-45deg) translate(-1px, 1px); }
}

@keyframes fun-flame {
    from { transform: scaleY(1);   opacity: 1; }
    to   { transform: scaleY(1.3); opacity: 0.8; }
}

@keyframes fun-launch {
    0%   { transform: translateY(0) scale(1); }
    15%  { transform: translateY(6px) scale(1.05, 0.92); }
    100% { transform: translateY(-110vh) scale(0.8); }
}

/* smoke puffs left behind */
.fun-puff {
    position: fixed;
    z-index: 44;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(200, 210, 220, 0.9);
    pointer-events: none;
    animation: fun-puff 0.9s ease-out forwards;
}

@keyframes fun-puff {
    from { transform: scale(0.4); opacity: 1; }
    to   { transform: scale(2.2) translateY(10px); opacity: 0; }
}

/* ---------- 3. Bouncy game cards ---------- */

.fun-reveal {
    opacity: 0;
    transform: translateY(40px) scale(0.92) rotate(-1.5deg);
}

.fun-reveal.is-in {
    opacity: 1;
    transform: none;
    transition:
        opacity 0.5s ease,
        transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* keep the footer text clear of the grass strip */
html.fun-on .home-footer {
    padding-bottom: 38px;
}

/* ---------- Phones ---------- */

@media (max-width: 600px) {
    .fun-ground { height: 26px; }
    .fun-cat { transform-origin: left bottom; }
    .fun-rocket { width: 42px; height: 42px; font-size: 17px; right: 12px; bottom: 34px; }
}

/* ---------- Dark theme ---------- */

html[data-theme="dark"] .fun-grass {
    background:
        radial-gradient(circle at 6px 0, transparent 5px, #3f8f2a 5.5px) 0 0 / 12px 7px repeat-x;
}

html[data-theme="dark"] .fun-bubble {
    background: #22303d;
    color: #e6edf3;
}

html[data-theme="dark"] .fun-bubble::after {
    border-top-color: #22303d;
}

/* ---------- Reduced motion: keep it calm ---------- */

@media (prefers-reduced-motion: reduce) {
    .fun-ground { display: none; }
    .fun-reveal { opacity: 1; transform: none; }
    .fun-rocket.is-launching { animation: none; }
}

/* =========================================
   MORE FUN
   4. Tap sparkles (tap/click empty space)
   5. Balloons that float up – pop them!
   6. Peekaboo owl with fun facts and jokes
========================================= */

/* ---------- 4. Tap sparkles / confetti ---------- */

.fun-spark {
    position: fixed;
    z-index: 60;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    pointer-events: none;
    border-radius: 50%;
    animation: fun-spark 0.8s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.fun-spark.star {
    border-radius: 0;
    background: none !important;
    color: var(--c);
    font-size: 14px;
    line-height: 10px;
    width: auto;
    height: auto;
}

.fun-spark.strip {
    width: 6px;
    height: 12px;
    border-radius: 2px;
}

@keyframes fun-spark {
    0%   { transform: translate(0, 0) scale(0.4) rotate(0deg); opacity: 1; }
    70%  { opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot)); opacity: 0; }
}

.fun-popword {
    position: fixed;
    z-index: 61;
    pointer-events: none;
    font-family: 'Luckiest Guy', 'Noto Sans Malayalam', 'Poppins', cursive;
    font-size: 26px;
    color: #ff4f8b;
    text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
    transform: translate(-50%, -50%);
    animation: fun-popword 0.9s ease-out forwards;
}

@keyframes fun-popword {
    0%   { transform: translate(-50%, -50%) scale(0.3) rotate(-10deg); opacity: 0; }
    25%  { transform: translate(-50%, -50%) scale(1.25) rotate(6deg);  opacity: 1; }
    100% { transform: translate(-50%, -140%) scale(1) rotate(0deg);    opacity: 0; }
}

/* ---------- 5. Balloons ---------- */

.fun-balloon {
    position: fixed;
    bottom: -110px;
    z-index: 35;
    width: 54px;
    height: 66px;
    border: none;
    padding: 0;
    background: none;
    cursor: pointer;
    animation: fun-rise var(--rise, 13s) linear forwards;
    -webkit-tap-highlight-color: transparent;
}

.fun-balloon-body {
    position: absolute;
    inset: 0;
    border-radius: 50% 50% 48% 48% / 55% 55% 45% 45%;
    background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.75) 0 7px, transparent 8px),
                radial-gradient(circle at 40% 35%, var(--c2), var(--c1) 70%);
    box-shadow: inset -6px -8px 0 rgba(0, 0, 0, 0.12);
    animation: fun-sway 3s ease-in-out infinite alternate;
    transform-origin: 50% 120%;
}

/* knot */
.fun-balloon-body::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    margin-left: -5px;
    border: 5px solid transparent;
    border-bottom: 7px solid var(--c1);
}

/* string */
.fun-balloon-body::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    width: 2px;
    height: 46px;
    margin-left: -1px;
    background: linear-gradient(rgba(120, 120, 120, 0.8), rgba(120, 120, 120, 0));
    border-radius: 2px;
}

/* cute face on some balloons */
.fun-balloon-face {
    position: absolute;
    left: 50%;
    top: 42%;
    width: 22px;
    margin-left: -11px;
    text-align: center;
    font-size: 13px;
    line-height: 1;
    color: rgba(0, 0, 0, 0.55);
    font-weight: 800;
    letter-spacing: 3px;
}

.fun-balloon:hover .fun-balloon-body {
    filter: brightness(1.08);
}

@keyframes fun-rise {
    from { transform: translateY(0); }
    to   { transform: translateY(calc(-100vh - 220px)); }
}

@keyframes fun-sway {
    from { transform: rotate(-7deg) translateX(-6px); }
    to   { transform: rotate(7deg)  translateX(6px); }
}

/* ---------- 6. Peekaboo owl ---------- */

.fun-owl {
    position: fixed;
    left: 0;
    bottom: 96px;
    z-index: 42;
    width: 74px;
    height: 80px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    transform: translateX(-110%);
    transition: transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
    -webkit-tap-highlight-color: transparent;
}

.fun-owl.is-out {
    transform: translateX(-8px);
}

.fun-owl:focus-visible {
    outline: 3px solid #ffb400;
    outline-offset: 2px;
    border-radius: 20px;
}

.fun-owl-body {
    position: absolute;
    left: 6px;
    bottom: 0;
    width: 62px;
    height: 68px;
    border-radius: 48% 48% 42% 42%;
    background: radial-gradient(ellipse at 50% 78%, #f7dcb4 0 16px, transparent 17px),
                linear-gradient(#a8693a, #8a5129);
    box-shadow: inset -5px -6px 0 rgba(0, 0, 0, 0.12);
}

/* ear tufts */
.fun-owl-body::before,
.fun-owl-body::after {
    content: "";
    position: absolute;
    top: -8px;
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 16px solid #8a5129;
}

.fun-owl-body::before { left: 4px;  transform: rotate(-18deg); }
.fun-owl-body::after  { right: 4px; transform: rotate(18deg); }

.fun-owl-eye {
    position: absolute;
    top: 14px;
    width: 23px;
    height: 23px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #f2b33d;
    overflow: hidden;
    animation: fun-owl-blink 5s infinite;
}

.fun-owl-eye.l { left: 7px; }
.fun-owl-eye.r { right: 7px; }

.fun-owl-pupil {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border-radius: 50%;
    background: #222;
    box-shadow: 2px -2px 0 -1px #fff inset;
    transition: transform 0.12s linear;
}

.fun-owl-beak {
    position: absolute;
    left: 50%;
    top: 36px;
    margin-left: -5px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 9px solid #f2b33d;
}

.fun-owl-wing {
    position: absolute;
    right: -4px;
    top: 34px;
    width: 16px;
    height: 28px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    background: #7a4522;
    transform-origin: top left;
}

.fun-owl.is-out .fun-owl-wing {
    animation: fun-owl-wave 0.5s ease-in-out 0.6s 3 alternate;
}

.fun-owl:hover .fun-owl-body {
    animation: fun-owl-hop 0.5s ease;
}

@keyframes fun-owl-blink {
    0%, 94%, 100% { transform: scaleY(1); }
    97%           { transform: scaleY(0.1); }
}

@keyframes fun-owl-wave {
    from { transform: rotate(0deg); }
    to   { transform: rotate(-70deg); }
}

@keyframes fun-owl-hop {
    0%, 100% { transform: translateY(0); }
    40%      { transform: translateY(-8px); }
}

/* owl speech bubble */
.fun-owl-say {
    font-family: "Noto Sans Malayalam", "Poppins", sans-serif;
    position: fixed;
    left: 78px;
    bottom: 128px;
    z-index: 43;
    max-width: min(260px, calc(100vw - 100px));
    padding: 10px 14px;
    border-radius: 16px 16px 16px 4px;
    background: #fff;
    color: #2b3a47;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    border: 2px solid #ffd23f;
    opacity: 0;
    transform: translateX(-10px) scale(0.85);
    transform-origin: bottom left;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fun-owl-say.show {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.fun-owl-say b {
    display: block;
    margin-bottom: 3px;
    font-size: 13px;
    letter-spacing: 0;
    text-transform: none;
    color: #e07b00;
    letter-spacing: 0;
}

html[data-theme="dark"] .fun-owl-say {
    background: #1c2834;
    color: #e6edf3;
    border-color: #a07c1c;
}

@media (max-width: 600px) {
    .fun-owl { bottom: 84px; transform: translateX(-110%) scale(0.8); transform-origin: left bottom; }
    .fun-owl.is-out { transform: translateX(-8px) scale(0.8); }
    .fun-owl-say { left: 64px; bottom: 112px; font-size: 12px; }
    .fun-balloon { width: 46px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
    .fun-balloon, .fun-owl, .fun-owl-say, .fun-spark, .fun-popword { display: none !important; }
}

/* =========================================
   CATEGORY CLICK EFFECTS
========================================= */

.cat-fx {
    position: fixed;
    z-index: 70;
    pointer-events: none;
    transform: translate(-50%, -50%);
    font-family: 'Luckiest Guy', 'Noto Sans Malayalam', 'Poppins', sans-serif;
    line-height: 1;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
    animation: cat-fx 0.95s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

@keyframes cat-fx {
    0%   { transform: translate(-50%, -50%) scale(0.3) rotate(0deg); opacity: 0; }
    15%  { opacity: 1; }
    70%  { opacity: 1; }
    100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(var(--rot)); opacity: 0; }
}

.cat-fx-word {
    position: fixed;
    z-index: 71;
    pointer-events: none;
    transform: translate(-50%, -50%);
    font-family: 'Luckiest Guy', 'Poppins', sans-serif;
    font-size: 17px;
    color: #005d91;
    white-space: nowrap;
    text-shadow: 0 2px 0 #ffffff, 0 4px 10px rgba(0, 0, 0, 0.15);
    animation: cat-fx-word 1s ease-out forwards;
}

@keyframes cat-fx-word {
    0%   { transform: translate(-50%, -30%) scale(0.5); opacity: 0; }
    25%  { transform: translate(-50%, -90%) scale(1.1); opacity: 1; }
    75%  { opacity: 1; }
    100% { transform: translate(-50%, -160%) scale(1); opacity: 0; }
}

.cat-tile.cat-pop {
    animation: cat-pop 0.45s ease;
}

@keyframes cat-pop {
    0%   { transform: scale(1); }
    35%  { transform: scale(0.9); }
    65%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}
