/* tandura.it / ninovalenti.it — sobrio, asciutto, rispettoso */

@font-face { font-family: 'EB Garamond'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/eb-garamond-400.woff2') format('woff2'); }
@font-face { font-family: 'EB Garamond'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/eb-garamond-500.woff2') format('woff2'); }
@font-face { font-family: 'EB Garamond'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/eb-garamond-700.woff2') format('woff2'); }
@font-face { font-family: 'EB Garamond'; font-style: italic; font-weight: 400; font-display: swap; src: url('/fonts/eb-garamond-italic-400.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/ibm-plex-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/ibm-plex-mono-500.woff2') format('woff2'); }

:root {
  /* Palette "Inchiostro" (default, 2026-10-19): ink and slate on paper.
     Every text colour is >= 5:1 on --bg, --bg-alt and --paper.
     The previous palette is kept as the "Seppia" version below. */
  --bg: #f6f4ef;
  --bg-alt: #ebe8e1;
  --paper: #fdfcf9;
  --text: #1f2226;
  --text-light: #555a60;
  --text-faded: #5c6167;
  --accent: #2f4858;
  --accent-light: #46606f;
  --border: #d3d0c8;
  --border-soft: #e6e3db;
  --gold: #8c6d3f;        /* bronze: decoration only (lines, borders) */
  --gold-light: #b39463;  /* decoration only */
  --gold-ink: #6b5232;    /* bronze for text */
  --red-muted: #8a2f2a;
  --green-muted: #3d6647;
  --max-width: 900px;
  --font-body: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

:root[data-palette="seppia"] {
  /* Palette "Seppia" (until 2026-10-19), contrast-fixed. */
  --bg: #fbf9f4;
  --bg-alt: #f0ece2;
  --paper: #fffdf9;
  --text: #2a2620;
  --text-light: #6b6355;
  --text-faded: #6e6452;  /* was #9a9080 (2.99:1); now ≥4.9:1 on every background */
  --accent: #4a2e1a;
  --accent-light: #7a5a3a;
  --border: #d8d0c0;
  --border-soft: #ece5d5;
  --gold: #a07830;
  --gold-light: #c0993a;  /* decoration only: lines, borders */
  --gold-ink: #7d5a1c;    /* gold for text: 5.3–6.2:1 */
  --red-muted: #8b3030;
  --green-muted: #4a7040;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  font-size: 19px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 28px;
  width: 100%;
}

/* Header — wordmark style, no Groupon */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 24px 0 18px;
}

.site-header .container {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.site-wordmark {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.wordmark-name {
  font-family: var(--font-body);
  font-size: 32px;
  font-weight: 500;
  font-style: italic;
  color: var(--accent);
  letter-spacing: -0.5px;
}
.wordmark-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  color: var(--text-faded);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 4px;
}

.site-nav {
  display: flex;
  gap: 22px;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.site-nav a {
  color: var(--text-light);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: all 0.15s;
}
.site-nav a:hover {
  color: var(--accent);
  border-bottom-color: var(--gold);
}

main {
  flex: 1;
  padding: 48px 0 80px;
}

h1 {
  font-size: 42px;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 6px;
  line-height: 1.15;
  letter-spacing: -0.5px;
}

h2 {
  font-size: 26px;
  font-weight: 500;
  color: var(--text);
  margin: 48px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 22px 0 6px;
}

p { margin-bottom: 18px; }

.subtitle {
  font-size: 15px;
  color: var(--text-light);
  margin-bottom: 36px;
  font-style: italic;
}

a { color: var(--accent); }

blockquote {
  margin: 36px 0;
  padding: 28px 40px;
  border-left: 3px solid var(--gold);
  background: var(--bg-alt);
  font-style: italic;
  font-size: 22px;
  line-height: 1.55;
  color: var(--text);
}
blockquote cite {
  display: block;
  margin-top: 16px;
  font-size: 14px;
  font-style: normal;
  color: var(--text-light);
  font-family: var(--font-mono);
}

.confidential-banner {
  background: var(--bg-alt);
  border-left: 3px solid var(--red-muted);
  padding: 14px 22px;
  margin: 16px 0 32px;
  font-size: 15px;
  color: var(--red-muted);
}

.disclaimer-box {
  background: var(--bg-alt);
  border-left: 3px solid var(--gold);
  padding: 18px 24px;
  margin: 0 0 40px;
  font-size: 15px;
  color: var(--text);
  line-height: 1.65;
}
.disclaimer-box strong {
  color: var(--accent);
  font-weight: 600;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 8px;
}
.badge-pub { color: var(--accent); }

/* Reading path annotation */
.reading-path {
  background: var(--bg-alt);
  border-left: 3px solid var(--gold);
  padding: 16px 22px;
  margin: 0 0 28px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
}
.reading-path strong {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold-ink);
}

.notice {
  background: var(--bg-alt);
  border-left: 3px solid var(--gold);
  padding: 12px 18px;
  margin: 18px 0;
  font-size: 15px;
  color: var(--text-light);
  font-style: italic;
}

/* Person card grid (home page family members) */
.person-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin: 32px 0;
}

.person-card {
  background: var(--paper);
  border: 1px solid var(--border);
  padding: 24px 26px;
  position: relative;
}

.person-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gold);
}

.person-card h3 {
  font-size: 22px;
  font-weight: 500;
  color: var(--accent);
  margin: 4px 0 2px;
  font-style: italic;
}
.person-card .dates {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faded);
  letter-spacing: 1px;
  margin-bottom: 14px;
}
.person-card p {
  font-size: 15px;
  line-height: 1.65;
  margin-bottom: 12px;
}
.person-card p:last-child { margin-bottom: 0; }

/* Card list (sections) */
.section-list {
  list-style: none;
  margin: 24px 0 36px;
}
.section-list li {
  padding: 16px 22px;
  border: 1px solid var(--border);
  background: var(--paper);
  margin-bottom: 12px;
}
.section-list li a {
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  text-decoration: none;
  font-style: italic;
}
.section-list li a:hover { text-decoration: underline; }
.section-list li p {
  font-size: 14px;
  color: var(--text-light);
  margin: 6px 0 0;
}

/* Card list grid */
.card-list {
  list-style: none;
  display: grid;
  gap: 16px;
  margin: 24px 0;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}
.card {
  padding: 22px 26px;
  border: 1px solid var(--border);
  background: var(--paper);
}
.card h3 {
  margin: 0 0 6px;
  font-size: 18px;
  font-style: italic;
}
.card h3 a { color: var(--accent); text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.card p { font-size: 14px; color: var(--text-light); margin: 0; }

/* Document card (article list) */
.doc-list { margin: 20px 0; }

.doc-card {
  padding: 20px 24px;
  border: 1px solid var(--border);
  background: var(--paper);
  margin-bottom: 10px;
  transition: border-color 0.15s, transform 0.1s;
}
.doc-card:hover {
  border-color: var(--gold);
}
.doc-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  font-style: italic;
}
.doc-card h3 a { color: var(--accent); text-decoration: none; }
.doc-card h3 a:hover { text-decoration: underline; }
.doc-card .meta {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-family: var(--font-mono);
}
.doc-card .excerpt {
  font-size: 15px;
  color: var(--text);
  margin: 0;
  line-height: 1.65;
}
.doc-card.hidden { display: none; }

/* Document body */
.doc-header {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 18px 0 32px;
  font-size: 12px;
  color: var(--text-light);
  font-family: var(--font-mono);
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.5px;
}

.document-body {
  background: var(--paper);
  padding: 56px 64px;
  border: 1px solid var(--border);
  font-size: 19px;
  line-height: 1.85;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.document-body p {
  margin-bottom: 18px;
  text-align: left;
}
@media (max-width: 600px) {
  .document-body { padding: 28px 24px; font-size: 17px; }
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 9px;
  padding: 2px 8px;
  border-radius: 2px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  line-height: 1.9;
  font-family: var(--font-mono);
}
.badge           { background: transparent; border: 1px solid currentColor; }
.badge-signed    { color: var(--accent); }
.badge-likely    { color: var(--accent-light); }
.badge-external  { color: var(--red-muted); }
.badge-unknown   { color: var(--text-light); }
.badge-private   { color: var(--red-muted); }
.badge-personal  { color: var(--gold-ink); }
.badge-published { color: var(--green-muted); }
.badge-review    { color: var(--gold-ink); }
.badge-fragment  { color: var(--text-light); }

/* Photo strip / grid */
.photo-strip,
.cover-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 36px 0;
}
.photo-strip img,
.cover-strip img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border: 1px solid var(--border);
  filter: sepia(0.08) contrast(0.97);
  display: block;
}
.cover-item { display: block; }
.cover-item img { transition: filter 0.2s; }
.cover-item:hover img { filter: none; }

@media (max-width: 600px) {
  .photo-strip,
  .cover-strip { grid-template-columns: repeat(2, 1fr); }
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin: 24px 0;
}
.photo-grid a {
  display: block;
  content-visibility: auto;
  contain-intrinsic-size: 180px 180px;
}
.photo-grid img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border: 1px solid var(--border);
  filter: sepia(0.05);
  transition: filter 0.2s, transform 0.1s;
}
.photo-grid a:hover img { filter: none; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 8px;
  margin: 16px 0 24px;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 7px 16px;
  border: 1px solid var(--border);
  background: var(--paper);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text);
}
.filter-btn.active {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}

/* ─── Tag system ─────────────────────────────────────────── */

.tag-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--accent);
  color: var(--paper);
  padding: 10px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  z-index: 1000;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.15);
}
.tag-bar .container {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.tag-bar-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: var(--paper);
  padding: 6px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-radius: 2px;
}
.tag-bar-btn:hover { background: rgba(255,255,255,0.2); }
.tag-bar-hint {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.7;
}
.tag-bar-hint kbd {
  background: rgba(255,255,255,0.15);
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 10px;
}

body { padding-bottom: 50px; }

/* Tag strip on doc cards */
.tag-strip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-soft);
  align-items: center;
}
.tag-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 10px;
  background: var(--gold-ink);
  color: var(--paper);
  letter-spacing: 0.5px;
  cursor: pointer;
}
.tag-chip-active:hover { background: var(--red-muted); }
.tag-chip-active::after { content: ' ×'; opacity: 0.7; }

.tag-add-btn {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 10px;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-faded);
  border-radius: 10px;
  cursor: pointer;
  letter-spacing: 0.5px;
}
.tag-add-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.tag-picker {
  position: absolute;
  background: var(--paper);
  border: 1px solid var(--accent);
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 320px;
  z-index: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.tag-picker button {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 10px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  border-radius: 2px;
  letter-spacing: 0.5px;
}
.tag-picker button:hover {
  background: var(--gold-ink);
  color: var(--paper);
  border-color: var(--gold-ink);
}
.tag-picker input {
  width: 100%;
  padding: 5px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--border);
  margin-top: 4px;
}

.doc-tag-controls {
  background: var(--bg-alt);
  padding: 14px 22px;
  margin: 16px 0;
  border-left: 3px solid var(--gold);
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

/* Cross-references */
.cross-ref-section {
  margin: 36px 0 0;
  padding: 24px 28px;
  background: var(--bg-alt);
  border: 1px solid var(--border-soft);
}
.cross-ref-section h2 {
  font-size: 16px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin: 0 0 12px;
  padding: 0;
  border: none;
}
.cross-ref-list,
.cross-ref-series {
  list-style: none;
  margin: 0;
}
.cross-ref-list li,
.cross-ref-series li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.cross-ref-list li:last-child,
.cross-ref-series li:last-child { border-bottom: none; }
.cross-ref-list a,
.cross-ref-series a {
  color: var(--accent);
  text-decoration: none;
  font-style: italic;
}
.cross-ref-list a:hover,
.cross-ref-series a:hover { text-decoration: underline; }
.cross-ref-year {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faded);
  flex-shrink: 0;
}

/* Site footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  font-size: 12px;
  color: var(--text-faded);
  text-align: center;
  font-family: var(--font-mono);
  letter-spacing: 1px;
  text-transform: uppercase;
}

@media (max-width: 768px) {
  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .site-nav {
    flex-wrap: wrap;
    gap: 14px;
  }
  h1 { font-size: 32px; }
  h2 { font-size: 22px; }
  .wordmark-name { font-size: 26px; }
  .photo-strip { grid-template-columns: repeat(2, 1fr); }
  /* Tag bar: at the end of the page instead of covering the content */
  .tag-bar { position: static; box-shadow: none; }
  .tag-bar-hint { display: none; }
  body { padding-bottom: 0; }
}

/* ─── Family pages (/la-famiglia, /persone, /luoghi, /voci) ── */
.fonti {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
}
.fatti { padding-left: 1.2em; }
.fatti li { margin-bottom: 12px; }
.persona-foto {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin: 24px 0;
}
.persona-foto figure, .luogo figure { margin: 0; max-width: 240px; }
.persona-foto img, .luogo img { width: 100%; height: auto; border: 1px solid var(--border); display: block; }
figcaption { font-size: 14px; color: var(--text-light); font-style: italic; margin-top: 6px; }
.articoli-persona li { margin-bottom: 6px; }
.notice ul { margin: 6px 0 0; padding-left: 1.2em; }
.voce { margin: 96px 0; }
.voce:first-of-type { margin-top: 48px; }
.person-card h3 a { color: inherit; text-decoration: none; }
.person-card h3 a:hover { text-decoration: underline; }

/* Palette switch in the footer */
.palette-switch { margin-top: 8px; font-family: var(--font-mono); font-size: 12px; }
.palette-switch button {
  background: none; border: 1px solid var(--border); color: var(--text-light);
  font: inherit; padding: 2px 10px; margin-left: 6px; cursor: pointer; border-radius: 2px;
}
.palette-switch button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* Photo viewer (galleria, homepage, family pages) */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgb(15, 17, 20);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 3rem 4rem 4.5rem;
  overflow: auto;
}
.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 8rem);
  object-fit: contain;
  cursor: zoom-in;
  background: #222;
}
.lightbox.zoomed:not([style*="none"]) { display: block !important; padding: 0; }
.lightbox.zoomed img { max-width: none; max-height: none; cursor: zoom-out; }
.lightbox button {
  position: fixed;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  font-size: 1.8rem;
  line-height: 1;
  width: 2.75rem;
  height: 2.75rem;
  cursor: pointer;
  z-index: 10001;
}
.lightbox button:hover, .lightbox button:focus-visible { background: rgba(0, 0, 0, 0.85); outline: 2px solid #fff; }
.lb-close { top: 0.75rem; right: 0.75rem; }
.lb-prev { left: 0.75rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: 0.75rem; top: 50%; transform: translateY(-50%); }
.lb-caption, .lb-counter {
  position: fixed;
  left: 0;
  right: 0;
  color: #eee;
  text-align: center;
  font-size: 0.95rem;
  padding: 0 4rem;
}
.lb-caption { bottom: 2rem; }
.lb-counter { bottom: 0.6rem; font-size: 0.8rem; color: #bbb; }
.lightbox.zoomed .lb-caption, .lightbox.zoomed .lb-counter { display: none; }
@media (max-width: 640px) {
  .lightbox { padding: 3.75rem 0.5rem 6rem; }
  .lightbox img { max-height: calc(100vh - 10rem); }
  .lb-prev, .lb-next { top: 0.75rem; transform: none; }
  .lb-next { right: auto; left: 4rem; }
  .lb-caption { bottom: 2rem; padding: 0 1rem; font-size: 0.85rem; }
}

/* Article preview dialog (links inside texts) */
dialog.anteprima { margin: auto; border: 0; padding: 0; background: transparent; max-width: min(640px, calc(100vw - 32px)); width: 100%; }
dialog.anteprima::backdrop { background: rgba(20, 18, 15, 0.55); }
.anteprima-box { position: relative; background: var(--paper); color: var(--text); border: 1px solid var(--border); border-top: 3px solid var(--gold); padding: 1.5rem 1.5rem 1rem; max-height: calc(100vh - 4rem); overflow-y: auto; font-family: var(--font-body); }
.anteprima-box h2 { margin: 0 2rem 0.25rem 0; font-size: 1.35rem; line-height: 1.25; }
.anteprima-meta { color: var(--text-faded); font-size: 0.9rem; margin: 0 0 1rem; }
.anteprima-body p { margin: 0 0 0.8rem; line-height: 1.55; }
.anteprima-segue { color: var(--text-faded); }
.anteprima-x { position: absolute; top: 0.5rem; right: 0.6rem; background: none; border: 0; font-size: 1.6rem; line-height: 1; color: var(--text-light); cursor: pointer; padding: 0.25rem 0.5rem; }
.anteprima-azioni { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: center; border-top: 1px solid var(--border-soft); padding-top: 0.9rem; margin: 1rem 0 0; position: sticky; bottom: -1rem; background: var(--paper); padding-bottom: 1rem; }
.anteprima-vai { font-weight: 600; color: var(--accent); }
.anteprima-chiudi { background: none; border: 1px solid var(--border); color: var(--text); font: inherit; padding: 0.3rem 0.9rem; cursor: pointer; }
.anteprima-chiudi:hover, .anteprima-x:hover { color: var(--accent); border-color: var(--accent); }
