/* ==========================================================================
   base.css — font locali, reset, tipografia, accessibilità di base
   ========================================================================== */

/* ── FONT LOCALI (OFL) ─────────────────────────────────────────────────────
   I file vanno in assets/fonts/ (vedi assets/fonts/LEGGIMI.md).
   Senza file il sito resta leggibile: i fallback sono metricamente vicini. */
@font-face {
  font-family: "Barlow Condensed";
  src: url("../fonts/barlow-condensed-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Barlow";
  src: url("../fonts/barlow-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Barlow";
  src: url("../fonts/barlow-500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Barlow";
  src: url("../fonts/barlow-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}

/* ── RESET ESSENZIALE ── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 5rem;
  color-scheme: light;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  min-height: 100dvh;
  background: var(--calce);
  color: var(--inchiostro);
  font-family: var(--f-testo);
  font-size: var(--t-testo);
  line-height: var(--lh-testo);
  font-kerning: normal;
  font-variant-numeric: tabular-nums; /* le cifre si allineano come in un computo */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg, video, picture { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
table { border-collapse: collapse; width: 100%; }
p, li, dd, figcaption { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; }

/* ── TIPOGRAFIA ── */
h1, h2, h3, .display {
  font-family: var(--f-display);
  font-weight: 600;
  line-height: var(--lh-display);
  letter-spacing: -0.01em;
  hyphens: manual;
}
h1, .t-h1 { font-size: var(--t-h1); }
h2, .t-h2 { font-size: var(--t-h2); }
h3, .t-h3 { font-size: var(--t-h3); line-height: 1; }
h4 { font-size: var(--t-testo); font-weight: 500; }

p + p { margin-top: 0.85em; }
.lead { font-size: var(--t-lead); line-height: 1.35; max-width: 34ch; }
.prosa { max-width: var(--misura); }
.prosa > * + * { margin-top: 0.85em; }
.prosa ul { padding-left: 1.1em; }
.prosa li + li { margin-top: 0.35em; }

/* Etichetta tecnica: mono, maiuscolo spaziato. Mai sotto i 13 px. */
.dato {
  font-family: var(--f-mono);
  font-size: var(--t-dato);
  line-height: 1.4;
  letter-spacing: var(--track-dato);
  text-transform: uppercase;
}
.dato--basso { text-transform: none; letter-spacing: 0; }
.fg-2 { color: var(--fg-2); }

abbr[title] { text-decoration: underline dotted; text-underline-offset: 0.2em; cursor: help; }
strong { font-weight: 500; }

/* ── LINK ──
   Sottolineatura sempre presente (il colore non è l'unico indicatore).   */
a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  text-decoration-color: var(--accento);
  transition: text-decoration-thickness var(--dur-breve) var(--ease);
}
a:hover { text-decoration-thickness: 2px; }
/* Link a fine paragrafo su una riga propria, con area di tocco da 44 px. */
.link-blocco { display: block; width: fit-content; padding-block: 0.75rem; }

/* ── FUOCO VISIBILE ──
   Anello pieno, colore preso dalla superficie (--fuoco): ≥3:1 ovunque.     */
:focus-visible {
  outline: 3px solid var(--fuoco);
  outline-offset: 3px;
}
:focus:not(:focus-visible) { outline: none; }

/* ── UTILITÀ DI ACCESSIBILITÀ ── */
.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.salta {
  position: absolute; left: var(--s-4); top: var(--s-4);
  z-index: var(--z-salta);
  padding: var(--s-3) var(--s-4);
  background: var(--paglia); color: var(--inchiostro);
  font-weight: 500;
  transform: translateY(-200%);
}
.salta:focus { transform: none; }

::selection { background: var(--paglia); color: var(--inchiostro); }

/* ── LAYOUT ── */
.contenitore {
  width: 100%;
  max-width: var(--larghezza);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.sezione { padding-block: var(--s-sezione); }
.griglia {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: var(--s-4);
}
@media (min-width: 48em) {
  .griglia { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--s-5); }
}

/* ── MOVIMENTO RIDOTTO: rispetto totale ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── TRANSIZIONI TRA PAGINE (View Transitions, cross-document) ──
   Funziona solo su http(s) e browser che la supportano; altrove si ignora. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: 220ms var(--ease) both vt-esce; }
  ::view-transition-new(root) { animation: 360ms var(--ease) both vt-entra; }
  .sito-testata { view-transition-name: testata; }
}
@keyframes vt-esce  { to   { opacity: 0; transform: translateY(-0.5rem); } }
@keyframes vt-entra { from { opacity: 0; transform: translateY(0.75rem); } }

/* ── STAMPA: chi stampa la checklist deve avere solo la checklist utile ── */
@media print {
  .sito-testata, .sito-piede, .indice-interventi, .mirino, form { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .sup-cotto, .sup-inchiostro, .sup-intonaco { background: #fff !important; color: #000 !important; }
  a { text-decoration: none; }
}

/* Verso della transizione (impostato da main.js): tornando alla home si scende. */
@media (prefers-reduced-motion: no-preference) {
  html:active-view-transition-type(indietro)::view-transition-new(root) { animation-name: vt-entra-giu; }
}
@keyframes vt-entra-giu { from { opacity: 0; transform: translateY(-0.75rem); } }
