/*
 * Optional ambient audio: first-visit welcome overlay and the nav speaker toggle.
 * Everything here is driven by /assets/audio.js. Without JS the toggles stay hidden
 * (via the [hidden] attribute) and the overlay is never created.
 */

/* ---------- Speaker toggle (nav) ---------- */
.kga-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid #E3E8EC;
    border-radius: 999px;
    background: #FFFFFF;
    color: #0A192F;
    cursor: pointer;
    transition: border-color 200ms cubic-bezier(0.22, 1, 0.36, 1), color 200ms cubic-bezier(0.22, 1, 0.36, 1), background-color 200ms cubic-bezier(0.22, 1, 0.36, 1);
    -webkit-tap-highlight-color: transparent;
}
.kga-toggle[hidden] { display: none; }
.kga-toggle:hover { border-color: #2F6F6B; color: #2F6F6B; }
.kga-toggle:focus-visible { outline: 3px solid #7FB8B2; outline-offset: 2px; }
.kga-toggle[aria-pressed="true"] { border-color: rgba(47, 111, 107, 0.55); color: #2F6F6B; background: #EEF5F4; }
.kga-toggle svg { width: 1.125rem; height: 1.125rem; overflow: visible; }
.kga-toggle .kga-wave { opacity: 0; transition: opacity 300ms cubic-bezier(0.22, 1, 0.36, 1); }
.kga-toggle .kga-x { opacity: 1; transition: opacity 300ms cubic-bezier(0.22, 1, 0.36, 1); }
.kga-toggle[aria-pressed="true"] .kga-wave { opacity: 1; }
.kga-toggle[aria-pressed="true"] .kga-x { opacity: 0; }
/* Soft breathing waves while audible */
.kga-toggle.is-playing .kga-wave { animation: kga-breathe 2.4s cubic-bezier(0.22, 1, 0.36, 1) infinite; transform-origin: 9px 12px; }
.kga-toggle.is-playing .kga-wave-2 { animation-delay: 0.3s; }
.kga-toggle.is-loading::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 999px;
    border: 1px solid transparent;
    border-top-color: #7FB8B2;
    animation: kga-spin 0.8s linear infinite;
}
@keyframes kga-breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes kga-spin { to { transform: rotate(360deg); } }
.kga-toggle-mobile { margin-right: 0; }

/* ---------- Welcome overlay ---------- */
.kga-lock { overflow: hidden; }
.kga-intro {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
    background:
        radial-gradient(ellipse 70% 55% at 50% 42%, rgba(127, 184, 178, 0.13), rgba(127, 184, 178, 0) 70%),
        radial-gradient(ellipse 120% 90% at 50% 120%, #112240 0%, #0A192F 60%);
    color: #FFFFFF;
    text-align: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: opacity 800ms cubic-bezier(0.22, 1, 0.36, 1), clip-path 800ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s 800ms;
    clip-path: inset(0 0 0 0);
}
/* Fine meridian lines, purely decorative */
.kga-intro::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(127, 184, 178, 0.18) 50%, transparent calc(50% + 0.5px)) no-repeat,
        repeating-radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 96px);
    -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 45%, #000 20%, transparent 75%);
    mask-image: radial-gradient(ellipse 60% 60% at 50% 45%, #000 20%, transparent 75%);
}
.kga-intro.is-leaving { opacity: 0; clip-path: inset(0 0 100% 0); visibility: hidden; }
.kga-intro-inner { position: relative; max-width: 40rem; width: 100%; }
.kga-mark {
    width: 3.5rem;
    height: 3.5rem;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(127, 184, 178, 0.6);
    color: #7FB8B2;
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 600;
    font-size: 1.6rem;
    border-radius: 1rem;
}
.kga-brand {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.42em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
    margin: 0 0 2rem;
    padding-left: 0.42em;
}
.kga-rule { width: 3rem; height: 1px; margin: 0 auto 2rem; background: #7FB8B2; }
.kga-title {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1.9rem, 5.4vw, 3.4rem);
    line-height: 1.12;
    letter-spacing: -0.01em;
    margin: 0 0 1.25rem;
}
.kga-title em { font-style: italic; font-weight: 500; color: #7FB8B2; }
.kga-sub {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 300;
    font-size: 1rem;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 auto 2.5rem;
    max-width: 30rem;
}
.kga-actions { display: flex; flex-direction: column; gap: 0.875rem; align-items: stretch; max-width: 22rem; margin: 0 auto; }
@media (min-width: 640px) {
    .kga-actions { flex-direction: row; max-width: none; justify-content: center; }
}
.kga-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 3.25rem;
    padding: 0.9rem 1.75rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 0.8125rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 300ms cubic-bezier(0.22, 1, 0.36, 1), border-color 300ms cubic-bezier(0.22, 1, 0.36, 1), color 300ms cubic-bezier(0.22, 1, 0.36, 1), transform 300ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 300ms cubic-bezier(0.22, 1, 0.36, 1);
    -webkit-tap-highlight-color: transparent;
}
.kga-btn svg { width: 1rem; height: 1rem; flex-shrink: 0; }
.kga-btn:focus-visible { outline: 3px solid #7FB8B2; outline-offset: 3px; }
.kga-btn-sound { background: #7FB8B2; color: #0A192F; border: 1px solid #7FB8B2; }
.kga-btn-sound:hover { background: #A9D2CD; transform: translateY(-2px); box-shadow: 0 10px 28px rgba(127, 184, 178, 0.28); }
.kga-btn-quiet { background: transparent; color: #FFFFFF; border: 1px solid rgba(255, 255, 255, 0.35); }
.kga-btn-quiet:hover { border-color: #7FB8B2; color: #7FB8B2; transform: translateY(-2px); }
.kga-note {
    margin: 1.75rem 0 0;
    font-size: 0.75rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.5);
}

/* Cinematic entrance: staged fade-up of the overlay contents */
.kga-intro .kga-stage { opacity: 0; transform: translateY(14px); }
.kga-intro.is-in .kga-stage {
    opacity: 1;
    transform: none;
    transition: opacity 800ms cubic-bezier(0.22, 1, 0.36, 1), transform 800ms cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: var(--d, 0ms);
}
.kga-intro .kga-rule.kga-stage { transform: scaleX(0); }
.kga-intro.is-in .kga-rule.kga-stage { transform: scaleX(1); }
.kga-intro.is-leaving .kga-intro-inner { opacity: 0; transform: translateY(-18px); transition: opacity 650ms cubic-bezier(0.22, 1, 0.36, 1), transform 650ms cubic-bezier(0.22, 1, 0.36, 1); }

/* Reduced motion: no staging, lifting or breathing; a plain short cross-fade only */
@media (prefers-reduced-motion: reduce) {
    .kga-intro { transition: opacity 200ms linear, visibility 0s 200ms; clip-path: none; }
    .kga-intro.is-leaving { clip-path: none; }
    .kga-intro .kga-stage,
    .kga-intro .kga-rule.kga-stage { opacity: 1; transform: none; transition: none; }
    .kga-intro.is-leaving .kga-intro-inner { transform: none; transition: none; }
    .kga-toggle.is-playing .kga-wave { animation: none; }
    .kga-toggle.is-loading::after { animation-duration: 2.4s; }
    .kga-btn:hover { transform: none; }
}


