/* STILE TEST INTEGRALI DEFINITI - VERSIONE DSA 
   Linee guida: Alta leggibilità, contrasto riposante, spaziatura aumentata.
*/

:root {
    --bg-dsa: #fdf6e3;          /* Sfondo crema/paglierino per ridurre l'abbagliamento */
    --text-dsa: #202124;        /* Grigio quasi nero per contrasto morbido */
    --primary-blue: #0056b3;
    --verify-blue: #004494;
    --reset-red: #b22222;
    --index-bordeaux: #800020;
    --step-bg: #fff9e6;         /* Sfondo evidenziato per i passaggi */
}

body {
    /* Verdana è uno dei font più leggibili per DSA tra quelli standard */
    font-family: 'Verdana', 'Geneva', sans-serif;
    background-color: var(--bg-dsa);
    color: var(--text-dsa);
    line-height: 1.8;           /* Interlinea aumentata per evitare sovrapposizioni */
    letter-spacing: 0.05em;     /* Spaziatura tra lettere aumentata */
    margin: 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.main-test-wrapper {
    background-color: #ffffff;
    max-width: 1000px;          /* Più largo come la versione standard */
    width: 100%;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    margin-top: 20px;
    box-sizing: border-box;
}

/* Header compatto */
.header-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.left-image, .right-image {
    max-height: 45px;
    height: auto;
}

/* Titoli e Istruzioni */
h1 {
    font-size: 2rem;
    color: var(--primary-blue);
    text-align: center;         /* Centrato come versione standard */
    margin: 10px 0;
}

.instruction-text {
    background-color: #e7f3ff;  /* Azzurro come versione standard */
    border-left: 6px solid #0056b3;
    padding: 20px;
    font-weight: bold;
    margin-bottom: 30px;
    border-radius: 4px;
}

/* Box argomenti (verde) */
.topics-box {
    background: #d4edda;
    padding: 15px;
    border-left: 4px solid #28a745;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

/* Box istruzioni smartphone (giallo) */
.instruction-box {
    background: #fff3cd;
    padding: 15px;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

/* Domande e Formule */
.question {
    background: #fff;
    border: 2px solid #ced4da;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 40px;        /* Molto spazio tra una domanda e l'altra */
}

/* Ingrandimento formule MathJax per DSA */
.mjx-chtml, .MathJax {
    font-size: 1.25rem !important;
    margin: 15px 0 !important;
}

/* Opzioni di risposta larghe e ben distanziate */
label {
    display: block;
    background: #f8f9fa;
    padding: 15px;
    margin: 12px 0;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    cursor: pointer;
    transition: background 0.2s;
}

label:hover {
    background: #e9ecef;
}

input[type="radio"] {
    transform: scale(1.5);      /* Radio button più grandi per facilitare il clic */
    margin-right: 15px;
}

/* Passaggi e Soluzioni */
.steps {
    display: none;
    margin-top: 20px;
    padding: 20px;
    background-color: var(--step-bg);
    border-radius: 8px;
    border: 1px dashed #d4a017;
    font-size: 1.1rem;
}

/* Container grafici */
.graph-container {
    margin-top: 15px;
    text-align: center;
    background: #fff;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 8px;
}

/* BOTTONI - Grandi e con colori differenziati */
button {
    font-family: 'Verdana', sans-serif;
    padding: 15px 25px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    margin: 10px;
}

/* Mostra Spiegazione (Grigio) */
.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #495057;
}

/* Bottone Grafico (Azzurro) */
.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #138496;
}

/* Ascolta (Verde) - già presente */
.btn-listen {
    background-color: #28a745;
    color: white;
}

.btn-listen:hover {
    background-color: #218838;
}

/* Verifica (Blu) */
.btn-verify {
    background-color: var(--verify-blue);
    color: white;
}

.btn-verify:hover {
    background-color: #003d82;
}

/* Bottone RICOMINCIA (Viola - Azione di reset) */
.btn-reset {
    background-color: #6f42c1;
    color: white;
    transition: all 0.3s ease;
    font-weight: bold;
}

.btn-reset:hover {
    background-color: #59359a;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}

/* Indice (Bordeaux) */
.btn-index {
    background-color: var(--index-bordeaux);
    color: white;
}

.btn-index:hover {
    background-color: #600018;
    transform: translateY(-2px);
}

/* Teoria (Blu chiaro) */
.btn-theory {
    background-color: #007bff;
    color: white;
}

.btn-theory:hover {
    background-color: #0056b3;
}

/* Bottone per tornare alla Versione Standard (Arancione) */
.btn-standard-version {
    background-color: #ff8c00;
    color: white;
    transition: all 0.3s ease;
    font-weight: bold;
}

.btn-standard-version:hover {
    background-color: #e67e00;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}

button:hover {
    transform: translateY(-3px);
    filter: brightness(1.1);
}

/* Footer centrato e ordinato */
.footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    padding: 20px 0;
}

.footer-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

/* Risultati chiari */
#results {
    margin-top: 30px;
    padding: 20px;
    border-radius: 10px;
    display: none;
    width: 100%;
    max-width: 800px;
}

#results h3 {
    color: var(--primary-blue);
    margin-top: 0;
}

/* --- RESPONSIVE SMARTPHONE --- */
@media (max-width: 768px) {
    .main-test-wrapper {
        max-width: 100%;
        padding: 15px;
        margin: 0;
        border-radius: 8px;
    }
    
    body {
        padding: 5px;
    }
    
    h1 {
        font-size: 1.6rem;
    }
    
    .instruction-text {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .question {
        padding: 15px;
    }
    
    .question h2 {
        font-size: 1.3rem;
    }
    
    label {
        padding: 12px;
        font-size: 1rem;
    }
    
    button {
        font-size: 1rem;
        padding: 12px 20px;
    }
    
    .header-box img {
        max-height: 35px;
    }
    
    /* Grafici più piccoli su mobile */
    [id^="plot"] {
        min-height: 200px !important;
    }
    
    .steps {
        padding: 15px;
        font-size: 1rem;
    }
}

/* --- REGOLE PER LA STAMPA --- */
@media print {
    /* 1. Forza la visualizzazione di soluzioni, grafici e SVG */
    .steps, 
    .box, 
    #results, 
    .graph-container, 
    [id^="graph"], 
    [id^="solution"], 
    [id^="plot"],
    svg,
    svg * {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        overflow: visible !important;
    }

    /* 2. FONDAMENTALE: Forza i colori e gli sfondi per i grafici SVG */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    /* 3. Regole specifiche per SVG e path dei grafici */
    svg {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid !important;
    }
    
    svg path,
    svg line,
    svg circle,
    svg rect,
    svg text,
    svg g {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* 4. Assicurati che i container dei grafici siano visibili */
    .graph-container,
    [id^="plot"] {
        display: block !important;
        visibility: visible !important;
        width: 100% !important;
        min-height: 300px !important;
        page-break-inside: avoid !important;
        margin: 20px 0 !important;
        border: 1px solid #ddd !important;
        padding: 10px !important;
    }

    /* 5. Nascondi elementi interattivi e inutili su carta */
    button, 
    .footer-buttons, 
    .header-box, 
    input[type="radio"], 
    .button-group, 
    hr, 
    .btn-theory,
    .btn-listen {
        display: none !important;
    }

    /* 6. Layout pulito per le domande */
    .question {
        page-break-inside: avoid;
        border: none !important;
        border-bottom: 1px solid #ddd !important;
        margin-bottom: 30px !important;
        padding-bottom: 20px !important;
    }

    /* 7. Ottimizzazione immagini */
    img {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
    }
    
    /* 8. Rimuove ombre e sfondi grigi per risparmiare inchiostro */
    body {
        background: white !important;
    }
    
    .main-test-wrapper {
        box-shadow: none !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* 9. Spiegazioni con sfondo leggero stampabile */
    .steps {
        background: #fffef5 !important;
        border-left: 3px solid #999 !important;
        page-break-inside: avoid;
    }
}

@media (min-width: 600px) {
    .footer {
        flex-direction: row;
        justify-content: center;
    }
}