/* ============================================================
   KIZO — scroll-guide mascot
   Reuses tokens from style.css (--teal, --card, --ease, --spring…)
   ============================================================ */

/* ── Mascot container (moved with transform from JS) ── */
.kz-guide {
    position: fixed;
    left: 0;
    top: 0;
    width: 64px;
    height: 64px;
    z-index: 450;              /* below nav (500) + mobile menu (490)… and video modal (1000) */
    pointer-events: none;
    transition: transform 0.75s var(--ease);
    will-change: transform;
}
.kz-guide.kz-gone { display: none; }

/* Button that carries the hop animation */
.kz-body {
    pointer-events: auto;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    transform-origin: 50% 100%;
}
.kz-body:focus-visible,
.kz-launch:focus-visible,
.kz-btn:focus-visible,
.kz-x:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 3px;
}

/* Idle bob lives on the inner sprite so it never fights the hop */
.kz-sprite {
    display: block;
    width: 100%;
    height: 100%;
    animation: kz-idle 3.2s ease-in-out infinite;
}
.kz-sprite svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(0 8px 14px rgba(0, 212, 192, 0.28));
}

@keyframes kz-idle {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-3px); }
}

.kz-guide.is-hop .kz-body {
    animation: kz-hop 0.72s var(--ease);
}
@keyframes kz-hop {
    0%   { transform: translateY(0)     scale(1, 1); }
    14%  { transform: translateY(0)     scale(1.12, 0.86); }
    45%  { transform: translateY(-38px) scale(0.93, 1.1); }
    78%  { transform: translateY(0)     scale(1.1, 0.9); }
    100% { transform: translateY(0)     scale(1, 1); }
}

/* Blink + antenna wave */
.kz-eye {
    transform-box: fill-box;
    transform-origin: center;
    animation: kz-blink 5s infinite;
}
@keyframes kz-blink {
    0%, 94%, 100% { transform: scaleY(1); }
    97%           { transform: scaleY(0.1); }
}
.kz-wave { animation: kz-wave 2s ease-in-out infinite; }
@keyframes kz-wave {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.25; }
}

/* ── Speech bubble ── */
.kz-bubble {
    --tail: 32px;
    position: absolute;
    width: min(290px, calc(100vw - 24px));
    background: var(--card);
    border: 1px solid rgba(0, 212, 192, 0.28);
    border-radius: 14px;
    padding: 1rem 1.1rem 0.9rem;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
    color: var(--w80);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px) scale(0.97);
    transition: opacity 0.25s var(--ease), transform 0.3s var(--spring), visibility 0.25s;
    pointer-events: none;
}
.kz-bubble.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.kz-bubble [hidden] { display: none !important; }

/* Tail */
.kz-bubble::after {
    content: '';
    position: absolute;
    left: var(--tail);
    width: 12px;
    height: 12px;
    background: var(--card);
    transform: rotate(45deg);
}
.kz-bubble.kz-up::after {
    bottom: -7px;
    border-right: 1px solid rgba(0, 212, 192, 0.28);
    border-bottom: 1px solid rgba(0, 212, 192, 0.28);
}
.kz-bubble.kz-down::after {
    top: -7px;
    border-left: 1px solid rgba(0, 212, 192, 0.28);
    border-top: 1px solid rgba(0, 212, 192, 0.28);
}

.kz-kind {
    font-family: var(--mono);
    font-size: 0.64rem;
    color: var(--teal);
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
    padding-right: 1.4rem;
}
.kz-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--white);
    margin-bottom: 0.4rem;
}
.kz-text {
    font-size: 0.8rem;
    line-height: 1.65;
    color: var(--w60);
}

.kz-x {
    position: absolute;
    top: 0.55rem;
    right: 0.6rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: var(--w40);
    font-size: 1rem;
    line-height: 1;
    transition: color 0.2s, background 0.2s;
}
.kz-x:hover { color: var(--white); background: var(--w08); }

.kz-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-top: 0.8rem;
    padding-top: 0.7rem;
    border-top: 1px solid var(--border);
}
.kz-progress {
    font-family: var(--mono);
    font-size: 0.6rem;
    color: var(--w40);
}
.kz-actions {
    display: flex;
    gap: 0.4rem;
}
.kz-btn {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.38rem 0.8rem;
    border-radius: 6px;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, color 0.2s;
}
.kz-btn.primary {
    background: var(--teal);
    color: #0a0a0f;
}
.kz-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 212, 192, 0.35);
}
.kz-btn.ghost {
    border: 1px solid var(--border-light);
    color: var(--w60);
}
.kz-btn.ghost:hover {
    border-color: var(--teal);
    color: var(--teal);
}

/* ── Element currently being explained ── */
.kz-spot {
    box-shadow: inset 0 0 0 1px rgba(0, 212, 192, 0.55), inset 0 0 44px rgba(0, 212, 192, 0.07) !important;
}

/* ── Launcher shown when the guide is switched off ── */
.kz-launch {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 450;
    width: 48px;
    height: 48px;
    padding: 6px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid rgba(0, 212, 192, 0.35);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: none;
}
.kz-launch.show { display: block; }
.kz-launch svg { width: 100%; height: 100%; overflow: visible; }

/* ── Responsive ── */
@media (max-width: 640px) {
    .kz-guide  { width: 52px; height: 52px; }
    .kz-launch { right: 14px; bottom: 14px; }
}

/* ── Low-power: keep it simple, reuse the flag set by script.js ── */
body.low-power .kz-sprite,
body.low-power .kz-wave,
body.low-power .kz-eye { animation: none; }
body.low-power .kz-sprite svg { filter: none; }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .kz-guide  { transition-duration: 0.01ms; }
    .kz-bubble { transition-duration: 0.01ms; }
    .kz-guide.is-hop .kz-body,
    .kz-sprite,
    .kz-wave,
    .kz-eye { animation: none; }
}