/* Manuale "Il cuore di LED che batte" - foglio di stile */
:root {
  --blu: #1f6f8b;
  --blu-scuro: #174f63;
  --testo: #222;
  --grigio: #666;
  --sfondo: #fafaf7;
  --carta: #ffffff;
  --nota: #fff4d6;
  --nota-bordo: #e0a800;
  --codice: #f3f3f3;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--testo);
  background: var(--sfondo);
}
/* barra superiore con logo e ritorno al sito (intestazione) */
.barra-sito {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  background: var(--carta); border-bottom: 1px solid #ddd;
  padding: 8px 20px;
}
.barra-sito .logo-link img { height: 44px; width: auto; display: block; }
.barra-sito .barra-testo { flex: 1; font-size: 0.95em; color: var(--testo); }
.barra-sito .torna-sito { color: var(--blu); font-weight: bold; text-decoration: none; white-space: nowrap; }
.barra-sito .torna-sito:hover { text-decoration: underline; }

/* pagina iniziale (copertina) */
header.copertina {
  background: linear-gradient(135deg, var(--blu-scuro), var(--blu));
  color: #fff;
  padding: 64px 24px 48px;
  text-align: center;
}
header.copertina h1 { margin: 0 0 12px; font-size: 2.6em; }
header.copertina p { margin: 6px auto; max-width: 760px; opacity: 0.95; }
header.copertina .sottotitolo { font-size: 1.3em; margin-bottom: 18px; }
header.copertina .docente { font-weight: bold; font-size: 1.1em; margin-top: 18px; }
header.copertina .versione { font-size: 0.9em; opacity: 0.8; margin-top: 24px; }

nav.indice {
  background: var(--carta);
  border-bottom: 1px solid #ddd;
  padding: 16px 24px;
}
nav.indice ul { list-style: none; margin: 0 auto; padding: 0; max-width: 960px; display: flex; flex-wrap: wrap; gap: 6px 18px; }
nav.indice a { color: var(--blu); text-decoration: none; font-weight: bold; }
nav.indice a:hover { text-decoration: underline; }

main { max-width: 960px; margin: 0 auto; padding: 24px 20px 60px; }
section { background: var(--carta); border-radius: 10px; padding: 24px 28px; margin-bottom: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
h2 { color: var(--blu); margin-top: 0; border-bottom: 2px solid var(--blu); padding-bottom: 6px; }
h3 { color: var(--blu-scuro); margin: 28px 0 8px; }
h4 { margin: 20px 0 6px; }
p { margin: 0 0 12px; }
ul, ol { margin: 0 0 14px; padding-left: 26px; }
li { margin-bottom: 5px; }
code { font-family: Consolas, "Courier New", monospace; background: var(--codice); padding: 1px 5px; border-radius: 4px; font-size: 0.92em; }
.formula { text-align: center; font-family: Consolas, "Courier New", monospace; background: var(--codice); padding: 10px; border-radius: 6px; margin: 12px 0; }

figure { margin: 18px 0 22px; text-align: center; }
figure img { max-width: 100%; height: auto; border: 1px solid #e3e3e3; border-radius: 6px; background: #fff; }
figure.stretta img { max-width: 620px; }
figcaption { font-size: 0.88em; color: var(--grigio); font-style: italic; margin-top: 8px; }

table { width: 100%; border-collapse: collapse; margin: 12px 0 18px; font-size: 0.93em; }
th { background: var(--blu); color: #fff; text-align: left; padding: 7px 9px; }
td { border: 1px solid #ddd; padding: 6px 9px; vertical-align: top; }
tr:nth-child(even) td { background: #f6f9fb; }

.nota { background: var(--nota); border-left: 6px solid var(--nota-bordo); padding: 10px 14px; border-radius: 0 6px 6px 0; margin: 14px 0; }

.codice-box { position: relative; margin: 16px 0; }
.codice-box pre {
  background: #f8f8f6; color: #1a1a1a; padding: 18px; border-radius: 8px; border: 1px solid #d8d8d8;
  overflow-x: auto; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 1.5; margin: 0;
}
.codice-box pre code { background: none; padding: 0; color: inherit; font-size: inherit; border-radius: 0; }
.codice-box button {
  position: absolute; top: 10px; right: 10px;
  background: var(--blu); color: #fff; border: none; border-radius: 6px;
  padding: 7px 12px; cursor: pointer; font-size: 0.9em;
}
.codice-box button:hover { background: var(--blu-scuro); }
.codice-box button.ok { background: #2a9d4b; }

footer { text-align: center; color: var(--grigio); font-size: 0.85em; padding: 22px 20px 70px; border-top: 1px solid #ddd; background: var(--carta); }
footer .pie-riga { margin: 4px 0; }
footer a { color: var(--blu); }
a.torna-su { position: fixed; right: 18px; bottom: 18px; background: var(--blu); color: #fff; text-decoration: none; padding: 10px 14px; border-radius: 30px; font-size: 0.9em; box-shadow: 0 2px 6px rgba(0,0,0,0.25); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .barra-sito { flex-wrap: wrap; gap: 8px 12px; }
  .barra-sito .barra-testo { font-size: 0.85em; }
  section { padding: 18px 14px; }
  header.copertina h1 { font-size: 1.8em; }
  table { font-size: 0.85em; }
}
@media print {
  header.copertina { background: #fff; color: #000; }
  nav.indice, a.torna-su, .codice-box button, .barra-sito .torna-sito { display: none; }
  .barra-sito { position: static; }
  section { box-shadow: none; page-break-inside: avoid; }
}

/* ---- simulazione del prototipo ---- */
.sim { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.sim-colonna { flex: 1 1 380px; min-width: 0; }
#sim-cuore { width: 100%; max-width: 460px; background: #f4f1e8; border: 1px solid #d8d3c4; border-radius: 10px; display: block; }
.sim-comandi { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 12px; }
.sim-btn-avvio { background: var(--blu); color: #fff; border: none; border-radius: 8px; padding: 10px 16px; font-size: 1em; cursor: pointer; }
.sim-btn-avvio:hover { background: var(--blu-scuro); }
.sim-btn-pulsante { width: 84px; height: 84px; border-radius: 50%; border: 4px solid #303030; background: radial-gradient(circle at 35% 35%, #9a9a9a, #555); color: #fff; font-weight: bold; cursor: pointer; box-shadow: 0 4px 0 #222; line-height: 1.1; }
.sim-btn-pulsante:active { transform: translateY(3px); box-shadow: 0 1px 0 #222; }
.sim-btn-pulsante small { font-weight: normal; font-size: 0.75em; }
.sim-audio { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.sim-spia { display: inline-block; padding: 4px 10px; border-radius: 14px; background: #ddd; color: #777; font-size: 0.85em; transition: background 0.05s, color 0.05s; }
.sim-spia.attiva { background: #ffb400; color: #000; }
.sim-lcd { background: #2a5fb0; color: #eaf2ff; font-family: Consolas, "Courier New", monospace; font-size: 1.35em; padding: 14px 18px; border-radius: 8px; border: 6px solid #2f8f4e; letter-spacing: 0.08em; display: inline-block; min-width: 18ch; line-height: 1.5; }
.sim-lcd div { white-space: pre; }
#sim-curva { display: block; width: 100%; max-width: 420px; height: auto; border: 1px solid #ddd; border-radius: 8px; margin-top: 14px; }
.sim-dati { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 10px; font-size: 0.92em; color: var(--grigio); }
.sim-nota { font-size: 0.88em; color: var(--grigio); margin-top: 8px; }
.bottone-pdf { display: inline-block; background: #c0392b; color: #fff; text-decoration: none; padding: 12px 20px; border-radius: 8px; font-weight: bold; }
.bottone-pdf:hover { background: #962d22; }
