/* ============================================================ */
/*   STILE QUESTIONARIO STANDARD — MODELLO BASE                 */
/*   Compatibile con: Chrome, Safari, Firefox                   */
/*   Dispositivi: Desktop, iPhone (Chrome + Safari), Android    */
/* ============================================================ */

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa;
    color: #333;
}

.container {
    max-width: 95%;
    width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    border-radius: 8px;
    margin-top: 30px;
    margin-bottom: 30px;
    border-left: none;
}

/* --- TESTATA --- */
.header-box {
    width: 100%;
    border: 2px dashed #28a745;
    box-sizing: border-box;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white !important;
    min-height: 80px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.header-box img {
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    height: auto;
}

.left-image   { max-height: 50px; max-width: 250px; }
.center-image { max-height: 50px; max-width: 50px;  }
.right-image  { max-height: 50px; max-width: 150px; }

@media (max-width: 600px) {
    .header-box { padding: 5px; }
    .header-box img { max-height: 35px; }
}

/* --- TITOLO --- */
.problem-title {
    font-size: 1.8em;
    font-weight: bold;
    color: black;
    margin: 25px 0 15px 0;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

/* --- SEPARATORE --- */
.separator {
    border: 0;
    height: 2px;
    background: linear-gradient(to right, transparent, #28a745, transparent);
    margin: 0 0 20px 0;
}

/* --- TESTO PROBLEMA --- */
.problem-text {
    font-weight: bold;
    margin-left: 8px;
    padding-left: 17px;
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.1em;
    line-height: 1.7;
}

/* --- SOLUZIONE (toggle) ---
     IMPORTANTE: usa display:block + max-height:0 (NON display:none).
     La classe .show passa a max-height:none + overflow:visible,
     così il contenuto non viene mai tagliato (bottone incluso). */
.solution {
    display: block;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition:
        opacity 0.4s ease,
        transform 0.4s ease,
        max-height 0.5s ease;
    background-color: white;
    padding: 0 15px 0 25px;
    margin: 0;
    border-left: 4px solid #28a745;
    border-radius: 0 8px 8px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.solution.show {
    opacity: 1;
    transform: translateY(0);
    max-height: none;       /* nessun taglio — il contenuto è completamente visibile */
    overflow: visible;
    padding: 15px 15px 15px 25px;
    margin: 15px 0;
}

/* --- BOTTONI GENERICI --- */
button {
    background-color: #a5d6a7;
    color: black;
    border: 2px solid #81c784;
    padding: 10px 20px;
    text-align: center;
    display: inline-block;
    font-size: 14px;
    margin: 8px 4px;
    cursor: pointer;
    border-radius: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    font-weight: 600;
    /* Rimozione stile nativo iOS Safari */
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

button:hover {
    background-color: #81c784;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Stato attivo (soluzione aperta) */
button.active-solution {
    background-color: #2196f3;
    color: white;
    border: 2px solid #1976d2;
}

button.active-solution:hover {
    background-color: #1976d2;
}

/* --- CONTAINER BOTTONE SOLUZIONE --- */
.solution-button-container {
    text-align: center;
    margin-top: 0;
    margin-bottom: 15px;
}

/* --- BOTTONE "NASCONDI SOLUZIONE" IN FONDO --- */
.close-solution-container {
    text-align: center;
    margin-top: 25px;
}

.close-solution-btn {
    background-color: #2196f3;
    color: white;
    border: 2px solid #1976d2;
    padding: clamp(5px, 1vw, 8px) clamp(10px, 2vw, 18px);
    font-size: clamp(12px, 2vw, 16px);
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.close-solution-btn:hover {
    background-color: #1976d2;
    transform: translateY(-2px);
}

/* --- INTESTAZIONI SOLUZIONE --- */
h3 {
    color: #28a745;
    border-bottom: none;
    padding-bottom: 0;
    margin-top: 30px;
    font-size: 1.4em;
}

/* --- GRAFICI --- */
.graph {
    text-align: center;
    margin: 25px 0;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
}

.graph img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
}

.solution .graph {
    overflow: visible;
    text-align: center;
}

.solution .graph img {
    max-height: 300px;
    width: auto;
    display: block;
    margin: 10px auto;
}

/* --- IMMAGINI AFFIANCATE --- */
.image-pair {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.image-pair img {
    max-width: 45%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* --- MathJax --- */
.MathJax {
    font-size: 1.1em;
    color: #2c3e50;
}

a { text-decoration: none; }

/* --- QUESITI --- */
.question {
    background-color: #f8f9fa;
    padding: 18px 18px 18px 25px;
    margin: 0 0 25px 0;
    border-radius: 12px;
    border-left: 4px solid #0000FF;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: box-shadow 0.3s ease;
}

.question:hover {
    box-shadow: 0 8px 18px rgba(0,0,0,0.08);
}

.question .problem-text {
    color: #2c3e50;
}

/* --- INSTRUCTION BOX --- */
.instruction-box {
    background-color: #e8f5e9;
    border-left: 5px solid #2e7d32;
    padding: 15px;
    margin: 20px auto;
    border-radius: 4px;
    font-size: 0.9em;
    color: #1b5e20;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* --- FOOTER --- */
.footer {
    text-align: center;
    margin-top: 5px;
    padding-top: 5px;
    padding-bottom: 60px;
}

/* Stile base condiviso dai bottoni footer (applicato via style inline nell'HTML) */
.footer-btn-base {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 16px;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    vertical-align: middle;
    margin: 5px;
    box-sizing: border-box;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

/* --- STAMPA --- */
@media print {
    .solution {
        display: block !important;
        max-height: none !important;
        opacity: 1 !important;
        overflow: visible !important;
        padding: 15px 15px 15px 25px !important;
        margin: 15px 0 !important;
    }

    .footer, .footer-btn-base, .validator-container,
    button, .solution-button-container {
        display: none !important;
    }
}

/* --- RESPONSIVE TABLET --- */
@media (max-width: 768px) {
    body {
        font-size: 17px;
        line-height: 1.65;
    }

    .container {
        padding: 15px;
        margin-top: 15px;
        margin-bottom: 20px;
        box-shadow: 0 6px 16px rgba(0,0,0,0.08);
    }

    .question {
        padding: 20px;
        margin-bottom: 28px;
        border-radius: 14px;
    }

    h3 {
        font-size: 1.3em;
        margin-top: 10px;
    }

    .problem-text { font-size: 1.05em; }

    button {
        width: 100%;
        padding: 14px 0;
        font-size: 1em;
        border-radius: 12px;
    }

    .solution-button-container { margin-bottom: 20px; }

    .footer {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding-bottom: 70px;
    }

    .footer a,
    .footer button {
        width: 100%;
        margin: 0;
        height: 46px;
        border-radius: 10px;
    }
}
/* Impedisce alle virgole o ai segni di punteggiatura di finire da soli a capo dopo una formula */
.no-wrap {
    white-space: nowrap;
}
