/* Estilos para la página de inicio del Wordle */

.wordle-main {
    padding: 2rem;
    display: flex;
    justify-content: center;
    text-align: center;
}

.game-intro {
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    transition: opacity 0.5s ease-out;
    position: relative;
    z-index: 0;
}

.game-intro::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(100%, 780px);
    background: rgba(255, 255, 255, 0.15);
    border-radius: 36px;
    z-index: -1;
    pointer-events: none;
}

/* Clase para ocultar la intro */
.game-intro.hidden {
    opacity: 0;
    pointer-events: none;
    height: 0;
    margin: 0;
    padding: 0;
}


.level-selector {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.level-button {
    width: 200px;
    min-height: 180px;
    border-radius: 24px;
    border: 4px solid #ffffff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    font-family: 'Oswald', sans-serif;
    color: #ffffff;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 1.5rem 1rem;
    text-align: center;
}

.level-button span {
    line-height: 1.2;
}

.level-button .level-code {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.level-button .level-spanish {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
}

.level-button .level-english {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: none;
}

.level-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.2);
}

/* Colores de los botones por nivel */
:root {
    --color-a1: #3498db;
    --color-a2: #2980b9;
    --color-b1: #2ecc71;
    --color-b2: #27ae60;
    --color-c1: #f39c12;
    --color-c2: #e67e22;

    /* Colores del juego Wordle (Estilo oscuro/moderno) */
    --color-correct: #538d4e;
    --color-present: #b59f3b;
    --color-absent: #787c7e;
    --tile-border-idle: #d3d6da; /* Borde gris claro */
    --tile-border-active: #86888a; /* Borde gris medio */
    --text-color-light: #ffffff;
    --text-color-dark: #000000;
}

.level-button.level-a1 { background-color: var(--color-a1); }
.level-button.level-a2 { background-color: var(--color-a2); }
.level-button.level-b1 { background-color: var(--color-b1); }
.level-button.level-b2 { background-color: var(--color-b2); }
.level-button.level-c1 { background-color: var(--color-c1); }
.level-button.level-c2 { background-color: var(--color-c2); }

.level-button:disabled,
.level-button[aria-disabled="true"] {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.level-button:disabled:hover,
.level-button[aria-disabled="true"]:hover {
    transform: none;
    box-shadow: none;
}



/* ####################################################
 ESTILOS PARA EL JUEGO
####################################################
*/

.game-container {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.game-main-area {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    align-items: flex-start;
}

.game-board-area {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    min-width: 0;
}

.clue-panel {
    width: 240px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
    background-color: #ffe066;
    border-radius: 16px;
    padding: 1.5rem 1rem;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.clue-button {
    width: 100%;
    padding: 1rem 1.25rem;
    border: none;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    font-weight: 900;
    text-transform: uppercase;
    background-color: #7a7a7a;
    color: #ffffff;
    cursor: not-allowed;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.clue-button.active {
    background-color: #c0392b;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(192, 57, 43, 0.35);
}

.clue-button.active:hover {
    background-color: #a93226;
    transform: translateY(-2px);
}

.clue-button:disabled {
    opacity: 0.85;
}

.clue-messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    color: #2c3e50;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    font-weight: 900;
    text-align: left;
}

.clue-message {
    background: #ffffff;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 6px 12px rgba(0, 0, 0, 0.08);
}

@media (max-width: 900px) {
    .game-main-area {
        flex-direction: column;
        align-items: center;
    }

    .clue-panel {
        width: 100%;
        max-width: 360px;
    }
}

/* --- (NUEVO) Barra de Controles del Juego --- */
.game-controls {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px; /* Pequeño padding lateral */
    margin-bottom: -1rem; /* Acercarlo al tablero */
}

.game-controls__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.game-controls h2 {
    font-family: 'Oswald', sans-serif;
    color: var(--secondary-color);
    font-size: 2rem;
    margin: 0;
}

.instructions-button {
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #1d8cf8, #3358f4);
    color: #ffffff;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    padding: 0.55rem 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
    white-space: nowrap;
}

.instructions-button:hover,
.instructions-button:focus {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(51, 88, 244, 0.35);
    outline: none;
}

.instructions-button:focus-visible {
    outline: 3px solid rgba(51, 88, 244, 0.6);
    outline-offset: 3px;
}

#calendar-button {
    background: none;
    border: none;
    font-size: 2.5rem; /* Tamaño del emoji */
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

#calendar-button:hover {
    background-color: rgba(0,0,0,0.05);
}

.instructions-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.instructions-modal.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.instructions-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.instructions-modal__content {
    position: relative;
    background: #ffffff;
    border-radius: 18px;
    padding: 2rem;
    max-width: min(480px, 90vw);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    text-align: left;
    font-family: 'Montserrat', sans-serif;
    color: #1f1f1f;
    line-height: 1.6;
    z-index: 1;
}

.instructions-modal__content h3 {
    margin-top: 0;
    font-family: 'Oswald', sans-serif;
    font-size: 2rem;
    color: var(--secondary-color);
}

.instructions-modal__content ul {
    padding-left: 1.2rem;
    margin: 1rem 0;
}

.instructions-modal__content li {
    margin-bottom: 0.5rem;
}

.instructions-modal__note {
    font-weight: 600;
    color: #3358f4;
}

.instructions-modal__close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    border: none;
    background: transparent;
    font-size: 1.25rem;
    cursor: pointer;
    color: #5a5a5a;
    padding: 0.25rem;
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.instructions-modal__close:hover,
.instructions-modal__close:focus {
    background-color: rgba(0, 0, 0, 0.05);
    color: #000000;
    outline: none;
}

.instructions-modal__close:focus-visible {
    outline: 3px solid rgba(51, 88, 244, 0.6);
    outline-offset: 3px;
}

@media (max-width: 600px) {
    .instructions-modal__content {
        padding: 1.5rem 1.25rem 1.75rem;
    }

    .instructions-button {
        font-size: 0.85rem;
        padding: 0.45rem 0.8rem;
    }
}


/* --- Rejilla del Juego --- */

.game-grid {
    display: grid;
    grid-template-columns: repeat(var(--word-length, 5), 1fr);
    grid-template-rows: repeat(var(--max-tries, 6), 1fr);
    gap: 5px;
    width: var(--grid-width, 320px);
    height: var(--grid-height, 380px);
    perspective: 1000px;
}

.grid-tile {
    width: 100%;
    height: 100%;
    border: 2px solid var(--tile-border-idle);
    font-size: 2rem;
    font-weight: bold;
    font-family: 'Oswald', sans-serif;
    color: var(--text-color-dark); /* Texto inicial NEGRO */
    text-transform: uppercase;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
    background-color: #ffffff; /* Fondo inicial BLANCO */
    backface-visibility: hidden;
    position: relative;
    transition: transform 0.8s ease-in-out; /* Esta es la transición */
}

/* Estado: Letra escrita (aún no enviada) */
.grid-tile.filled {
    border-color: var(--tile-border-active);
    animation: popIn 0.1s ease;
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0;}
    to { transform: scale(1); opacity: 1;}
}

/* --- Animación de giro (Suave) --- */
/* El giro se aplica al añadir la clase de estado */
.grid-tile.correct,
.grid-tile.present,
.grid-tile.absent {
    border-color: transparent;
    color: var(--text-color-dark); /* Mantener letras negras tras el giro */
}

/* El texto de la cara trasera debe estar espejado para que se lea bien al girar */
.grid-tile.correct::before,
.grid-tile.present::before,
.grid-tile.absent::before {
    content: attr(data-letter); /* Usaremos un atributo de datos para el texto */
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    transform: rotateX(180deg); /* Voltear el texto en la cara trasera */
    backface-visibility: hidden;
    color: var(--text-color-dark);
}

.grid-tile.correct { background-color: var(--color-correct); }
.grid-tile.present { background-color: var(--color-present); }
.grid-tile.absent { background-color: var(--color-absent); }

.grid-tile.flip {
    animation: flipReveal 0.8s ease forwards;
}

@keyframes flipReveal {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}


/* Estado: Animación de error (palabra no válida) */
.game-grid.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}


/* --- Teclado Virtual --- */
.game-keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 500px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.keyboard-key {
    font-family: 'Montserrat', sans-serif;
    font-weight: bold;
    font-size: 0.9rem;
    height: 58px;
    flex: 1;
    padding: 0 8px;
    margin: 0 3px;
    border: none;
    background-color: #b0b4b7;
    color: #ffffff;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease;
}

.keyboard-key:hover {
    background-color: #c4c7c9;
}

.keyboard-key.large {
    flex: 1.5;
    font-size: 0.8rem;
}

.keyboard-key.correct { background-color: var(--color-correct); color: #ffffff; }
.keyboard-key.present { background-color: var(--color-present); color: #ffffff; }
.keyboard-key.absent { background-color: var(--color-absent); color: #ffffff; }


/* --- Notificaciones (Toast) --- */
.toast-container {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.toast {
    background-color: rgba(255, 255, 255, 0.95);
    color: #121213;
    padding: 0.8rem 1.2rem;
    border-radius: 4px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: slideInFadeOut 2.3s ease-out forwards;
}

@keyframes slideInFadeOut {
    0% { opacity: 0; transform: translateY(-20px); }
    15% { opacity: 1; transform: translateY(0); }
    85% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}
