/* === STILE TEST 2 "RICONOSCI IL MODELLO" VARIABILI ALEATORIE DISCRETE
   - VERSIONE DSA (v3) ===
   Base identica a stile-test2-variabili-aleatorie-discrete-standard.css
   (stessa struttura header/breadcrumb/main-menu/footer v3, stesse classi
   .question-body/.hint/.steps/.btn-aiuto/.progress-item), con lo stesso
   layer di override DSA usato in stile-test1-variabili-aleatorie-discrete-dsa.css
   in fondo al file: sfondo crema, Verdana, interlinea/spaziatura aumentate,
   bottoni più grandi, bottone "Ascolta" per la sintesi vocale (legge lo
   scenario e le due domande di ciascun quesito, non le opzioni). */

/* --- VARIABILI --- */
:root {
    --primary-color: #0056b3;
    --secondary-color: #28a745;
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-color: #333;
    --border-radius: 12px;

    /* variabili v3 (allineate a stile-variabili-aleatorie-discrete.css) */
    --green: #009966;
    --green-dk: #00754d;
    --green-lt: #e6f5ee;
    --border: #e0e0e0;
    --muted: #777;
    --radius: 8px;
}

/* --- BASE --- */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.main-test-wrapper {
    background-color: var(--card-bg);
    max-width: 1000px;
    width: 100%;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    box-sizing: border-box;
}

/* --- HEADER v3 (dashed border, logo, breadcrumb, main-menu) --- */
.header-box {
    border: 2px dashed var(--green);
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    row-gap: 8px;
    background-color: #ffffff;
    cursor: pointer;
    margin-bottom: 15px;
    border-radius: 6px;
}
.header-box .brand-left,
.header-box .brand-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.header-box img { height: 50px; width: auto; }
.header-box .site-url { font-size: 0.85rem; color: #555; font-weight: 600; }
.header-box .logo-block { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.header-box .since { font-size: 0.72rem; color: #999; font-style: italic; }

.breadcrumb {
    font-size: 0.9rem;
    margin-bottom: 20px;
    color: #666;
}
.breadcrumb a {
    color: var(--green);
    text-decoration: none;
    font-weight: 600;
}

.main-menu {
    background-color: #f4f7f5;
    border: 1px solid #009900;
    border-radius: 8px;
    margin-bottom: 25px;
    padding: 5px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}
.main-menu a {
    display: inline-block;
    padding: 10px 20px;
    color: #2c3e50;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}
.main-menu a:hover, .main-menu a.current {
    background-color: var(--green);
    color: #ffffff;
}

@media (max-width: 420px) {
    .header-box img { height: 36px; }
    .header-box .site-url { font-size: 0.75rem; }
}

/* --- TITOLO --- */
h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 10px;
}

/* --- TESTO ISTRUZIONI --- */
.instruction-text {
    background: #e7f3ff;
    padding: 15px;
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
    font-size: 0.95rem;
    margin-bottom: 25px;
}

/* --- DOMANDE --- */
.question {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.question h2 {
    color: var(--secondary-color);
    margin-top: 0;
}

/* --- ETICHETTE RISPOSTA --- */
label {
    display: block;
    background: #f8f9fa;
    padding: 12px;
    margin: 8px 0;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.2s;
}

label:hover { background: #e9ecef; }

input[type="radio"] {
    margin-right: 10px;
    transform: scale(1.2);
}

/* --- SPIEGAZIONE & AIUTO (CONTENUTI) --- */
.steps {
    display: none;
    margin-top: 15px;
    padding: 15px;
    background: #fff9db;
    border-left: 4px solid #800020;
    border-radius: 4px;
    font-size: 0.9rem;
}

.hint {
    display: none;
    margin-top: 10px;
    padding: 12px;
    background: #e7f1ff;
    border-left: 4px solid #74c0fc;
    border-radius: 5px;
    font-size: 0.9rem;
}

/* --- CONTROLLI (BOTTONI) --- */
.controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 10px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

/* ============================================================ */
/* SEZIONE BOTTONI (SPIEGAZIONE E AIUTO) */
/* ============================================================ */

/* --- 1. BOTTONE SPIEGAZIONE (Arancione -> Giallino) --- */

.controls button:not(.btn-aiuto), 
.btn-secondary {
    background-color: #fd7e14 !important; 
    color: white !important;
    border: 1px solid #d96b0f !important;
    transition: all 0.2s ease;
}

.controls button:not(.btn-aiuto):hover, 
.btn-secondary:hover {
    background-color: #e67000 !important;
    color: white !important;
    border-color: #c45a00 !important;
}

.controls button:not(.btn-aiuto).is-active,
.btn-secondary.is-active {
    background-color: #fff9db !important;
    color: #856404 !important;
    border: 1px solid #fcc419 !important;
    border-bottom: none !important;
    border-radius: 8px 8px 0 0 !important;
    padding-bottom: 11px !important;
}

.controls button:not(.btn-aiuto).is-active:hover,
.btn-secondary.is-active:hover {
    background-color: #ffe8a1 !important;
    color: #856404 !important;
}


/* --- 2. BOTTONE AIUTO (Blu -> Azzurrino) --- */

.controls .btn-aiuto {
    background-color: #007bff !important;
    color: #ffffff !important;
    border: 1px solid #0056b3 !important;
    transition: all 0.2s ease;
}

.controls .btn-aiuto:hover {
    background-color: #0056b3 !important;
    color: #ffffff !important;
}

.controls .btn-aiuto.is-active {
    background-color: #e7f1ff !important; 
    color: #084298 !important;            
    border: 1px solid #74c0fc !important; 
    border-bottom: none !important;       
    border-radius: 8px 8px 0 0 !important;
    padding-bottom: 11px !important;
}

.controls .btn-aiuto.is-active:hover {
    background-color: #d0ebff !important;
}
/* --- FOOTER & AZIONI FINALI --- */
.footer-container {
    padding: 30px 20px;
    border-top: 3px solid #4CAF50;
    background-color: #f9f9f9;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.flex-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-verify  { background-color: #28a745; color: white; }
.btn-verify:hover  { background-color: #1e7e34; }

.btn-reset   { background-color: #333333; color: white; }
.btn-reset:hover   { background-color: #1a1a1a; }

.btn-print   { background-color: #6f42c1; color: white; }
.btn-print:hover   { background-color: #5a32a3; }
.btn-dsa-version { background-color: #fd7e14 !important; color: white !important; }
.btn-dsa-version:hover { background-color: #e67e00 !important; }

.btn-index { background-color: #800020 !important; color: white !important; }
.btn-index:hover { background-color: #600018 !important; }

/* --- FOOTER v3 --- */
footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    text-align: center;
    font-size: 0.88rem;
    color: #555;
}
.license-box {
    background-color: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    font-size: 0.8rem;
    color: #777;
}
.validation-link {
    margin-top: 15px;
    font-size: 0.8rem;
    color: #999;
}
.validation-link a {
    color: #999;
    text-decoration: none;
}
.validation-link a:hover {
    text-decoration: underline;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    .controls button { width: 100%; }
}

/* --- STAMPA --- */
@media print {
    button, .footer-container, input[type="radio"] { display: none !important; }
    .steps { display: block !important; visibility: visible !important; background: #fffef5 !important; }
}

/* TABELLE */
table, th, td { border: 1px solid black; border-collapse: collapse; }

/* Stile per il testo del quesito */
.question-body {
    background-color: #f0f7ff;
    border: 1px solid #d0e3ff;
    border-left: 3px solid #007bff;
    padding: 15px 20px;
    border-radius: 4px 8px 8px 4px;
    margin: 15px 0 25px 0;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.02);
}

.question-body p {
    margin: 10px 0;
    font-size: 1.1rem;
    font-weight: normal;
    line-height: 1.6;
    color: #2c3e50;
}

.question-body ol, .question-body ul {
    margin: 10px 0 10px 25px;
    font-weight: normal;
    color: #2c3e50;
}
/* --- PROGRESS BAR --- */
.progress-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

.progress-item {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;

    background: #e9ecef;
    color: #333;
    border: 2px solid #ced4da;

    transition: all 0.25s ease;
    cursor: default;
}

.progress-item.answered {
    background: #ffc107;
    border-color: #e0a800;
    color: #333;
}

.progress-item.correct {
    background: #28a745 !important;
    border-color: #1e7e34 !important;
    color: white !important;
}

.progress-item.wrong {
    background: #dc3545 !important;
    border-color: #bd2130 !important;
    color: white !important;
}

.progress-item:hover {
    transform: scale(1.08);
}

.progress-item.correct::after { content: ' ✓'; font-size: 0.7em; }
.progress-item.wrong::after   { content: ' ✗'; font-size: 0.7em; }

/* ---- Bottone torna su ---- */
#btn-top {
    position: fixed;
    bottom: 20px;
    right: 4px;
    background: #9C27B0;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: background 0.2s;
}
#btn-top:hover { background: #7a00cc; }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
}

@media print {
    #btn-top { display: none !important; }
}

/* ============================================================
   ================   LAYER DI OVERRIDE DSA   ===================
   (da qui in poi: solo aggiunte/override rispetto al CSS
   standard qui sopra — leggibilità aumentata, sfondo crema,
   bottoni più grandi, bottone "Ascolta")
   ============================================================ */

:root {
    --bg-dsa: #fdf6e3;
    --text-dsa: #202124;
    --green-dsa: #1a6b35;
}

body {
    font-family: 'Verdana', 'Geneva', sans-serif;
    background-color: var(--bg-dsa);
    color: var(--text-dsa);
    line-height: 1.8;
    letter-spacing: 0.05em;
    padding: 10px;
}

.main-test-wrapper {
    background-color: #ffffff;
    max-width: 1000px;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    margin: 20px auto 0;
    box-sizing: border-box;
}

.header-box {
    border-color: var(--green-dsa);
    border-width: 2.5px;
    padding: 12px 14px;
    border-radius: 10px;
    row-gap: 8px;
}
.header-box .brand-left .site-url,
.header-box .brand-right .since {
    font-size: 0.95rem;
}

.breadcrumb {
    font-size: 1rem;
    margin-bottom: 22px;
}
.breadcrumb a { color: var(--green-dsa); font-weight: 700; }

.main-menu {
    border-color: var(--green-dsa);
    border-width: 1.5px;
    margin-bottom: 28px;
}
.main-menu a {
    padding: 11px 20px;
    font-size: 1rem;
    font-weight: 700;
}
.main-menu a:hover, .main-menu a.current { background-color: var(--green-dsa); }

h1 {
    font-size: 2rem;
    line-height: 1.4;
}

.instruction-text {
    font-size: 1rem;
    font-weight: 500;
}

/* Formule più grandi, come negli altri test DSA del sito */
.mjx-chtml, mjx-container {
    font-size: 1.12em !important;
}

/* Bottoni più grandi e touch-friendly */
.controls button, button.btn-aiuto,
.btn-verify, .btn-reset, .btn-print, .btn-dsa-version, .btn-index {
    padding: 14px 24px;
    font-size: 1rem;
}

.hint {
    font-size: 1.05rem;
    line-height: 1.8;
}

.question-body p {
    font-size: 1.1rem;
    line-height: 1.8;
}

.steps {
    font-size: 1rem;
    line-height: 1.8;
}

label {
    font-size: 1.05rem;
    padding: 14px;
}

/* Bottone "Ascolta" (sintesi vocale) */
.btn-ascolta {
    background-color: #28a745;
    color: white;
    border: 2px solid #1e7e34;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-left: 10px;
    vertical-align: middle;
}
.btn-ascolta:hover {
    background-color: white;
    color: #1e7e34;
    transform: translateY(-2px);
}
.btn-ascolta.playing {
    background-color: #ffc107;
    color: #333;
    border-color: #e0a800;
}

@media print {
    .btn-ascolta { display: none !important; }
}

@media (max-width: 768px) {
    body { font-size: 17px; }
    h1 { font-size: 1.6rem; }
    .controls button, button.btn-aiuto, .btn-ascolta {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
        margin-left: 0;
        margin-top: 8px;
    }
    .controls { flex-direction: column; }
    .question h2 { display: flex; flex-direction: column; align-items: flex-start; }
}
