/* ============================================================
   NM OS™ — theme.css (design system condiviso per tutti i tool)
   ------------------------------------------------------------
   TEMA CHIARO PREDEFINITO (decisione dell'11/09/2026, Brief §10).
   Il dark è opzionale: <html data-theme="dark">, gestito da
   theme-toggle.js (bottone sole/luna, localStorage "nmos-theme",
   "?theme=dark" nell'URL forza il dark per la sessione).

   REBRAND IN 60 SECONDI: cambia solo le variabili nel blocco
   :root qui sotto (colori, font, raggio). Tutto il resto segue.
   Se vuoi anche il dark sul tuo brand, ripeti le stesse chiavi
   nel blocco :root[data-theme="dark"].
   Esempio "brand blu":
     --accent: #2563EB;  --accent-hover: #3B82F6;
     --accent-glow: rgba(37,99,235,.30);
     --accent-ink: #1D4ED8;   (testo/link/icone in accento)
     --on-accent: #FFFFFF;    (testo sopra i riempimenti in accento)
   ============================================================ */

:root {
  color-scheme: light;

  /* Sfondi */
  --bg: #F6F7FB;
  --surface: #FFFFFF;
  --surface-2: #EEF1F7;
  --border: rgba(15, 23, 42, 0.10);

  /* Accento primario (Neon Lime): riempimenti SEMPRE con testo scuro sopra */
  --accent: #C8FF00;
  --accent-hover: #D9FF4D;
  --accent-glow: rgba(124, 185, 0, 0.30);
  --accent-ink: #5C8A00;          /* testo, link, icone in accento su fondo chiaro (AA) */
  --accent-ink-hover: #4A7000;
  --on-accent: #05060A;           /* testo sopra bottoni/riempimenti accent */
  --accent-soft: rgba(124, 185, 0, 0.12);  /* sfondi tenui in accento */

  /* Accento secondario (Electric Violet) */
  --accent-2: #6D28D9;
  --violet: var(--accent-2);
  --violet-soft: rgba(109, 40, 217, 0.10);

  /* Colori di fase (versioni scure per contrasto su bianco) */
  --valida: #0891B2;
  --costruisci: #65A30D;
  --vendi: #EA580C;
  --duplica: #7C3AED;
  --badge-mix: 12%;               /* i badge di fase: sfondo al 12% del colore */

  /* Stati */
  --ok: #16A34A;
  --warn: #D97706;
  --err: #DC2626;

  /* Testo */
  --text: #0B0F19;
  --text-2: #4B5563;
  --muted: #8A93A6;
  --text-3: var(--muted);

  /* Terminali / blocchi codice: restano scuri anche in chiaro (voluto) */
  --terminal-bg: #0C0E16;
  --terminal-text: #F5F7FA;
  --terminal-border: rgba(255, 255, 255, 0.08);

  /* Overlay, righe, mesh del hero (molto tenue in chiaro) */
  --overlay: rgba(15, 23, 42, 0.35);
  --row-hover: rgba(15, 23, 42, 0.03);
  --mesh-1: var(--accent-glow);
  --mesh-2: rgba(109, 40, 217, 0.16);
  --mesh-3: rgba(8, 145, 178, 0.12);
  --mesh-opacity: .45;

  /* Font */
  --font-display: "Unbounded", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  /* Forma */
  --radius: 16px;
  --radius-sm: 10px;
  --pill: 999px;
  --shadow-soft: 0 8px 30px rgba(15, 23, 42, 0.08);   /* ombre morbide e grigie al posto dei glow */
  --shadow-card: var(--shadow-soft);
  --shadow-glow: 0 0 0 1px var(--accent-glow), 0 8px 30px rgba(124, 185, 0, 0.18); /* solo elementi attivi/CTA */

  /* Layout */
  --container: 1120px;
  --nav-h: 64px;
}

/* ---------- Tema DARK (identico al design system originale) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #05060A;
  --surface: #0C0E16;
  --surface-2: #131626;
  --border: rgba(255, 255, 255, 0.08);

  --accent: #C8FF00;
  --accent-hover: #D9FF4D;
  --accent-glow: rgba(200, 255, 0, 0.35);
  --accent-ink: #C8FF00;
  --accent-ink-hover: #D9FF4D;
  --on-accent: #05060A;
  --accent-soft: rgba(200, 255, 0, 0.06);

  --accent-2: #8B5CF6;
  --violet-soft: rgba(139, 92, 246, 0.14);

  --valida: #00E5FF;
  --costruisci: #C8FF00;
  --vendi: #FF6B35;
  --duplica: #8B5CF6;
  --badge-mix: 0%;

  --ok: #22C55E;
  --warn: #F59E0B;
  --err: #EF4444;

  --text: #F5F7FA;
  --text-2: #A3A9B8;
  --muted: #6B7280;

  --overlay: rgba(0, 0, 0, 0.5);
  --row-hover: rgba(255, 255, 255, 0.02);
  --mesh-2: rgba(139, 92, 246, 0.35);
  --mesh-3: rgba(0, 229, 255, 0.2);
  --mesh-opacity: .35;

  --shadow-soft: none;
  --shadow-card: none;
  --shadow-glow: 0 0 0 1px var(--accent-glow), 0 0 32px var(--accent-glow);
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}
img, video, canvas { max-width: 100%; display: block; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { color: var(--accent-ink-hover); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.2rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0 0 1em; color: var(--text-2); }
small, .muted { color: var(--muted); }
code, pre, .mono { font-family: var(--font-mono); font-size: .9em; }
.terminal { background: var(--terminal-bg); color: var(--terminal-text); border: 1px solid var(--terminal-border); border-radius: var(--radius-sm); padding: 1rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ---------- Layout ---------- */
.container { width: min(var(--container), 100% - 2rem); margin-inline: auto; }
.section { padding: clamp(3rem, 8vw, 6rem) 0; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { text-align: center; }

/* ---------- Navbar ---------- */
.nav {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.logo { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; color: var(--text); letter-spacing: .02em; white-space: nowrap; }
.logo .os { color: var(--accent-ink); }
.logo .cursor { display: inline-block; width: .55em; color: var(--accent-ink); animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* ---------- Toggle tema (sole/luna, montato da theme-toggle.js) ---------- */
.theme-toggle {
  width: 36px; height: 36px; flex: none; padding: 0;
  display: inline-grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer;
  transition: color .18s ease, border-color .18s ease, transform .18s ease;
}
.theme-toggle:hover { color: var(--accent-ink); border-color: var(--accent-ink); transform: translateY(-1px); }
.theme-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
.theme-toggle .ico-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: none; }
.theme-toggle.fixed { position: fixed; top: .85rem; right: .85rem; z-index: 120; box-shadow: var(--shadow-soft); }

/* ---------- Bottoni ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .85rem 1.5rem; border-radius: var(--pill);
  font-family: var(--font-body); font-weight: 600; font-size: 1rem; line-height: 1;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 0 24px var(--accent-glow); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); box-shadow: var(--shadow-glow); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent-ink); color: var(--accent-ink); }
.btn-danger { background: transparent; color: var(--err); border-color: var(--err); }
.btn-sm { padding: .5rem 1rem; font-size: .875rem; }
.btn-lg { padding: 1.05rem 2rem; font-size: 1.1rem; }
.btn-block { width: 100%; }

/* ---------- Card / pannelli ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  box-shadow: var(--shadow-card);
}
.card-2 { background: var(--surface-2); }
.card.active, .card.glow { border-color: var(--accent-ink); box-shadow: var(--shadow-glow); }
.card h3 { margin-top: 0; }

/* ---------- Badge / pill ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .75rem; border-radius: var(--pill);
  font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge-accent { color: var(--accent-ink); border-color: var(--accent-glow); background: var(--accent-soft); }
.badge-valida { color: var(--valida); background: color-mix(in srgb, var(--valida) var(--badge-mix), var(--surface-2)); }
.badge-costruisci { color: var(--costruisci); background: color-mix(in srgb, var(--costruisci) var(--badge-mix), var(--surface-2)); }
.badge-vendi { color: var(--vendi); background: color-mix(in srgb, var(--vendi) var(--badge-mix), var(--surface-2)); }
.badge-duplica { color: var(--duplica); background: color-mix(in srgb, var(--duplica) var(--badge-mix), var(--surface-2)); }
.badge-ok { color: var(--ok); }
.badge-warn { color: var(--warn); }
.badge-err { color: var(--err); }

/* ---------- Form ---------- */
label { display: block; font-size: .875rem; font-weight: 600; color: var(--text-2); margin-bottom: .35rem; }
input, select, textarea {
  width: 100%; padding: .8rem 1rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font-body); font-size: 1rem; outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--accent-ink); box-shadow: 0 0 0 3px var(--accent-glow); }
textarea { min-height: 120px; resize: vertical; }
select { appearance: none; }
.field { margin-bottom: 1rem; }
.check { display: flex; align-items: flex-start; gap: .6rem; font-size: .875rem; color: var(--text-2); font-weight: 400; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent-ink); flex: none; }
.help { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.error { color: var(--err); font-size: .875rem; }
.success { color: var(--ok); font-size: .875rem; }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface); }
tr:hover td { background: var(--row-hover); }

/* ---------- Alert / disclaimer ---------- */
.alert {
  padding: 1rem 1.25rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: .9rem;
}
.alert-accent { border-color: var(--accent-glow); }
.alert-warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.disclaimer { font-size: .8rem; color: var(--muted); line-height: 1.5; }

/* ---------- Hero con gradient mesh animato ---------- */
.hero { position: relative; overflow: hidden; padding: clamp(4rem, 12vw, 8rem) 0; }
.hero::before {
  content: ""; position: absolute; inset: -40%; z-index: -1; opacity: var(--mesh-opacity);
  background:
    radial-gradient(40% 40% at 30% 30%, var(--mesh-1), transparent 60%),
    radial-gradient(35% 35% at 70% 60%, var(--mesh-2), transparent 60%),
    radial-gradient(30% 30% at 50% 80%, var(--mesh-3), transparent 60%);
  animation: mesh 18s ease-in-out infinite alternate;
  filter: blur(40px);
}
@keyframes mesh { from { transform: translate(-4%, -2%) rotate(0deg); } to { transform: translate(4%, 3%) rotate(8deg); } }
.eyebrow { font-family: var(--font-mono); font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 1rem; }
.lead { font-size: 1.2rem; color: var(--text-2); max-width: 60ch; }

/* ---------- Motion ---------- */
.fade-up { animation: fadeUp .4s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); } 50% { box-shadow: 0 0 0 10px transparent; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Utility ---------- */
.kpi { font-family: var(--font-display); font-size: 2.2rem; font-weight: 800; color: var(--accent-ink); line-height: 1; }
.progress { height: 8px; background: var(--surface-2); border-radius: var(--pill); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: var(--pill); box-shadow: 0 0 12px var(--accent-glow); transition: width .4s ease; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.footer { padding: 2rem 0; border-top: 1px solid var(--border); font-size: .85rem; color: var(--muted); }
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--accent-ink); color: var(--text);
  padding: .8rem 1.25rem; border-radius: var(--pill); box-shadow: var(--shadow-glow); z-index: 100;
}
@media (max-width: 640px) {
  .btn { width: 100%; }
  .nav { height: auto; min-height: var(--nav-h); padding: .6rem 0; }
  .nav .container { flex-wrap: wrap; row-gap: .5rem; }
  .nav .btn { width: auto; }
  .nav .row { gap: .5rem; }
}
