/* ============================================================ */
/*   STILE QUESTIONARIO 4 DSA — MODELLO BASE + AIUTI           */
/*   Derivato da stile-questionario-dsa.css                    */
/*   Aggiunte: btn-aiuto, hint box, feedback finale            */
/* ============================================================ */

body {
    font-family: Arial, Verdana, sans-serif;
    background: #f5f7fa;
    margin: 0;
    padding: 20px;
    letter-spacing: 0.04em;
    line-height: 1.9;
}

.container {
    width: 95%;
    max-width: 1100px;
    margin: auto;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* --- HEADER --- */
.header-box {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    min-height: 80px;
    border: 2px dashed #28a745;
    border-radius: 8px;
    background-color: white !important;
    margin-bottom: 25px;
    box-sizing: border-box;
}

.header-box img {
    height: auto;
    max-height: 50px;
}

.header-box:hover {
    background-color: #f0fdf4 !important;
    cursor: pointer;
}

/* --- TITOLO --- */
.header-title h1 {
    color: #2e7d32;
    font-size: 1.8em;
    margin-bottom: 8px;
}

.header-title .subtitle {
    color: #555;
    font-style: italic;
    font-size: 1.05em;
}

/* --- SEPARATORE --- */
.separator {
    border: 0;
    height: 2px;
    background: linear-gradient(to right, transparent, #28a745, transparent);
    margin: 20px 0;
}

/* --- QUESITI --- */
.question {
    background: #f0f4f8;
    padding: 20px;
    margin: 20px 0 0 0;
    border-left: 5px solid #2e7d32;
    border-radius: 8px;
}

.question h2 {
    color: #1b5e20;
    font-size: 1.3em;
    margin-top: 0;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

/* --- TESTO DEL PROBLEMA --- */
.problem-text {
    background: white;
    padding: 15px 20px;
    margin: 10px 0 0 0;
    border-left: 4px solid #2196f3;
    border-radius: 4px;
    font-size: 1.05em;
    line-height: 1.9;
}

/* --- BOTTONE SEZIONE (apri/chiudi soluzione) --- */
.section-button {
    width: 100%;
    padding: 15px;
    font-size: 1.15em;
    background: #e0f2f1;
    border: 2px solid #80cbc4;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-weight: bold;
    color: #004d40;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,77,64,0.1);
    margin-top: 10px;
    font-family: Arial, Verdana, sans-serif;
    letter-spacing: 0.04em;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    -webkit-appearance: none;
    appearance: none;
}

.section-button:hover {
    background: #b2dfdb;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,77,64,0.2);
}

.section-button.active-open {
    background-color: #2196f3;
    color: white;
    border-color: #1976d2;
    box-shadow: 0 4px 10px rgba(33,150,243,0.3);
}

.section-button.active-open .arrow {
    color: white;
}

.section-button.active-open:hover {
    background-color: #1976d2;
}

.arrow {
    transition: transform 0.3s ease, color 0.3s ease;
    font-size: 0.85em;
    color: #00796b;
    user-select: none;
    -webkit-user-select: none;
}

/* --- TABELLE NELLE SOLUZIONI --- */
.section-content table th,
.section-content table td {
    border: 1px solid #66bb6a;
    padding: 6px 12px;
    text-align: center;
}

.section-content table thead {
    background-color: #c8e6c9;
    font-weight: bold;
}

/* --- CONTENUTO SOLUZIONE --- */
.section-content {
    display: block;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding: 0 20px;
    border: 2px solid #e8f5e9;
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: #fafafa;
    transition: max-height 0.6s ease-in-out, opacity 0.5s ease, padding 0.5s ease;
    box-sizing: border-box;
}

.section-content.is-visible {
    max-height: none;
    opacity: 1;
    padding-top: 20px;
    padding-bottom: 20px;
}

/* --- STEP DELLA SOLUZIONE --- */
.step {
    background: #f1f8e9;
    padding: 15px 20px;
    margin: 15px 0;
    border-radius: 8px;
    line-height: 1.9;
}

.step h3 {
    color: #2e7d32;
    margin-top: 0;
    font-size: 1.1em;
    border-bottom: 1px solid #c8e6c9;
    padding-bottom: 6px;
    margin-bottom: 12px;
}

/* --- FORMULA BOX --- */
.formula-box {
    background: white;
    padding: 15px 20px;
    margin: 12px auto;
    border-left: 4px solid #4caf50;
    border-radius: 4px;
    overflow-x: visible;
    overflow-y: visible;
    width: 100%;
    max-width: 500px;
    box-sizing: border-box;
}

.formula-box img {
    display: block;
    margin: 20px auto;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.formula-box.no-border {
    border-left: none;
}

/* --- RESULT BOX --- */
.result-box {
    background: #e8f5e9;
    padding: 15px;
    border: 2px solid #2e7d32;
    border-radius: 8px;
    margin-top: 12px;
    line-height: 1.9;
}

/* --- GRAFICI --- */
.graph-container {
    background-color: white;
    border: 1px solid #c8e6c9;
    border-radius: 12px;
    padding: 20px;
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.graph-container img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.graph-container p {
    margin: 10px 0 0 0;
    font-size: 0.95em;
    color: #2c3e50;
    font-style: italic;
}

/* (compatibilità con .graph del questionario4) */
.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: 400px;
    height: auto;
    border-radius: 5px;
    display: block;
    margin: 0 auto;
}

/* --- BOTTONE AUDIO --- */
.btn-ascolta-domanda {
    background-color: #ff9800;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9em;
    font-family: Arial, Verdana, sans-serif;
    transition: all 0.3s ease;
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-ascolta-domanda:hover {
    background-color: #e65100;
    transform: translateY(-1px);
}

.btn-ascolta-domanda.speaking {
    background-color: #e53935;
}

/* --- RIGA AIUTO + SEZIONE (controls) --- */
.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 12px 0 0 0;
    align-items: stretch;
}

.controls .section-button {
    flex: 1;
    margin-top: 0;
}

/* --- BOTTONE AIUTO --- */
button.btn-aiuto {
    background-color: #fff9db !important;
    color: #856404 !important;
    border: 2px solid #ffca28 !important;
    border-radius: 8px !important;
    padding: 10px 18px !important;
    font-size: 1em !important;
    font-weight: bold !important;
    font-family: Arial, Verdana, sans-serif !important;
    cursor: pointer !important;
    white-space: nowrap;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08) !important;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

button.btn-aiuto:hover {
    background-color: #ffca28 !important;
    border-color: #ffa000 !important;
    color: #4e342e !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15) !important;
}

button.btn-aiuto.is-active {
    background-color: #e3f2fd !important;
    color: #0d47a1 !important;
    border-color: #2196f3 !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1) !important;
}

/* --- BOX AIUTO (HINT) --- */
.hint {
    background-color: #e3f2fd;
    border-left: 5px solid #2196f3;
    margin: 10px 0;
    padding: 15px;
    border-radius: 8px;
    color: #0d47a1;
    font-size: 0.95em;
    line-height: 1.7;
    display: none;
}

.hint strong {
    color: #1565c0;
    display: block;
    margin-bottom: 5px;
}

/* --- BOX ISTRUZIONE --- */
.instruction-box {
    background: #fff3cd;
    padding: 15px;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    margin: 10px 0 25px 0;
    font-size: 1em;
    line-height: 1.7;
    text-align: center;
    font-weight: 500;
    font-size: 0.95em;
    box-sizing: border-box;
}

/* --- BOTTONI NAVIGAZIONE --- */
.nav-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn-nav {
    padding: 12px 20px;
    background: white;
    color: #2e7d32;
    border: 2px solid #2e7d32;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    font-family: Arial, Verdana, sans-serif;
    cursor: pointer;
    transition: 0.3s;
    font-size: 0.95em;
    letter-spacing: 0.03em;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-nav:hover {
    background: #2e7d32;
    color: white;
}

.close-icon {
    color: #d32f2f;
    font-weight: bold;
    margin-right: 8px;
    font-size: 1.1em;
}

.btn-nav.close-solution {
    background-color: #2196f3;
    color: white;
    border-color: #1976d2;
}

.btn-nav.close-solution:hover {
    background-color: #1976d2;
}

/* --- FEEDBACK FINALE --- */
#feedback-box {
    margin: 30px 0 10px 0;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 8px;
    text-align: center;
    font-size: 0.95em;
    border: 1px solid #dee2e6;
}

/* --- ACCESSIBILITÀ --- */
button:focus-visible,
a:focus-visible {
    outline: 3px solid #ff9800;
    outline-offset: 2px;
}

/* --- CONTATORE FISSO --- */
#progress-box {
    position: fixed;
    top: 15px;
    right: 15px;
    background: #e3f2fd;
    border-left: 6px solid #0277bd;
    padding: 10px 16px;
    font-weight: 600;
    font-size: 1.05em;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    white-space: nowrap;
    font-family: Arial, Verdana, sans-serif;
}

#progress-count {
    font-size: 1.25em;
    font-weight: 700;
    color: #0277bd;
}

#hint-count {
    font-weight: 700;
    color: #e65100;
}

.progress-container {
    width: 100%;
    height: 14px;
    background: #e0e0e0;
    border-radius: 8px;
    margin: 10px 0 0 0;
    overflow: hidden;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background: #28a745;
    transition: width 0.4s ease, background 0.6s ease;
}

.gold-complete {
    background: linear-gradient(270deg, #ffd700, #ffec8b, #ffd700, #ffec8b) !important;
    background-size: 400% 400%;
    animation: goldShine 2s ease infinite;
}

@keyframes goldShine {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* --- BOTTONI FOOTER --- */
.btn-footer-bordeaux,
.btn-footer-arancio,
.btn-footer-viola,
.btn-footer-blu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 260px;
    height: 45px;
    background: white;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.95em;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    box-sizing: border-box;
    font-family: Arial, Verdana, sans-serif;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.btn-footer-bordeaux { color: #7b1f2e; border: 2px solid #7b1f2e; }
.btn-footer-arancio  { color: #ff9800; border: 2px solid #ff9800; }
.btn-footer-viola    { color: #9c27b0; border: 2px solid #9c27b0; }
.btn-footer-blu      { color: #0277bd; border: 2px solid #0277bd; font-size: 0.85em; }

.btn-footer-bordeaux:hover { background: #7b1f2e; color: white; transform: translateY(-2px); }
.btn-footer-arancio:hover  { background: #ff9800; color: white; transform: translateY(-2px); }
.btn-footer-viola:hover    { background: #9c27b0; color: white; transform: translateY(-2px); }
.btn-footer-blu:hover      { background: #0277bd; color: white; transform: translateY(-2px); }

/* Impedisce alle formule di spezzarsi su più righe */
.no-wrap {
    white-space: nowrap;
}

/* --- STAMPA --- */
@media print {
    body { background: white; padding: 0; }

    .container {
        width: 100%;
        max-width: 100%;
        box-shadow: none;
        border: none;
    }

    .section-content {
        display: block !important;
        max-height: none !important;
        opacity: 1 !important;
        overflow: visible !important;
        border: 1px solid #eee !important;
        padding: 20px !important;
        margin-bottom: 20px;
    }

    /* Gli hint NON vengono mostrati in stampa */
    .hint { display: none !important; }

    .section-button, .arrow, .nav-buttons,
    .btn-ascolta-domanda, .instruction-box,
    .btn-aiuto, #progress-box, #feedback-box { display: none !important; }

    .section { page-break-inside: avoid; margin-bottom: 30px; }
    .step, .formula-box { page-break-inside: avoid; }
}

/* --- RESPONSIVE TABLET --- */
@media (max-width: 768px) {
    body {
        padding: 10px;
        font-size: 17px;
        line-height: 1.8;
    }

    .container { padding: 15px; }

    .question h2 {
        font-size: 1.15em;
        flex-direction: column;
        align-items: flex-start;
    }

    .section-button {
        font-size: 1.05em;
        padding: 14px;
    }

    .controls {
        flex-direction: column;
    }

    .btn-aiuto {
        width: 100% !important;
        text-align: center;
        box-sizing: border-box !important;
    }

    .nav-buttons {
        flex-direction: column;
        align-items: center;
    }

    .btn-nav {
        width: 100%;
        text-align: center;
    }

    .graph-container {
        max-width: 100%;
        padding: 10px;
    }

    #progress-box {
        font-size: 11px;
        padding: 3px 6px;
        top: 4px;
        right: 4px;
        max-width: 150px;
        white-space: normal;
        border-left-width: 4px;
    }

    #progress-count { font-size: 13px; }
    .progress-container { height: 8px; margin: 4px 0 0 0; }
}

/* --- RESPONSIVE SMARTPHONE --- */
@media (max-width: 600px) {
    .header-box {
        flex-direction: column;
        gap: 15px;
    }

    .formula-box {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .btn-footer-bordeaux,
    .btn-footer-arancio,
    .btn-footer-viola,
    .btn-footer-blu {
        width: 100%;
        max-width: 300px;
    }
}
.section-content {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.5s ease, opacity 0.4s ease;
}

.section-content.is-visible {
    opacity: 1;
}