@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Inter:wght@300;400;600&display=swap');

:root {
    --primario:     #1a3a6b;
    --primario-dim: rgba(26, 58, 107, 0.25);
    --acento:       #c9a227;
    --negro:        #050a0f;
    --blanco:       #ffffff;
    --txt-muted:    rgba(255, 255, 255, 0.55);
    --glass:        rgba(5, 10, 15, 0.78);
    --glass-border: rgba(201, 162, 39, 0.25);
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body:    'Inter', 'Segoe UI', sans-serif;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: var(--negro);
    font-family: var(--font-body);
    touch-action: none;
}

body > video,
a-scene > video {
    width: 100vw !important;
    height: 100vh !important;
    object-fit: cover !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 0 !important;
}

a-assets video {
    position: static !important;
    width: auto !important;
    height: auto !important;
}

canvas { z-index: 2 !important; }

.hidden { display: none !important; }

/* ── Loading ── */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 40000;
    background: var(--negro);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

#loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

#loading-card,
#overlay-transicion {
    text-align: center;
    padding: 32px 24px;
    max-width: 92vw;
}

#loading-logo,
#transicion-logo {
    width: auto;
    height: 72px;
    max-width: 200px;
    object-fit: contain;
    margin-bottom: 16px;
    animation: logoPulse 1.5s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.05); opacity: 0.85; }
}

#loading-titulo,
#transicion-titulo {
    font-family: var(--font-display);
    font-size: clamp(20px, 5vw, 28px);
    color: var(--blanco);
    margin-bottom: 8px;
}

#loading-subtitulo,
#transicion-subtitulo {
    font-size: 13px;
    color: var(--txt-muted);
    margin-bottom: 20px;
}

#loading-barra-wrap,
#transicion-barra-wrap {
    width: min(260px, 78vw);
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin: 0 auto 12px;
    overflow: hidden;
}

#loading-barra,
#transicion-barra {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primario), var(--acento));
    border-radius: 4px;
    transition: width 0.25s ease;
}

#loading-texto {
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--txt-muted);
    text-transform: uppercase;
}

/* ── Overlay transición (opaco) ── */
#overlay-transicion {
    position: fixed;
    inset: 0;
    z-index: 50000;
    background: var(--negro);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

#overlay-transicion.visible {
    opacity: 1;
    pointer-events: all;
}

#gorros-container,
#gorros-transicion {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: -1;
}

.gorro {
    position: absolute;
    top: -36px;
    font-size: 20px;
    opacity: 0.5;
    animation: gorroCae linear infinite;
}

@keyframes gorroCae {
    0%   { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(110vh) rotate(360deg); }
}

/* ── UI info ── */
#ui-info {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    background: var(--glass);
    color: var(--blanco);
    padding: 16px 24px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    pointer-events: none;
    max-width: 88vw;
    text-align: center;
}

#ui-info-principal {
    display: block;
    font-family: var(--font-display);
    font-size: clamp(17px, 4.2vw, 24px);
    line-height: 1.3;
}

.ui-sub {
    display: block;
    font-size: 12px;
    color: var(--txt-muted);
    margin-top: 8px;
}

/* ── Scanner ── */
#scanner-ui {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scanner-ring {
    position: absolute;
    border: 2px solid rgba(201, 162, 39, 0.35);
    border-radius: 20px;
    animation: scanPulse 2s ease-in-out infinite;
}

.s-ring-1 { width: 58vw; height: 72vw; max-width: 290px; max-height: 370px; }
.s-ring-2 { width: 63vw; height: 77vw; max-width: 310px; max-height: 390px; animation-delay: 0.25s; opacity: 0.65; }
.s-ring-3 { width: 68vw; height: 82vw; max-width: 330px; max-height: 410px; animation-delay: 0.5s; opacity: 0.35; }

@keyframes scanPulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.02); }
}

.scanner-label {
    position: absolute;
    bottom: 16vh;
    font-size: 10px;
    letter-spacing: 3px;
    color: var(--txt-muted);
}

/* ── Badge colegio ── */
#colegio-badge {
    position: fixed;
    top: max(14px, env(safe-area-inset-top));
    right: 14px;
    z-index: 10002;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 11px;
    color: var(--acento);
    backdrop-filter: blur(8px);
}

/* ── Overlay título ── */
#overlay-titulo {
    position: fixed;
    bottom: 11vh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    text-align: center;
    pointer-events: none;
    max-width: 90vw;
}

.overlay-linea-1 {
    font-family: var(--font-display);
    font-size: clamp(18px, 4.8vw, 26px);
    color: var(--blanco);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85);
}

.overlay-linea-2 {
    font-size: 12px;
    color: var(--acento);
    margin-top: 4px;
}

/* ── Perfil ── */
#btn-perfil {
    position: fixed;
    bottom: max(22px, env(safe-area-inset-bottom));
    right: 18px;
    z-index: 10002;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--blanco);
    font-size: 20px;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

#btn-perfil.btn-activo {
    border-color: var(--acento);
    background: var(--primario-dim);
}

#ui-stats {
    position: fixed;
    bottom: max(86px, calc(env(safe-area-inset-bottom) + 64px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10002;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 14px 18px;
    min-width: 230px;
    max-width: 92vw;
    backdrop-filter: blur(12px);
}

#ui-stats h3 {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-size: 17px;
    color: var(--acento);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    color: var(--txt-muted);
    margin-bottom: 5px;
}

.stat-item b {
    color: var(--blanco);
    font-weight: 600;
    text-align: right;
}

#hint-swipe {
    position: fixed;
    bottom: max(92px, calc(env(safe-area-inset-bottom) + 70px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    background: var(--glass);
    padding: 7px 14px;
    border-radius: 18px;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--txt-muted);
    border: 1px solid var(--glass-border);
}

/* ── Video loader ── */
#video-loader {
    position: fixed;
    inset: 0;
    z-index: 15000;
    background: rgba(5, 10, 15, 0.82);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.vl-ring {
    width: 42px;
    height: 42px;
    border: 3px solid rgba(255, 255, 255, 0.12);
    border-top-color: var(--acento);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.vl-label {
    margin-top: 14px;
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--txt-muted);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ── */
#error-overlay {
    position: fixed;
    inset: 0;
    z-index: 60000;
    background: var(--negro);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}

#error-overlay h2 {
    font-family: var(--font-display);
    color: var(--blanco);
    margin: 0 0 10px;
}

#error-overlay p {
    color: var(--txt-muted);
    max-width: 320px;
    margin-bottom: 20px;
}

#error-retry {
    background: var(--primario);
    color: var(--blanco);
    border: none;
    padding: 12px 22px;
    border-radius: 22px;
    font-size: 14px;
    cursor: pointer;
}

@media (max-width: 380px) {
    #ui-info, #ui-stats, #btn-perfil { backdrop-filter: blur(4px); }
}

@media (prefers-reduced-motion: reduce) {
    .gorro, .scanner-ring, #loading-logo, #transicion-logo { animation: none !important; }
}
