/* main.css - v0.30 (SPEC-15 UI Injection) */

:root {
    /* Variables Dinámicas (Se sobreescriben via JS) */
    --primary-color: #666;
    --secondary-color: #888;
    --bg-color: #000000;
    --text-color: #ffffff;
    --surface-color: rgba(255, 255, 255, 0.1);

    /* ⭐ Fuentes personalizables */
    --font-family-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* ⭐ Animaciones y efectos configurables */
    --transition-speed: 0.5s;
    --border-radius-main: 50px;
    --border-radius-cards: 20px;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-glow: rgba(157, 0, 255, 0.3);
}

/* 1. RESET Y BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family-main);
    -webkit-tap-highlight-color: transparent;
}

body,
html {
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    transition: background-color var(--transition-speed) ease;
}

/* 2. PANTALLAS */
#app-container {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 2000;
    /* Ensure UI is always above AR container */
    pointer-events: none;
    /* Let clicks pass through to child elements that have auto */
}

#app-container>* {
    pointer-events: auto;
    /* Re-enable pointer events for all children */
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background-color: var(--bg-color);
    z-index: 100;
    /* Base screen z-index */
    padding: 30px;
    transition: opacity var(--transition-speed) ease;
    display: none;
    /* Hidden by default */
}

.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
    display: none !important;
    /* CRITICAL: Remove from layout to prevent ghost clicks */
}

.visible {
    opacity: 1;
    pointer-events: auto;
    z-index: 2000;
    /* Active screen is high */
    display: flex !important;
}

.fading {
    opacity: 0 !important;
    pointer-events: none;
    transition: opacity 0.3s ease-out;
}

/* 3. SPLASH & LOGO */
.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 320px;
}

.splash-icon {
    width: var(--logo-width, auto);
    height: auto;
    max-width: 280px;
    max-height: 180px;
    border-radius: var(--border-radius-cards);
    margin-bottom: 20px;
    object-fit: contain;
    display: block;
    margin-left: auto;
    margin-right: auto;
    transition: width 0.5s ease, height 0.5s ease;
}

.app-title {
    font-size: var(--title-font-size, 24px);
    font-weight: 700;
    margin-bottom: 5px;
    text-align: center;
    width: 100%;
    display: block;
    transition: color 0.5s ease;
}

.app-version {
    font-size: 11px;
    opacity: 0.6;
    margin-bottom: 5px;
    text-align: center;
    width: 100%;
    display: block;
    letter-spacing: 0.5px;
}

.loading-text-small {
    font-size: 13px;
    opacity: 0.7;
    text-align: center;
    width: 100%;
    display: block;
    margin-top: 5px;
    font-style: italic;
}

/* Barra de Progreso */
.progress-container {
    width: 280px;
    max-width: 90%;
    height: 6px;
    background-color: var(--surface-color);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    margin-bottom: 5px;
}

.progress-bar {
    width: 0%;
    height: 100%;
    /* branding.progressGradient (opcional, por experiencia) pisa este
       degradado default de 2 colores -- sin el override, todas las
       experiencias se ven exactamente igual que antes. */
    background: var(--progress-gradient, linear-gradient(90deg, rgba(255, 255, 255, 0.2) 0%, var(--primary-color) 100%));
    border-radius: 10px;
    transition: width 0.3s ease-out, background 0.5s ease;
    box-shadow: 0 0 10px var(--shadow-glow);
}

/* FULLSCREEN UI */
.fullscreen-toggle {
    position: absolute;
    top: 25px;
    right: 25px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1500;
    /* Lower than screens */
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 10px;
    /* Ensure padding for icon */
}

.fullscreen-toggle svg,
.fullscreen-toggle img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
}

.fullscreen-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* SHARE BUTTON (ARP05-143) — esquina opuesta al fullscreen, mismo look */
.share-toggle {
    position: absolute;
    top: 25px;
    left: 25px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1500;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 10px;
}

.share-toggle svg {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
}

.share-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.share-toggle.share-done {
    background: rgba(46, 204, 113, 0.35);
    border-color: rgba(46, 204, 113, 0.6);
}

.loading-text {
    font-size: 12px;
    color: #aaa;
    letter-spacing: 0.5px;
}

/* 4. ELEMENTOS UI */
.content-box {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.icon-instruction {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 15px;
}

h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 10px;
}

p {
    font-size: 15px;
    color: #ccc;
    line-height: 1.5;
    margin-bottom: 5px;
}

.btn-purple {
    background: var(--primary-color);
    color: var(--text-color);
    font-family: var(--font-family-main);
    border: none;
    padding: 16px 0;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--border-radius-main);
    cursor: pointer;
    width: 100%;
    margin-top: 15px;
    box-shadow: 0 4px 15px var(--shadow-color);
    outline: none;
    transition: transform 0.1s, background-color 0.3s, opacity 0.3s;
    text-decoration: none;
    display: inline-block;
    text-transform: none;
    letter-spacing: 1px;
    position: relative;
    z-index: 50;
    /* Above box background but under modal tools if any */
}

.btn-purple:active {
    transform: scale(0.97);
    background-color: var(--secondary-color);
}

.btn-purple:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

.btn-purple {
    cursor: pointer !important;
    pointer-events: auto !important;
}

/* 4b. CALL TO ACTION (CTA) */
.btn-cta {
    position: fixed;
    /* ARP05-91: respeta la barra de gestos / notch inferior */
    bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    color: white;
    padding: 14px 28px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    /* Lower than screens but above AR */
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    letter-spacing: 0.5px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: nowrap;
}

.btn-cta:hover {
    background: var(--primary-color);
    transform: translateX(-50%) translateY(-5px);
    box-shadow: 0 12px 40px var(--shadow-glow);
    border-color: rgba(255, 255, 255, 0.4);
}

.btn-cta:active {
    transform: translateX(-50%) scale(0.95);
}

.btn-cta svg {
    transition: transform 0.3s ease;
}

.btn-cta:hover svg {
    transform: translateX(4px);
}

/* 5. GUÍA DE ESCANEO */
#screen-guide-image {
    background: rgba(0, 0, 0, 0.1);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.scan-frame {
    position: relative;
    width: 260px;
    height: 260px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.scan-frame-corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border-color: white;
    border-style: solid;
    opacity: 0.95;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.corner-tl {
    top: 0;
    left: 0;
    border-width: 4px 0 0 4px;
    border-radius: 16px 0 0 0;
}

.corner-tr {
    top: 0;
    right: 0;
    border-width: 4px 4px 0 0;
    border-radius: 0 16px 0 0;
}

.corner-bl {
    bottom: 0;
    left: 0;
    border-width: 0 0 4px 4px;
    border-radius: 0 0 0 16px;
}

.corner-br {
    bottom: 0;
    right: 0;
    border-width: 0 4px 4px 0;
    border-radius: 0 0 16px 0;
}

.avatar-scan {
    width: 180px;
    height: auto;
    z-index: 2;
    filter: drop-shadow(0 5px 20px rgba(0, 0, 0, 0.5));
}

.pulsate {
    animation: pulse-animation 2.5s infinite ease-in-out;
}

@keyframes pulse-animation {
    0% {
        transform: scale(1);
        opacity: 0.9;
    }

    50% {
        transform: scale(1.08);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0.9;
    }
}

/* 6. FOOTER CON EFECTO DE APARICIÓN */
/* ARP05-91: el footer vive EN FLUJO dentro del splash (antes era fixed/absolute
   y en pantallas cortas se montaba sobre el boton Comenzar; el z-index bajo no
   evita traslapes, solo decide quien queda encima). */
#app-footer {
    position: static;
    width: 100%;
    flex-shrink: 0;
    text-align: center;
    font-size: 11px;
    color: var(--primary-color);
    pointer-events: none;
    line-height: 1.6;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
}

/* ARP05-91: splash como columna — contenido centrado con margin:auto y footer
   al fondo en flujo; el traslape es imposible por construccion. Scroll de
   respaldo para pantallas muy cortas. */
#screen-loading {
    justify-content: flex-start;
    overflow-y: auto;
}

#screen-loading .content-box {
    margin: auto;
    padding: 24px 0 8px;
}

#app-footer.footer-visible {
    opacity: 1;
}

#app-footer a {
    pointer-events: auto;
    color: inherit;
    font-weight: 500;
    text-decoration: underline;
    opacity: 0.7;
    transition: opacity 0.3s;
}

#app-footer a:hover {
    opacity: 1;
}

/* ARP05-94: badge global de version+build — visible sobre todos los frames.
   z-index por encima de todas las pantallas (screen-inapp usa 100000);
   pointer-events:none garantiza que nunca bloquea un tap. En el splash queda
   visualmente bajo "© | Privacidad" (dentro del padding inferior del footer). */
.version-badge {
    position: fixed;
    bottom: calc(3px + env(safe-area-inset-bottom, 0px));
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 9px;
    line-height: 1;
    color: var(--text-color, #fff);
    opacity: 0.45;
    letter-spacing: 0.06em;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    z-index: 100001;
    pointer-events: none;
    user-select: none;
}

/* 7. CONTENEDOR AR */
#ar-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    overflow: hidden;
    display: block;
    background: transparent !important;
}

#ar-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10 !important;
}

/* ARP05-91: blindaje del video de camara. MindAR re-aplica estilos inline en su
   propio resize (ancho en px + margen negativo para centrar el recorte); sin
   neutralizar margin/transform el video queda corrido y deja franja negra. */
#ar-container video {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    margin: 0 !important;
    transform: none !important;
    z-index: -2 !important;
    display: block !important;
}

/* ARP05-91: pantallas cortas (Galaxy S7 y similares, <=660px de alto) —
   compacta el splash para que contenido + footer siempre quepan sin scroll. */
@media (max-height: 660px) {
    .content-box {
        gap: 12px;
    }

    #screen-loading .content-box {
        padding: 12px 0 4px;
    }

    #branding-logo {
        max-width: 110px;
    }

    .btn-purple {
        padding: 13px 0;
        margin-top: 8px;
    }

    #app-footer {
        padding-top: 8px;
        font-size: 10px;
    }
}

/* 8. PWA FIX */
@media all and (display-mode: standalone),
all and (display-mode: fullscreen),
all and (display-mode: minimal-ui) {
    #fullscreen-toggle {
        display: none !important;
    }
}

/* 9. IN-APP BROWSER & COMPATIBILITY */
#screen-inapp {
    background-color: var(--bg-color) !important;
    z-index: 5000;
    /* Very high but normalized */
    overflow-y: auto;
    display: none;
    padding: 30px;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

.arrow-pointer {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 32px;
    color: var(--text-color);
    transform: rotate(-45deg);
    animation: bounceRight 1.5s infinite ease-in-out;
}

@keyframes bounceRight {

    0%,
    100% {
        transform: translate(0, 0) rotate(-45deg);
        opacity: 0.6;
    }

    50% {
        transform: translate(10px, -10px) rotate(-45deg);
        opacity: 1;
    }
}

/* 10. BLOQUEO DE ORIENTACIÓN */
.screen-overlay-warning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 10000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
}

/* Detectar si está en horizontal (Landscape) en un celular */
@media screen and (orientation: landscape) and (max-width: 950px) {
    .screen-overlay-warning {
        display: flex !important;
    }
}

@keyframes rotate-device {
    0% {
        transform: rotate(0deg);
    }

    30% {
        transform: rotate(-90deg);
    }

    70% {
        transform: rotate(-90deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

/* 12. VOLUME SCREEN ANIMATIONS */
.volume-anim-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 120px;
    margin-bottom: 10px;
}

.speaker-icon {
    position: relative;
    color: var(--primary-color);
    display: flex;
    align-items: center;
}

.volume-waves {
    position: absolute;
    right: -20px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wave {
    display: block;
    width: 4px;
    background: var(--primary-color);
    border-radius: 4px;
    animation: wave-glow 1.5s infinite ease-in-out;
}

.wave-1 {
    height: 10px;
    animation-delay: 0s;
}

.wave-2 {
    height: 20px;
    animation-delay: 0.2s;
}

.wave-3 {
    height: 30px;
    animation-delay: 0.4s;
}

@keyframes wave-glow {

    0%,
    100% {
        opacity: 0.3;
        transform: scaleY(1);
    }

    50% {
        opacity: 1;
        transform: scaleY(1.5);
        box-shadow: 0 0 15px var(--shadow-glow);
    }
}

/* 12. CAMERA TRANSITION LOADER */
.loader-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.spinner-ring {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    /* Anillo via mask (en vez de border-top) para poder pintarlo con un
       conic-gradient -- un borde normal no admite degradados. Default:
       arco solido en --primary-color sobre pista tenue, mismo look de
       siempre. branding.spinnerGradient (opcional, por experiencia) pisa
       esto con su propio conic-gradient (ej. tricolor viva-mexico) --
       sin el campo, cualquier experiencia se ve exactamente igual que antes. */
    background: var(--spinner-gradient, conic-gradient(rgba(255, 255, 255, 0.1) 0deg 270deg, var(--primary-color) 270deg 360deg));
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
    animation: spin 1s linear infinite;
    box-shadow: 0 0 15px var(--shadow-glow);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}