/* ═══════════════════════════════════════════════════════════════════
   neri.css — Estetica pergamena per Tomismo
   MOBILE-FIRST: default = mobile, media query → desktop.
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║
   Mobile-first: tutti i selettori base valgono per mobile (<640px).
   Desktop upgrade: @media (min-width: 768px) e (min-width: 1024px).
   Touch: target minimi 44px, spazi ariosi, gesture facili.
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

/* Font caricato via <link> in index.html (Crimson Pro + Inter).
   @import rimosso per evitare render-blocking duplicato. */

/* ── Design Tokens ───────────────────────────────────────────── */
:root {
  --ink:        #2b2117;
  --ink-muted:  #6b5b3e;
  --bg:         #f4ecd8;
  --paper:      #fbf6e9;
  --paper-dim:  #f0e8d4;
  --accent:     #7a1f1f;
  --accent-golden: #8b6914;
  --hl:         #ffd24d;
  --border:     #d8c9a6;
  --border-dim: #c8b68c;
  --shadow:     rgba(43,33,23,0.1);

  --serif:  "TeX Gyre Pagella","Crimson Pro","Palatino Linotype","Georgia",serif;
  --sans:   "Inter","Segoe UI",system-ui,sans-serif;

  /* Scala fluida — mobile-first, cresce con viewport */
  --fs-xs:   clamp(0.65rem, 0.6rem + 0.25vw, 0.72rem);
  --fs-sm:   clamp(0.75rem, 0.7rem + 0.25vw, 0.82rem);
  --fs-base: clamp(0.95rem, 0.9rem + 0.25vw, 1rem);
  --fs-md:   clamp(1.05rem, 1.0rem + 0.25vw, 1.125rem);
  --fs-lg:   clamp(1.2rem,  1.1rem + 0.5vw,  1.35rem);
  --fs-xl:   clamp(1.4rem,  1.25rem + 0.75vw, 1.65rem);
  --fs-2xl:  clamp(1.6rem,  1.4rem + 1vw,    2rem);

  --header-h: 52px;
  --radius:   8px;
  --radius-sm: 6px;
}

/* ── Reset ───────────────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--serif);
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
img,svg { display: block; max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input,select,textarea { font: inherit; }

/* ── Accesso rapido ──────────────────────────────────────────── */
.skip-link {
  position: absolute; top: -100%; left: .75rem;
  background: var(--paper); color: var(--ink);
  padding: .5rem .8rem; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  z-index: 10000; font-size: var(--fs-sm); text-decoration: none;
}
.skip-link:focus { top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ══════════════════════════════════════════════════════════════
   HEADER — mobile compatto
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .4rem;
  padding: 0 .6rem;
  box-shadow: 0 1px 4px var(--shadow);
}
header .logo {
  display: flex; align-items: center; gap: .35rem;
  font-size: 1.05rem; font-weight: 700;
  color: var(--accent); white-space: nowrap; text-decoration: none;
}
header .logo:hover { text-decoration: none; }
header .logo .crown { font-size: 1.15em; line-height: 1; }
header .logo .sub { display: none; }
#menu-toggle {
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  width: 40px; height: 40px;  /* ≥44px touch */
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink); font-size: 1.25rem;
  transition: background 200ms;
}
#menu-toggle:active { background: var(--paper-dim); }

/* Search bar mobile — sotto l'header, non dentro */
#search-form {
  display: flex; align-items: center; gap: .35rem;
  position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 99;
  padding: .4rem .6rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border-dim);
}
#search-form input {
  flex: 1; min-width: 0;
  padding: .55rem .65rem;
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-base);
  -webkit-appearance: none;
}
#search-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(122,31,31,.15);
}
#search-form input::placeholder { color: var(--ink-muted); font-style: italic; font-size: var(--fs-sm); }
#search-form button {
  padding: .55rem .8rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fbf6e9;
  font-size: var(--fs-sm);
  font-weight: 500; font-family: var(--sans);
  white-space: nowrap;
  transition: background 200ms;
}
#search-form button:active { background: #8f2828; }

/* ══════════════════════════════════════════════════════════════
   LAYOUT — mobile: sidebar drawer, main pieno
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

/* Layout base — sovrascritto da mobile e desktop più sotto */

/* Sidebar — drawer da sinistra su mobile */
aside {
  position: fixed; top: calc(var(--header-h) + 48px); left: 0; bottom: 0; z-index: 90;
  width: min(320px, 85vw);
  background: var(--paper);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateX(-100%);
  transition: transform 250ms ease;
  padding: .5rem 0;
  box-shadow: 4px 0 24px var(--shadow);
}
aside.open { transform: translateX(0); }

/* Overlay per sidebar */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 85;
  background: rgba(43,33,23,.35);
}
#sidebar-overlay.open { display: block; }

/* Sidebar nav */
aside h3 {
  font-family: var(--sans);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-muted);
  padding: .6rem .8rem .25rem;
}
aside ul { list-style: none; }
aside a,aside button {
  display: block; width: 100%; text-align: left;
  padding: .5rem .8rem .5rem 1rem;
  border: none; background: none;
  color: var(--ink); font-size: var(--fs-base);
  cursor: pointer; text-decoration: none;
  transition: background 150ms;
  border-left: 3px solid transparent;
}
aside a:active,aside button:active { background: var(--paper-dim); }
aside li.active > a,aside li.active > button {
  background: var(--paper-dim);
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
aside .pars-link {
  font-weight: 600; font-family: var(--sans);
  font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .05em;
}

/* ══════════════════════════════════════════════════════════════
   MAIN CONTENT — mobile full-width
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

main {
  flex: 1; min-width: 0;
  padding: 1rem .8rem 5rem;
  max-width: 100%;
}

/* Layout: senza vincoli d'altezza su mobile (body scrolla) */
.layout {
  display: flex;
  margin-top: calc(var(--header-h) + 48px);
}

/* ══════════════════════════════════════════════════════════════
   HOME — mobile
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

.hero { text-align: center; padding: 1.5rem .5rem 1rem; }
.hero h1 {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.hero .subtitle {
  font-size: var(--fs-md);
  color: var(--ink-muted);
  font-style: italic;
  margin-top: .35rem;
}
.hero .desc {
  margin: 1rem auto 0;
  max-width: 480px;
  font-size: var(--fs-base);
  line-height: 1.6;
}
.hero .stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
  margin: 1.25rem auto 0;
  max-width: 320px;
}
.hero .stat {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .4rem;
}
.hero .stat-num {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--accent);
  font-family: var(--sans);
}
.hero .stat-label {
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* Pars grid — 2 colonne su mobile, 3-5 su desktop */
.pars-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
  margin-top: 1.25rem;
}
.pars-grid a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: .8rem .5rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  transition: all 200ms;
  min-height: 80px;
}
.pars-grid a:active {
  background: var(--paper-dim);
  border-color: var(--accent);
}
.pars-grid .pars-abbr {
  font-weight: 700;
  font-size: var(--fs-lg);
  color: var(--accent);
  font-family: var(--sans);
}
.pars-grid .pars-name {
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  margin-top: .15rem;
  text-align: center;
}

/* ══════════════════════════════════════════════════════════════
   ARTICLE — mobile leggibile
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

.article { max-width: 100%; }
.article-header {
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.article-ref {
  font-family: var(--sans);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-muted);
}
.article-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--accent);
  line-height: 1.25;
  margin-top: .15rem;
}
.article-breadcrumb {
  font-size: var(--fs-sm);
  color: var(--ink-muted);
  margin-top: .2rem;
  font-style: italic;
}
.article-breadcrumb a { color: var(--ink-muted); text-decoration: underline; }

.article-section { margin: 0 0 1rem; }
.article-section .label {
  font-family: var(--sans);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-muted);
  display: block;
  margin-bottom: .3rem;
  padding-top: .4rem;
  border-top: 1px solid var(--border);
}
.article-section .label:first-child { border-top: none; padding-top: 0; }

/* Obiezioni */
.obiectiones { list-style: none; counter-reset: obi; }
.obiectio {
  counter-increment: obi;
  margin-bottom: .5rem;
  padding: .55rem .65rem;
  background: var(--paper-dim);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border);
  font-size: var(--fs-base);
}
.obiectio::before {
  content: "Ob. " counter(obi);
  font-family: var(--sans);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-muted);
  display: block;
  margin-bottom: .2rem;
}

/* Responsioni */
.responsiones { list-style: none; }
.responsio {
  margin-bottom: .5rem;
  padding: .55rem .65rem;
  background: var(--paper);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-golden);
  font-size: var(--fs-base);
}
.responsio::before {
  content: "Ad " attr(data-n);
  font-family: var(--sans);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-muted);
  display: block;
  margin-bottom: .2rem;
}

/* Sed contra */
.sed-contra {
  padding: .65rem .8rem;
  background: var(--paper);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent);
  font-style: italic;
  font-size: var(--fs-base);
}

/* ══════════════════════════════════════════════════════════════
   SEARCH RESULTS
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

.search-results { list-style: none; }
.search-result {
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 150ms;
  -webkit-tap-highlight-color: transparent;
}
.search-result:last-child { border-bottom: none; }
.search-result:active { background: var(--paper-dim); }
.search-result .sr-ref {
  font-family: var(--sans);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
  font-weight: 600;
}
.search-result .sr-title {
  font-size: var(--fs-base);
  margin: .1rem 0 .15rem;
  font-weight: 500;
}
.search-result .sr-snippet {
  font-size: var(--fs-sm);
  color: var(--ink-muted);
  line-height: 1.5;
}
.search-result .sr-snippet em {
  background: var(--hl);
  font-style: normal;
  padding: 0 .15rem;
}
.search-result .sr-meta {
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  font-family: var(--sans);
  margin-top: .15rem;
}

/* ══════════════════════════════════════════════════════════════
   ARTICLE NAV — mobile friendly
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

.article-nav {
  display: flex; justify-content: space-between; gap: .5rem;
  margin-top: 2rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.article-nav a {
  font-size: var(--fs-sm);
  color: var(--ink-muted);
  font-style: italic;
  transition: color 200ms;
  padding: .4rem 0;  /* touch target */
}
.article-nav a:active { color: var(--accent); }
.article-nav .next { margin-left: auto; text-align: right; }

/* ══════════════════════════════════════════════════════════════
   LOADER / STATES
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

.loader {
  display: flex; justify-content: center; align-items: center;
  padding: 2.5rem 1rem;
  color: var(--ink-muted);
  font-style: italic;
  font-size: var(--fs-base);
}
.loader::after {
  content: '';
  width: 1.1rem; height: 1.1rem;
  margin-left: .5rem;
  border: 2px solid var(--border-dim);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 2.5rem .5rem;
  color: var(--ink-muted);
}
.empty-state .icon { font-size: 2.2rem; margin-bottom: .4rem; }
.empty-state h2 { font-size: var(--fs-lg); margin-bottom: .4rem; }

/* ══════════════════════════════════════════════════════════════
   DESKTOP UPGRADE — ≥768px
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

@media (min-width: 768px) {
  :root { --header-h: 56px; }

  /* Header: search bar torna dentro */
  header { gap: .75rem; padding: 0 1rem; }
  header .logo { font-size: 1.15rem; }
  header .logo .sub {
    display: inline; font-size: var(--fs-sm);
    font-weight: 400; color: var(--ink-muted); font-style: italic;
  }
  #menu-toggle { display: none; }
  #search-form {
    position: static;
    flex: 1; max-width: 400px;
    padding: 0;
    background: none;
    border-bottom: none;
  }
  #search-form input { padding: .4rem .65rem; }

  /* Layout: sidebar fissa, main affiancato */
  .layout {
    margin-top: var(--header-h);
    min-height: calc(100vh - var(--header-h) - 48px);
  }

  aside {
    position: sticky;
    top: var(--header-h);
    width: 240px;
    height: calc(100vh - var(--header-h));
    transform: none;
    box-shadow: none;
    padding: .75rem 0;
  }
  aside.open { transform: none; }
  #sidebar-overlay { display: none !important; }

  main {
    padding: 2rem 1.5rem 2rem;
    max-width: 780px;
    height: calc(100vh - var(--header-h));
  }

  /* Home desktop */
  .hero { padding: 3rem 1rem 2rem; }
  .hero .stats {
    grid-template-columns: repeat(4, auto);
    gap: 1.5rem;
    max-width: none;
  }
  .hero .stat { background: none; border: none; padding: 0; }
  .pars-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    max-width: 640px;
    margin-left: auto; margin-right: auto;
  }
  .pars-grid a { min-height: 90px; }
  .pars-grid a:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 12px var(--shadow);
    transform: translateY(-1px);
  }

  .article { max-width: 700px; }
  .article-nav a:hover { color: var(--accent); }
}

/* ══════════════════════════════════════════════════════════════
   DESKTOP LARGE — ≥1024px
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

@media (min-width: 1024px) {
  main { padding: 2.5rem 2.5rem; }
}

/* ══════════════════════════════════════════════════════════════
   FOOTER
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

#site-footer {
  text-align: center;
  padding: .6rem .8rem calc(.6rem + env(safe-area-inset-bottom, 0px));
  font-size: var(--fs-xs);
  font-family: var(--sans);
  border-top: 1px solid var(--border);
  background: var(--paper);
}
#site-footer a {
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 200ms;
}
#site-footer a:hover { color: var(--accent); text-decoration: none; }

/* ══════════════════════════════════════════════════════════════
   PRINT
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

@media print {
  header, aside, .article-nav, #menu-toggle, #search-form, #site-footer { display: none !important; }
  .layout { display: block; margin-top: 0; }
  main { max-width: none; padding: .5in; }
  body { font-size: 11pt; }
}

/* ══════════════════════════════════════════════════════════════
   RIDUZIONE MOVIMENTO
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ══════════════════════════════════════════════════════════════
   SCROLLBAR
║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║═║*/

@media (min-width: 768px) {
  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border-dim); border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--ink-muted); }
}
