/* Corso di fisica — foglio di stile unico. Nessun font esterno. */
:root {
  --bg: #fbfcfe; --fg: #18202b; --muted: #5b6676; --line: #dfe5ee; --card: #ffffff;
  --acc: #1f5fd6; --acc-soft: #e8f0ff; --acc2: #e0682b; --acc2-soft: #fff1e8;
  --ok: #17803d; --ok-soft: #e7f6ec; --ko: #c2352b; --ko-soft: #fdecea;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b; --fg: #e6ebf2; --muted: #9aa6b6; --line: #273141; --card: #161d27;
    --acc: #7aa7ff; --acc-soft: #1a2944; --acc2: #ff9a5e; --acc2-soft: #33231a;
    --ok: #4cc77a; --ok-soft: #14301f; --ko: #ff7a70; --ko-soft: #3a1a18;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--acc); }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { line-height: 1.25; }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin: .4em 0 .3em; }
h2 { font-size: 1.45rem; margin: 1.6em 0 .5em; }
h3 { font-size: 1.15rem; }
code { background: var(--acc-soft); padding: 0 .3em; border-radius: 4px; font-size: .92em; }
var { font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 1.07em; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 10px; top: 10px; background: var(--card); padding: 8px 12px; z-index: 99; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.acc { color: var(--acc); }

/* header */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-size: 1.15rem; }
.brand b { color: var(--acc); }
.logo { width: 30px; height: 30px; color: var(--fg); }
.acc-fill { fill: var(--acc2); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--fg); font-size: .95rem; }
.nav a:hover { background: var(--acc-soft); }
.nav a[aria-current] { background: var(--acc); color: #fff; }

main { padding-bottom: 48px; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 46em; }

/* buttons */
.btn { display: inline-block; border: 1px solid var(--acc); background: var(--acc); color: #fff; padding: 9px 18px; border-radius: 999px; font: inherit; font-size: .97rem; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--acc); }
.btn.small { padding: 4px 12px; font-size: .88rem; }

/* home */
.hero { padding: 36px 0 12px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); max-width: 16em; }
.cta { display: flex; gap: 10px; flex-wrap: wrap; }
.overall { color: var(--muted); }
.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card a { display: grid; grid-template-columns: 48px 1fr; gap: 6px 14px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--fg); box-shadow: var(--shadow); height: 100%; }
.card a:hover { border-color: var(--acc); }
.card .num { grid-row: span 2; width: 44px; height: 44px; border-radius: 50%; background: var(--acc-soft); color: var(--acc); display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; }
.card-t b { display: block; }
.card-t small { color: var(--muted); font-size: .9rem; line-height: 1.4; display: block; }
.card-s { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--muted); }
.bar { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); width: 0; }
.bar i.w1 { width: 10%; } .bar i.w2 { width: 20%; } .bar i.w3 { width: 30%; } .bar i.w4 { width: 40%; } .bar i.w5 { width: 50%; }
.bar i.w6 { width: 60%; } .bar i.w7 { width: 70%; } .bar i.w8 { width: 80%; } .bar i.w9 { width: 90%; } .bar i.w10 { width: 100%; }
.score.done { color: var(--ok); font-weight: 700; }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 36px; }
.how div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 18px; }

/* lezione */
.crumb { color: var(--muted); font-size: .9rem; margin: 18px 0 0; }
.kicker { color: var(--acc2); font-weight: 600; margin: 0; text-transform: uppercase; letter-spacing: .04em; font-size: .85rem; }
.lesson-head { border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.score-line { color: var(--muted); }
.lesson-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; }
.toc { position: sticky; top: 76px; align-self: start; font-size: .92rem; max-height: calc(100vh - 90px); overflow: auto; padding-top: 18px; }
.toc h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; }
.toc ol { padding-left: 1.2em; margin: 0 0 18px; }
.toc a { color: var(--fg); text-decoration: none; }
.toc a:hover { color: var(--acc); }
.obj ul { padding-left: 1.1em; color: var(--muted); }
.lesson-body { max-width: 760px; }
.sec { margin-bottom: 12px; }
.formula { text-align: center; font-size: 1.3rem; margin: 18px auto; padding: 14px 18px; background: var(--acc-soft); border-radius: var(--radius); overflow-x: auto; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 .15em; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 .2em; }
.frac > span { line-height: 1.25; }
.box { border: 1px solid var(--line); border-left: 4px solid var(--acc); background: var(--card); border-radius: 8px; padding: 2px 18px 6px; margin: 18px 0; }
.box h4 { margin: 12px 0 4px; }
.box.esempio { border-left-color: var(--acc); }
.box.esempio h4 { color: var(--acc); }
.box.nota { border-left-color: var(--acc2); background: var(--acc2-soft); }
.box.nota h4 { color: var(--acc2); }
.box.curiosita { border-left-color: var(--ok); }
.box.curiosita h4 { color: var(--ok); }
figure { margin: 20px 0; text-align: center; }
figure svg { width: 100%; max-width: 520px; height: auto; color: var(--fg); }
figure svg .acc, figure svg.acc { stroke: var(--acc); color: var(--acc); }
figure svg text.acc { fill: var(--acc); stroke: none; }
figure svg .acc2 { stroke: var(--acc2); color: var(--acc2); }
figure svg text.acc2 { fill: var(--acc2); stroke: none; }
figure svg [fill="currentColor"].acc { fill: var(--acc); }
figure svg [fill="currentColor"].acc2 { fill: var(--acc2); }
figcaption { color: var(--muted); font-size: .9rem; }
table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: .95rem; display: block; overflow-x: auto; }
th, td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: middle; }
thead th { background: var(--acc-soft); }
.formule { display: table; }
.formule .fx { font-size: 1.08rem; white-space: nowrap; }
.formule .u { color: var(--muted); white-space: nowrap; }
.prevnext { display: flex; justify-content: space-between; gap: 14px; margin-top: 36px; }
.pn { flex: 1; max-width: 48%; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; background: var(--card); }
.pn small { display: block; color: var(--muted); }
.pn.next { text-align: right; }

/* esercizi */
.hint { color: var(--muted); font-size: .93rem; }
.ex { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin: 14px 0; box-shadow: var(--shadow); }
.ex.solved { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.ex-q { display: flex; gap: 12px; }
.ex-q p:first-child { margin-top: 0; }
.ex-n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--acc-soft); color: var(--acc); font-weight: 700; display: grid; place-items: center; font-size: .9rem; }
.ex.solved .ex-n { background: var(--ok); color: #fff; }
.opts { list-style: none; padding: 0 0 0 40px; margin: 8px 0 0; display: grid; gap: 6px; counter-reset: o; }
.opts li { counter-increment: o; }
.opt { width: 100%; text-align: left; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.opts .opt::before { content: counter(o, upper-alpha) ")  "; font-weight: 700; color: var(--muted); }
.opt:hover:not(:disabled) { border-color: var(--acc); }
.opt:disabled { cursor: default; }
.opt.right { background: var(--ok-soft); border-color: var(--ok); }
.opt.wrong { background: var(--ko-soft); border-color: var(--ko); }
.vf { display: flex; gap: 8px; padding-left: 40px; margin-top: 8px; }
.vf .opt { width: auto; min-width: 90px; text-align: center; }
.num { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-left: 40px; margin-top: 8px; }
.num input { font: inherit; width: 160px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); }
.num input:focus { outline: 2px solid var(--acc); border-color: var(--acc); }
.unit { font-weight: 600; min-width: 2em; }
.ex-fb { padding-left: 40px; margin: 8px 0 0; font-weight: 600; min-height: 0; }
.ex-fb:empty { display: none; }
.ex.ok .ex-fb { color: var(--ok); }
.ex.ko .ex-fb { color: var(--ko); }
.ex-sol { margin: 10px 0 0 40px; padding: 4px 14px 6px; border-left: 3px solid var(--acc); background: var(--acc-soft); border-radius: 6px; }
.ex-sol h4 { margin: 8px 0 2px; color: var(--acc); }
.reset-row { margin-top: 18px; }
.from { margin: 22px 0 -8px; font-size: .88rem; color: var(--muted); }

/* allenamento */
.train-form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
.howmany { display: block; margin: 12px 0; }
.howmany select { font: inherit; padding: 4px 8px; border-radius: 6px; }

/* contatti */
.contact-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.contact-cards .box a { font-weight: 600; font-size: 1.05rem; }

.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; padding: 18px 0 30px; }
.foot a { color: var(--muted); }

@media (max-width: 860px) {
  .lesson-grid { grid-template-columns: 1fr; gap: 0; }
  .toc { position: static; max-height: none; border-bottom: 1px solid var(--line); }
  .opts, .vf, .num, .ex-fb { padding-left: 0; }
  .ex-sol { margin-left: 0; }
}
@media (max-width: 420px) {
  body { font-size: 16px; }
  .nav a { padding: 5px 9px; font-size: .9rem; }
  .cards { grid-template-columns: 1fr; }
  .pn { max-width: none; }
  .prevnext { flex-direction: column; }
}
@media print {
  .top, .foot, .toc, .num, .reset-row, .prevnext { display: none; }
  .ex-sol { display: block !important; }
}
