/* ============================================================
   styles.css — Design System + HUD + Modales base
   Octalysis Serious Game
   ============================================================ */

/* ── Google Fonts — Inter ────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Design Tokens ───────────────────────────────────────── */
:root {
    /* Colores */
    --bg-deep:        #06040f;
    --bg-surface:     #0d0b1e;
    --bg-raise:       rgba(255,255,255,.05);
    --bg-hover:       rgba(255,255,255,.09);

    --border:         rgba(255,255,255,.09);
    --border-strong:  rgba(255,255,255,.18);

    --accent:         #7B5FD4;    /* violeta principal */
    --accent-light:   #a07fe8;
    --gold:           #FFD700;    /* logros / monedas */
    --gold-dim:       rgba(255,215,0,.18);
    --green:          #4ADE80;    /* éxito */
    --red:            #F87171;    /* error */
    --text-primary:   #F0EEF8;
    --text-secondary: #9890C4;
    --text-muted:     rgba(255,255,255,.3);

    /* Tipografía */
    --font:           'Inter', system-ui, -apple-system, sans-serif;
    --fs-xs:          11px;
    --fs-sm:          13px;
    --fs-base:        14px;
    --fs-md:          16px;
    --fs-lg:          20px;
    --fs-xl:          24px;

    /* Espaciado */
    --radius-sm:      8px;
    --radius-md:      12px;
    --radius-lg:      16px;
    --radius-xl:      20px;

    /* Sombras */
    --shadow-panel:   0 8px 32px rgba(0,0,0,.5);
    --shadow-modal:   0 24px 64px rgba(0,0,0,.7);
    --blur:           blur(16px);
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg-deep);
    overflow: hidden;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ── Canvas ──────────────────────────────────────────────── */
#game-container { width: 100vw; height: 100vh; position: relative; }
#gameCanvas     { display: block; width: 100%; height: 100%; }

/* ═══════════════════════════════════════════════════════════
   HUD — Paneles de juego
═══════════════════════════════════════════════════════════ */

/* Panel base compartido */
.hud-panel {
    background: rgba(13,11,30,.82);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--shadow-panel);
    font-family: var(--font);
}

/* ── Info panel (top-left) ───────────────────────────────── */
#hud-container {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 10;
    pointer-events: none;
}

#info-panel {
    composes: hud-panel;
    background: rgba(13,11,30,.82);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--shadow-panel);
    padding: 14px 16px;
    max-width: 260px;
    /* Sin animación de pulso — fue eliminada */
}

#info-panel h3 {
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 10px;
    letter-spacing: .3px;
    /* Sin uppercase — más legible */
}

#info-panel p {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    margin: 5px 0;
    line-height: 1.5;
}

#info-panel strong { color: var(--text-primary); font-weight: 600; }

#player-position,
#current-zone {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

#artifacts-collected { color: var(--gold); font-weight: 600; font-size: var(--fs-sm); }

/* ── Score panel (top-right area) ───────────────────────── */
#score-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10;
    pointer-events: none;
}

#score-panel {
    background: rgba(13,11,30,.82);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--shadow-panel);
    padding: 12px 16px;
    min-width: 140px;
    text-align: center;
    pointer-events: all;  /* habilita clics en el panel y sus hijos */
}

#score-panel h3 {
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

#score-value {
    font-size: var(--fs-md);
    font-weight: 800;
    color: var(--gold);
    display: block;
    margin-bottom: 4px;
}

#coins-value {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--gold);
    display: block;
}

/* ── Inventory panel (right) ─────────────────────────────── */
#inventory-container {
    position: fixed;
    top: 16px;
    right: 166px; /* margen del score */
    z-index: 10;
    pointer-events: none;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#inventory-panel {
    background: rgba(13,11,30,.82);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--shadow-panel);
    padding: 14px 14px;
    width: 136px;
    pointer-events: all;
}

#inventory-panel h3 {
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 10px;
}

#inventory-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.inventory-item {
    background: var(--bg-raise);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 4px;
    text-align: center;
    font-size: 22px;
    cursor: pointer;
    transition: background .2s, transform .15s, border-color .2s;
    animation: slideIn .35s ease both;
    pointer-events: all;
    line-height: 1;
}

.inventory-item.collected {
    border-color: rgba(123,95,212,.4);
    background: rgba(123,95,212,.1);
}

.inventory-item.collected:hover {
    background: rgba(123,95,212,.2);
    transform: scale(1.08);
    border-color: rgba(123,95,212,.7);
}

.inventory-item.empty {
    opacity: .25;
    font-size: 16px;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════
   MODAL BASE — Compartido
═══════════════════════════════════════════════════════════ */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    from { transform: scale(.88) translateY(16px); opacity: 0; }
    to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

/* ── Modal Artefacto ─────────────────────────────────────── */
#artifact-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

#artifact-modal.hidden { display: none; }

.modal-content {
    background: var(--bg-surface);
    border: 1px solid rgba(255,215,0,.25);
    border-radius: var(--radius-xl);
    padding: 36px 32px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-modal), 0 0 60px rgba(255,215,0,.12);
    animation: popIn .35s cubic-bezier(.34,1.56,.64,1) both;
}

/* Ícono: animación de entrada UNA sola vez, sin rebote infinito */
.modal-icon {
    font-size: 64px;
    margin-bottom: 16px;
    line-height: 1;
    animation: popIn .5s cubic-bezier(.34,1.56,.64,1) both;
    animation-delay: .1s;
    display: block;
}

.modal-content h2 {
    font-size: var(--fs-lg);
    font-weight: 800;
    color: var(--gold);
    margin-bottom: 10px;
}

.modal-content p {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 24px;
}

/* ── Botón primario compartido ───────────────────────────── */
.modal-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    border: none;
    padding: 11px 28px;
    font-size: var(--fs-base);
    font-weight: 700;
    font-family: var(--font);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: filter .15s, transform .15s;
    pointer-events: all;
    letter-spacing: .3px;
}

.modal-btn:hover  { filter: brightness(1.15); }
.modal-btn:active { transform: scale(.96); }

/* ═══════════════════════════════════════════════════════════
   MODAL CAJA MISTERIOSA
═══════════════════════════════════════════════════════════ */
#mystery-box-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
#mystery-box-modal.hidden { display: none; }

.quiz-modal-content {
    background: var(--bg-surface);
    border: 1px solid rgba(147,112,219,.28);
    border-radius: var(--radius-xl);
    padding: 32px 28px;
    max-width: 440px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-modal), 0 0 50px rgba(147,112,219,.12);
    animation: popIn .35s cubic-bezier(.34,1.56,.64,1) both;
}

.quiz-modal-content h2 {
    font-size: var(--fs-lg);
    font-weight: 800;
    color: #BA55D3;
    margin-bottom: 6px;
}

.quiz-modal-content p {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 22px;
    font-style: italic;
}

.quiz-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.quiz-btn {
    background: rgba(147,112,219,.1);
    border: 1px solid rgba(147,112,219,.3);
    color: #BA55D3;
    padding: 14px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--fs-base);
    font-weight: 700;
    font-family: var(--font);
    pointer-events: all;
    transition: background .2s, transform .15s, border-color .2s;
    line-height: 1.4;
}

.quiz-btn:hover {
    background: rgba(147,112,219,.22);
    border-color: rgba(147,112,219,.6);
    transform: translateY(-2px);
}

.quiz-btn small {
    display: block;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════
   MODAL LEADERBOARD
═══════════════════════════════════════════════════════════ */
#leaderboard-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
#leaderboard-modal.hidden { display: none; }

.leaderboard-modal-content {
    background: var(--bg-surface);
    border: 1px solid rgba(255,215,0,.2);
    border-radius: var(--radius-xl);
    padding: 28px;
    max-width: 500px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-modal);
    animation: popIn .35s cubic-bezier(.34,1.56,.64,1) both;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.leaderboard-header h2 {
    font-size: var(--fs-lg);
    font-weight: 800;
    color: var(--gold);
    margin: 0;
}

.npc-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    transition: color .2s;
    pointer-events: all;
}
.npc-close-btn:hover { color: var(--text-primary); }

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.leaderboard-table thead { background: var(--gold-dim); }

.leaderboard-table th {
    color: var(--gold);
    padding: 10px 12px;
    text-align: left;
    font-weight: 700;
    font-size: var(--fs-xs);
    letter-spacing: .8px;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255,215,0,.2);
}

.leaderboard-table td {
    color: var(--text-secondary);
    padding: 10px 12px;
    font-size: var(--fs-sm);
    border-bottom: 1px solid var(--border);
}

.leaderboard-table tbody tr:first-child td {
    color: var(--gold);
    font-weight: 700;
}

.leaderboard-question {
    background: var(--gold-dim);
    border-left: 3px solid var(--gold);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 14px 16px;
    margin: 16px 0;
}

.leaderboard-question p {
    color: var(--gold);
    font-weight: 700;
    font-size: var(--fs-sm);
    margin: 0 0 12px 0;
}

.leaderboard-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.leaderboard-choice-btn {
    background: var(--gold-dim);
    border: 1px solid rgba(255,215,0,.25);
    color: var(--gold);
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 22px;
    pointer-events: all;
    text-align: center;
    transition: background .2s, transform .15s;
    font-family: var(--font);
}

.leaderboard-choice-btn:hover {
    background: rgba(255,215,0,.22);
    transform: translateY(-2px);
}

/* Feedback reutilizado */
.npc-feedback         { display: none; }
.npc-feedback.hidden  { display: none; }
#leaderboard-feedback { display: none; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar       { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    #info-panel        { max-width: 220px; padding: 12px; }
    #inventory-panel   { width: 120px; }
    #score-container   { top: auto; right: 8px; bottom: 60px; }
    #inventory-container { right: 136px; }
}

/* ══════════════════════════════════════════════════════════
   PROXIMIDAD DE ARTEFACTOS
══════════════════════════════════════════════════════════ */

/* Etiqueta flotante sobre el artefacto */
.drive-proximity-label {
    position: fixed;
    z-index: 20;
    pointer-events: none;
    transform: translate(-50%, -100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    transition: opacity .25s ease, transform .25s ease;
    will-change: transform;
}

.drive-proximity-label .dpl-inner {
    background: rgba(10,8,28,.88);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 20px;
    padding: 5px 12px;
    display: flex;
    align-items: center;
    gap: 7px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0,0,0,.5);
    white-space: nowrap;
}

.drive-proximity-label .dpl-emoji { font-size: 16px; line-height: 1; }

.drive-proximity-label .dpl-name {
    font-family: var(--font, 'Inter', sans-serif);
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .2px;
}

.drive-proximity-label .dpl-hint {
    font-family: var(--font, 'Inter', sans-serif);
    font-size: 10px;
    color: rgba(255,255,255,.45);
    text-align: center;
    animation: dpl-pulse 1.2s ease-in-out infinite;
}

/* Flecha apuntando hacia abajo */
.drive-proximity-label .dpl-arrow {
    width: 0; height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid rgba(255,255,255,.18);
    margin-top: -1px;
}

/* Pulsado de entrada/salida de la zona */
@keyframes dpl-pulse {
    0%, 100% { opacity: .45; }
    50%       { opacity: .9; }
}

/* Flash de recolección */
#drive-collect-flash {
    position: fixed;
    inset: -20px;   /* desborda ligeramente los bordes para efecto más envolvente */
    z-index: 19;
    pointer-events: none;
    opacity: 0;
    transition: opacity .19s ease;
    mix-blend-mode: screen;  /* mezcla aditiva — intensifica los colores del juego */
}
#drive-collect-flash.active {
    opacity: 1;
    transition: opacity .04s ease;
}
