/* Home: Kore acompaña el recorrido, menú móvil y sonido */

/* ── Kore viajera ── */
.kp-buddy {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 60;
    opacity: 0;
    pointer-events: none;
    cursor: pointer;
    transform-origin: 50% 50%;
    will-change: transform, opacity;
    -webkit-tap-highlight-color: transparent;
}
.kp-buddy.is-on { pointer-events: auto; }
.kp-buddy canvas { position: absolute; pointer-events: none; }
.kp-buddy--top { z-index: 1210; }

/* ── Círculo del chat: vacío hasta que llega Kore ── */
.kc-fab { position: relative; }
html:not(.kp-static) .kc-fab:not(.kp-home) .kc-kore { visibility: hidden; }
html:not(.kp-static) .kc-fab.kc-fab--kore:not(.kp-home)::after {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    border: 1.5px dashed rgba(125, 249, 255, .38);
    animation: kpNest 6s linear infinite;
    pointer-events: none;
}
.kc-fab.kp-pop { animation: kpPop .55s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes kpNest { to { transform: rotate(360deg); } }
@keyframes kpPop {
    0% { transform: scale(1); }
    35% { transform: scale(1.2); }
    65% { transform: scale(.94); }
    100% { transform: scale(1); }
}

/* ── Barra de capítulos: hueco de Kore y sonido ── */
.kp-perch { display: none; flex: none; width: 38px; height: 33px; }
html.kp-bar .kp-perch { display: block; }
html.kp-home .kp-perch,
html.kp-static .kp-perch { display: none; }
.kp-trigger { display: none; }

.kp-sound {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 33px;
    height: 33px;
    margin-left: .2rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: rgba(255, 255, 255, .6);
    cursor: pointer;
    transition: color .2s ease, background .2s ease;
}
.kp-sound:hover { color: #fff; background: rgba(125, 249, 255, .08); }
.kp-sound:focus-visible, .kp-trigger:focus-visible, .kp-menu :focus-visible {
    outline: 2px solid var(--neon);
    outline-offset: 2px;
}
.kp-sound svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.kp-sound .kp-wave { display: none; }
.kp-sound[aria-pressed="true"] { color: var(--neon); }
.kp-sound[aria-pressed="true"] .kp-wave { display: inline; }
.kp-sound[aria-pressed="true"] .kp-mute { display: none; }

/* ── Móvil: barra compacta (Kore · sección actual · menú · sonido) ── */
@media (max-width: 760px) {
    .chapters {
        flex-direction: row;
        align-items: center;
        gap: .15rem;
        padding: .25rem .3rem;
        border-radius: 999px;
    }
    .chapters.is-open { background: rgba(13, 6, 32, .72); }
    .chapters .chapters__toggle,
    .chapters a,
    .chapters.is-open a { display: none; }
    .kp-perch { display: block; width: 44px; height: 44px; }
    .kp-trigger {
        display: flex;
        flex: 1;
        min-width: 0;
        align-items: center;
        gap: .6rem;
        padding: .6rem .55rem .6rem .35rem;
        border: 0;
        border-radius: 999px;
        background: transparent;
        color: #fff;
        font: inherit;
        font-size: .95rem;
        font-weight: 700;
        text-align: left;
        cursor: pointer;
    }
    .kp-trigger__current { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--neon); }
    .kp-trigger__label { font-size: .82rem; font-weight: 600; color: rgba(255, 255, 255, .7); }
    .kp-bars, .kp-bars::before, .kp-bars::after {
        display: block;
        width: 18px;
        height: 2px;
        border-radius: 2px;
        background: #fff;
    }
    .kp-bars { position: relative; }
    .kp-bars::before, .kp-bars::after { content: ""; position: absolute; left: 0; }
    .kp-bars::before { top: -6px; }
    .kp-bars::after { top: 6px; }
    .kp-sound { width: 44px; height: 44px; margin-left: 0; }
    .kp-trigger { min-height: 44px; }
}

/* ── Menú móvil a pantalla casi completa ── */
.kp-menu {
    position: fixed;
    inset: 10px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    padding: max(14px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 26px;
    border: 1px solid var(--line);
    background:
        radial-gradient(120% 55% at 50% 0%, rgba(74, 44, 130, .55), transparent 70%),
        #0d0620;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
    opacity: 0;
    transform: translateY(-10px) scale(.985);
    transition: opacity .28s ease, transform .32s cubic-bezier(.2, .8, .2, 1);
}
.kp-menu[hidden] { display: none; }
.kp-menu.is-open { opacity: 1; transform: none; }
.kp-menu__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(255, 255, 255, .04);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}
.kp-menu__head {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 22px 0 6px;
    text-align: center;
}
.kp-menu__logo { width: auto; height: 42px; }
.kp-menu__kore {
    display: grid;
    place-items: center;
    width: 96px;
    height: 92px;
    margin: 10px 0 4px;
}
.kp-menu__hi {
    margin: 0;
    padding: .55rem 1rem;
    border-radius: 999px;
    background: rgba(125, 249, 255, .07);
    border: 1px solid var(--line-soft);
    color: rgba(255, 255, 255, .88);
    font-size: .98rem;
}
.kp-menu__list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}
.kp-menu__list li {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .3s ease, transform .35s cubic-bezier(.2, .8, .2, 1);
    transition-delay: calc(var(--i, 0) * 35ms + 90ms);
}
.kp-menu.is-open .kp-menu__list li { opacity: 1; transform: none; }
.kp-menu__list a {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 54px;
    padding: .8rem 1.2rem;
    border-radius: 16px;
    color: rgba(255, 255, 255, .82);
    font-size: 1.12rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .2s ease, color .2s ease;
}
.kp-menu__list a:hover { background: rgba(255, 255, 255, .04); color: #fff; }
.kp-menu__list a[aria-current] { color: var(--neon); background: rgba(125, 249, 255, .08); }
.kp-menu__list a[aria-current]::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 50%;
    width: 4px;
    height: 22px;
    margin-top: -11px;
    border-radius: 4px;
    background: var(--neon);
    box-shadow: 0 0 12px var(--neon);
}
.kp-menu__foot {
    display: flex;
    justify-content: center;
    margin-top: auto;
    padding-top: 18px;
}
.kp-switch {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: rgba(255, 255, 255, .85);
    font: inherit;
    font-size: .92rem;
    cursor: pointer;
}
.kp-switch__track {
    position: relative;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .16);
    transition: background .2s ease;
}
.kp-switch__track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform .2s ease, background .2s ease;
}
.kp-switch[aria-checked="true"] .kp-switch__track { background: var(--neon); }
.kp-switch[aria-checked="true"] .kp-switch__track::after { transform: translateX(18px); background: var(--bg-deep); }
body.kp-lock { overflow: hidden; }
@media (min-width: 761px) { .kp-menu { display: none !important; } }
@media (pointer: coarse) { .kp-sound { width: 44px; height: 44px; } }

@media (prefers-reduced-motion: reduce) {
    .kp-menu, .kp-menu__list li { transition: none; }
    html:not(.kp-static) .kc-fab.kc-fab--kore::after, .kc-fab.kp-pop { animation: none; }
}

/* Tarjeta de Plataforma: el hueco de Kore se ve como su nido mientras ella está de viaje */
html:not(.kp-static) .kore-tile:not(.kp-here) {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='144' height='134'%3E%3Ccircle cx='72' cy='64' r='34' fill='none' stroke='rgba(125,249,255,.38)' stroke-width='1.5' stroke-dasharray='4 5'/%3E%3C/svg%3E") center / 144px 134px no-repeat;
}
