/* Pulcino — tema scuro tech, blu metallico e argento. Mobile-first. */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap");

:root {
  --bg: #0b1017;
  --bg-2: #101722;
  --panel: #141d2b;
  --panel-2: #1a2536;
  --line: #273449;
  --line-2: #34445e;
  --text: #dfe6ef;
  --muted: #9aa8bb;
  --silver: #c9d3de;
  --blue: #5b9bd5;
  --blue-2: #3a78b8;
  --blue-hi: #8cc2f2;
  --steel: linear-gradient(135deg, #8aa4c2 0%, #d7e0ea 45%, #6f8bab 100%);
  --ok: #5fc39a;
  --warn: #e6b450;
  --danger: #f07a6e;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #16243a 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font);
  overflow-x: hidden;
}
img, svg, video { max-width: 100%; height: auto; }
a { color: var(--blue-hi); text-underline-offset: 3px; }
a:hover { color: #b7dafa; }
code, kbd, pre { font-family: var(--mono); font-size: 0.9em; }
code { background: var(--panel-2); border: 1px solid var(--line); padding: 0.05em 0.35em; border-radius: 5px; overflow-wrap: anywhere; }
pre { background: #0a0f16; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; line-height: 1.5; max-width: 100%; }
pre code { background: none; border: 0; padding: 0; overflow-wrap: normal; }
kbd { background: var(--panel-2); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 0 0.35em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
:focus-visible { outline: 2px solid var(--blue-hi); outline-offset: 2px; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px; padding: 10px 16px;
  background: rgba(11, 16, 23, 0.88);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 0.02em; color: var(--silver); text-decoration: none; font-size: 1.1rem; }
.brand img { display: block; }
.nav-toggle {
  font: 600 0.9rem var(--font); color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 14px; cursor: pointer;
}
.site-nav { display: none; flex-basis: 100%; flex-direction: column; padding: 6px 0 8px; }
.site-nav.open { display: flex; max-height: calc(100dvh - 60px); overflow-y: auto; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 9px 10px; border-radius: 8px; font-weight: 500; }
.site-nav a:hover { color: var(--text); background: var(--panel); }
.site-nav a.active { color: #fff; background: var(--panel-2); box-shadow: inset 3px 0 0 var(--blue); }

@media (min-width: 1100px) {
  .nav-toggle { display: none; }
  .site-nav { display: flex; flex-direction: row; flex-basis: auto; flex-wrap: wrap; padding: 0; gap: 2px; }
  .site-nav a { padding: 6px 9px; font-size: 0.9rem; }
  .site-nav a.active { box-shadow: inset 0 -2px 0 var(--blue); }
}

/* ---------- Layout ---------- */
main { max-width: 980px; margin: 0 auto; padding: 24px 16px 48px; }
section { margin: 2.5rem 0; scroll-margin-top: 80px; }
h1, h2, h3, h4 { line-height: 1.25; color: #f1f5fa; scroll-margin-top: 80px; }
h1 { font-size: clamp(1.9rem, 6vw, 2.9rem); font-weight: 800; margin: 0.4rem 0 0.6rem; letter-spacing: -0.02em; }
h1 .steel, .steel { background: var(--steel); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { font-size: clamp(1.35rem, 4.5vw, 1.8rem); margin: 2.2rem 0 0.8rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--line); }
h3 { font-size: 1.15rem; margin: 1.6rem 0 0.5rem; color: var(--silver); }
.lead { font-size: 1.12rem; color: var(--silver); }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.eyebrow { font: 600 0.78rem var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--blue); margin: 0; }

.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  min-width: 0;
}
.card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }
a.card { display: block; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--blue-2); transform: translateY(-2px); }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 1.2rem 0; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 1.35rem; color: #fff; }
.stat span { font-size: 0.82rem; color: var(--muted); }

.badge { display: inline-block; font: 600 0.72rem var(--mono); padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--silver); background: var(--panel-2); vertical-align: middle; }
.badge.blue { border-color: var(--blue-2); color: var(--blue-hi); }
.price-note { font-size: 0.82rem; color: var(--warn); }

/* Callout */
.note, .warn, .danger, .tip {
  border: 1px solid var(--line); border-left-width: 4px; border-radius: 10px;
  padding: 12px 16px; margin: 1.2rem 0; background: var(--panel);
}
.note { border-left-color: var(--blue); }
.tip { border-left-color: var(--ok); }
.warn { border-left-color: var(--warn); }
.danger { border-left-color: var(--danger); background: #1d1518; }
.note > :first-child, .warn > :first-child, .danger > :first-child, .tip > :first-child { margin-top: 0; }
.note > :last-child, .warn > :last-child, .danger > :last-child, .tip > :last-child { margin-bottom: 0; }

/* Tabelle: scroll orizzontale interno su mobile */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1rem 0; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--panel-2); color: var(--silver); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tfoot td { background: var(--panel); font-weight: 700; }
td.num { white-space: nowrap; }

/* Viewer 3D */
.viewer {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  background: radial-gradient(ellipse at 50% 30%, #1b2a40 0%, #0c121b 75%);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 1rem 0;
}
@media (min-width: 768px) { .viewer { aspect-ratio: 16 / 9; } }
.viewer canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }
.viewer:empty::after {
  content: "Anteprima 3D in caricamento…"; position: absolute; inset: 0;
  display: grid; place-items: center; color: var(--muted); font: 0.85rem var(--mono);
}
figure { margin: 1.2rem 0; }
figcaption { font-size: 0.86rem; color: var(--muted); margin-top: 6px; }

/* Hero */
.hero { display: grid; gap: 18px; align-items: center; margin-top: 0.5rem; }
@media (min-width: 900px) { .hero { grid-template-columns: 1fr 1.15fr; } .hero .viewer { margin: 0; } }

/* Percorso a tappe */
.path { list-style: none; padding: 0; margin: 1rem 0; counter-reset: tappa; display: grid; gap: 10px; }
@media (min-width: 700px) { .path { grid-template-columns: repeat(2, 1fr); } }
.path li { counter-increment: tappa; }
.path a {
  display: flex; gap: 12px; align-items: flex-start; height: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; text-decoration: none; color: var(--text);
}
.path a:hover { border-color: var(--blue-2); }
.path a::before {
  content: counter(tappa); flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font: 700 0.9rem var(--mono); color: #0b1017; background: var(--steel);
}
.path strong { display: block; color: #fff; }
.path span { font-size: 0.88rem; color: var(--muted); }

/* Passi assemblaggio */
.steps { list-style: none; padding: 0; margin: 0; counter-reset: passo; }
.step { counter-increment: passo; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); padding: 16px; margin: 18px 0; }
.step > h3 { margin-top: 0; display: flex; gap: 10px; align-items: center; }
.step > h3::before {
  content: counter(passo); flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font: 700 0.95rem var(--mono); color: #0b1017; background: var(--steel);
}

/* Schema elettrico */
.schematic-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: #0a0f16; margin: 1rem 0; }
.schematic-wrap svg { display: block; width: 900px; max-width: none; height: auto; }
@media (min-width: 940px) { .schematic-wrap svg { width: 100%; } }
.zoom-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.btn {
  display: inline-block; font: 600 0.9rem var(--font); color: #0b1017; background: var(--steel);
  border: 0; border-radius: 9px; padding: 9px 16px; text-decoration: none; cursor: pointer;
}
.btn:hover { color: #0b1017; filter: brightness(1.08); }
.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); }
.btn.ghost:hover { color: #fff; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 1rem 0; }

/* Elenco file del repo */
.files { list-style: none; padding: 0; display: grid; gap: 6px; }
.files a { font-family: var(--mono); font-size: 0.88rem; overflow-wrap: anywhere; }
.files li::before { content: "▸ "; color: var(--blue); }

/* TOC */
.toc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; font-size: 0.93rem; }
.toc ol, .toc ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }

/* FAQ */
details { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
details[open] { border-color: var(--line-2); }
summary { cursor: pointer; font-weight: 600; color: #f1f5fa; }
details > :not(summary):first-of-type { margin-top: 0.6rem; }

.photo { display: block; width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--line); background: var(--bg-2); color: var(--muted);
  padding: 22px 16px 30px; font-size: 0.88rem; text-align: center;
}
.site-footer p { margin: 0.3rem 0; }
.site-footer a { color: var(--silver); }
.pager { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 3rem; }
.pager a { flex: 1 1 200px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; text-decoration: none; }
.pager a:hover { border-color: var(--blue-2); }
.pager .next { text-align: right; }
.pager small { display: block; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } a.card { transition: none; } }
.part { margin: 18px 0; }
.part .viewer { margin-top: 0.5rem; }
