/* ============================================================
   Ayni ADN - main.css
   Identidad: "Reciprocidad cosmica andina"
   - A/T comparten familia calida (son pareja)
   - G/C comparten familia fria (son pareja)
   - Motivo geometrico andino como acento, sin iconografia sagrada
   - Respeta prefers-reduced-motion en todas las animaciones
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=Inter:wght@400;600&display=swap');

:root {
    --color-bg: #0b1024;
    --color-bg-alt: #161d3a;
    --color-bg-card: #1b2447;
    --color-primary: #22d3ee;
    --color-primary-dark: #0891b2;
    --color-success: #34d399;
    --color-error: #fb7185;
    --color-text: #f4f6fb;
    --color-muted: #9aa3c7;
    --radius: 20px;
    --radius-sm: 12px;

    /* Familia calida: A y T (pareja) */
    --warm-1: #fb923c; /* A */
    --warm-2: #f472b6; /* T */
    /* Familia fria: G y C (pareja) */
    --cool-1: #34d399; /* G */
    --cool-2: #22d3ee; /* C */

    --shadow-soft: 0 12px 32px rgba(0,0,0,0.35);
    --font-display: 'Baloo 2', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* CRITICO: cualquier elemento con el atributo HTML "hidden" debe
   ocultarse SIEMPRE, sin importar que otras reglas mas abajo le
   asignen display:flex/block. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font-body);
    background:
        radial-gradient(circle at 20% 10%, rgba(34,211,238,0.10), transparent 40%),
        radial-gradient(circle at 80% 85%, rgba(244,114,182,0.08), transparent 40%),
        linear-gradient(180deg, var(--color-bg) 0%, var(--color-bg-alt) 100%);
    background-attachment: fixed;
    color: var(--color-text);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, .font-display { font-family: var(--font-display); }

a { color: inherit; }

/* ---------- Motivo andino (zigzag abstracto) ---------- */
.andean-strip {
    height: 8px;
    width: 100%;
    background-image: linear-gradient(135deg, var(--warm-1) 25%, transparent 25%),
                       linear-gradient(225deg, var(--warm-1) 25%, transparent 25%),
                       linear-gradient(45deg, var(--cool-2) 25%, transparent 25%),
                       linear-gradient(315deg, var(--cool-2) 25%, transparent 25%);
    background-position: 0 0, 8px 0, 0 0, 8px 0;
    background-size: 16px 8px;
    background-repeat: repeat-x;
    opacity: 0.85;
    border-radius: 999px;
}

/* ---------- Botones base ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: 999px;
    background: var(--color-bg-card);
    color: var(--color-text);
    text-decoration: none;
    font-weight: 700;
    font-family: var(--font-display);
    font-size: 1rem;
    border: 2px solid rgba(255,255,255,0.12);
    cursor: pointer;
    min-height: 48px;
    min-width: 48px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 2px; }

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    border-color: transparent;
    color: #04202a;
}
.btn-small { padding: 10px 16px; font-size: 0.9rem; }

/* ---------- Home ---------- */
.home-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.home-card {
    text-align: center;
    max-width: 460px;
    background: var(--color-bg-card);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius);
    padding: 40px 28px 32px;
    box-shadow: var(--shadow-soft);
}
.home-emoji {
    font-size: 4rem;
    display: inline-block;
    animation: float-gentle 4s ease-in-out infinite;
}
@keyframes float-gentle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
.home-card h1 { font-size: 2.2rem; margin: 12px 0 4px; }
.tagline { color: var(--color-muted); margin-bottom: 12px; font-size: 0.95rem; }
.name-meaning {
    font-size: 0.85rem;
    color: var(--color-muted);
    line-height: 1.55;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin: 16px 0 24px;
    text-align: left;
}
.name-meaning strong { color: var(--warm-1); }
.home-menu { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.home-footnote { margin-top: 20px; color: var(--color-muted); font-size: 0.8rem; }

/* ---------- Worlds ---------- */
.worlds-screen { max-width: 960px; margin: 0 auto; padding: 24px 20px 60px; }
.worlds-header { display: flex; flex-direction: column; gap: 10px; margin-bottom: 28px; }
.back-link { text-decoration: none; color: var(--color-muted); font-weight: 600; }
.worlds-header h1 { font-size: 1.8rem; margin: 4px 0; }
.world-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 18px;
}
.world-card {
    background: var(--color-bg-card);
    border-radius: var(--radius);
    padding: 22px;
    border: 1px solid rgba(255,255,255,0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.world-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-soft); }
.world-card h2 { font-size: 1.15rem; margin: 0 0 6px; }
.world-card p { color: var(--color-muted); font-size: 0.9rem; margin: 0 0 12px; }
.world-card--locked { opacity: 0.45; }
.level-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.locked-note { color: var(--color-muted); }
.empty-state { color: var(--color-muted); text-align: center; margin-top: 60px; }

/* ---------- Play screen ---------- */
.play-screen {
    max-width: 560px;
    margin: 0 auto;
    padding: 16px 16px 40px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}
.play-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 700;
    font-family: var(--font-display);
}
.play-stats { display: flex; align-items: center; gap: 14px; font-size: 1.05rem; }
.stat-score { position: relative; }
.stat-score.pop { animation: score-pop 0.4s ease; }
@keyframes score-pop {
    0% { transform: scale(1); color: var(--color-text); }
    40% { transform: scale(1.35); color: var(--color-success); }
    100% { transform: scale(1); color: var(--color-text); }
}
.stat-lives { transition: transform 0.2s ease; }
.stat-lives.shake { animation: shake-hearts 0.4s ease; }
@keyframes shake-hearts {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}
.stat-combo { font-weight: 800; color: var(--warm-1); }
.stat-combo.combo-pulse { animation: combo-flame 0.5s ease; }
@keyframes combo-flame {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.4) rotate(-6deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.sound-toggle {
    background: transparent;
    border: none;
    color: var(--color-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
    min-width: 40px;
    min-height: 40px;
}
.sound-toggle:focus-visible { outline: 2px solid var(--color-primary); }

/* Transicion suave entre paneles: fade + leve escala */
.lesson-panel, .countdown-panel, .game-panel, .result-panel {
    animation: panel-in 0.35s ease;
}
@keyframes panel-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.lesson-panel, .result-panel {
    background: var(--color-bg-card);
    border-radius: var(--radius);
    padding: 28px 24px;
    text-align: center;
    margin-top: 20px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: var(--shadow-soft);
}
.lesson-panel h2, .result-panel h2 { font-size: 1.4rem; margin-top: 0; }
.big-rule {
    font-size: 1.6rem;
    font-weight: 800;
    font-family: var(--font-display);
    margin: 16px 0;
}
.big-rule .warm { color: var(--warm-1); }
.big-rule .cool { color: var(--cool-2); }

.countdown-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 40vh;
}
.countdown-number {
    font-size: 6.5rem;
    font-weight: 800;
    font-family: var(--font-display);
    color: var(--color-primary);
    animation: countdown-pop 0.55s ease;
}
@keyframes countdown-pop {
    0% { transform: scale(0.4); opacity: 0; }
    60% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.game-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    text-align: center;
    position: relative;
    min-height: 50vh;
}
.stimulus {
    font-size: 5rem;
    font-weight: 800;
    font-family: var(--font-display);
    width: 150px;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.06), transparent 60%), var(--color-bg-card);
    border: 5px solid var(--color-primary);
    box-shadow: 0 0 0 6px rgba(34,211,238,0.12);
    animation: stimulus-in 0.4s ease;
}
@keyframes stimulus-in {
    from { transform: scale(0.7); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.stimulus[data-base="A"], .stimulus[data-base="T"] { border-color: var(--warm-1); box-shadow: 0 0 0 6px rgba(251,146,60,0.15); }
.stimulus[data-base="G"], .stimulus[data-base="C"] { border-color: var(--cool-2); box-shadow: 0 0 0 6px rgba(34,211,238,0.15); }

.prompt { color: var(--color-muted); margin: 0; font-size: 0.95rem; }

.choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(96px, 1fr));
    gap: 14px;
    width: 100%;
    max-width: 340px;
}
.choice-btn {
    font-size: 1.9rem;
    font-weight: 800;
    font-family: var(--font-display);
    padding: 22px 0;
    border-radius: 20px;
    border: 3px solid rgba(255,255,255,0.15);
    background: var(--color-bg-card);
    color: var(--color-text);
    cursor: pointer;
    min-height: 68px;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.choice-btn:hover:not(:disabled) { transform: translateY(-2px); }
.choice-btn:active:not(:disabled) { transform: scale(0.96); }
.choice-btn:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 2px; }
.choice-btn:disabled { cursor: default; }

/* A y T = familia calida (pareja). G y C = familia fria (pareja). */
.choice-btn[data-base="A"] { border-color: var(--warm-1); }
.choice-btn[data-base="T"] { border-color: var(--warm-2); }
.choice-btn[data-base="G"] { border-color: var(--cool-1); }
.choice-btn[data-base="C"] { border-color: var(--cool-2); }

.choice-btn.is-correct {
    background: var(--color-success);
    color: #04241a;
    animation: correct-pulse 0.45s ease;
}
@keyframes correct-pulse {
    0% { transform: scale(1); }
    35% { transform: scale(1.12); }
    100% { transform: scale(1); }
}
.choice-btn.is-incorrect {
    background: var(--color-error);
    color: #2a0a0a;
    animation: incorrect-shake 0.45s ease;
}
@keyframes incorrect-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

.feedback { min-height: 26px; font-weight: 700; font-family: var(--font-display); }
.feedback.correct { color: var(--color-success); }
.feedback.incorrect { color: var(--color-error); }

/* Particulas al acertar */
.particle-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
}
.particle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: particle-burst 0.7s ease-out forwards;
}
@keyframes particle-burst {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0); opacity: 0; }
}

.result-score {
    font-size: 2.2rem;
    font-weight: 800;
    font-family: var(--font-display);
    color: var(--color-primary);
    margin: 8px 0;
}
.result-stars { font-size: 1.8rem; letter-spacing: 4px; }
.result-stars .star {
    display: inline-block;
    opacity: 0;
    animation: star-in 0.4s ease forwards;
}
.result-stars .star:nth-child(1) { animation-delay: 0.1s; }
.result-stars .star:nth-child(2) { animation-delay: 0.35s; }
.result-stars .star:nth-child(3) { animation-delay: 0.6s; }
@keyframes star-in {
    0% { transform: scale(0) rotate(-30deg); opacity: 0; }
    70% { transform: scale(1.3) rotate(8deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.result-actions { display: flex; gap: 12px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

.btn-help {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: var(--color-bg-card);
    color: var(--color-text);
    font-weight: 800;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    z-index: 5;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* ---------- Breakpoints: movil -> tablet -> desktop ---------- */
@media (min-width: 480px) {
    .choices { max-width: 360px; }
}

@media (min-width: 640px) {
    .stimulus { font-size: 6rem; width: 180px; height: 180px; }
    .home-card h1 { font-size: 2.6rem; }
}

@media (min-width: 900px) {
    .play-screen { max-width: 620px; padding-top: 32px; }
    .worlds-screen { padding-top: 48px; }
    .choice-btn { font-size: 2.1rem; }
}

@media (max-width: 380px) {
    .stimulus { font-size: 4.2rem; width: 120px; height: 120px; }
    .choice-btn { font-size: 1.6rem; padding: 18px 0; min-height: 58px; }
    .countdown-number { font-size: 5rem; }
}
