/* ============================================================
   stile-studio-asintoti-interattivo.css
   Pagina "Studio interattivo degli asintoti", v3: base come le altre pagine
   v3, piu' il pannello scuro del laboratorio (grafico, sintesi, dimostrazione).
   ============================================================ */


:root {
    --green: #009966;
    --green-dk: #00754d;
    --green-lt: #e6f5ee;
    --orange: #ff9800;
    --orange-dk: #e68a00;
    --border: #e0e0e0;
    --muted: #777;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    overflow-y: scroll;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 10px;
    background-color: #f8f9fa;
    color: #2c3e50;
}

.page-wrap {
    max-width: 1000px;
    margin: 0 auto;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    padding: 20px;
}

h1, h2, h3 { text-align: center; }

/* ---------- Header v3 (dashed border, logo, breadcrumb) ---------- */
.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;
}

.main-page-title {
    color: var(--green);
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.sottotitolo {
    text-align: center;
    color: var(--muted);
    font-size: 1.05rem;
    font-style: italic;
    margin-top: 0;
    margin-bottom: 20px;
}

.page-intro {
    background-color: #eaf3fb;
    border: 1px solid var(--border);
    padding: 15px 20px;
    margin-bottom: 25px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ---------- Barra di collegamento rapido a pagine correlate ---------- */
.quick-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0 0 30px;
    padding: 10px;
    background-color: #eaf7f1;
    border: 1px solid var(--green);
    border-radius: 8px;
}
.quick-links a {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #2c3e50;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 999px;
    background: #f4f7f5;
    border: 1.5px solid #a8d9c4;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.quick-links a:hover {
    background: #eaf3fb;
    border-color: #3b82c4;
    color: #3b82c4;
}


/* ---------- 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;
}
.footer-nav-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}
.footer-nav-btn {
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.footer-nav-btn.btn-index { background-color: #7b1f2e; }
.footer-nav-btn.btn-index:hover { background-color: #5a1722; }

p.contatore {
    margin-top: 12px;
    font-size: 0.8rem;
    color: #aaa;
    font-style: italic;
}
.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;
}

/* ---- 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, .main-menu, footer {
        display: none !important;
    }
}

@media (max-width: 420px) {
    .header-box img { height: 36px; }
    .header-box .site-url { font-size: 0.75rem; }
}


/* ============================================================ */
/* STUDIO INTERATTIVO DEGLI ASINTOTI                             */
/* ============================================================ */
.sa-section { margin-bottom: 26px; }
.sa-section h2 {
    margin: 10px 0 14px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--green);
    font-size: 1.35rem;
    color: var(--green-dk);
}

/* Parte chiara: coefficienti ed esempi */
.sa-controls { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; }
.sa-card {
    background: #f8f9fa;
    border: 1px solid #e1e4e8;
    border-radius: 10px;
    padding: 16px;
}
.sa-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.sa-card h3 { margin: 0; text-align: left; font-size: 1.02rem; color: #0056b3; }
.sa-link-btn {
    background: transparent; border: none; padding: 4px 2px; cursor: pointer;
    color: #b02a37; font-size: 0.85rem; font-weight: 700; font-family: inherit;
}
.sa-link-btn:hover { text-decoration: underline; }

.sa-fraction {
    display: flex; flex-direction: column; align-items: center;
    background: #fff; border: 1px solid #d0e3ff; border-radius: 8px; padding: 12px;
}
.sa-poly { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; font-family: serif; font-size: 1.08rem; }
.sa-bar { width: 100%; height: 2px; background: #333; margin: 9px 0; }
.sa-coef {
    width: 54px; height: 38px; text-align: center; font-size: 0.98rem; font-weight: 700;
    border: 2px solid #0056b3; border-radius: 6px; background: #fff; color: #2c3e50;
    font-family: inherit;
}
.sa-coef:focus { outline: 3px solid #f59e0b; outline-offset: 1px; border-color: var(--green); background: var(--green-lt); }
.sa-formula { margin-top: 10px; background: #fff; border: 1px solid #d0e3ff; border-radius: 8px; padding: 8px 10px; text-align: center; overflow-x: auto; }
.sa-formula mjx-container[display="true"] { margin: 0.4em 0 !important; }

.sa-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sa-preset {
    background: #fff; color: #2c3e50; border: 1px solid #cbd5e1; border-radius: 6px;
    padding: 8px 10px; text-align: left; cursor: pointer; font-family: inherit;
    font-size: 0.86rem; font-weight: 700; line-height: 1.25;
}
.sa-preset span { display: block; font-size: 0.75rem; font-weight: 400; color: #5b6676; margin-top: 2px; }
.sa-preset:hover { background: #f1f5f9; border-color: #0056b3; }
.sa-preset.is-on { border-color: var(--green); background: var(--green-lt); }
.sa-preset:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* Pannello scuro del laboratorio */
.sa-lab {
    --lab-bg: #0f172a;
    --lab-card: #172033;
    --lab-line: #334155;
    --lab-text: #e2e8f0;
    --lab-muted: #a8b4c7;
    --c-curve: #a5b4fc;
    --c-v: #f87171;
    --c-h: #60a5fa;
    --c-o: #34d399;
    background: var(--lab-bg);
    color: var(--lab-text);
    border-radius: 12px;
    border: 1px solid var(--lab-line);
    padding: 18px;
    margin-bottom: 20px;
}
.sa-lab h2 {
    margin: 0 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--c-o);
    font-size: 1.35rem; color: #fff;
}
.sa-lab h3 { text-align: left; color: #fff; font-size: 1.02rem; margin: 20px 0 10px; }
.sa-lab a { color: #93c5fd; }
.sa-lab :focus-visible { outline: 3px solid #fbbf24; outline-offset: 2px; }

.sa-lab-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sa-lab-head h3 { margin: 0; }
.sa-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.82rem; color: var(--lab-muted); align-items: center; }
.sa-lg { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 24px; height: 0; border-top: 3px solid; }
.sw-curve { border-color: var(--c-curve); }
.sw-v { border-color: var(--c-v); border-top-style: dashed; }
.sw-h { border-color: var(--c-h); border-top-style: dotted; }
.sw-o { border-color: var(--c-o); border-top-style: dashed; border-top-width: 2px; }
.sw-hole { width: 11px; height: 11px; border: 2px solid var(--c-curve); border-radius: 50%; }

.sa-tools { display: flex; gap: 6px; }
.sa-tool {
    width: 38px; height: 38px; border-radius: 6px; border: 1px solid #475569;
    background: #1e293b; color: #fff; font-size: 1.15rem; font-weight: 700; cursor: pointer; font-family: inherit;
}
.sa-tool:hover { background: #334155; }

.sa-canvas-box { border: 1px solid var(--lab-line); border-radius: 8px; overflow: hidden; background: var(--lab-bg); }
.sa-canvas-box canvas { display: block; width: 100%; cursor: grab; touch-action: pan-y; }
.sa-canvas-box canvas.is-drag { cursor: grabbing; }
.sa-coord { margin: 6px 0 0; font-size: 0.82rem; color: var(--lab-muted); text-align: center; min-height: 1.3em; }

/* Sintesi */
.sa-synth { display: flex; flex-direction: column; gap: 8px; }
.sa-pill {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 14px;
    padding: 10px 14px; border-radius: 6px; font-size: 0.95rem;
    background: var(--lab-card); border-left: 5px solid var(--lab-line); color: var(--lab-text);
}
.sa-pill b { font-size: 1.02rem; color: #fff; }
.sa-pill-v { border-left-color: var(--c-v); }
.sa-pill-h { border-left-color: var(--c-h); }
.sa-pill-o { border-left-color: var(--c-o); }
.sa-pill-hole { border-left-color: var(--c-curve); border-left-style: dotted; }
.sa-pill-none { border-left-color: #64748b; color: var(--lab-muted); }
.sa-pill-err { border-left-color: #fbbf24; color: #fde68a; }

/* Dimostrazione */
.sa-steps { display: flex; flex-direction: column; gap: 12px; }
.sa-step { background: var(--lab-card); border: 1px solid var(--lab-line); border-radius: 8px; padding: 12px 16px; font-size: 0.96rem; line-height: 1.6; }
.sa-step h4 { margin: 0 0 6px; font-size: 1rem; color: #fff; text-align: left; }
.sa-step p { margin: 6px 0; }
.sa-step .sa-res { margin: 8px 0 2px; padding: 6px 12px; border-left: 4px solid var(--c-o); background: rgba(52, 211, 153, 0.10); font-weight: 600; }
.sa-step .sa-res-v { border-left-color: var(--c-v); background: rgba(248, 113, 113, 0.10); }
.sa-step .sa-res-h { border-left-color: var(--c-h); background: rgba(96, 165, 250, 0.10); }
.sa-step .sa-res-hole { border-left-color: var(--c-curve); background: rgba(165, 180, 252, 0.10); }
.sa-step mjx-container { color: var(--lab-text); }
.sa-step mjx-container[display="true"] { margin: 0.5em 0 !important; overflow-x: auto; overflow-y: hidden; }

@media (max-width: 800px) {
    .sa-controls { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .sa-lab { padding: 12px; }
    .sa-coef { width: 42px; height: 36px; padding: 0 2px; font-size: 0.9rem; }
    .sa-poly { gap: 2px; font-size: 0.95rem; }
    .sa-fraction { padding: 10px 6px; }
    .sa-presets { grid-template-columns: 1fr; }
}
@media print {
    .sa-lab { background: #fff; color: #000; border-color: #999; }
    .sa-step, .sa-pill { background: #fff; color: #000; }
}
.sa-step .sa-nota { color: var(--lab-muted); font-size: 0.88rem; }
@media (max-width: 380px) { .sa-coef { width: 37px; } .sa-poly { font-size: 0.88rem; } }

/* Prova tu */
.sa-mode { margin-top: 12px; }
.sa-check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.92rem; color: var(--lab-text); cursor: pointer; }
.sa-check input { width: 18px; height: 18px; accent-color: #34d399; }
.sa-try { margin-top: 6px; }
.sa-try-intro { color: var(--lab-muted); font-size: 0.92rem; line-height: 1.55; margin: 0 0 12px; }
.sa-try-intro code, .sa-lab code { background: #1e293b; color: #fde68a; padding: 1px 6px; border-radius: 4px; }
.sa-q { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; margin-bottom: 8px; background: var(--lab-card); border: 1px solid var(--lab-line); border-radius: 8px; }
.sa-ql { font-weight: 600; min-width: 250px; }
.sa-obl { display: inline-flex; align-items: center; gap: 6px; }
.sa-tin {
    flex: 1 1 160px; min-width: 120px; max-width: 320px; height: 38px; padding: 0 10px;
    background: #0b1222; color: #e2e8f0; border: 2px solid #64748b; border-radius: 6px;
    font-size: 1rem; font-family: inherit;
}
.sa-tin-s { flex: 0 0 76px; min-width: 0; width: 76px; text-align: center; }
.sa-tin::placeholder { color: #8391a7; }
.sa-tin:focus { border-color: #34d399; outline: 3px solid #fbbf24; outline-offset: 1px; }
.sa-tin:disabled { opacity: 0.45; }
.sa-none { font-size: 0.9rem; }
.sa-fbrow { flex-basis: 100%; margin: 0; font-size: 0.92rem; line-height: 1.5; }
.sa-fbrow:empty { display: none; }
.sa-ok { color: #34d399; font-weight: 700; }
.sa-ko { color: #fbbf24; font-weight: 700; }
.sa-hint { color: var(--lab-muted); font-weight: 400; }
.sa-try-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 6px; }
.sa-btn { border: none; border-radius: 8px; padding: 11px 22px; font-size: 0.98rem; font-weight: 700; color: #fff; cursor: pointer; font-family: inherit; }
.sa-btn-go { background: #047857; }
.sa-btn-go:hover { background: #065f46; }
.sa-btn-rev { background: #334155; border: 1px solid #64748b; }
.sa-btn-rev:hover { background: #475569; }
.sa-btn-hide { background: #0f172a; color: #fdba74; border: 2px solid #fb923c; }
.sa-btn-hide:hover { background: #fb923c; color: #0f172a; }
.sa-btn-new { background: #1e293b; color: #e2e8f0; border: 2px solid #94a3b8; }
.sa-btn-new:hover { background: #e2e8f0; color: #0f172a; }
.sa-hide-wrap { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }
.sa-hide-wrap[hidden], .sa-btn[hidden] { display: none; }
.sa-fball { margin: 6px 0 0; font-size: 1rem; min-height: 1.4em; }
#sa-solution[hidden], .sa-try[hidden] { display: none; }
@media (max-width: 600px) { .sa-ql { min-width: 0; flex-basis: 100%; } .sa-tin { max-width: none; } }
.footer-nav-btn.btn-dsa { background-color: #ff9800; }
.footer-nav-btn.btn-dsa:hover { background-color: #e68a00; }
.footer-nav-btn.btn-altra { background-color: #1f4e9c; }
.footer-nav-btn.btn-altra:hover { background-color: #163a75; }