/* ============================================================
   stile-costruisci-la-funzione.css
   Pagina "Costruisci la funzione" (asintoti di una funzione), v3.
   Header/breadcrumb/menu/footer come nelle altre pagine v3, piu' gli
   stili del widget interattivo.
   ============================================================ */

: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; }
}

/* ============================================================ */
/* WIDGET "COSTRUISCI LA FUNZIONE"                               */
/* ============================================================ */
.af-section { margin-bottom: 28px; }
.af-section h2 {
    color: var(--green);
    font-size: 1.3rem;
    margin: 26px 0 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--green-lt);
}

/* Guida alla scrittura */
.af-guide {
    background: #fff9db;
    border: 1px solid #f0e2a0;
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 25px;
}
.af-guide h2 { border: none; margin: 0 0 8px; padding: 0; font-size: 1.1rem; color: #7a5c00; }
.af-guide table { border-collapse: collapse; width: 100%; font-size: 0.93rem; margin: 8px 0; }
.af-guide th, .af-guide td { border-bottom: 1px solid #efe3ad; padding: 6px 10px; text-align: left; vertical-align: top; }
.af-guide th { color: #7a5c00; font-size: 0.85rem; }
.af-guide code, .af-solution code {
    font-family: "Courier New", Courier, monospace;
    background: #fff;
    border: 1px solid #e3d9a8;
    border-radius: 4px;
    padding: 1px 6px;
    font-weight: 700;
    color: #2c3e50;
    overflow-wrap: anywhere;
}
.af-guide ul { margin: 6px 0 0 18px; padding: 0; font-size: 0.93rem; line-height: 1.55; }

/* Livelli */
.af-levels-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin-bottom: 14px; }
.af-levels-row .af-label { font-weight: 700; color: #2c3e50; }
.af-level-btn {
    width: 42px; height: 42px;
    border-radius: 50%;
    border: 2px solid var(--green);
    background: #fff;
    color: var(--green);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}
.af-level-btn:hover { background: var(--green-lt); }
.af-level-btn.active { background: var(--green); color: #fff; }

/* Richiesta */
.af-task {
    background: #eaf3fb;
    border: 1px solid #c3d9ee;
    border-left: 5px solid #3b82c4;
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 18px;
}
.af-task h3 { text-align: left; margin: 0 0 8px; font-size: 1.1rem; color: #1f4f82; }
.af-task p { margin: 6px 0; font-size: 0.95rem; }
.af-target-list { list-style: none; margin: 8px 0 0; padding: 0; }
.af-target-list li { padding: 5px 0; font-size: 1rem; font-weight: 600; }
.af-mark { display: inline-block; width: 1.4em; text-align: center; }
.af-target-list li.af-ok { color: var(--green-dk); }
.af-target-list li.af-miss { color: #c0392b; }
.af-target-list li.af-idle { color: #2c3e50; }

/* Campo e bottoni */
.af-input-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; margin-bottom: 8px; }
.af-fx { align-self: center; font-style: italic; font-weight: 700; font-size: 1.1rem; color: #2c3e50; }
#af-input {
    flex: 1 1 260px;
    min-width: 0;
    font-family: "Courier New", Courier, monospace;
    font-size: 1.15rem;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
}
#af-input:focus { outline: none; border-color: var(--green); }
.af-btn {
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}
.af-btn-draw { background: var(--green); }
.af-btn-draw:hover { background: var(--green-dk); }
.af-btn-hint { background: #3b82c4; }
.af-btn-hint:hover { background: #2d68a0; }
.af-btn-sol { background: #6f42c1; }
.af-btn-sol:hover { background: #5a32a3; }
.af-btn-new { background: #555; }
.af-btn-new:hover { background: #333; }
.af-btn-next { background: #28a745; margin-top: 12px; }
.af-btn-next:hover { background: #1e7e34; }
.af-keys { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; align-items: center; }
.af-keys .af-label { font-size: 0.85rem; color: var(--muted); margin-right: 2px; }
.af-key, .af-mini {
    font-family: "Courier New", Courier, monospace;
    font-size: 1rem;
    font-weight: 700;
    min-width: 40px;
    padding: 6px 10px;
    border: 1.5px solid #a8d9c4;
    border-radius: 6px;
    background: #f4f7f5;
    color: #2c3e50;
    cursor: pointer;
}
.af-key:hover, .af-mini:hover { background: var(--green-lt); border-color: var(--green); }
.af-mini { font-family: inherit; font-size: 0.85rem; min-width: 0; margin-left: 6px; }
.af-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 14px; }

/* Grafico */
.af-canvas-wrap { margin: 10px 0 14px; }
#af-canvas {
    width: 100%;
    display: block;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    background: #fff;
}
.af-legend { font-size: 0.85rem; color: var(--muted); text-align: center; margin: 6px 0 0; }
.af-legend .k-miss { color: #d62728; font-weight: 700; }
.af-legend .k-ok { color: #2e8b57; font-weight: 700; }
.af-legend .k-extra { color: #e08a00; font-weight: 700; }
.af-legend .k-curve { color: #1f5fbf; font-weight: 700; }

/* Feedback */
#af-feedback { background: #f8f9fa; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; font-size: 0.95rem; line-height: 1.55; }
#af-feedback p { margin: 6px 0; }
.af-muted { color: var(--muted); }
.af-warn { color: #a05a00; font-weight: 600; }
.af-error { color: #c0392b; font-weight: 600; }
.af-success { color: var(--green-dk); font-weight: 700; font-size: 1.05rem; }
#af-hint, #af-solution {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    line-height: 1.55;
}
#af-hint { background: #e6f2ff; border: 1px solid #b7d7f5; }
#af-solution { background: #f3eefb; border: 1px solid #d6c8ef; }
#af-hint[hidden], #af-solution[hidden], #af-next[hidden], #af-btn-sol[hidden] { display: none; }

@media (max-width: 600px) {
    .page-wrap { padding: 12px; }
    .af-guide table { font-size: 0.85rem; }
    .af-btn { flex: 1 1 auto; }
}
.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; }