/* Reset essenziale e variabili */
:root {
  --c-bg: #fafaf7;
  --c-surface: #ffffff;
  --c-text: #1a1a1a;
  --c-muted: #555;
  --c-border: #e4e4de;
  --c-accent: #b35900;
  --c-accent-soft: #fff3e6;
  --c-danger: #b00020;
  --c-positive: #0f6b3a;
  --c-link: #0a4d8a;
  --c-link-hover: #072f56;

  --max-w: 760px;
  --max-w-wide: 1040px;

  --fs-base: 1.075rem;
  --lh-base: 1.7;

  --radius: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Liberation Sans", sans-serif;
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a { color: var(--c-link); text-decoration: underline; text-underline-offset: 2px; }
a:hover, a:focus { color: var(--c-link-hover); }

h1, h2, h3, h4 {
  line-height: 1.25;
  color: #111;
  font-weight: 700;
  margin: 0 0 .6em;
}
h1 { font-size: clamp(1.75rem, 3.2vw + 1rem, 2.5rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.35rem, 1.2vw + 1rem, 1.7rem); margin-top: 2.2em; padding-top: .4em; border-top: 1px solid var(--c-border); }
h3 { font-size: 1.15rem; margin-top: 1.8em; }

p, ul, ol, table, figure, blockquote { margin: 0 0 1.1em; }

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 1.2rem; }

/* Header / breadcrumbs */
.site-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: .8rem 0;
  font-size: .9rem;
}
.breadcrumbs ol {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: .4rem .5rem;
  color: var(--c-muted);
}
.breadcrumbs li + li::before {
  content: "›"; margin-right: .5rem; color: var(--c-muted);
}
.breadcrumbs [aria-current="page"] { color: var(--c-text); }

/* Article */
article { padding: 2.5rem 0 3rem; }

.article-header { margin-bottom: 2.5rem; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .78rem;
  color: var(--c-accent);
  font-weight: 700;
  margin: 0 0 .8rem;
}
.lead {
  font-size: 1.18rem;
  line-height: 1.6;
  color: #222;
}
.lead strong { color: #111; }

.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .6rem 1.2rem;
  margin: 1.8rem 0 0;
  padding: 1rem 1.2rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .9rem;
}
.meta > div { margin: 0; }
.meta dt {
  font-weight: 600;
  color: var(--c-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 .1em;
}
.meta dd { margin: 0; color: var(--c-text); }

/* Preamble (hook di apertura) */
.preamble {
  margin: 0 0 2.5rem;
  padding: .2rem 0 .2rem 1.2rem;
  border-left: 3px solid var(--c-accent);
}
.preamble-label {
  margin: 0 0 .7rem;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-accent);
}
.preamble-lead {
  font-size: 1.15rem;
  color: #111;
  line-height: 1.55;
  margin-bottom: .9em;
}
.preamble p { color: #222; }
.preamble p:last-child { margin-bottom: 0; }

/* Summary box */
.summary {
  background: var(--c-accent-soft);
  border-left: 4px solid var(--c-accent);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  margin: 0 0 2.5rem;
}
.summary h2 {
  margin-top: 0; padding-top: 0;
  border: none;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-accent);
}
.summary ul { margin: 0; padding-left: 1.2rem; }
.summary li { margin-bottom: .4em; }

/* Table of contents */
.toc {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1.2rem 1.6rem 1.3rem;
  margin: 0 0 2.5rem;
}
.toc h2 {
  margin-top: 0; padding-top: 0;
  border: none;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
}
.toc ol {
  margin: 0; padding-left: 1.4rem;
  columns: 2;
  column-gap: 2rem;
  font-size: .95rem;
}
.toc li { margin-bottom: .3em; break-inside: avoid; }

/* Sections */
section { margin-bottom: 2.5rem; }
section p, section li { color: #222; }

section ul, section ol { padding-left: 1.3rem; }
section li { margin-bottom: .35em; }

/* Timeline */
.timeline {
  list-style: none;
  padding: 0; margin: 1rem 0;
  border-left: 2px solid var(--c-border);
}
.timeline li {
  position: relative;
  padding: .1rem 0 .8rem 1.4rem;
  margin: 0;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -.42rem;
  top: .55rem;
  width: .7rem; height: .7rem;
  background: var(--c-accent);
  border: 2px solid var(--c-bg);
  border-radius: 50%;
}

/* Figures */
figure {
  margin: 1.5rem 0 2rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: .6rem;
  box-shadow: var(--shadow-sm);
}
figure img {
  border-radius: 3px;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  background: #111;
}
figcaption {
  font-size: .88rem;
  color: var(--c-muted);
  padding: .7rem .6rem .3rem;
  line-height: 1.5;
}

/* Blockquote */
blockquote {
  border-left: 4px solid var(--c-border);
  padding: .4rem 0 .4rem 1.1rem;
  color: #333;
  font-style: italic;
}
blockquote p { margin: 0; }

q::before { content: "\201C"; }
q::after { content: "\201D"; }

/* Table */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
}
caption {
  caption-side: top;
  text-align: left;
  font-size: .85rem;
  color: var(--c-muted);
  padding: .2rem .2rem .6rem;
  font-style: italic;
}
th, td {
  padding: .65rem .85rem;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
}
thead th {
  background: #f2f1ec;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--c-muted);
}
tbody tr:last-child th, tbody tr:last-child td { border-bottom: none; }
tbody th { font-weight: 600; }
td.neg { color: var(--c-danger); font-weight: 600; white-space: nowrap; }
td.pos { color: var(--c-positive); font-weight: 600; white-space: nowrap; }
tbody tr.total th, tbody tr.total td {
  border-top: 2px solid var(--c-border);
  font-weight: 700;
  background: var(--c-accent-soft);
}
td small { color: var(--c-muted); font-weight: normal; }

.callout {
  margin: 1.4rem 0;
  padding: 1rem 1.2rem;
  background: var(--c-accent-soft);
  border-left: 4px solid var(--c-accent);
  border-radius: var(--radius);
}

.note {
  font-size: .95em;
  color: var(--c-muted);
  margin-top: -.4rem;
}

.changelog { list-style: none; padding-left: 0; }
.changelog li {
  padding: .6rem 0 .6rem 1rem;
  border-left: 3px solid var(--c-border);
  margin-bottom: .4rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #f2f1ec;
  padding: .1em .35em;
  border-radius: 3px;
  font-size: .92em;
}

/* Footer */
.site-footer {
  background: #1a1a1a;
  color: #d6d5d0;
  padding: 2.5rem 0;
  margin-top: 2rem;
  font-size: .9rem;
  line-height: 1.6;
}
.site-footer p { margin: 0 0 .8rem; }
.site-footer .visits {
  display: inline-block;
  margin-top: .4rem;
  padding: .35rem .7rem;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 999px;
  font-size: .82rem;
  color: #d6d5d0;
}
.site-footer .visits strong { color: #fff; font-variant-numeric: tabular-nums; }
.site-footer .copy { color: #888; font-size: .82rem; margin-top: 1.2rem; }
.site-footer em { color: #eee; font-style: normal; }

/* Rating block */
.rating-block {
  margin: 0 0 3rem;
  padding: 1.6rem 1.8rem 1.8rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.rating-block h2 {
  margin: 0 0 .4em;
  padding-top: 0;
  border-top: none;
  font-size: 1.25rem;
}
.rating-lead { color: var(--c-muted); margin-bottom: 1.2em; }
.rating-thanks { color: var(--c-positive); margin: 0 0 1.4em; }
.rating-empty { color: var(--c-muted); font-style: italic; margin: 1.2em 0 0; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0; padding: 0; margin: -1px;
}

.rating-form fieldset { border: 0; padding: 0; margin: 0 0 1.4em; }
.rating-form legend { padding: 0; }

.star-input {
  display: inline-flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: .15rem;
  font-size: 2.2rem;
  line-height: 1;
  margin: .2rem 0 .9rem;
}
.star-input input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  pointer-events: none;
}
.star-input label {
  cursor: pointer;
  color: #d0ccbf;
  transition: color .15s ease, transform .1s ease;
  padding: 0 .05em;
}
.star-input label:hover,
.star-input label:hover ~ label,
.star-input input:checked ~ label {
  color: #f5a623;
}
.star-input label:active { transform: scale(.94); }
.star-input input:focus-visible + label {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.rating-form button {
  font: inherit;
  padding: .55rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--c-accent);
  background: var(--c-accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}
.rating-form button:hover,
.rating-form button:focus-visible { background: #944700; border-color: #944700; }

.rating-stats {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr;
  gap: 1.4rem 1.8rem;
  align-items: center;
  padding-top: 1.2rem;
  margin-top: 1rem;
  border-top: 1px solid var(--c-border);
}
.rating-avg-wrap { text-align: center; }
.rating-avg-num {
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1;
  color: #111;
  font-variant-numeric: tabular-nums;
}
.rating-avg-stars {
  display: inline-flex;
  font-size: 1.2rem;
  letter-spacing: .05em;
  margin: .3rem 0;
}
.rating-avg-stars .star { color: #d0ccbf; }
.rating-avg-stars .star.full { color: #f5a623; }
.rating-avg-stars .star.half {
  background: linear-gradient(90deg, #f5a623 50%, #d0ccbf 50%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.rating-avg-count { font-size: .82rem; color: var(--c-muted); }
.rating-avg-count strong { color: var(--c-text); }

.rating-dist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: .4rem;
}
.rating-dist li {
  display: grid;
  grid-template-columns: 2.6rem 1fr 3rem;
  gap: .7rem;
  align-items: center;
  font-size: .9rem;
}
.rating-dist-label { color: var(--c-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rating-dist-label [aria-hidden] { color: #d0ccbf; margin-left: .15em; }
.rating-dist-bar {
  display: block;
  height: .55rem;
  background: #eeece3;
  border-radius: 999px;
  overflow: hidden;
}
.rating-dist-fill {
  display: block;
  height: 100%;
  background: #f5a623;
  border-radius: 999px;
  transition: width .3s ease;
}
.rating-dist-count {
  color: var(--c-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Responsive */
@media (max-width: 640px) {
  :root { --fs-base: 1.03rem; }
  article { padding: 1.6rem 0 2rem; }
  .toc ol { columns: 1; }
  .meta { padding: .8rem 1rem; }
  .summary, .toc { padding: 1rem 1.1rem; }
  h2 { margin-top: 1.8em; }

  .rating-block { padding: 1.2rem 1.1rem 1.4rem; }
  .rating-stats { grid-template-columns: 1fr; gap: 1rem; padding-top: 1rem; }
  .star-input { font-size: 2rem; }
}

/* Focus visible per accessibilità */
:focus-visible {
  outline: 3px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Print */
@media print {
  .site-header, .site-footer, .toc { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; text-decoration: underline; }
  figure, table { page-break-inside: avoid; }
}
