/* === STILE TEST 1 ASINTOTI DI UNA FUNZIONE - VERSIONE CON TIMER (v3) ===
   Base identica a stile-test1-asintoti-funzione.css (stessa
   struttura header/breadcrumb/main-menu/footer v3, stessa palette
   e componenti), con l'aggiunta del box timer fisso e dello stato di
   allarme negli ultimi 2 minuti (fissi, non proporzionali: il test dura
   15 minuti totali). */

/* --- 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) --- */

/* Stato Base: Arancione deciso (per non confondersi con le opzioni grigie) */
.controls button:not(.btn-aiuto), 
.btn-secondary {
    background-color: #fd7e14 !important; 
    color: white !important;
    border: 1px solid #d96b0f !important;
    transition: all 0.2s ease;
}

/* Hover quando è chiuso: Arancione più scuro */
.controls button:not(.btn-aiuto):hover, 
.btn-secondary:hover {
    background-color: #e67000 !important;
    color: white !important;
    border-color: #c45a00 !important;
}

/* Stato Aperto (is-active): Giallino a linguetta (si fonde col box) */
.controls button:not(.btn-aiuto).is-active,
.btn-secondary.is-active {
    background-color: #fff9db !important; /* Giallo box .steps */
    color: #856404 !important;
    border: 1px solid #fcc419 !important;
    border-bottom: none !important;
    border-radius: 8px 8px 0 0 !important;
    padding-bottom: 11px !important;
}

/* Hover quando aperto: Giallo più intenso */
.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) --- */

/* Stato Base: Blu professionale */
.controls .btn-aiuto {
    background-color: #007bff !important; /* Blu vivace */
    color: #ffffff !important;            /* Testo bianco per contrasto */
    border: 1px solid #0056b3 !important;
    transition: all 0.2s ease;
}

/* Hover quando è chiuso: Blu più scuro */
.controls .btn-aiuto:hover {
    background-color: #0056b3 !important;
    color: #ffffff !important;
}

/* Stato Aperto (is-active): Azzurrino a linguetta */
/* Questo rimane identico per fondersi con il box .hint */
.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;
}

/* Hover quando è aperto */
.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-dsa-version,
.btn-standard-version,
.btn-altri-test,
.btn-index {
    display: inline-block;
    line-height: normal;
    box-sizing: border-box;
}

.btn-index { background-color: #800020 !important; color: white !important; }
.btn-index:hover { background-color: #600018 !important; }
.btn-altri-test { background-color: #0056b3 !important; color: white !important; }
.btn-altri-test:hover { background-color: #003d80 !important; }
.btn-home-test { background-color: #17a2b8 !important; color: white !important; }
.btn-home-test:hover { background-color: #117a8b !important; }

/* --- FOOTER v3 (allineato a stile-variabili-aleatorie-discrete.css) --- */
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; }
/* Il nuovo contenitore unico per il testo della domanda */
.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);
}

/* Rimuoviamo i margini eccessivi dei paragrafi interni al box per non creare buchi */
/* Rimuoviamo il grassetto dai paragrafi interni al box della domanda */
.question-body p {
    margin: 10px 0;
    font-size: 1.1rem;
    font-weight: normal; /* Questo toglie il grassetto */
    line-height: 1.6;
    color: #2c3e50;
}

/* Facciamo lo stesso per gli elenchi, se presenti */
.question-body ol, .question-body ul {
    margin: 10px 0 10px 25px;
    font-weight: normal; /* Toglie il grassetto anche dagli elenchi */
    color: #2c3e50;
}
/* --- PROGRESS BAR --- */
.progress-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

/* cerchietto base */
.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;
}

/* 🟡 risposta selezionata (intermedio) */
.progress-item.answered {
    background: #ffc107;
    border-color: #e0a800;
    color: #333;
}

/* ✅ risposta corretta */
.progress-item.correct {
    background: #28a745 !important;
    border-color: #1e7e34 !important;
    color: white !important;
}

/* ❌ risposta sbagliata */
.progress-item.wrong {
    background: #dc3545 !important;
    border-color: #bd2130 !important;
    color: white !important;
}

/* effetto hover leggero */
.progress-item:hover {
    transform: scale(1.08);
}

/* Simboli dentro il cerchietto (come nella DSA) */
.progress-item.correct::after { content: ' ✓'; font-size: 0.7em; }
.progress-item.wrong::after   { content: ' ✗'; font-size: 0.7em; }

/* ---- Bottone torna su (flottante, appare dopo 300px di scroll) ---- */
#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; }
}

/* --- BOX AVVISO (visualizzazione formule su smartphone) --- */
.instruction-box {
    background: #fff3cd;
    padding: 15px;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.btn-timer-version { background-color: #333333 !important; color: white !important; }
.btn-timer-version:hover { background-color: #1a1a1a !important; }
.btn-dsa-version, .btn-standard-version, .btn-timer-version, .btn-home-test, .btn-altri-test, .btn-index {
    line-height: 1.2;
    font-size: 1rem;
    vertical-align: middle;
}

/* ---------- Smartphone: meno padding per guadagnare spazio ---------- */
@media (max-width: 600px) {
    .main-test-wrapper { padding: 12px; }
}

/* ============================================================ */
/* TIMER (versione con timer)                                    */
/* ============================================================ */
#timer-container {
    position: fixed;
    top: 12px;
    right: 15px;
    background-color: #333;
    color: #fff;
    padding: 12px 20px;
    border-radius: 50px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.1rem;
    font-weight: bold;
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    border: 2px solid #555;
    transition: all 0.3s ease;
}

.timer-warning {
    background-color: #d9534f !important;
    border-color: #c9302c !important;
    animation: pulse-timer 1s infinite;
}

@keyframes pulse-timer {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@media print {
    #timer-container { display: none !important; }
}

@media (max-width: 768px) {
    #timer-container {
        position: fixed;
        top: 20px;
        right: 10px;
        margin: 0;
        padding: 6px 12px;
        font-size: 0.85rem;
        z-index: 9999;
    }
    /* la barra di progresso lascia libero lo spazio a destra per il timer */
    #progressWrapper { padding-right: 90px !important; }
}

/* telefoni in orizzontale: timer più piccolo e allineato alla barra di progresso */
@media (max-height: 500px) {
    #timer-container {
        top: 23px;
        right: 10px;
        padding: 4px 10px;
        font-size: 0.75rem;
    }
}/* Versione senza timer: colore distinto dal bottone DSA */
.btn-standard-version { background-color: #009966 !important; color: white !important; }
.btn-standard-version:hover { background-color: #00754d !important; }

/* --- FIGURE (grafici nei quesiti e nelle soluzioni) --- */
.figure-box {
    text-align: center;
    margin: 10px 0 20px;
}
.figure-box img {
    width: 100%;
    max-width: 560px;
    height: auto;
    background: #ffffff;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
}
@media print {
    .figure-box { break-inside: avoid; }
}
