/* public/css/style.css */

/* --- Estilos del Splash Screen --- */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #f4f4f7; /* Un fondo claro y elegante, Gris claro */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out; /* Para la transición de salida */
}

.splash-logo {
    font-family: 'Segoe UI', 'Roboto', sans-serif;
    font-size: 4rem; /* Tamaño grande y legible */
    font-weight: 700;
    color: #E53935;
    letter-spacing: 2px;
    animation: fadeInLogo 1.5s ease-in-out forwards; /* Animación de entrada */
}

/* Versión mejorada */
#app-container {
    /* Por defecto, la app está visible pero su transición está lista */
    opacity: 1;
    transition: opacity 0.5s ease-in;
}

#app-container.hidden-by-splash {
    /* Cuando el splash está activo, ocultamos la app de forma que no afecte el renderizado */
    opacity: 0;
    visibility: hidden; /* ¡Clave! Le dice al navegador que el elemento no es interactivo */
}

#app-container.fade-in {
    /* Hacemos la app visible de nuevo */
    opacity: 1;
    visibility: visible;
}

/* Clases de control para la animación de salida */
.splash-screen.fade-out {
    opacity: 0;
    pointer-events: none; /* Para que no se pueda hacer clic en él cuando es invisible */
}

/* Definición de la animación del logo */
@keyframes fadeInLogo {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    50% {
        opacity: 1;
        transform: scale(1.02);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

:root {
    --primary-color: #D32F2F; /* Rojo principal */
    --background-color: #f4f4f7; /* Gris claro */
    --surface-color: #FFFFFF; /* Blanco */
    --text-color: #212121; /* Gris oscuro / Negro */
    --font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#app-container {
    width: 100%;
    max-width: 480px; /* Ancho típico de móvil */
    height: 100vh;
    max-height: 800px;
    background-color: var(--surface-color);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, transform 0.5s ease;
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.screen.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.card, .game-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.title {
    color: var(--primary-color);
    text-align: center;
    font-size: 2.5rem;
    font-weight: 700;
}

.input-field {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
}

.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    background-color: var(--primary-color);
    color: white;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn:hover {
    background-color: #B71C1C; /* Rojo más oscuro */
}

/* Estilos de la pantalla de juego */
.game-card {
    height: 100%;
    justify-content: flex-end; /* Alinea el contenido hacia abajo */
}

.narrative {
    font-size: 1.1rem;
    line-height: 1.6;
    padding: 16px;
    background-color: var(--background-color);
    border-radius: 12px;
    min-height: 150px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-btn {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    background-color: var(--surface-color);
    color: var(--primary-color);
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.choice-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

.reflection {
    font-style: italic;
    text-align: center;
    padding: 16px;
    background: #f9f9f9;
    border-left: 4px solid var(--primary-color);
}

/* Loader */
.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

/* Cuando la app está instalada, nos aseguramos de que los banners de instalación
   nunca se muestren, incluso si hay un error de lógica en el JS. */
body.is-standalone .install-banner {
    display: none !important;
}

/* Estilos para el banner de actualización */
#update-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #333; /* Color oscuro para distinguirlo */
    color: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    padding: 12px 16px;
    z-index: 2000;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    animation: slideUp 0.5s ease-out;
}

#update-bar.visible {
    display: flex; /* Lo hace visible */
}

#update-bar button {
    padding: 5px 10px;
    border: 1px solid white;
    background: transparent;
    color: white;
    border-radius: 5px;
    cursor: pointer;
}

/* Estilos para el Banner de Instalación de la PWA */
.install-banner {
    display: none; /* Oculto por defecto */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--surface-color);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
    padding: 12px 16px;
    z-index: 2000;
    animation: slideUp 0.5s ease-out;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.install-banner.visible {
    display: flex;
}

.install-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.install-banner-logo {
    width: 48px;
    height: 48px;
}

.install-banner-text {
    display: flex;
    flex-direction: column;
}

.install-banner-text strong {
    font-weight: 600;
    color: var(--text-color);
}

.install-banner-text span {
    font-size: 0.9em;
    color: #666;
}

.install-banner-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-install {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}
.btn-install:hover {
    background-color: #C62828;
}

.btn-dismiss {
    background: none;
    border: none;
    font-size: 1.8em;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.inline-icon {
    display: inline-block;
    vertical-align: middle; /* Alinea el icono con el texto */
    height: 1.2em; /* ajusta el tamaño para que sea similar al del texto */
    margin: 0 0.2em;
}

/* --- Mejora Visual: Centrado de la Pantalla de Carga --- */

/* Hacemos que la tarjeta de la pantalla de carga se comporte como un contenedor flexible.
   Esto nos da un control total sobre la alineación de sus hijos (el loader y el texto). */
#loading-screen .card {
    display: flex;
    flex-direction: column; /* Apila los elementos verticalmente (loader arriba, texto abajo) */
    justify-content: center; /* Centra el contenido verticalmente dentro de la tarjeta */
    align-items: center;   /* Centra el contenido horizontalmente dentro de la tarjeta */
    gap: 20px;             /* Añade un espacio agradable entre el loader y el texto */
    text-align: center;    /* Asegura que el texto en sí esté centrado si ocupa varias líneas */
}

/* Estilos adicionales para el texto de carga para que se vea mejor */
.loading-text {
    font-size: 1.1rem;
    color: #666; /* Un gris sutil */
    max-width: 80%; /* Evita que el texto se extienda demasiado en pantallas anchas */
    line-height: 1.5;
}