/* style.css */

/* 1. Estilos Generales y Reseteo Básico */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-image: url('img/wood_bg.jpg');
    background-size: cover;
    background-attachment: fixed;
    background-position: center center;
    color: #333;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    line-height: 1.6;
    font-size: 15px;
}

/* 2. Header (Encabezado) */
header {
    background-color: #2e8b57;
    color: white;
    padding: 10px 15px;
    text-align: center;
    width: 100%;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    max-width: 1100px;
    margin: 0 auto;
}

.school-logo {
    height: 75px;
    width: auto;
    max-width: 100px;
    object-fit: contain;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.25);
}

header h1 {
    margin: 0;
    font-size: 2.2em;
    text-shadow: 1.5px 1.5px 3px rgba(0, 0, 0, 0.3);
}

header h2 {
    margin: 3px 0 0;
    font-size: 1.1em;
    font-weight: normal;
}

/* 3. Main (Contenido Principal) */
main {
    flex-grow: 1;
    padding: 20px;
    width: 95%;
    max-width: 1200px;
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
}

/* 4. Nuevo contenedor para el tablero y la referencia */
.game-area {
    display: flex;
    flex-direction: row;
    gap: 25px;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    max-width: 700px; /* ↓ Reducido para ajustar proporciones */
    flex-wrap: wrap;
}

/* 5. Contenedor del Tablero */
.tangram-board {
    width: 300px; /* ↓ Reducido de 350px */
    height: 300px; /* ↓ Reducido de 350px */
    border: 3px dashed #9bc53d;
    position: relative;
    background-color: #f7f7f7;
    overflow: hidden;
    border-radius: 6px;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

/* 6. Sección de Referencia (Silueta + Controles) */
.reference-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background-color: #ffffff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
    flex-grow: 1;
    min-width: 220px; /* ↓ Reducido */
    max-width: 260px; /* ↓ Reducido */
}

.current-level-info {
    text-align: center;
}

.current-level-info h3 {
    margin-top: 0;
    color: #2e8b57;
    font-size: 1.2em; /* ↓ Reducido */
    margin-bottom: 10px;
}

#reference-shape {
    width: 100px; /* ↓ Reducido de 120px */
    height: 100px; /* ↓ Reducido de 120px */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.8;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #eee;
}

/* Estilos para los botones de control */
.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    margin-top: 10px;
}

.controls button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8em;
    transition: background-color 0.2s ease, transform 0.1s ease;
    flex-grow: 1;
    max-width: 110px;
}

.controls button:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}

.controls button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
}

/* 7. Contenedor del Cuadrado Inicial ✅ REDUCIDO */
.tangram-initial-square {
    position: relative;
    margin-top: 10px;
    margin-bottom: 15px;
    align-self: center;

    /* 👇 AQUÍ ES DONDE SE REDUJO EL TAMAÑO 👇 */
    width: 220px;  /* Antes: 300px */
    height: 220px; /* Antes: 300px */

    border: 2px solid #8bc34a;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2), 
                0 4px 4px rgba(0, 0, 0, 0.1);
    z-index: 50;
    position: relative;
}

/* 8. Estilos para las Piezas del Tangram */
.piece {
    position: absolute;
    cursor: grab;
    touch-action: none;
    transition: transform 0.15s ease-out, border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
    /* Las piezas se ajustan solas al tamaño del contenedor */
}

.piece img {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.25));
}

.piece.selected {
    filter: drop-shadow(0 0 8px #e74c3c) brightness(1.05);
    z-index: 100 !important;
}

/* 9. Estilos de los Niveles */
.level-selection {
    background-color: #e6f7ff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
    text-align: center;
    width: 100%;
    max-width: 220px; /* ↓ Reducido */
    flex-shrink: 0;
}

.level-selection button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: block;
    width: 100%;
    margin-bottom: 6px;
    max-width: 120px;
    margin-left: auto;
    margin-right: auto;
}

.level-selection h3 {
    color: #0056b3;
    font-size: 1.1em; /* ↓ Reducido */
    margin-top: 0;
    margin-bottom: 12px;
}

.level-selection .level-button:hover {
    background-color: #45a049;
}

.level-selection .level-button.active {
    background-color: #28a745;
    border: 1px solid #1e7e34;
    transform: scale(1.03);
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.4);
}

/* 10. Estilos de la sección de Beneficios Educativos */
.educational-benefits {
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    padding: 15px;
    background-color: #f8f8f8;
    border-top: 1px solid #eee;
    margin-top: 25px;
    width: 100%;
    max-width: 1100px;
    border-radius: 10px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.06);
}

.benefit-item {
    text-align: center;
    margin: 8px;
    max-width: 120px;
    flex-basis: 120px;
}

.benefit-item img {
    width: 50px;
    height: auto;
    margin-bottom: 8px;
    filter: drop-shadow(1px 1px 1.5px rgba(0,0,0,0.15));
}

.benefit-item p {
    font-size: 0.85em;
    color: #555;
    font-weight: 500;
}

/* Historia y Evolución */
.history-section {
    width: 95%;
    max-width: 1100px;
    margin: 40px auto 20px;
    padding: 25px;
    background-color: rgba(255, 255, 255, 0.92);
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.history-section h2 {
    text-align: center;
    color: #2e8b57;
    font-size: 1.8em;
    margin-top: 0;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.history-section .intro-text {
    text-align: center;
    font-size: 1em;
    color: #555;
    max-width: 800px;
    margin: 0 auto 35px;
}

.timeline-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.timeline-item {
    display: flex;
    align-items: center;
    gap: 25px;
    flex-wrap: wrap;
}

.timeline-item.reverse {
    flex-direction: row-reverse;
}

.timeline-image {
    flex: 1 1 300px;
    text-align: center;
}

.timeline-image img {
    width: 100%;
    max-width: 380px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    border: 3px solid #ffffff;
    transition: transform 0.3s ease;
}

.timeline-image img:hover {
    transform: scale(1.02);
}

.timeline-text {
    flex: 1 1 300px;
    padding: 15px;
}

.timeline-text h3 {
    color: #0056b3;
    font-size: 1.3em;
    margin-top: 0;
    border-bottom: 2px solid #8bc34a;
    padding-bottom: 5px;
}

.timeline-text p {
    color: #444;
    font-size: 0.95em;
    line-height: 1.7;
}

/* Panel de Información */
#info-panel {
    width: 95%;
    max-width: 350px; /* ↓ Reducido */
    margin: 15px auto;
    padding: 15px;
    background-color: #ffffff;
    border: 2px solid #9bc53d;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    text-align: center;
}

#info-panel h3 {
    color: #2e8b57;
    margin-top: 0;
    font-size: 1.1em; /* ↓ Reducido */
}

#info-panel ul {
    text-align: left;
    margin: 10px 0 0 20px;
    padding: 0;
}

#info-panel li {
    margin-bottom: 4px;
    font-size: 0.9em;
}

/* Footer */
footer {
    background-color: #2e8b57;
    color: white;
    text-align: center;
    padding: 10px 15px;
    width: 100%;
    margin-top: 25px;
    box-shadow: 0 -3px 6px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

footer p {
    margin: 3px 0;
    font-size: 0.85em;
}

/* Media Queries para Responsividad */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    header h1 {
        font-size: 1.8em;
    }

    header h2 {
        font-size: 1em;
    }

    .header-content {
        flex-direction: column;
        gap: 10px;
    }

    .school-logo {
        height: 60px;
    }

    main {
        padding: 15px;
        gap: 20px;
    }

    .game-area {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .tangram-board {
        width: 260px; /* ↓ Más chico en celular */
        height: 260px;
    }

    .reference-section {
        max-width: unset;
        width: 100%;
        padding: 15px;
    }

    #reference-shape {
        width: 90px;
        height: 90px;
    }

    /* 👇 TAMAÑO DEL CUADRO EN CELULARES 👇 */
    .tangram-initial-square {
        width: 180px;  /* Antes: 220px */
        height: 180px; /* Antes: 220px */
        margin-top: 10px;
    }

    .level-selection {
        padding: 12px;
        max-width: 200px;
    }

    .level-selection h3 {
        font-size: 1.1em;
        margin-bottom: 10px;
    }

    .controls button {
        font-size: 0.8em;
        padding: 5px 8px;
    }

    .level-selection button {
        font-size: 0.8em;
        padding: 5px 8px;
    }

    .history-section {
        padding: 15px;
        margin-top: 20px;
    }

    .history-section h2 {
        font-size: 1.5em;
    }

    .timeline-item,
    .timeline-item.reverse {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .timeline-text {
        padding: 0;
    }
    
    #info-panel {
        max-width: 260px;
    }
}

#undo-move:disabled{
    opacity:.5;
    cursor:not-allowed;
}
