/* ===========================
   Stili base e tema
   =========================== */
:root {
  --bg: #ffffff;
  --fg: #101418;
  --muted: #5b6670;
  --border: #e7ebef;
  --primary: #e53935;   /* accento rosso elegante */
  --primary-ink: #ffffff;
  --surface: #f7f9fb;
  --surface-2: #eef3f7;
  --success: #1b9e59;

  --radius: 16px;
  --shadow: 0 10px 30px rgba(16, 20, 24, 0.08);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI",
               Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans",
               Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1114;
    --fg: #e6edf3;
    --muted: #9aa7b3;
    --border: #1f2a34;
    --surface: #151a20;
    --surface-2: #11161c;
    --primary-ink: #ffffff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

/* Override manuale del tema */
html[data-theme="light"] {
  --bg: #ffffff;
  --fg: #101418;
  --muted: #5b6670;
  --border: #e7ebef;
  --surface: #f7f9fb;
  --surface-2: #eef3f7;
  --primary-ink: #ffffff;
  --shadow: 0 10px 30px rgba(16, 20, 24, 0.08);
}
html[data-theme="dark"] {
  --bg: #0e1114;
  --fg: #e6edf3;
  --muted: #9aa7b3;
  --border: #1f2a34;
  --surface: #151a20;
  --surface-2: #11161c;
  --primary-ink: #ffffff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
/* "auto" = segue il sistema */

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

.container {
  width: min(1100px, 94vw);
  margin-inline: auto;
}

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

/* Skip link per accessibilità */
.skiplink {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skiplink:focus {
  position: fixed;
  left: 16px;
  top: 16px;
  width: auto;
  height: auto;
  background: var(--fg);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 1000;
}

/* ===========================
   Header / Nav
   =========================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}
.brand-logo {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.brand-text { letter-spacing: 0.2px; }

.top-nav a {
  margin: 0 10px;
  padding: 6px 10px;
  border-radius: 10px;
}
.top-nav a:hover {
  background: var(--surface);
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .06s ease, box-shadow .2s ease, background .2s ease;
  text-decoration: none;
  font-weight: 600;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: color-mix(in oklab, var(--primary), #000 8%);
}
.btn.success {
  background: var(--success);
  color: #ffffff;
  border-color: color-mix(in oklab, var(--success), #000 8%);
}
.btn.ghost {
  background: transparent;
  border-color: var(--border);
}

/* ===========================
   Hero
   =========================== */
.hero {
  padding: 64px 0 24px;
  background: linear-gradient(
    180deg,
    color-mix(in oklab, var(--surface) 80%, transparent) 0%,
    transparent 100%
  );
}
.hero-inner { text-align: center; }
.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 3.6vw, 44px);
}
.lead {
  font-size: clamp(16px, 1.8vw, 20px);
  color: var(--muted);
  margin: 6px auto 20px;
  max-width: 850px;
}
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin: 18px 0 6px;
}
.badges {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  color: var(--muted);
}
.badges li {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 999px;
}

/* ===========================
   Sommario (TOC) sticky
   =========================== */
.toc {
  position: sticky;
  top: 70px;
  margin: 12px 0 0;
}
.toc-inner {
  width: min(1100px, 94vw);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.toc h2 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--muted);
}
.toc ol {
  margin: 0;
  padding-left: 18px;
}
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }

/* ===========================
   Sezioni
   =========================== */
.section {
  padding: clamp(28px, 6vw, 64px) 0;
}
.section-alt {
  background: var(--surface);
  border-block: 1px solid var(--border);
}
.section h2 {
  margin: 0 0 16px;
  font-size: clamp(22px, 2.8vw, 34px);
}

/* Steps numerati belli */
.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
}
.steps li {
  counter-increment: step;
  margin: 0 0 12px;
  padding-left: 44px;
  position: relative;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--primary);
  color: var(--primary-ink);
  display: inline-grid;
  place-items: center;
  font-weight: 700;
}

/* Screenshot */
.shot {
  margin: 18px 0 6px;
}
.shot figcaption {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
}

/* Cards / checklist */
.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 10px;
  font-size: 18px;
}
.checklist { margin: 0; padding-left: 22px; }

/* Note */
.note {
  background: color-mix(in oklab, var(--primary) 10%, var(--surface));
  border: 1px dashed color-mix(in oklab, var(--primary), var(--border) 70%);
  padding: 12px 14px;
  border-radius: 12px;
  color: color-mix(in oklab, var(--fg), var(--muted));
  margin-top: 12px;
}

/* CTA centrata */
.center { text-align: center; }

/* ===========================
   Footer
   =========================== */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.footer-inner {
  padding: 22px 0;
  color: var(--muted);
  font-size: 14px;
}
.muted { color: var(--muted); }

/* ===========================
   Back to top
   =========================== */
.to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
  transform: translateY(6px);
  cursor: pointer;
}
.to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ===========================
   Responsività
   =========================== */
@media (max-width: 860px) {
  .header-inner {
    grid-template-columns: 1fr auto;
  }
  .top-nav { display: none; } /* nav ridotta su mobile; le ancore sono nel TOC */
  .cards { grid-template-columns: 1fr; }
}

/* ===========================
   Print
   =========================== */
@media print {
  .site-header,
  .toc,
  .to-top,
  .cta-row,
  .hero .badges { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .note { box-shadow: none; }
}
