/* ==========================================================================
   AiLocalVoiceServer — design system del sito
   Token del tema in :root, componenti sotto. Nessun colore cablato nelle regole.
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #070a10;
  --bg-2: #0b1018;
  --surface: #111820;
  --surface-2: #161e2a;
  --surface-3: #1c2536;
  --line: #1e2738;
  --line-2: #273347;
  --line-3: #314058;
  --ink: #e8eef6;
  --ink-2: #b8c4d6;
  --muted: #6b7f99;
  --faint: #4a5d76;
  --accent: #35e0ff;
  --accent-dim: #1fa8c4;
  --accent-ink: #031218;
  --accent-soft: rgba(53, 224, 255, .10);
  --accent-glow: rgba(53, 224, 255, .25);
  --teal: #37d4a0;
  --teal-soft: rgba(55, 212, 160, .12);
  --amber: #ffb020;
  --amber-soft: rgba(255, 176, 32, .12);
  --red: #ff4030;
  --red-soft: rgba(255, 64, 48, .12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow: 0 2px 4px rgba(0, 0, 0, .4), 0 12px 40px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35);
  --glow: 0 0 30px var(--accent-soft), inset 0 0 1px var(--accent-glow);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --max: 1200px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f8;
  --bg-2: #e5ebf4;
  --surface: #fff;
  --surface-2: #f0f4fb;
  --surface-3: #e6ecf5;
  --line: #c8d2e2;
  --line-2: #b8c4d6;
  --line-3: #a8b6ca;
  --ink: #0d1520;
  --ink-2: #2a3848;
  --muted: #5a6d84;
  --faint: #8a9ab0;
  --accent: #0ea5c9;
  --accent-dim: #0b7f9b;
  --accent-ink: #f0fdfa;
  --accent-soft: rgba(14, 165, 201, .08);
  --accent-glow: rgba(14, 165, 201, .18);
  --teal: #0d9488;
  --teal-soft: rgba(13, 148, 136, .10);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, .10);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, .10);
  --shadow: 0 1px 3px rgba(13, 21, 32, .08), 0 8px 24px rgba(13, 21, 32, .06);
  --shadow-sm: 0 1px 2px rgba(13, 21, 32, .06);
  --glow: 0 0 24px var(--accent-soft);
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  /* The header (62px) and the page menu (52px) are sticky: the anchors of the
     index must land below them. */
  scroll-padding-top: 132px;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 16px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 800px 500px at 80% -10%, rgba(53, 224, 255, .06) 0%, transparent 60%),
    radial-gradient(ellipse 600px 400px at 5% 30%, rgba(55, 212, 160, .04) 0%, transparent 55%),
    radial-gradient(ellipse 500px 300px at 90% 80%, rgba(176, 124, 255, .04) 0%, transparent 50%);
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .4em; font-weight: 650; }
h1 { font-size: clamp(34px, 5.5vw, 60px); line-height: 1.02; letter-spacing: -.035em; }
h2 { font-size: clamp(22px, 3.2vw, 32px); letter-spacing: -.02em; }
h3 { font-size: clamp(17px, 2vw, 21px); letter-spacing: -.01em; }
p { margin: 0 0 1em; }

code, .mono {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .12em .4em;
  /* Percorsi lunghi (chiavi di registro, URL) non devono rompere il layout. */
  overflow-wrap: anywhere;
}

pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0 0 1em;
}
pre code { background: none; border: 0; padding: 0; }
pre.ex { border-left: 3px solid var(--accent); }

::selection { background: var(--accent-soft); color: var(--ink); }

/* ---------- bilingual blocks ---------- */

/* The pages carry both languages inline: only the one of <html lang> is shown.
   Without this rule the Italian and the English text would be printed together. */
html[lang="it"] .en { display: none; }
html[lang="en"] .it { display: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.small { font-size: .85rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.accent { color: var(--accent); }
.nowrap { white-space: nowrap; }

/* Visually hidden, still read by the screen readers (labels of the page menu). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- skip link ---------- */

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 300;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  transition: top .18s;
}
.skip-link:focus { top: 12px; text-decoration: none; }

/* ---------- header / nav ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
}

.nav {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 62px;
}

/* Menu statico di riserva: visibile solo quando gli script non vengono caricati
   (sito aperto da file:// o JavaScript non disponibile). */
.top-fallback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  min-height: 62px;
  padding: 10px 0;
}

.top-fallback-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.top-fallback-links a {
  color: var(--ink-2);
  font-weight: 500;
  text-decoration: none;
}

.top-fallback-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  font-size: 1.02rem;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  display: grid;
  place-items: center;
  color: var(--accent-ink);
  font-weight: 800;
  font-size: .8rem;
  flex: none;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 10px var(--teal);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.nav-link {
  color: var(--ink-2);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .93rem;
  font-weight: 550;
  white-space: nowrap;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-link.active {
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.ctrl-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  font: inherit;
  transition: background .15s, color .15s;
}
.ctrl-btn:hover { background: var(--surface-2); color: var(--ink); }
.lang-btn { font-size: .8rem; font-weight: 700; width: auto; padding: 0 10px; }
.theme-icon { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); display: block; }
[data-theme="light"] .theme-icon { background: var(--ink-2); }

.menu-toggle { display: none; }

/* ---------- page menu (indice della pagina) ---------- */

.page-menu {
  position: sticky;
  top: 62px;
  z-index: 90;
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.page-menu-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 52px;
}
.page-menu-title {
  flex: none;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  font-weight: 700;
}
.page-menu-list {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.page-menu-list a {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: .85rem;
  color: var(--ink-2);
  white-space: nowrap;
}
.page-menu-list a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.page-menu-list a.active { color: var(--accent); background: var(--accent-soft); }

/* ---------- hero ---------- */

.hero {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 48px;
  align-items: center;
  padding: 80px 0 56px;
}
.hero .lead { font-size: clamp(15px, 1.8vw, 18px); max-width: 600px; color: var(--ink-2); }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 18px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: .78rem;
  color: var(--muted);
}
.badge b { color: var(--ink-2); font-weight: 650; }

.hero-face-wrap { position: relative; }
.hero-face-frame {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-2);
  background: var(--surface);
  padding: 10px;
  box-shadow: var(--shadow), var(--glow);
  overflow: hidden;
}

/* ---------- sections ---------- */

main > section { padding: 52px 0; border-top: 1px solid var(--line); }
main > section:first-of-type { border-top: 0; }

.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, .55fr);
  gap: 28px;
  align-items: end;
  margin-bottom: 26px;
}
.section-head h2 { margin-bottom: .15em; }
.section-lead { color: var(--muted); margin: 0; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: .94rem;
  cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-3); text-decoration: none; transform: translateY(-1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: .85rem; }

/* ---------- grids / cards ---------- */

.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g5 { grid-template-columns: repeat(5, 1fr); }

/* I figli dei grid non devono imporre la larghezza minima del contenuto:
   senza min-width:0 una riga lunga fa traboccare la pagina dal viewport
   sui dispositivi mobili. */
.grid > *,
.hero > *,
.section-head > *,
.prose-grid > *,
.callout-grid > *,
.link-grid > *,
.gallery > *,
.stats-row > *,
.kpis > *,
.rows > * {
  min-width: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card h3 { margin-bottom: .35em; }
.card p { color: var(--ink-2); margin: 0; font-size: .94rem; }
.card .icon { font-size: 1.4rem; display: block; margin-bottom: 10px; }

/* ---------- gallery ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.gallery.g2 { grid-template-columns: repeat(2, 1fr); }
.gallery.g4 { grid-template-columns: repeat(4, 1fr); }
.shot {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.shot img { display: block; width: 100%; height: auto; background: var(--bg-2); }
.shot figcaption {
  padding: 10px 14px;
  font-size: .84rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* ---------- stats ---------- */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin: 8px 0 4px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.stat b {
  display: block;
  font-size: clamp(24px, 3.4vw, 34px);
  letter-spacing: -.03em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stat span { color: var(--muted); font-size: .84rem; }

/* ---------- panel / kpis / rows ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.panel-h {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 650;
  font-size: .9rem;
  color: var(--ink-2);
  background: var(--surface-2);
}
.panel-b { padding: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.kpi {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: .85rem;
}
.kpi b { display: block; font-size: 1.1rem; color: var(--ink); }
.kpi.ok { border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); background: var(--teal-soft); }
.kpi.warn { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); background: var(--amber-soft); }
.kpi.accent { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); }

.rows { display: grid; gap: 0; }
.row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: .92rem;
  flex-wrap: wrap;
}
.row:last-child { border-bottom: 0; }
.r-label { color: var(--muted); }
.r-value { color: var(--ink); font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* ---------- chips / methods ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: .78rem;
  color: var(--ink-2);
  font-family: var(--mono);
}
.method {
  display: inline-block;
  min-width: 46px;
  text-align: center;
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
}
.method.get { background: var(--teal-soft); color: var(--teal); }
.method.post { background: var(--accent-soft); color: var(--accent); }
.method.put { background: var(--amber-soft); color: var(--amber); }
.method.del { background: var(--red-soft); color: var(--red); }

/* ---------- api groups ---------- */

.api-grp {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 10px;
  overflow: hidden;
}
.api-grp summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 650;
  font-size: .92rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.api-grp summary::-webkit-details-marker { display: none; }
.api-grp summary::before {
  content: "▸";
  color: var(--muted);
  transition: transform .15s;
}
.api-grp[open] summary::before { transform: rotate(90deg); }
.api-grp .panel-b { border-top: 1px solid var(--line); }

/* ---------- notes ---------- */

.note {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0 0 1em;
  font-size: .93rem;
}
.note.warn { border-color: var(--amber); background: var(--amber-soft); }
.note.err { border-color: var(--red); background: var(--red-soft); }
.note.ok { border-color: var(--teal); background: var(--teal-soft); }

/* ---------- prose / tables ---------- */

.prose { max-width: 78ch; }
.prose-grid { display: grid; grid-template-columns: 1.4fr .6fr; gap: 24px; align-items: start; }
.prose h2, .prose h3 { margin-top: 1.6em; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .35em; }

.feature-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.feature-list li { padding-left: 26px; position: relative; }
.feature-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--teal);
  font-weight: 700;
}

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { border-collapse: collapse; min-width: 640px; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); color: var(--ink-2); font-weight: 650; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

.callout-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ---------- link grid / process / timeline ---------- */

.link-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.link-card {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
.link-card:hover { border-color: var(--accent); text-decoration: none; background: var(--surface-2); }
.link-card b { display: block; margin-bottom: 2px; }
.link-card span { color: var(--muted); font-size: .85rem; }

.process { display: grid; gap: 12px; counter-reset: step; }
.process-step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  counter-increment: step;
}
.process-step::before {
  content: counter(step);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: .9rem;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}

.timeline { border-left: 2px solid var(--line-2); margin-left: 8px; padding-left: 20px; display: grid; gap: 16px; }
.timeline .t-item { position: relative; }
.timeline .t-item::before {
  content: "";
  position: absolute;
  left: -27px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.timeline .t-when { color: var(--accent); font-size: .8rem; font-family: var(--mono); }

/* ---------- reveal ---------- */

.reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
.reveal.visible { opacity: 1; transform: none; }
.reveal-stagger > * { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
.reveal-stagger.visible > * { opacity: 1; transform: none; }
.reveal-stagger.visible > *:nth-child(2) { transition-delay: .06s; }
.reveal-stagger.visible > *:nth-child(3) { transition-delay: .12s; }
.reveal-stagger.visible > *:nth-child(4) { transition-delay: .18s; }
.reveal-stagger.visible > *:nth-child(5) { transition-delay: .24s; }

/* ---------- lightbox ---------- */

.is-zoomable { cursor: zoom-in; transition: filter .2s, box-shadow .2s; }
.is-zoomable:hover, .is-zoomable:focus-visible { filter: brightness(1.08); }
.has-zoom { position: relative; }
.zoom-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(4, 10, 16, .78);
  color: #e8eef6;
  font-size: .8rem;
  opacity: 0;
  transform: scale(.85);
  transition: opacity .18s, transform .18s;
  pointer-events: none;
  z-index: 3;
}
.has-zoom:hover .zoom-badge, .has-zoom:focus-within .zoom-badge { opacity: 1; transform: scale(1); }

.lightbox { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; }
.lightbox[hidden] { display: none; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(3, 7, 13, .88); backdrop-filter: blur(10px); }
.lightbox-panel {
  position: relative;
  z-index: 1;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  animation: lb-in .2s ease;
}
@keyframes lb-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.lightbox-image { max-width: 100%; border-radius: var(--radius); background: #000; cursor: zoom-in; }
.lightbox-image.is-upscaled { image-rendering: pixelated; }
.lightbox-panel.is-actual { max-height: 86vh; overflow: auto; }
.lightbox-panel.is-actual .lightbox-image { max-width: none; cursor: zoom-out; }
.lightbox-btn {
  position: absolute;
  z-index: 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(10, 17, 27, .82);
  color: #e8eef6;
  border: 1px solid rgba(255, 255, 255, .2);
  cursor: pointer;
  font-size: 1.1rem;
}
.lightbox-btn:hover { background: rgba(20, 30, 44, .95); }
.lightbox-close { top: 16px; right: 16px; }
.lightbox-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-caption { color: #d8e2ee; font-size: .9rem; text-align: center; max-width: 720px; }
.lightbox-caption b { color: #fff; }
.lightbox-counter { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); color: #93a6bb; font-size: .82rem; font-family: var(--mono); }
.lightbox-hint { color: #93a6bb; font-size: .78rem; }
body.lightbox-open { overflow: hidden; }

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding: 26px 0;
  color: var(--muted);
  font-size: .88rem;
}
footer .row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.footer-inner { display: flex; flex-direction: column; gap: 14px; }
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.footer-nav a {
  padding: 4px 9px;
  border-radius: 8px;
  color: var(--muted);
  font-size: .84rem;
}
.footer-nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.footer-nav a.active { color: var(--accent); background: var(--accent-soft); }
.footer-meta { display: flex; flex-wrap: wrap; gap: 10px 18px; justify-content: space-between; align-items: center; }
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: .76rem;
  font-family: var(--mono);
  color: var(--ink-2);
}

/* ---------- mermaid ---------- */

/* Niente display:none: azzererebbe le dimensioni e Mermaid emetterebbe
   transform NaN. Il sorgente resta leggibile finché non viene sostituito. */
pre.mermaid { background: transparent; border: 0; padding: 0; overflow: visible; }
pre.mermaid:not(:has(svg)) { color: var(--muted); font-size: .8rem; }
.mermaid-error { display: block; white-space: pre-wrap; color: var(--red); }

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .nav { gap: 10px; }
}

@media (max-width: 980px) {
  .menu-toggle { display: inline-grid; }
  .nav-links {
    display: none;
    position: absolute;
    top: 62px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px 16px 16px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--line);
    margin: 0;
  }
  .nav-links.open { display: flex; }
  .nav-link { padding: 10px 12px; }
  .hero { grid-template-columns: 1fr; gap: 30px; padding: 48px 0 36px; }
}

@media (max-width: 960px) {
  .g2, .g3, .g4, .g5 { grid-template-columns: repeat(2, 1fr); }
  .gallery { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .prose-grid { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .callout-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .section-head { grid-template-columns: 1fr; gap: 10px; }
  .page-menu-title { display: none; }
  .page-menu-inner { gap: 0; }
}

@media (max-width: 600px) {
  .g2, .g3, .g4, .g5 { grid-template-columns: 1fr; }
  .gallery, .gallery.g2, .gallery.g4 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .wrap { padding: 0 16px; }
}

@media (max-width: 560px) {
  .brand-name { display: none; }
  .lang-btn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal, .reveal-stagger > * { opacity: 1; transform: none; transition: none; }
  .dot { animation: none; }
  .lightbox-panel { animation: none; }
  .btn:hover { transform: none; }
}