/* =========================================================
   Ruta de evacuación del volcán Puracé
   Sistema visual: señalética de evacuación + alertas del SGC.
   El color de acento (--alert) cambia con el nivel de alerta.
   ========================================================= */

:root {
    --ceniza-950: #0f0d14;
    --ceniza-900: #17141f;
    --ceniza-800: #221e2c;
    --ceniza-700: #322d3f;
    --ceniza-500: #6f687f;
    --ceniza-300: #b4aec3;
    --senal: #eef0ee;
    --ruta: #23a45f;

    /* Acento dinámico (lo cambia body[data-alert]) */
    --alert: #f5c518;
    --alert-ink: #1c1500;

    --font-display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', system-ui, sans-serif;
    --font-body: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

    --r-panel: 10px;
    --r-ctl: 8px;
}

body[data-alert="amarilla"] { --alert: #f5c518; --alert-ink: #1c1500; }
body[data-alert="naranja"]  { --alert: #ff7a1a; --alert-ink: #1f0c00; }
body[data-alert="roja"]     { --alert: #e5322d; --alert-ink: #ffffff; }
body[data-alert="segura"]   { --alert: #2fbf71; --alert-ink: #04210f; }

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    overflow: hidden;
    background: var(--ceniza-950);
    color: var(--senal);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-user-select: none;
}

.hidden { display: none !important; }

#canvas-container { position: fixed; inset: 0; z-index: 0; }
#canvas-container canvas { display: block; }

button { font: inherit; color: inherit; }
button:focus-visible { outline: 3px solid var(--senal); outline-offset: 2px; }

.ico { width: 20px; height: 20px; flex: none; }

/* ---------- Paneles ---------- */
.panel {
    pointer-events: auto;
    background: rgba(20, 17, 28, 0.84);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(238, 240, 238, 0.12);
    border-radius: var(--r-panel);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.hud {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 20;
    padding: 14px 16px;
    display: flex;
    gap: 12px;
    pointer-events: none;
}
.hud-top { top: 0; justify-content: space-between; align-items: flex-start; }
.hud-bottom { bottom: 0; justify-content: center; align-items: flex-end; padding-bottom: max(16px, env(safe-area-inset-bottom)); }

/* ---------- Panel de alerta (semáforo volcánico) ---------- */
.alert-panel {
    display: flex;
    gap: 14px;
    padding: 12px 18px 12px 14px;
    border-left: 4px solid var(--alert);
    min-width: 300px;
    max-width: 400px;
    transition: border-color 0.4s;
}

.semaforo {
    list-style: none;
    margin: 0;
    padding: 7px 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #0a0910;
    border-radius: 999px;
    align-self: center;
    border: 1px solid rgba(238, 240, 238, 0.1);
}
.luz {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    transition: background 0.4s, box-shadow 0.4s;
}
.luz[data-n="roja"].on     { background: #e5322d; box-shadow: 0 0 12px 3px rgba(229, 50, 45, 0.65); }
.luz[data-n="naranja"].on  { background: #ff7a1a; box-shadow: 0 0 12px 3px rgba(255, 122, 26, 0.65); }
.luz[data-n="amarilla"].on { background: #f5c518; box-shadow: 0 0 12px 3px rgba(245, 197, 24, 0.65); }
.luz[data-n="segura"].on   { background: #2fbf71; box-shadow: 0 0 12px 3px rgba(47, 191, 113, 0.65); }

.alert-info { min-width: 0; flex: 1; }
.kicker { margin: 0; font-size: 12px; color: var(--ceniza-300); }
.level-name {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 30px;
    line-height: 1.05;
    letter-spacing: 0.005em;
}
.alert-line { margin: 4px 0 0; font-size: 13px; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.alert-line strong { color: var(--alert); font-weight: 700; transition: color 0.4s; }
.alert-src { color: var(--ceniza-300); font-size: 12px; }

.route { display: flex; gap: 4px; margin-top: 10px; }
.seg { flex: 1; height: 5px; border-radius: 3px; background: rgba(238, 240, 238, 0.14); }
.seg.done { background: var(--senal); }
.seg.current { background: var(--alert); box-shadow: 0 0 8px var(--alert); }

/* ---------- Estadísticas ---------- */
.stats { display: flex; gap: 10px; align-items: stretch; pointer-events: none; }
.stat { padding: 9px 16px; display: flex; flex-direction: column; justify-content: center; min-width: 120px; }
.stat-label { font-size: 12px; color: var(--ceniza-300); }
.stat-value {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 28px;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-value .ico { color: var(--ceniza-300); }
.pips { display: flex; gap: 4px; margin-top: 5px; min-height: 8px; }
.pip { width: 24px; height: 6px; border-radius: 3px; background: rgba(238, 240, 238, 0.16); transition: background 0.3s; }
.pip.on { background: var(--ruta); }
.stat.bump { animation: bump 0.45s ease-out; }

.btn-guide {
    padding: 9px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--ceniza-300);
    transition: background 0.2s, color 0.2s;
}
.btn-guide:hover { background: rgba(50, 45, 63, 0.95); color: var(--senal); }

/* ---------- Sofía habla ---------- */
.speech {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px 12px 14px;
    width: 100%;
    max-width: 860px;
}
.avatar { width: 48px; height: 48px; flex: none; border-radius: 50%; box-shadow: 0 0 0 2px rgba(238, 240, 238, 0.25); }
.avatar-lg { width: 56px; height: 56px; }
.speech-text { flex: 1; min-width: 0; }
.speaker { margin: 0; font-size: 12px; font-weight: 700; color: var(--alert); transition: color 0.4s; }
.story { margin: 1px 0 0; font-size: 15px; font-weight: 500; line-height: 1.35; max-width: 62ch; }
.goal { margin: 3px 0 0; font-size: 13px; color: var(--ceniza-300); }

.progress { flex: none; width: 190px; display: flex; flex-direction: column; gap: 6px; }
.progress-label { font-size: 12px; color: var(--ceniza-300); text-align: right; font-variant-numeric: tabular-nums; }
.progress-bar { display: block; height: 6px; border-radius: 3px; background: rgba(238, 240, 238, 0.14); overflow: hidden; }
.progress-fill { display: block; height: 100%; width: 0; background: var(--ruta); border-radius: 3px; transition: width 0.25s linear; }

/* ---------- Overlays y tarjetas ---------- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(10, 8, 16, 0.72);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
/* El intro deja ver el vuelo de cámara sobre el volcán */
.overlay-light { background: linear-gradient(90deg, rgba(10, 8, 16, 0.86) 0%, rgba(10, 8, 16, 0.55) 55%, rgba(10, 8, 16, 0.15) 100%); backdrop-filter: none; -webkit-backdrop-filter: none; justify-content: flex-start; padding-left: clamp(16px, 7vw, 110px); }

.card {
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 520px;
    padding: 30px 28px 26px;
    background: var(--ceniza-900);
    border: 1px solid rgba(238, 240, 238, 0.14);
    border-radius: 14px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}
.card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 5px;
    background: var(--alert);
}

.btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    border: 0;
    border-radius: var(--r-ctl);
    background: var(--alert);
    color: var(--alert-ink);
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: filter 0.15s, transform 0.1s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }

/* Intro */
.card-intro { max-width: 540px; }
.intro-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.intro-from { margin: 0; font-size: 14px; color: var(--ceniza-300); }
.intro-title {
    margin: 0 0 12px;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(36px, 6vw, 52px);
    line-height: 0.96;
    letter-spacing: 0.003em;
}
.intro-text { margin: 0 0 18px; color: #d8d5e0; font-size: 15px; line-height: 1.55; max-width: 56ch; }
.howto { list-style: none; margin: 0 0 22px; padding: 0; display: grid; gap: 9px; font-size: 14px; color: var(--ceniza-300); }
.howto li { display: flex; align-items: center; gap: 10px; }
.keys { display: inline-flex; gap: 3px; }

kbd {
    display: inline-block;
    min-width: 24px;
    padding: 2px 6px;
    text-align: center;
    font: 700 12px var(--font-body);
    color: var(--senal);
    background: var(--ceniza-700);
    border: 1px solid rgba(238, 240, 238, 0.25);
    border-bottom-width: 3px;
    border-radius: 5px;
}

/* Créditos */
.credits { margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(238, 240, 238, 0.14); }
.credits-school { margin: 0 0 4px; font-family: var(--font-display); font-weight: 700; font-size: 20px; line-height: 1.1; }
.credits-line { margin: 0; font-size: 13px; color: var(--ceniza-300); }
.credits-line strong { color: var(--senal); font-weight: 600; }
.manual-credits { margin: 0 0 16px; padding-top: 12px; border-top: 1px solid rgba(238, 240, 238, 0.14); font-size: 12px; color: var(--ceniza-500); }

/* Pregunta */
.card-quiz { max-width: 600px; }
.quiz-tag { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--alert); }
.quiz-question { margin: 0 0 20px; font-size: 21px; font-weight: 700; line-height: 1.3; max-width: 46ch; }
.options { display: grid; gap: 10px; }
.option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    background: var(--ceniza-800);
    border: 1.5px solid rgba(238, 240, 238, 0.14);
    border-radius: var(--r-ctl);
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.option:hover:not(:disabled) { border-color: var(--alert); background: var(--ceniza-700); }
.option:disabled { cursor: default; }
.option .chip {
    flex: none;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: var(--ceniza-700);
    font: 700 15px var(--font-display);
}
.option.wrong { border-color: #e5322d; background: rgba(229, 50, 45, 0.14); animation: shake 0.32s; }
.option.wrong .chip { background: #e5322d; color: #fff; }
.option.right { border-color: var(--ruta); background: rgba(35, 164, 95, 0.2); }
.option.right .chip { background: var(--ruta); color: #fff; }
.quiz-feedback { min-height: 22px; margin: 14px 0 0; font-size: 14px; color: var(--ceniza-300); }
.quiz-feedback.ok { color: #5fd69a; }
.quiz-feedback.bad { color: #ff8a84; }

/* Guía */
.card-manual { max-width: 560px; }
.manual-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.manual-title { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 32px; line-height: 1; }
.btn-close {
    background: var(--ceniza-800);
    border: 1px solid rgba(238, 240, 238, 0.18);
    border-radius: var(--r-ctl);
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.btn-close:hover { background: var(--ceniza-700); }
.manual-lead { margin: 0 0 14px; color: var(--ceniza-300); }
.steps { margin: 0 0 14px; padding-left: 22px; display: grid; gap: 8px; }
.steps li::marker { font-family: var(--font-display); font-weight: 700; color: var(--alert); }
.manual-note { margin: 0 0 18px; font-size: 13px; color: var(--ceniza-300); }
.manual-foot { max-width: 220px; margin-left: auto; }

/* Resultado */
.card-result { max-width: 440px; text-align: center; }
.result-icon { width: 76px; height: 76px; margin: 4px auto 14px; color: var(--ruta); animation: pop 0.5s cubic-bezier(.2, 1.4, .4, 1); }
.result-icon.warn { color: #f5c518; }
.result-icon svg { width: 100%; height: 100%; }
.result-title { margin: 0 0 8px; font-family: var(--font-display); font-weight: 800; font-size: 38px; line-height: 1; }
.result-desc { margin: 0 0 22px; color: #d8d5e0; line-height: 1.55; }

/* ---------- Controles táctiles ---------- */
.touchpad { display: none; }
@media (pointer: coarse) {
    .touchpad {
        display: grid;
        position: fixed;
        right: 14px;
        bottom: 128px;
        z-index: 25;
        grid-template-columns: repeat(3, 58px);
        grid-template-rows: repeat(2, 58px);
        grid-template-areas: ". up ." "left down right";
        gap: 6px;
    }
    .touchpad button {
        border: 1px solid rgba(238, 240, 238, 0.25);
        border-radius: 12px;
        background: rgba(20, 17, 28, 0.78);
        color: var(--senal);
        font-size: 20px;
        touch-action: none;
    }
    .touchpad button:active { background: var(--alert); color: var(--alert-ink); }
    .tp-up { grid-area: up; } .tp-left { grid-area: left; } .tp-down { grid-area: down; } .tp-right { grid-area: right; }
}

/* ---------- Animaciones ---------- */
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes pop { 0% { transform: scale(0.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .hud { padding: 10px; }
    .hud-top { flex-direction: column; gap: 8px; }
    .alert-panel { min-width: 0; max-width: none; width: 100%; padding: 10px 14px 10px 12px; }
    .level-name { font-size: 25px; }
    .stats { width: 100%; }
    .stat { flex: 1; padding: 7px 12px; min-width: 0; }
    .stat-value { font-size: 24px; }
    .btn-guide { padding: 7px 14px; }
    .speech { flex-wrap: wrap; padding: 10px 12px; }
    .story { font-size: 14px; }
    .progress { width: 100%; flex-direction: row-reverse; align-items: center; gap: 10px; }
    .progress-bar { flex: 1; }
    .progress-label { text-align: left; white-space: nowrap; }
    .overlay-light { justify-content: center; padding-left: 16px; background: rgba(10, 8, 16, 0.72); }
    .card { padding: 24px 20px 20px; }
    .quiz-question { font-size: 18px; }
}

@media (max-height: 560px) {
    .alert-info .route, .alert-src { display: none; }
    .level-name { font-size: 22px; }
}