/* ============================================================
   Successioni e progressioni — stile locale
   (copia identica nelle tre app: successioni,
   progressione-aritmetica, progressione-geometrica)
   Colori e font arrivano da math-base.css: qui solo la forma.
   ============================================================ */

main.container {
    max-width: 900px;
    width: 92%;
    padding-top: 2rem;
    padding-bottom: 3rem;
}

h1 {
    font-size: clamp(1.5rem, 5vw, 2rem);
    margin: 0 0 .35rem;
    color: var(--brand);
}

.sommario {
    margin: 0 0 1.5rem;
    color: var(--ink-2);
    font-size: 1.05rem;
}

.card {
    padding: clamp(1.1rem, 3.5vw, 2rem);
    margin-top: 1.2rem;
}

.card > h2 {
    margin: 0 0 .6rem;
    font-size: 1.25rem;
    color: var(--brand);
}

.card > .sotto {
    margin: -.3rem 0 1rem;
    color: var(--ink-2);
}

/* ---- scelta del modo ---- */
.modi {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 1.4rem;
}

.modo-btn {
    appearance: none;
    border: 1px solid #d7e3e3;
    background: #fff;
    color: var(--ink-2);
    border-radius: 10px;
    padding: 9px 15px;
    font: 600 .95rem var(--font-body);
    cursor: pointer;
    flex: 1 1 auto;
}

.modo-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.modo-btn.attivo {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

/* ---- campi ---- */
.griglia {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.label {
    display: block;
    font-weight: 600;
    margin-bottom: .4rem;
    color: var(--ink-2);
}

.input {
    width: 100%;
    padding: .8rem 1rem;
    border-radius: 12px;
    border: 1px solid #d7e3e3;
    font-family: var(--font-mono);
    font-size: 1.05rem;
    background: #fff;
}

.aiuto {
    margin: .45rem 0 0;
    font-size: .9rem;
    color: var(--ink-2);
}

.esempi {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: .8rem 0 1.2rem;
}

.esempio {
    appearance: none;
    border: 1px dashed #b9cfd1;
    background: #f6fbfb;
    color: var(--brand);
    border-radius: 999px;
    padding: 6px 13px;
    font: 600 .92rem var(--font-mono);
    cursor: pointer;
}

.esempio:hover {
    border-style: solid;
    border-color: var(--brand);
}

.scelta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin: 0 0 1rem;
    padding: 0;
    border: 0;
}

.scelta label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
}

.scelta input {
    accent-color: var(--brand);
    width: 18px;
    height: 18px;
}

.btn-primary {
    width: 100%;
    border-radius: 999px;
    font-size: 1.05rem;
    font-weight: 700;
}

.errore {
    margin: 1rem 0 0;
    padding: .85rem 1rem;
    border-radius: 12px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #991b1b;
    font-weight: 600;
}

.errore:empty {
    display: none;
}

/* ---- risultato ---- */
.formula-letta {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    color: var(--brand);
    background: #f0f7f7;
    border-radius: 12px;
    padding: .7rem 1rem;
    margin: 0 0 1rem;
    overflow-x: auto;
}

.grandi {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: .8rem;
    margin-bottom: .8rem;
}

.grande {
    background: #f0f7f7;
    border: 1px solid #d5e8e9;
    border-radius: 14px;
    padding: .8rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.grande .etic {
    font-size: .85rem;
    font-weight: 700;
    color: var(--ink-2);
}

.grande .mono {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--brand);
    overflow-wrap: anywhere;
}

.dato {
    margin: .3rem 0;
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: .95rem;
    overflow-wrap: anywhere;
}

.dato.serie,
.esito {
    font-family: var(--font-body);
}

.esito {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--brand);
    margin: 0 0 .5rem;
}

.soluzione + .soluzione {
    margin-top: 1.4rem;
    padding-top: 1.2rem;
    border-top: 2px dashed var(--line);
}

.soluzione h3 {
    margin: 0 0 .6rem;
    color: var(--brand);
}

.analisi {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .6rem 1.2rem;
    margin: 1rem 0 0;
}

.analisi div {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: .6rem .9rem;
}

.analisi dt {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
}

.analisi dd {
    margin: .2rem 0 0;
    font-family: var(--font-mono);
    overflow-wrap: anywhere;
}

.nota {
    font-size: .9rem;
    color: var(--ink-2);
    margin: .6rem 0 0;
}

.nota:empty {
    display: none;
}

/* ---- primi termini ---- */
.elenco {
    list-style: none;
    margin: .4rem 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.elenco li {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 4px 10px;
    background: #fff;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.elenco .pos {
    font-size: .8rem;
    color: var(--muted);
}

.elenco li.evidenza {
    border-color: var(--accent);
    background: #fff7e6;
    font-weight: 700;
}

/* ---- tabelle ---- */
.passaggi-wrap,
.tabella-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.steps-table,
.tabella {
    width: 100%;
    border-collapse: collapse;
    font-size: .98rem;
}

.steps-table th,
.tabella th {
    text-align: left;
    border-bottom: 2px solid #cbd5e1;
    padding: 8px;
    color: #64748b;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}

.steps-table td,
.tabella td {
    border-bottom: 1px solid #e2e8f0;
    padding: 10px 8px;
    vertical-align: top;
}

.steps-table th:first-child {
    width: 1%;
}

.steps-table .calcolo,
.tabella .calcolo,
.tabella .valore,
.tabella .approssimato,
.tabella .mono {
    font-family: var(--font-mono);
}

.tabella .approssimato {
    color: var(--ink-2);
}

.steps-table .perche {
    color: var(--ink-2);
    font-size: .92rem;
}

.sale { color: #047857; font-weight: 700; white-space: nowrap; }
.scende { color: #b91c1c; font-weight: 700; white-space: nowrap; }
.uguale { color: var(--ink-2); font-weight: 700; white-space: nowrap; }

details.passaggi {
    margin-top: .8rem;
}

details.passaggi summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--brand);
    padding: .5rem 0;
}

/* ---- animazioni ---- */
.anim {
    margin-top: .4rem;
}

.anim-tela {
    background: #fbfdfd;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
}

.anim canvas {
    display: block;
    width: 100%;
    height: clamp(260px, 46vw, 380px);
}

.anim-gauss .anim canvas,
#anim-gauss canvas {
    height: clamp(300px, 46vw, 360px);
}

.anim-didascalia {
    min-height: 3.2em;
    margin: .8rem 0 .6rem;
    padding: .6rem .9rem;
    border-left: 4px solid var(--accent);
    background: #fffaf0;
    border-radius: 0 10px 10px 0;
    font-family: var(--font-mono);
    font-size: .95rem;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.anim-comandi {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.anim-btn {
    appearance: none;
    border: 1px solid #cfe0e1;
    background: #fff;
    color: var(--brand);
    border-radius: 10px;
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    font: 700 1rem var(--font-body);
    cursor: pointer;
}

.anim-btn:hover {
    border-color: var(--brand);
}

.anim-play {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    min-width: 110px;
}

.anim-vel {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .9rem;
    font-weight: 600;
    color: var(--ink-2);
}

.anim-vel select {
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid #cfe0e1;
    padding: 0 8px;
    font: 600 1rem var(--font-body);
    background: #fff;
    color: var(--ink);
}

.anim-contatore {
    margin-left: auto;
    font-size: .85rem;
    color: var(--muted);
    font-weight: 600;
}

.legenda {
    font-size: .88rem;
    color: var(--ink-2);
    margin: .5rem 0 0;
}

/* ---- Come funziona ---- */
.teoria h2 {
    margin-top: 0;
    font-size: 1.3rem;
    color: var(--brand);
}

.teoria h3 {
    font-size: 1rem;
    margin: 1.5rem 0 .4rem;
    color: var(--ink);
}

.teoria p,
.teoria li,
.teoria dd {
    color: var(--ink-2);
}

.teoria ol,
.teoria ul {
    padding-left: 1.2rem;
}

.teoria dt {
    font-weight: 700;
    color: var(--ink);
    margin-top: .8rem;
}

.teoria dd {
    margin: .15rem 0 0;
}

.formula {
    font-family: var(--font-mono);
    background: #f1f5f9;
    padding: .1rem .4rem;
    border-radius: 6px;
    white-space: nowrap;
}

.corso {
    margin-top: 1.5rem;
    padding: 1rem 1.1rem;
    border-radius: 14px;
    background: #f0f7f7;
    border: 1px solid #d5e8e9;
}

.corso p {
    margin: 0 0 .6rem;
}

.altre {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: .4rem;
}

/* ---- telefono ---- */
@media (pointer: coarse) {
    .modo-btn,
    .esempio,
    .scelta label {
        min-height: 44px;
    }

    .scelta input {
        width: 24px;
        height: 24px;
    }

    details.passaggi summary {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

@media (max-width: 600px) {
    .steps-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .steps-table tr {
        display: block;
        padding: 10px 2px;
        border-bottom: 1px solid #e2e8f0;
    }

    .steps-table td {
        display: block;
        border: 0;
        padding: 1px 4px;
    }

    .steps-table td:first-child {
        font-size: .78rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .5px;
        color: var(--muted);
    }

    .steps-table td:first-child::before {
        content: 'Passo ';
    }

    .steps-table td.calcolo {
        font-size: 1rem;
        margin: 2px 0 4px;
        overflow-wrap: anywhere;
    }

    .anim-contatore {
        width: 100%;
        margin-left: 0;
    }

    .anim-play {
        flex: 1 1 auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
