/* ==========================================================================
   STILE STRUTTURALE ESTRATTO E OTTIMIZZATO – MATEFILIA
   ========================================================================== */

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;
}

/* ---- Header ---- */
.header-box {
    width: 100%;
    border: 2px dashed #28a745;
    box-sizing: border-box;
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
    min-height: 60px;
    border-radius: 8px;
    margin-bottom: 25px;
    overflow: hidden;
}

.header-link {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
    text-decoration: none;
    padding: 10px;
    box-sizing: border-box;
}

.header-link img {
    display: block;
    height: auto;
}

.left-image,
.right-image {
    max-height: 60px;
    height: auto;
    margin: 10px;
}

/* ---- Titoli Principali ---- */
.main-page-title {
    font-size: 2.2em;
    font-weight: bold;
    text-align: center;
    margin-bottom: 30px;
}

.main-page-title .blue {
    color: #0000FF;
}

.main-page-title .red {
    color: #FF0000;
}

.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);
}

/* Classe universale per nascondere h1 in modo accessibile e SEO-friendly */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.separator {
    border: 0;
    height: 2px;
    background: linear-gradient(to right, transparent, #28a745, transparent);
    margin: 15px 0 25px 0;
}

/* ---- Testi del Problema e Quesiti ---- */
.problem-text {
    font-weight: bold;
    margin-left: 8px;
    padding-left: 17px;
    margin-bottom: 25px;
    color: #2c3e50;
    font-size: 1.1em;
    line-height: 1.7;
}

/* Titoli dei punti a), b), c)… dentro .problem-text (Spostato dall'HTML) */
.problem-text h2 {
    color: #28a745;
    margin-top: 30px;
    font-size: 1.4em;
    font-weight: bold;
    border-bottom: none;
    padding-bottom: 0;
}

.question {
    background-color: #f8f9fa;
    padding: 15px 15px 15px 25px;
    margin-left: 8px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #6c757d;
    position: relative;
}

.question strong {
    color: #2c3e50;
}

/* ---- Box Avviso Smartphone (Spostato dall'HTML) ---- */
.instruction-box {
    background: #fff3cd;
    padding: 15px;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    margin-top: 10px;
    margin-bottom: 25px;
    font-size: 0.95rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    color: #856404;
    line-height: 1.5;
}

/* ---- Soluzioni ---- */
.solution-container {
    display: none;
}

.solution {
    background-color: #f8f9fa;
    padding: 15px 15px 15px 25px;
    margin: 15px 0 15px 8px;
    border-left: 4px solid #0000FF;
    border-radius: 0 5px 5px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    position: relative;
}

.solution h3 {
    color: #28a745;
    margin-top: 15px;
    margin-bottom: 10px;
    font-size: 1.2em;
    border-bottom: none;
}

h4 {
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.2em;
}

/* Riquadro dei risultati finali delle soluzioni (Spostato dall'HTML) */
.result-box {
    border: 2px solid #28a745;
    background-color: #f4fbf6;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    text-align: center;
}

.result-box p {
    margin: 0;
    font-size: 1.1em;
    color: #1e632d;
}

/* ---- Tabelle nelle Soluzioni (Spostato dall'HTML) ---- */
.my-table {
    border-collapse: collapse;
    border: 1px solid #000;
    padding: 5px;
    margin: 15px auto;
}

.my-table td,
.my-table th {
    border: 1px solid #000;
    padding: 5px 10px;
}

/* ---- Elementi Grafici e Formule ---- */
.graph {
    text-align: center;
    margin: 25px auto;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
    max-width: 600px;
}

.MathJax {
    font-size: 1.1em;
    color: #2c3e50;
}

a {
    text-decoration: none;
}

/* ---- Bottoni Soluzione e Azioni ---- */
.solution-button {
    background-color: #a5d6a7;
    color: black;
    border: 2px solid #81c784;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    margin: 8px 4px;
    cursor: pointer;
    border-radius: 25px;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    font-weight: 600;
}

.solution-button:hover {
    filter: brightness(92%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-nascondi-container {
    display: flex !important;
    justify-content: center !important;
    width: 100% !important;
    padding: 20px 0 !important;
}

.btn-nascondi {
    background-color: #FF9800 !important;
    color: white !important;
    border: none !important;
    padding: 10px 25px !important;
    cursor: pointer !important;
    border-radius: 20px !important;
    font-size: 14px !important;
    font-weight: bold !important;
    display: inline-block !important;
    margin: 10px auto !important;
    transition: all 0.3s ease !important;
}

.btn-nascondi:hover {
    background-color: #E68A00 !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3) !important;
    transform: translateY(-2px) !important;
}

/* ---- Footer e relativi Bottoni ---- */
.footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.footer button {
    background-color: #0000FF;
    color: white;
    border: 2px solid #0000CC;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    margin: 8px 4px;
    cursor: pointer;
    border-radius: 25px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    font-weight: 600;
}

.footer button:nth-child(1) {
    background-color: #1a237e;
    border: 2px solid #0d1a4b;
}

.footer button:nth-child(1):hover {
    background-color: #3949ab;
    border-color: #1a237e;
    box-shadow: 0 4px 12px rgba(26, 35, 126, 0.4);
    transform: translateY(-2px);
}

.footer button:nth-child(2) {
    background-color: #007bff;
    border: 2px solid #0056b3;
}

.footer button:nth-child(2):hover {
    background-color: #339aff;
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
    transform: translateY(-2px);
}

.footer button:nth-child(3) {
    background-color: #FFA500;
    border: 2px solid #CC8400;
}

.footer button:nth-child(3):hover {
    background-color: #ffb733;
    border-color: #FFA500;
    box-shadow: 0 4px 12px rgba(255, 165, 0, 0.4);
    transform: translateY(-2px);
}

.footer button.stampa {
    background-color: #9C27B0 !important;
    border: 2px solid #7B1FA2 !important;
    color: white !important;
    padding: 10px 25px !important;
    cursor: pointer !important;
    border-radius: 20px !important;
    font-weight: bold !important;
    margin-top: 15px !important;
    margin-bottom: 15px !important;
    display: inline-block !important;
    transition: all 0.3s ease !important;
}

.footer button.stampa:hover {
    background-color: #BA68C8 !important;
    border-color: #9C27B0 !important;
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.4) !important;
    transform: translateY(-2px) !important;
}

/* ---- 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; 
}

/* ==========================================================================
   MEDIA QUERIES (RESPONSIVE & STAMPA)
   ========================================================================== */

/* Gestione Formule Matematiche Mobile */
mjx-container, .MathJax_Display {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Stampa */
@media print {
    .btn-nascondi, .solution-button, .footer, .instruction-box, #btn-top {
        display: none !important;
    }
    .solution-container {
        display: block !important;
    }
}

/* Schermi Mobile Piccoli */
@media (max-width: 480px) {
    .left-image,
    .right-image {
        max-height: 38px;
    }
    .header-link {
        justify-content: space-around;
        padding: 6px;
    }
    .footer button {
        display: block;
        width: 90%;
        margin: 6px auto;
    }
    .problem-text {
        font-size: 1em;
    }
}