/* =========================================================
   Laboratorio di Informatica – foglio di stile comune
   ========================================================= */

:root {
  --ink: #1b2232;
  --ink-2: #3a4356;
  --muted: #5f6879;
  --bg: #f4f6fa;
  --paper: #ffffff;
  --line: #e1e6ef;
  --line-2: #cfd6e3;

  /* colore del corso (cambia con la classe sul body) */
  --brand: #2b579a;
  --brand-ink: #183c74;
  --brand-soft: #e8eff9;

  --accent: #d9480f;
  --accent-soft: #fff1e7;
  --ok: #2b8a3e;
  --ok-soft: #e9f6ec;
  --bad: #c92a2a;
  --bad-soft: #fdeded;
  --tip: #6741d9;
  --tip-soft: #f0ecfd;

  --radius: 14px;
  --side: 300px;
  --head: 64px;
  --font: "Lexend", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
}

.corso-excel { --brand: #217346; --brand-ink: #134b2c; --brand-soft: #e6f3ec; }
.corso-html  { --brand: #c2410c; --brand-ink: #8a2d07; --brand-soft: #fdeee6; }

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--head) + 16px); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  font-weight: 300;
  color: var(--ink);
  background: var(--bg);
}

strong, b { font-weight: 600; }
img { max-width: 100%; height: auto; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.salta { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 14px; z-index: 100; }
.salta:focus { left: 8px; }

/* ---------- Testata ---------- */
.testata {
  position: sticky; top: 0; z-index: 30;
  height: var(--head);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.marchio { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); line-height: 1.2; }
.marchio strong { display: block; font-weight: 600; font-size: 16px; }
.marchio small { display: block; color: var(--muted); font-size: 13px; }
.logo {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 20px;
}
.corso-chip {
  margin-left: auto;
  font-size: 14px; font-weight: 500;
  color: var(--brand-ink); background: var(--brand-soft);
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}
.apri-menu {
  display: none; align-items: center; gap: 8px;
  font: inherit; font-size: 15px; font-weight: 500;
  background: var(--brand-soft); color: var(--brand-ink);
  border: 0; border-radius: 10px; padding: 8px 12px; cursor: pointer;
}
.hamburger, .hamburger::before, .hamburger::after {
  display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; position: relative;
}
.hamburger::before, .hamburger::after { content: ""; position: absolute; left: 0; }
.hamburger::before { top: -6px; }
.hamburger::after { top: 6px; }

/* ---------- Struttura ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  min-height: calc(100vh - var(--head));
}

/* ---------- Menu laterale ---------- */
.menu {
  position: sticky; top: var(--head);
  height: calc(100vh - var(--head));
  overflow-y: auto;
  padding: 22px 14px 40px;
  background: var(--paper);
  border-right: 1px solid var(--line);
  font-size: 15px;
}
.menu-titolo {
  margin: 0 10px 10px; font-size: 12px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.menu-lista, .menu-sezioni { list-style: none; margin: 0; padding: 0; }
.menu a { text-decoration: none; color: var(--ink-2); }
.menu-pagina a {
  display: block; padding: 8px 12px; border-radius: 10px; font-weight: 400;
}
.menu-pagina a:hover { background: var(--bg); }
.menu-pagina.attiva a { background: var(--brand-soft); color: var(--brand-ink); font-weight: 500; }
.menu-pagina:last-of-type { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }

.menu-lezione { margin: 2px 0; }
.menu-lez-riga { display: flex; align-items: stretch; border-radius: 10px; }
.menu-lez-riga > a, span.menu-lez-riga {
  flex: 1; display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 6px 8px 10px; border-radius: 10px; line-height: 1.35;
}
.menu-lez-riga > a:hover { background: var(--bg); }
.menu .num {
  flex: none; width: 26px; height: 26px; margin-top: -2px;
  display: grid; place-items: center; border-radius: 8px;
  background: var(--bg); color: var(--ink-2);
  font-weight: 600; font-size: 14px;
}
.menu .tit { font-weight: 400; padding-top: 1px; }
.menu-lezione.attiva .num { background: var(--brand); color: #fff; }
.menu-lezione.attiva .tit { color: var(--brand-ink); font-weight: 600; }
.menu-lezione.bloccata { opacity: .55; }
.menu-lezione.bloccata small { display: block; font-size: 12px; color: var(--muted); }
.menu-lezione.bloccata .num::after { content: ""; }

.espandi {
  flex: none; width: 34px; border: 0; background: transparent; cursor: pointer; border-radius: 10px;
  color: var(--muted);
}
.espandi::before {
  content: ""; display: block; width: 8px; height: 8px; margin: auto;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .2s;
}
.espandi:hover { background: var(--bg); color: var(--ink); }
.menu-lezione.aperta .espandi::before { transform: rotate(45deg); }

.menu-sezioni {
  display: none;
  margin: 2px 0 10px 22px; padding-left: 14px;
  border-left: 2px solid var(--line);
}
.menu-lezione.aperta .menu-sezioni { display: block; }
.menu-sezioni a {
  display: block; padding: 5px 10px; font-size: 14px; line-height: 1.35;
  border-radius: 8px; color: var(--muted);
}
.menu-sezioni a:hover { color: var(--ink); background: var(--bg); }
.menu-sezioni a.qui { color: var(--brand-ink); background: var(--brand-soft); font-weight: 500; }

/* ---------- Contenuto ---------- */
.contenuto {
  width: 100%; max-width: 900px;
  margin: 0 auto;
  padding: 36px 40px 80px;
}

h1, h2, h3, h4 { line-height: 1.25; color: var(--ink); text-wrap: balance; }
h1 { font-size: clamp(30px, 4vw, 42px); font-weight: 700; margin: 6px 0 14px; letter-spacing: -.01em; }
h2 { font-size: 27px; font-weight: 600; margin: 0 0 14px; }
h3 { font-size: 20px; font-weight: 600; margin: 30px 0 8px; }
h4 { font-size: 17px; font-weight: 600; margin: 20px 0 6px; }
p { margin: 0 0 14px; }
ul, ol { padding-left: 24px; margin: 0 0 16px; }
li { margin: 4px 0; }
li::marker { color: var(--brand); }

main section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px 34px;
  margin: 0 0 22px;
}
main section > h2 { display: flex; align-items: baseline; gap: 12px; }
main section > h2 .n {
  flex: none; font-size: 15px; font-weight: 600; color: var(--brand);
  background: var(--brand-soft); padding: 2px 10px; border-radius: 999px; transform: translateY(-3px);
}

/* Intestazione di lezione */
.hero {
  padding: 8px 0 22px;
}
.occhiello {
  display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap;
  font-size: 14px; font-weight: 500; color: var(--brand-ink); margin: 0;
}
.occhiello span { background: var(--brand-soft); padding: 4px 12px; border-radius: 999px; }
.hero .intro { font-size: 19px; color: var(--ink-2); max-width: 680px; }
.azioni { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 15px; font-weight: 500; text-decoration: none;
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  background: var(--brand); color: #fff; border: 1px solid var(--brand);
}
.btn:hover { background: var(--brand-ink); color: #fff; }
.btn.sec { background: var(--paper); color: var(--brand-ink); border-color: var(--line-2); }
.btn.sec:hover { background: var(--brand-soft); color: var(--brand-ink); }

.obiettivi {
  margin-top: 24px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.obiettivi > div {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px;
}
.obiettivi h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.obiettivi ul { margin: 0; padding-left: 20px; font-size: 16px; }

details.scaletta {
  background: var(--paper); border: 1px dashed var(--line-2); border-radius: var(--radius);
  padding: 14px 22px; margin: 0 0 22px;
}
details.scaletta summary { cursor: pointer; font-weight: 500; color: var(--ink-2); }
details.scaletta[open] summary { margin-bottom: 10px; }

/* Figure */
figure.fig {
  margin: 22px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
  overflow: hidden;
  break-inside: avoid;
}
figure.fig img { display: block; width: 100%; height: auto; background: #fff; }
figure.fig figcaption {
  font-size: 14.5px; color: var(--ink-2); padding: 10px 16px;
  border-top: 1px solid var(--line); background: var(--paper);
}
figure.fig figcaption b { color: var(--brand-ink); }
figure.fig.stretta { max-width: 560px; margin-left: auto; margin-right: auto; }
.due-figure { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.due-figure figure.fig { margin: 0; }

/* Riquadri */
.box {
  position: relative;
  border-radius: 12px;
  padding: 16px 20px 14px 20px;
  margin: 20px 0;
  border: 1px solid;
  break-inside: avoid;
}
.box > :last-child { margin-bottom: 0; }
.box-titolo {
  display: inline-block; margin: 0 0 8px; font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
}
.box.prova      { background: var(--accent-soft); border-color: #ffd3b5; }
.box.prova .box-titolo { color: var(--accent); }
.box.ricorda    { background: var(--brand-soft); border-color: #c9d8f0; }
.box.ricorda .box-titolo { color: var(--brand-ink); }
.box.attenzione { background: var(--bad-soft); border-color: #f6c6c6; }
.box.attenzione .box-titolo { color: var(--bad); }
.box.sapevi     { background: var(--tip-soft); border-color: #d9cffa; }
.box.sapevi .box-titolo { color: var(--tip); }
.box.progetto   { background: var(--ok-soft); border-color: #bfe3c8; }
.box.progetto .box-titolo { color: var(--ok); }

/* Percorso dei comandi: Inserisci › Tabella */
.cmd {
  display: inline;
  font-weight: 500; font-size: .94em;
  color: var(--brand-ink); background: var(--brand-soft);
  padding: 1px 7px; border-radius: 6px;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
kbd {
  display: inline-block; min-width: 1.6em; text-align: center;
  font-family: var(--font); font-size: .82em; font-weight: 500; line-height: 1.5;
  padding: 0 7px; margin: 0 1px;
  color: var(--ink); background: #fff;
  border: 1px solid var(--line-2); border-bottom-width: 3px; border-radius: 6px;
  white-space: nowrap;
}
code { font-family: var(--mono); font-size: .9em; background: var(--bg); padding: 1px 6px; border-radius: 5px; }

/* Passi numerati */
ol.passi { list-style: none; counter-reset: passo; padding: 0; margin: 14px 0 18px; }
ol.passi > li {
  counter-increment: passo; position: relative;
  padding: 2px 0 10px 46px; margin: 0;
}
ol.passi > li::before {
  content: counter(passo);
  position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 600; font-size: 15px;
}
ol.passi > li:not(:last-child)::after {
  content: ""; position: absolute; left: 14px; top: 34px; bottom: 2px; width: 2px; background: var(--line);
}

/* Legenda dei numeri nelle figure */
ol.legenda {
  list-style: none; counter-reset: leg; padding: 0; margin: 4px 0 20px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 26px;
}
ol.legenda li { counter-increment: leg; position: relative; padding-left: 36px; margin: 0; font-size: 15.5px; line-height: 1.5; }
ol.legenda li::before {
  content: counter(leg);
  position: absolute; left: 0; top: 0;
  width: 25px; height: 25px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 700;
}

/* Soluzioni degli esercizi */
details.soluzione { margin: 10px 0 18px; }
details.soluzione summary { cursor: pointer; color: var(--ok); font-weight: 500; }
details.soluzione[open] summary { margin-bottom: 8px; }

/* Confronto sì / no */
.confronto { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0 20px; }
.confronto > div { border-radius: 12px; padding: 14px 18px; border: 1px solid; }
.confronto .no { background: var(--bad-soft); border-color: #f6c6c6; }
.confronto .si { background: var(--ok-soft); border-color: #bfe3c8; }
.confronto .etichetta { font-weight: 600; font-size: 14px; margin: 0 0 6px; }
.confronto .no .etichetta { color: var(--bad); }
.confronto .si .etichetta { color: var(--ok); }
.confronto .no .etichetta::before { content: "✗  "; }
.confronto .si .etichetta::before { content: "✓  "; }
.confronto > div > :last-child { margin-bottom: 0; }
.esempio-testo { font-family: "Calibri", "Segoe UI", Arial, sans-serif; font-size: 16px; white-space: pre-wrap; background: #fff; border-radius: 8px; padding: 8px 12px; border: 1px solid rgba(0,0,0,.06); }

/* Tabelle del sito */
.tabella-wrap { overflow-x: auto; margin: 16px 0 20px; }
table.tabella { width: 100%; border-collapse: collapse; font-size: 15.5px; }
.tabella th, .tabella td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.tabella thead th { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; border-bottom: 2px solid #c9d8f0; }
.tabella tbody tr:nth-child(even) td { background: #fafbfd; }
.tabella td:first-child { font-weight: 500; }
.tabella.compatta td:first-child { white-space: nowrap; }

/* Testo da copiare */
.testo-copia {
  position: relative; margin: 16px 0 20px;
  border: 1px solid var(--line-2); border-radius: 12px; background: #fff;
}
.testo-copia .testo {
  font-family: "Calibri", "Segoe UI", Arial, sans-serif; font-size: 15.5px; line-height: 1.55;
  padding: 18px 20px; white-space: pre-wrap; max-height: 340px; overflow: auto;
}
.testo-copia .copia {
  position: sticky; top: 0; float: right; margin: 10px 10px 0 10px;
  font: inherit; font-size: 13.5px; font-weight: 500;
  background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
.testo-copia .copia.ok { background: var(--ok); }

/* Quiz */
.quiz { counter-reset: domanda; }
.quiz details {
  counter-increment: domanda;
  border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; background: #fff;
}
.quiz summary {
  cursor: pointer; list-style: none; padding: 12px 16px 12px 52px; position: relative; font-weight: 500;
}
.quiz summary::-webkit-details-marker { display: none; }
.quiz summary::before {
  content: counter(domanda); position: absolute; left: 14px; top: 11px;
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-ink); font-size: 14px; font-weight: 600;
}
.quiz summary::after { content: "Mostra la risposta"; display: block; font-size: 13px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.quiz details[open] summary::after { content: "Risposta:"; }
.quiz details > p { margin: 0; padding: 0 16px 14px 52px; color: var(--ok); font-weight: 400; }

/* Checklist */
.checklist { list-style: none; padding: 0; margin: 10px 0 0; }
.checklist li { margin: 0; border-bottom: 1px solid var(--line); }
.checklist label { display: flex; gap: 12px; align-items: flex-start; padding: 10px 4px; cursor: pointer; }
.checklist input { width: 20px; height: 20px; margin-top: 3px; flex: none; accent-color: var(--ok); }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--ok); }
.checklist-conta { font-weight: 600; color: var(--ok); }

/* Schede (card) */
.schede { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 18px 0; }
.scheda {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; text-decoration: none; color: var(--ink);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
a.scheda:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: 0 8px 24px -14px rgba(27, 34, 50, .35); color: var(--ink); }
.scheda .num { font-size: 13px; font-weight: 600; color: var(--brand); text-transform: uppercase; letter-spacing: .06em; }
.scheda h3 { margin: 0; font-size: 19px; }
.scheda p { margin: 0; font-size: 15px; color: var(--muted); }
.scheda.bloccata { opacity: .55; }

.due-colonne { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.colonna { border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; background: #fff; }
.colonna h3 { margin-top: 0; }

/* Navigazione tra lezioni */
.pag-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 30px; }
.pag-nav a {
  display: block; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); text-decoration: none; color: var(--ink); font-weight: 500;
}
.pag-nav a:hover { border-color: var(--brand); }
.pag-nav small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.pag-nav .succ { text-align: right; }

.pie { font-size: 13px; color: var(--muted); text-align: center; padding: 30px 0 0; }

/* ---------- Telefono e tablet ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .apri-menu { display: inline-flex; }
  .menu {
    position: fixed; top: var(--head); left: 0; bottom: 0; z-index: 25;
    width: min(340px, 88vw); height: auto;
    transform: translateX(-102%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.18);
  }
  body.menu-aperto .menu { transform: none; }
  body.menu-aperto::after {
    content: ""; position: fixed; inset: var(--head) 0 0 0; background: rgba(20, 26, 40, .35); z-index: 20;
  }
  .contenuto { padding: 24px 16px 60px; }
  main section { padding: 22px 18px; }
  .corso-chip { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .marchio small { display: none; }
  .obiettivi, .confronto, .due-figure, .due-colonne, .pag-nav, ol.legenda { grid-template-columns: 1fr; }
  h2 { font-size: 23px; }
  main section > h2 { flex-direction: column; gap: 6px; }
  main section > h2 .n { transform: none; }
}

/* ---------- Stampa e dispense PDF ---------- */
@page {
  size: A4;
  margin: 16mm 15mm 18mm 15mm;
  @bottom-left { content: "Laboratorio di Informatica · Scuola Sant'Anna"; font-family: "Lexend", "Segoe UI", sans-serif; font-size: 8pt; color: #7a8394; }
  @bottom-right { content: "pagina " counter(page) " di " counter(pages); font-family: "Lexend", "Segoe UI", sans-serif; font-size: 8pt; color: #7a8394; }
}
@media print {
  html { scroll-behavior: auto; }
  body { background: #fff; font-size: 10.5pt; line-height: 1.5; }
  .testata, .menu, .azioni, .pag-nav, .copia, .salta, .no-stampa { display: none !important; }
  .layout { display: block; }
  .contenuto { max-width: none; padding: 0; }
  .hero { padding-top: 0; border-bottom: 2px solid var(--brand); margin-bottom: 14px; }
  h1 { font-size: 24pt; }
  h2 { font-size: 16pt; }
  h3 { font-size: 12.5pt; }
  main section { border: 0; padding: 0; margin: 0 0 10mm; border-radius: 0; }
  main section > h2 { break-after: avoid; border-bottom: 1px solid var(--line-2); padding-bottom: 4px; }
  h3, h4 { break-after: avoid; }
  .box, figure.fig, .confronto > div, .quiz details, .colonna, tr { break-inside: avoid; }
  .box:has(ol, ul) { break-inside: auto; }
  .box li { break-inside: avoid; }
  figure.fig { margin: 10px 0; }
  figure.fig img { max-height: 120mm; width: auto; max-width: 100%; margin: 0 auto; }
  .testo-copia .testo { max-height: none; overflow: visible; }
  .quiz summary::after { content: "Risposta: ______________________________"; }
  .quiz details > p { display: none; }
  details.scaletta { border-style: solid; }
  a { color: inherit; text-decoration: none; }
  .obiettivi > div, .colonna { border-color: var(--line-2); }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
