/* ==========================================================================
   Hoomin — foglio di stile principale
   --------------------------------------------------------------------------
   Direzione grafica: "tecnico". Look da documentazione/specifica: etichette
   e titoli in monospace, bordi sottili al posto delle ombre, angoli netti,
   griglia a colonne asimmetriche, un solo colore di accento.

   Indice
     1. Design token (colori, spaziature, tipografia) + tema scuro
     2. Reset e base
     3. Layout e utility
     4. Componenti: header, bottoni, hero, demo widget
     5. Sezioni: funzionalità, step, privacy, confronto, codice, FAQ, CTA
     6. Footer, pagine secondarie
     7. Animazioni e preferenze utente

   NB: nessun font esterno (privacy): si usano gli stack di sistema.
   Dopo ogni modifica esegui tools/asset-hash.sh per aggiornare ?v= negli HTML.
   ========================================================================== */

/* 1. DESIGN TOKEN ========================================================= */
:root {
  --bg: #f3f3ef;
  --bg-alt: #eaeae4;
  --surface: #fbfbf8;
  --text: #111110;
  --text-muted: #55554f;
  --border: #cbcbc2;       /* linee sottili */
  --line: #111110;         /* linee strutturali */
  --grid: rgb(17 17 16 / 6%);

  --accent: #c2410c;       /* arancio segnale */
  --accent-strong: #9a3412;
  --on-accent: #ffffff;
  --danger: #b42318;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;

  --container: 1160px;
  --gutter: clamp(16px, 4vw, 32px);
  --section-y: clamp(56px, 8vw, 96px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0c;
    --bg-alt: #121214;
    --surface: #101012;
    --text: #ececE6;
    --text-muted: #9a9a92;
    --border: #2a2a2d;
    --line: #5b5b60;
    --grid: rgb(236 236 230 / 5%);

    --accent: #ff8f4d;
    --accent-strong: #ffb07c;
    --on-accent: #0b0b0c;
    --danger: #ff7b6b;
  }
}

/* 2. RESET E BASE ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

img, svg { display: block; max-width: 100%; }
h1, h2, h3 { font-family: var(--font-mono); line-height: 1.15; letter-spacing: -0.03em; margin: 0 0 0.6em; text-wrap: balance; }
h1 { font-size: clamp(1.75rem, 4vw, 2.9rem); font-weight: 700; line-height: 1.1; }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.75rem); font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; }
p { margin: 0 0 1em; }
a { color: var(--text); text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
code { font-family: var(--font-mono); font-size: 0.9em; }

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

/* 3. LAYOUT E UTILITY ===================================================== */
.container { width: min(100% - 2 * var(--gutter), var(--container)); margin-inline: auto; }
.narrow { max-width: 760px; }

.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 {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  background: var(--accent); color: var(--on-accent);
  padding: 10px 16px; font-family: var(--font-mono); font-weight: 700;
}
.skip-link:focus { top: 16px; color: var(--on-accent); }

.eyebrow {
  font-family: var(--font-mono); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 1em;
}
.lead { font-size: clamp(1.05rem, 1.5vw, 1.2rem); color: var(--text-muted); max-width: 58ch; }
.note { font-size: 0.9rem; color: var(--text-muted); border-left: 2px solid var(--accent); padding-left: 12px; }

.section { padding-block: var(--section-y); border-top: 1px solid var(--border); }
.section-alt { background: var(--bg-alt); }

/* Intestazione a sinistra, contenuto a destra: la testata resta in vista allo scroll */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr); gap: clamp(24px, 5vw, 72px); align-items: start; }
.section-head { margin: 0; }
.section-head p:last-child { color: var(--text-muted); margin-bottom: 0; }
.section-body { min-width: 0; }
@media (min-width: 901px) {
  .section-head { position: sticky; top: 88px; }
}
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .section-head { margin-bottom: 8px; }
}

/* 4. COMPONENTI =========================================================== */

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 56px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand-mark { width: 28px; height: 28px; color: var(--accent); }
.brand-mark path { stroke: var(--on-accent); }

.site-nav ul { display: flex; gap: 0; list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: 18px 14px 16px; border-bottom: 2px solid transparent;
  font-family: var(--font-mono); font-size: 0.82rem; font-weight: 500;
  color: var(--text-muted); text-decoration: none;
}
.site-nav a:hover { color: var(--text); border-bottom-color: var(--accent); }

.nav-toggle {
  display: none; width: 44px; height: 44px; border: 1px solid var(--line);
  background: transparent; cursor: pointer; position: relative;
}
.nav-toggle-bar, .nav-toggle-bar::before, .nav-toggle-bar::after {
  position: absolute; left: 12px; width: 18px; height: 2px; background: var(--text);
  transition: transform 0.2s, opacity 0.2s; content: "";
}
.nav-toggle-bar { top: 21px; }
.nav-toggle-bar::before { left: 0; top: -6px; }
.nav-toggle-bar::after { left: 0; top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .site-nav:not(.site-nav-static) {
    position: absolute; inset: 56px 0 auto; padding: 0 var(--gutter) 8px;
    background: var(--bg); border-bottom: 1px solid var(--line); display: none;
  }
  .site-nav.is-open { display: block; }
  .site-nav:not(.site-nav-static) ul { flex-direction: column; }
  .site-nav:not(.site-nav-static) a { padding: 14px 0; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
}

/* Bottoni */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 12px 20px;
  font-family: var(--font-mono); font-weight: 600; font-size: 0.9rem; text-decoration: none;
  border: 1px solid var(--line); transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary::after { content: "→"; }
.btn-primary:hover { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text); }
.btn-light { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-light::after { content: "→"; }
.btn-light:hover { color: var(--on-accent); background: var(--accent-strong); border-color: var(--accent-strong); }

/* Hero */
.hero { position: relative; padding-block: clamp(40px, 7vw, 88px); border-bottom: 1px solid var(--line); }
/* Griglia millimetrata, sfumata verso il basso */
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: linear-gradient(#000 40%, transparent);
  mask-image: linear-gradient(#000 40%, transparent);
}
.hero-grid { position: relative; display: grid; grid-template-columns: 1.25fr 1fr; gap: clamp(32px, 6vw, 72px); align-items: start; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-block: 28px; }

/* Specifiche in riga, come una riga di intestazione tecnica */
.hero-badges {
  display: flex; flex-wrap: wrap; list-style: none; padding: 0; margin: 0;
  border: 1px solid var(--border); background: var(--bg);
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted);
}
.hero-badges li { padding: 8px 14px; border-right: 1px solid var(--border); }
.hero-badges li:last-child { border-right: 0; }
.hero-badges li::before { content: "▸ "; color: var(--accent); }

@media (max-width: 520px) { .hero-actions .btn { width: 100%; } }
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-badges li { border-right: 0; border-bottom: 1px solid var(--border); width: 100%; }
  .hero-badges li:last-child { border-bottom: 0; }
}

/* Demo card + widget: pannello con barra del titolo */
.demo-card { background: var(--surface); border: 1px solid var(--line); padding-bottom: 20px; }
.demo-title {
  margin: 0; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--bg-alt);
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
}
.demo-title::before { content: "● "; color: var(--accent); }
.demo-card > :not(.demo-title) { margin-inline: 20px; }
.demo-hint { margin-top: 16px; margin-bottom: 16px; font-size: 0.9rem; color: var(--text-muted); }

.widget {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px; border: 1px solid var(--line);
  background: var(--bg); overflow: hidden;
}
.widget-check {
  display: inline-flex; align-items: center; gap: 12px; padding: 4px; margin: -4px;
  background: none; border: 0; color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.widget-check:disabled { cursor: default; }
.widget-box {
  display: grid; place-items: center; width: 26px; height: 26px; flex: none;
  border: 2px solid var(--text); background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
}
.widget-box svg { width: 16px; height: 16px; color: var(--on-accent); opacity: 0; transition: opacity 0.15s; }
.widget-brand { font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; color: var(--text-muted); text-transform: uppercase; }
.widget-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; }
.widget-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.1s linear; }

.widget[data-state="working"] .widget-box { border-color: var(--accent); border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
.widget[data-state="done"] .widget-box { background: var(--accent); border-color: var(--accent); }
.widget[data-state="done"] .widget-box svg { opacity: 1; }
.widget[data-state="error"] .widget-box { border-color: var(--danger); }

.demo-status { margin-top: 12px; margin-bottom: 0; font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted); min-height: 1.5em; }
.demo-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 16px; margin-bottom: 0; border: 1px solid var(--border); }
.demo-stats div { padding: 10px 12px; border-right: 1px solid var(--border); }
.demo-stats div:last-child { border-right: 0; }
.demo-stats dt { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.demo-stats dd { margin: 0; font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; }

/* 5. SEZIONI ============================================================== */

/* Funzionalità: celle a bordi condivisi */
.features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--border); }
.feature { padding: 24px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); }
.feature p { color: var(--text-muted); margin: 0; font-size: 0.97rem; }
.feature-id { display: block; margin-bottom: 20px; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; color: var(--accent); }
@media (max-width: 620px) { .features { grid-template-columns: 1fr; } }

/* Step: elenco numerato con filo conduttore */
.steps { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.step { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 8px 16px; padding: 24px 0; border-bottom: 1px solid var(--border); }
.step-num { grid-row: span 2; font-family: var(--font-mono); font-size: 2.25rem; font-weight: 700; line-height: 1; letter-spacing: -0.04em; color: var(--accent); }
.step h3 { margin: 0; }
.step p { color: var(--text-muted); margin: 0; }
@media (max-width: 520px) { .step { grid-template-columns: 56px minmax(0, 1fr); } .step-num { font-size: 1.6rem; } }

/* Privacy: due colonne in stile "diff" */
.privacy-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); background: var(--surface); }
.privacy-col + .privacy-col { border-left: 1px solid var(--line); }
.privacy-col h3 {
  margin: 0; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--bg-alt);
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
}
.privacy-col .checklist { padding: 20px; }
@media (max-width: 760px) {
  .privacy-grid { grid-template-columns: 1fr; }
  .privacy-col + .privacy-col { border-left: 0; border-top: 1px solid var(--line); }
}

.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.checklist li { position: relative; padding-left: 28px; font-size: 0.97rem; }
.checklist li::before { position: absolute; left: 0; top: 0; font-family: var(--font-mono); font-weight: 700; }
.checklist-no li::before { content: "−"; color: var(--danger); }
.checklist-yes li::before { content: "+"; color: var(--accent); }

.compliance { display: grid; grid-template-columns: repeat(3, 1fr); list-style: none; padding: 0; margin: 24px 0 0; border-top: 1px solid var(--line); border-left: 1px solid var(--border); }
.compliance li { display: grid; gap: 6px; align-content: start; padding: 20px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); }
.compliance strong { font-family: var(--font-mono); font-size: 0.88rem; }
.compliance span { color: var(--text-muted); font-size: 0.92rem; }
@media (max-width: 860px) { .compliance { grid-template-columns: 1fr; } }

/* Tabella di confronto */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }
.compare { width: 100%; border-collapse: collapse; min-width: 520px; }
.compare th, .compare td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--border); }
.compare thead th { font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); background: var(--bg-alt); border-bottom: 1px solid var(--line); }
.compare thead th:last-child { color: var(--accent); }
.compare tbody tr:last-child > * { border-bottom: 0; }
.compare tbody th { font-weight: 600; }
.compare td:last-child { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.compare .yes, .compare .no { font-family: var(--font-mono); font-size: 0.88rem; font-weight: 600; }
.compare .yes { color: var(--accent); }
.compare .yes::before { content: "+ "; }
.compare .no { color: var(--text-muted); }
.compare .no::before { content: "− "; }

/* Codice (sempre su fondo scuro, anche nel tema chiaro) */
.code-tabs { display: grid; gap: 16px; min-width: 0; }
.code { margin: 0; overflow: hidden; background: #0b0b0c; border: 1px solid var(--line); }
.code figcaption { padding: 9px 16px; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #9a9a92; background: #121214; border-bottom: 1px solid #2a2a2d; }
.code figcaption::before { content: "$ "; color: #ff8f4d; }
.code pre { margin: 0; padding: 16px; overflow-x: auto; color: #ececE6; font-size: 0.85rem; line-height: 1.65; }

/* FAQ: elenco a righe con numerazione */
.faq { border-top: 1px solid var(--line); counter-reset: q; }
.faq details { border-bottom: 1px solid var(--border); counter-increment: q; }
.faq summary {
  cursor: pointer; list-style: none; padding: 18px 48px 18px 0; font-weight: 600; position: relative;
  display: flex; gap: 16px; align-items: baseline;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "Q" counter(q, decimal-leading-zero); flex: none; font-family: var(--font-mono); font-size: 0.78rem; color: var(--accent); }
.faq summary::after {
  content: "+"; position: absolute; right: 4px; top: 14px;
  font-family: var(--font-mono); font-size: 1.4rem; font-weight: 400; color: var(--accent);
}
.faq details[open] summary::after { content: "−"; }
.faq summary:hover { color: var(--accent); }
.faq details p { padding: 0 48px 20px 44px; margin: 0; color: var(--text-muted); }

/* CTA: blocco invertito */
.cta { padding-block: clamp(56px, 8vw, 96px); background: var(--text); color: var(--bg); border-top: 1px solid var(--line); }
.cta-inner > * { max-width: 760px; }
.cta h2 { font-size: clamp(1.5rem, 3.4vw, 2.25rem); }
.cta h2::after { content: "_"; margin-left: 2px; color: var(--accent); animation: blink 1.1s steps(1) infinite; }
.cta p { color: color-mix(in srgb, var(--bg) 70%, transparent); margin-bottom: 28px; }
.cta-inner > p { max-width: 56ch; }

/* 6. FOOTER E PAGINE SECONDARIE ========================================== */
.site-footer { padding-block: 28px; border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.footer-inner p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; list-style: none; padding: 0; margin: 0; }

.prose h2 { font-size: 1.15rem; margin-top: 2em; }
.prose p { color: var(--text-muted); }
.prose .note { margin-top: 3em; }

.error-page { min-height: 100vh; display: grid; place-items: center; padding: var(--gutter); }
.error-page .container { padding: clamp(24px, 5vw, 48px); border: 1px solid var(--line); background: var(--surface); }
.error-page .lead { margin-bottom: 28px; }

/* 7. ANIMAZIONI E PREFERENZE ============================================= */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0; } }

/* Gli elementi .reveal compaiono allo scroll solo se JS è attivo (classe .js su <html>) */
.js .reveal { opacity: 0; transition: opacity 0.45s ease; }
.js .reveal.is-visible { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .js .reveal { opacity: 1; }
}
