/* --- ESTILOS GENERALES --- */
body {
    background-color: #ffffff;
    color: #1a1a1a;
    font-family: 'Nunito', sans-serif;
    margin: 0;
    padding: 20px 0; /* Quitamos padding lateral para el scroll */
    text-align: center;
}

header {
    margin-bottom: 20px;
    padding: 0 20px;
}

h1 {
    font-size: 2.5em;
    margin-bottom: 0.2em;
}

.instruccion {
    font-size: 0.9em;
    color: #666;
    font-style: italic;
}

/* --- EL BOSQUE (SCROLL HORIZONTAL) --- */
.bosque {
    display: flex;
    overflow-x: auto;
    gap: 50px; /* Espacio entre árboles */
    padding: 20px 40px;
    align-items: flex-end; /* Alinea los árboles por abajo */
    scroll-snap-type: x mandatory; /* Efecto imán al pasar "páginas" */
    scroll-behavior: smooth;
}

/* Ocultar la barra de scroll para que parezca más un libro (opcional) */
.bosque::-webkit-scrollbar {
    height: 8px;
}
.bosque::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 4px;
}

/* Contenedor individual de cada árbol */
.arbol-wrapper {
    flex: 0 0 auto;
    width: 320px; /* Ancho de cada "página/árbol" */
    scroll-snap-align: center; /* Centra el árbol al hacer scroll */
}

/* --- ESTILOS DE LAS HOJAS --- */
.hoja {
    stroke: #1a1a1a;
    stroke-width: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.hoja.vacia {
    fill: #ffffff;
    stroke-dasharray: 5, 3;
}

.hoja.llena {
    fill: #1a1a1a;
    stroke-dasharray: 0;
}

.hoja.llena:hover {
    transform: scale(1.15);
}

/* --- VENTANA MODAL (Igual que antes) --- */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
}

.modal.mostrar {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-contenido {
    background-color: #fff;
    padding: 30px;
    border: 4px solid #1a1a1a;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    border-radius: 15px;
    box-shadow: 8px 8px 0 rgba(0,0,0,0.2);
    text-align: left;
}

.cerrar {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.texto-cuento {
    line-height: 1.6;
    font-size: 1.1em;
    white-space: pre-line;
}

/* Importamos una fuente amigable para cuentos */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700&display=swap');

body {
    background-color: #ffffff; /* Fondo blanco */
    color: #1a1a1a; /* Texto casi negro para mejor lectura */
    font-family: 'Nunito', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    text-align: center;
    margin-top: 40px;
    margin-bottom: 20px;
}

h1 {
    font-size: 3em;
    margin: 0;
    letter-spacing: 2px;
}

.tree-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

/* --- ESTILOS DE LAS HOJAS DEL ÁRBOL --- */
.hoja {
    stroke: #1a1a1a; /* Borde negro (como tinta) */
    stroke-width: 3px;
    cursor: pointer;
    transition: all 0.5s ease-in-out; /* Animación suave */
}

/* Hoja sin cuento: Fondo blanco */
.hoja.vacia {
    fill: #ffffff;
    stroke-dasharray: 4; /* Da un efecto de línea punteada o boceto */
}

/* Hoja con cuento: Relleno negro (o puedes cambiarlo a un gris oscuro) */
.hoja.llena {
    fill: #1a1a1a;
    stroke-dasharray: 0; /* Línea continua */
}

.hoja.llena:hover {
    transform: scale(1.1); /* Crece un poquito al pasar el ratón */
    transform-origin: center;
}

/* Controles de prueba */
.controles {
    margin-top: 30px;
}

button {
    background: white;
    border: 2px solid black;
    padding: 10px 15px;
    border-radius: 20px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    margin: 5px;
}

button:hover {
    background: #f0f0f0;
}

/* --- ESTILOS DE LA VENTANA MODAL (Estilo Manga) --- */
.modal {
    display: none; /* Oculta por defecto */
    position: fixed;
    z-index: 10;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Fondo oscuro para resaltar la ventana */
    justify-content: center;
    align-items: center;
}

.modal:not(.oculta) {
    display: flex;
}

.modal-contenido {
    background-color: #ffffff;
    padding: 30px;
    border: 4px solid #1a1a1a; /* Borde grueso estilo viñeta */
    border-radius: 10px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto; /* Barra de desplazamiento si el cuento es largo */
    position: relative;
    box-shadow: 10px 10px 0px #1a1a1a; /* Sombra dura estilo manga */
}

.cerrar {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 32px;
    font-weight: bold;
    color: #1a1a1a;
    cursor: pointer;
    transition: color 0.3s;
}

.cerrar:hover {
    color: #888;
}

audio {
    width: 100%;
    margin: 20px 0;
}

.texto-cuento {
    line-height: 1.8;
    font-size: 1.1em;
    text-align: justify;
}