/* =========================================================
   Bibliografia Valsesiana
   Metafora: l'album del collezionista. La pagina è il foglio
   verde dell'album, i contenuti sono carte appoggiate sopra;
   in homepage la carta è il retro di una cartolina postale.
   ========================================================= */
:root {
  /* colore */
  --album: #263a35;        /* foglio d'album verde scuro */
  --album-deep: #1d2d29;
  --on-album: #e6dfcb;     /* testo sul foglio d'album */
  --on-album-dim: #a8b4ab;
  --card: #ece4cf;         /* cartoncino della cartolina */
  --sheet: #f2ecdd;        /* carta da lettere per moduli e schede */
  --ink: #23211d;          /* inchiostro di stampa */
  --ink-dim: #5c564b;
  --rule: #c8bc9f;
  --carmine: #a3272f;      /* francobollo: azione principale */
  --carmine-deep: #841d24;
  --violet: #463d63;       /* inchiostro da timbro: link */
  --ok: #3f6136;
  --warn: #8a5a10;
  --focus: #2f5ea8;

  /* caratteri */
  --serif: 'Bodoni Moda', 'Didot', 'Bodoni 72', Georgia, serif;
  --sans: 'Archivo', 'Helvetica Neue', Arial, sans-serif;

  /* scala tipografica (Bringhurst): 14 · 16 · 18 · 21 · 24 · 36 · 48 */
  --t-small: .875rem;
  --t-ui: 1rem;
  --t-body: 1.125rem;
  --t-lede: 1.3125rem;
  --t-h2: 1.5rem;
  --t-h1: 2.25rem;
  --t-display: 3rem;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--serif);
  font-size: var(--t-body);
  line-height: 1.6;
  color: var(--on-album);
  background-color: var(--album);
  /* grana fine del cartoncino d'album */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .18 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
p { margin: 0 0 1em; }
a { color: var(--violet); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
form.inline { display: inline; margin: 0; }

/* ---------- Testata ---------- */
.masthead {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem 2rem;
  width: 100%; max-width: 1120px; margin: 0 auto; padding: 1.25rem 1.5rem;
}
.brand { display: flex; align-items: center; gap: .75rem; color: var(--on-album); text-decoration: none; }
/* lo stemma, nero su bianco, diventa un'incisione chiara sul verde */
.brand__logo { filter: invert(1); mix-blend-mode: screen; opacity: .9; }
.brand__name { font-size: var(--t-h2); font-style: italic; }
.masthead :focus-visible { outline-color: var(--on-album); }

.mainnav { display: flex; align-items: center; gap: .25rem 1.5rem; flex-wrap: wrap; font-family: var(--sans); font-size: var(--t-ui); }
.mainnav a, .mainnav__logout {
  color: var(--on-album-dim); text-decoration: none; padding: .25rem 0;
  border-bottom: 1px solid transparent;
}
.mainnav a:hover, .mainnav__logout:hover { color: var(--on-album); }
.mainnav a[aria-current="page"] { color: var(--on-album); border-bottom-color: var(--on-album); }
.mainnav__logout { font: inherit; background: none; border-top: 0; border-left: 0; border-right: 0; cursor: pointer; }

/* ---------- Struttura ---------- */
.page { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 1.5rem 1.5rem 4rem; }

.colophon {
  max-width: 1120px; width: 100%; margin: 0 auto; padding: 1.5rem;
  font-family: var(--sans); font-size: var(--t-small); color: var(--on-album-dim);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .25rem 2rem;
}
.colophon p { margin: 0; }

/* ---------- La cartolina (homepage) ---------- */
.postcard {
  position: relative;
  max-width: 980px;
  margin: 1.5rem auto 0;
  padding: 2.75rem 3rem 3rem;
  color: var(--ink);
  background: var(--card);
  /* leggero ingiallimento ai bordi, come il cartoncino vero */
  background-image: radial-gradient(ellipse at center, transparent 55%, rgba(150,110,40,.13) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.35) inset, 0 18px 40px -20px rgba(0,0,0,.6);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "plate   plate"
    "message address";
  column-gap: 3rem;
}

/* angolini fotografici che tengono la cartolina sull'album */
.corner {
  position: absolute; width: 38px; height: 38px; background: #151d1b;
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.corner--tl { top: -6px; left: -6px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.corner--tr { top: -6px; right: -6px; clip-path: polygon(0 0, 100% 0, 100% 100%); }
.corner--bl { bottom: -6px; left: -6px; clip-path: polygon(0 0, 100% 100%, 0 100%); }
.corner--br { bottom: -6px; right: -6px; clip-path: polygon(100% 0, 100% 100%, 0 100%); }

.postcard__nameplate {
  grid-area: plate; text-align: center; margin: 0 0 2rem;
  font-size: var(--t-h2); font-style: italic; letter-spacing: .02em; color: var(--ink-dim);
}
.postcard__message {
  grid-area: message; position: relative; padding-right: .5rem;
}
/* la linea verticale che divide il retro della cartolina */
.postcard__message::after {
  content: ''; position: absolute; top: 0; bottom: 0; right: -1.5rem; border-right: 1px solid var(--rule);
}
.postcard__message h1 { font-size: var(--t-display); font-weight: 500; letter-spacing: -.01em; margin-bottom: .6em; }
.postcard__message p { max-width: 34em; color: var(--ink); }

.postcard__address { grid-area: address; display: flex; flex-direction: column; }

.franking { position: relative; display: flex; justify-content: flex-end; height: 140px; margin-bottom: 1rem; }

/* francobollo dentellato: i fori sono un motivo di cerchi a metà sul bordo */
.stamp {
  width: 110px; height: 130px; padding: 5px;
  background: radial-gradient(circle, transparent 3px, #fbf8ef 3.5px) -5px -5px / 10px 10px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.18));
  transform: rotate(2deg);
}
.stamp__face {
  height: 100%; padding: 3px; overflow: hidden;
  background: var(--carmine);   /* il filetto carminio attorno alla vignetta */
  border: 4px solid #fbf8ef;
}
/* l'incisione nera diventa carminio su carta bianca, come un francobollo monocromo */
.stamp__face img {
  display: block; width: 100%; height: 100%; object-fit: contain;
  background: #fff; mix-blend-mode: screen;
  transform: scale(1.22); /* il PNG ha ampi margini bianchi */
}

.postmark {
  position: absolute; top: 14px; right: 42px; width: 230px; height: auto;
  fill: none; stroke: var(--violet); stroke-width: 2.2; opacity: .82;
  transform: rotate(-9deg);
  animation: stamp-down .38s cubic-bezier(.3,1.6,.6,1) .35s both;
}
.postmark text { fill: var(--violet); stroke: none; font-family: var(--sans); font-weight: 600; }
.postmark__ring { font-size: 11px; letter-spacing: .14em; }
.postmark__date { font-size: 13px; letter-spacing: .06em; }
.postmark__wave { stroke-width: 2; }

@keyframes stamp-down {
  from { opacity: 0; transform: rotate(-9deg) scale(1.25); }
  to   { opacity: .82; transform: rotate(-9deg) scale(1); }
}

.address-form { display: flex; flex-direction: column; gap: 1.1rem; margin-top: auto; }
.address-form h2 { font-style: italic; margin: 0; }
/* i campi sono le righe dell'indirizzo */
.line { display: grid; grid-template-columns: 6.5rem 1fr; align-items: end; gap: .75rem; }
.line > span { font-family: var(--sans); font-size: var(--t-small); color: var(--ink-dim); padding-bottom: .4rem; }
.line input {
  font: inherit; font-size: var(--t-body); color: var(--ink);
  background: transparent; border: 0; border-bottom: 1px dotted var(--ink-dim); border-radius: 0;
  padding: .3rem .1rem; width: 100%;
}
.line input:focus { outline: none; border-bottom: 2px solid var(--focus); padding-bottom: calc(.3rem - 1px); }
.address-form .btn { align-self: flex-start; margin-top: .5rem; }
.address-form__alt { font-family: var(--sans); font-size: var(--t-ui); margin: .25rem 0 0; color: var(--ink-dim); }
.field-error { font-family: var(--sans); font-size: var(--t-ui); color: var(--carmine-deep); margin: 0; }

/* ---------- Fogli (pagine interne) ---------- */
.sheet {
  max-width: 860px; margin: 1rem auto 2rem; padding: 2.75rem 3rem;
  color: var(--ink); background: var(--sheet);
  box-shadow: 0 16px 36px -22px rgba(0,0,0,.65);
}
.sheet--narrow { max-width: 600px; }
.sheet--wide { max-width: none; }
.sheet h2 { margin-top: 1.5rem; }
.sheet > h2:first-child { margin-top: 0; }
.sheet__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.sheet--danger h2 { color: var(--carmine-deep); }
.lede { font-size: var(--t-lede); line-height: 1.5; color: var(--ink-dim); max-width: 34em; }
.backlink { font-family: var(--sans); font-size: var(--t-ui); margin-bottom: 1.5rem; }
.hint { font-family: var(--sans); font-size: var(--t-small); color: var(--ink-dim); margin: 0 0 1rem; }

.facts { display: flex; flex-wrap: wrap; gap: .5rem 2.5rem; margin: 0 0 1.5rem; font-family: var(--sans); font-size: var(--t-small); }
.facts dt { color: var(--ink-dim); }
.facts dd { margin: 0; color: var(--ink); }

/* ---------- Indice della biblioteca ---------- */
.index-title { font-style: italic; margin-top: 2.25rem; }
.index { list-style: none; margin: 0; padding: 0; }
.index li { padding: .9rem 0; border-top: 1px solid var(--rule); }
.index li:last-child { border-bottom: 1px solid var(--rule); }
.index__row { display: flex; align-items: baseline; gap: .6rem; }
.index__name { font-size: var(--t-lede); }
.index__leader { flex: 1; border-bottom: 2px dotted var(--rule); transform: translateY(-.3em); min-width: 2rem; }
.index__state { font-style: italic; color: var(--ink-dim); white-space: nowrap; }
.index__desc { margin: .2rem 0 0; color: var(--ink-dim); font-size: var(--t-ui); max-width: 40em; }

/* ---------- Moduli ---------- */
.form { display: flex; flex-direction: column; gap: 1.5rem; }
fieldset { border: 0; border-top: 1px solid var(--rule); margin: 0; padding: 1.25rem 0 0; min-width: 0; }
legend { font-size: var(--t-h2); font-style: italic; padding-right: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.5rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
fieldset > .field, fieldset > .check, fieldset > .grid-2 + .check { margin-top: 1rem; }
.field > span { font-family: var(--sans); font-size: var(--t-small); font-weight: 500; color: var(--ink); }
.field > span em { font-style: normal; font-weight: 400; color: var(--ink-dim); margin-left: .35em; }

.field input, .field select, .field textarea, .search input {
  font-family: var(--sans); font-size: var(--t-ui); color: var(--ink);
  background: #fffdf7; border: 1px solid #b9ad91; border-radius: 2px;
  padding: .6rem .7rem; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus {
  outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus);
}
textarea { resize: vertical; line-height: 1.5; }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .5rem 1.5rem; }
.check { display: flex; gap: .6rem; align-items: baseline; font-family: var(--sans); font-size: var(--t-ui); cursor: pointer; }
.check input { accent-color: var(--carmine); width: 1rem; height: 1rem; flex: none; transform: translateY(.15em); }
.check--consent { color: var(--ink-dim); }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--sans); font-size: var(--t-ui); font-weight: 600; line-height: 1.2;
  padding: .7rem 1.4rem; border-radius: 2px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
}
.btn--primary { background: var(--carmine); color: #fff; }
.btn--primary:hover { background: var(--carmine-deep); }
.btn--quiet { background: transparent; color: var(--ink); border-color: #b9ad91; }
.btn--quiet:hover { border-color: var(--ink); }
.btn--danger { background: transparent; color: var(--carmine-deep); border-color: var(--carmine); }
.btn--danger:hover { background: var(--carmine); color: #fff; }
.btn--small { font-size: var(--t-small); padding: .35rem .8rem; }

/* ---------- Avvisi ---------- */
.notice {
  font-family: var(--sans); font-size: var(--t-ui); line-height: 1.5;
  color: var(--ink); background: #f7f1e1; border-left: 4px solid var(--warn);
  padding: .8rem 1rem; margin: 0 0 1.5rem;
}
.page > .notice { max-width: 860px; margin-left: auto; margin-right: auto; }
.notice p { margin: 0; }
.notice ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.notice--error { border-left-color: var(--carmine); background: #f7e7e3; }
.notice--success { border-left-color: var(--ok); background: #e9eedd; }
.notice--actions { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.notice--actions .inline + .inline { margin-left: .4rem; }

/* ---------- Gestione utenti ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; margin: 1.25rem 0 1.25rem; border-bottom: 1px solid var(--rule); font-family: var(--sans); font-size: var(--t-ui); }
.tabs a { color: var(--ink-dim); text-decoration: none; padding: .5rem 0; margin-bottom: -1px; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--ink); }
.tabs a.is-active { color: var(--ink); border-bottom-color: var(--carmine); }
.badge { display: inline-block; min-width: 1.5em; margin-left: .3em; padding: 0 .4em; font-size: .8rem; text-align: center; border-radius: 1em; background: #e2d8bf; color: var(--ink); }
.badge--alert { background: var(--carmine); color: #fff; }

.search { display: flex; gap: .6rem; margin-bottom: 1.25rem; max-width: 30rem; }
.table-wrap { overflow-x: auto; }
.ledger { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: var(--t-ui); }
.ledger th { text-align: left; font-weight: 500; font-size: var(--t-small); color: var(--ink-dim); padding: .5rem .75rem .5rem 0; border-bottom: 1px solid var(--ink); }
.ledger td { padding: .7rem .75rem .7rem 0; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.ledger td a { color: var(--ink); text-decoration: none; }
.ledger td a:hover { text-decoration: underline; }
.ledger td .btn { color: var(--ink); }
.ledger td .btn--primary { color: #fff; }
.ledger .right { text-align: right; padding-right: 0; }
.ledger .inline + .inline { margin-left: .3rem; }
.nowrap { white-space: nowrap; }

.status, .role { font-family: var(--sans); font-size: var(--t-small); white-space: nowrap; }
.status::before { content: ''; display: inline-block; width: .55em; height: .55em; border-radius: 50%; margin-right: .45em; background: currentColor; transform: translateY(-.05em); }
.status--active { color: var(--ok); }
.status--pending { color: var(--warn); }
.status--disabled { color: var(--ink-dim); }
.status--rejected { color: var(--carmine-deep); }
.role--admin { font-weight: 600; }
.empty { font-style: italic; color: var(--ink-dim); padding: 2rem 0; }

/* ---------- Schermi piccoli ---------- */
/* ---------- catalogo e importazione CSV ---------- */
.upload { max-width: 34rem; gap: 1rem; }
.upload input[type="file"] { font-family: var(--sans); font-size: var(--t-ui); padding: .6rem; border: 1px dashed var(--rule); background: #fbf8f0; }
.rules { margin: 1.5rem 0 0; padding-left: 1.2rem; font-family: var(--sans); font-size: var(--t-small); color: var(--ink-dim); max-width: 46em; }
.rules li + li { margin-top: .3rem; }
.field-list { columns: 15rem; column-gap: 2rem; margin: 0; padding-left: 1.8rem; font-family: var(--sans); font-size: var(--t-ui); }
.field-list li { padding: .15rem 0; break-inside: avoid; }
.num { font-variant-numeric: tabular-nums; }
.tally { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem 2.5rem; margin: 0 0 1.5rem; padding: 1rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); font-family: var(--sans); font-size: var(--t-ui); color: var(--ink-dim); }
.tally strong { font-family: var(--serif); font-size: var(--t-h2); font-weight: 500; color: var(--ink); margin-right: .3rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem !important; }
.chip { padding: .1rem .6rem; border: 1px solid var(--violet); border-radius: 1em; color: var(--violet); font-size: var(--t-small); }
.confirm fieldset { padding-top: 1rem; }
.confirm fieldset .check + .check { margin-top: .5rem; }
.outcome { font-family: var(--sans); font-size: var(--t-small); font-weight: 500; }
.outcome--create { color: var(--ok); }
.outcome--update { color: var(--warn); }
.outcome--same { color: var(--ink-dim); font-weight: 400; }
.ledger.preview td { vertical-align: top; }
.preview__item tr:first-child td { border-bottom: 0; padding-bottom: .2rem; }
.preview__detail td { padding-top: 0; }
.preview__detail summary { cursor: pointer; font-size: var(--t-small); color: var(--violet); width: max-content; max-width: 100%; }
.record { display: grid; grid-template-columns: fit-content(10rem) minmax(0, 1fr); gap: .35rem 1.25rem; margin: .75rem 0 .5rem; font-size: var(--t-small); }
.record > div { display: contents; }
.record dt { color: var(--ink-dim); }
.record dd { margin: 0; max-width: 60em; white-space: pre-line; }
.record .is-changed dt, .record .is-changed dd { color: var(--warn); font-weight: 600; }

/* ---------- consultazione del catalogo ---------- */
.catalog-head { margin-bottom: 2.5rem; }
.catalog-head__count { font-family: var(--sans); font-size: var(--t-ui); color: var(--ink-dim); margin: 0; }
.finder { display: grid; grid-template-columns: minmax(0, 1fr) 13rem auto auto; gap: 1rem 1.25rem; align-items: end; margin-top: 1rem; }
.finder__img { padding-bottom: .7rem; white-space: nowrap; }
.finder__result { margin: 1rem 0 0; }

/* le schede sono "montate" sull'album: passe-partout color cartoncino con gli angolini */
.plates { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2.75rem 2.25rem; }
.plate__link { display: flex; flex-direction: column; gap: 1rem; color: var(--on-album); text-decoration: none; }
.mount {
  position: relative; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 3 / 4; padding: 10%; background: var(--card);
  box-shadow: 0 14px 28px -18px rgba(0,0,0,.75);
  transition: transform .2s ease, box-shadow .2s ease;
}
.mount .corner { width: 24px; height: 24px; }
.plate__link:hover .mount { transform: translateY(-3px); box-shadow: 0 20px 34px -18px rgba(0,0,0,.85); }
.plate__link:focus-visible { outline: none; }
.plate__link:focus-visible .mount { outline: 3px solid var(--on-album); outline-offset: 4px; }
.mount img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
/* nell'elenco l'immagine sta dentro il passe-partout 3:4, qualunque sia il suo formato */
.mount > .protected { position: absolute; inset: 10%; display: flex; align-items: center; justify-content: center; }
.mount--large > .protected { position: relative; inset: auto; }
.mount img.placeholder { width: 62%; mix-blend-mode: multiply; opacity: .28; }
.plate__caption { display: flex; flex-direction: column; gap: .2rem; }
.plate__title { font-size: var(--t-body); font-style: italic; line-height: 1.3; }
.plate__link:hover .plate__title { text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: 1px; }
.plate__author { font-family: var(--sans); font-size: var(--t-small); color: var(--on-album); }
.plate__meta { font-family: var(--sans); font-size: var(--t-small); color: var(--on-album-dim); font-variant-numeric: tabular-nums; }

.pager { display: flex; justify-content: space-between; align-items: center; margin: 3rem 0 0; font-family: var(--sans); font-size: var(--t-ui); color: var(--on-album-dim); }
.pager a, .leaf-nav a { color: var(--on-album); }
.leaf-nav { display: flex; justify-content: space-between; gap: 1rem 2rem; flex-wrap: wrap; margin: 0 0 1rem; font-family: var(--sans); font-size: var(--t-ui); }
.leaf-nav span { display: flex; gap: 1.5rem; }

/* immagini protette: un velo trasparente sopra l'immagine intercetta clic destro e trascinamento */
.protected { position: relative; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.protected::after { content: ''; position: absolute; inset: 0; }
.protected img { pointer-events: none; }

/* scheda di dettaglio */
.entry { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 3rem; align-items: start; }
.entry__figure { position: sticky; top: 1.5rem; }
.mount--large { aspect-ratio: auto; min-height: 22rem; padding: 7%; }
.mount--large .corner { width: 34px; height: 34px; }
.mount--large.mount--empty { aspect-ratio: 3 / 4; min-height: 0; }
.entry__noimg { font-family: var(--sans); font-size: var(--t-small); color: var(--ink-dim); text-align: center; margin: .9rem 0 0; }
.entry__code { font-family: var(--sans); font-size: var(--t-small); color: var(--ink-dim); font-variant-numeric: tabular-nums; margin-bottom: .4rem; }
.entry h1 { font-style: italic; margin-bottom: .3em; }
.entry__subtitle { font-size: var(--t-lede); line-height: 1.4; color: var(--ink-dim); margin-bottom: .6rem; }
.entry__author { font-size: var(--t-body); margin-bottom: 1.75rem; }
.record--entry { font-size: var(--t-ui); font-family: var(--sans); padding-top: 1.25rem; border-top: 1px solid var(--rule); gap: .55rem 1.5rem; }
.entry__prose { margin-top: 1.75rem; }
.entry__prose h2 { font-size: var(--t-body); font-style: italic; margin: 0 0 .4rem; }
.entry__prose p { line-height: 1.6; max-width: 38em; white-space: pre-line; }
.reserved { font-family: var(--sans); font-style: normal; font-weight: 500; font-size: .75rem; color: var(--carmine-deep); border: 1px solid currentColor; border-radius: 2px; padding: 0 .3em; margin-left: .35em; white-space: nowrap; }
.image-admin { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px dashed var(--rule); }
.image-admin h2 { font-size: var(--t-body); font-style: italic; margin: 0 0 .4rem; }
.image-admin .upload { margin-bottom: .75rem; }
.image-admin input[type="file"] { width: 100%; }
.dash-count { font-family: var(--sans); font-size: var(--t-small); color: var(--ink-dim); }
/* immagine della scheda: cliccabile per ingrandire */
.zoom { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; font: inherit; }
.zoom picture { display: contents; }
.zoom:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }

/* visione ingrandita: il foglio d'album scuro a tutto schermo */
.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgba(21, 29, 27, .97); color: var(--on-album);
  display: none; flex-direction: column;
}
.lightbox[open] { display: flex; }
.lightbox::backdrop { background: rgba(21, 29, 27, .97); }
.lightbox__bar { display: flex; align-items: center; gap: 1.5rem; padding: .9rem 1.5rem; font-family: var(--sans); font-size: var(--t-ui); border-bottom: 1px solid rgba(230, 223, 203, .15); }
.lightbox__title { font-family: var(--serif); font-style: italic; font-size: var(--t-body); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox__code { font-family: var(--sans); font-style: normal; font-size: var(--t-small); color: var(--on-album-dim); margin-left: .5rem; }
.lightbox__hint { font-size: var(--t-small); color: var(--on-album-dim); }
.lightbox__hint--actual, .lightbox.is-actual .lightbox__hint--fit { display: none; }
.lightbox.is-actual .lightbox__hint--actual { display: inline; }
.lightbox__close { font: inherit; font-weight: 600; color: var(--on-album); background: none; border: 1px solid rgba(230, 223, 203, .4); border-radius: 2px; padding: .4rem 1rem; cursor: pointer; }
.lightbox__close:hover { border-color: var(--on-album); }
.lightbox__stage { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; padding: 1.5rem; cursor: zoom-out; }
.lightbox__frame { display: block; cursor: zoom-in; box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .9); }
.lightbox__frame img { display: block; max-width: calc(100vw - 3rem); max-height: calc(100dvh - 7rem); width: auto; height: auto; }
.lightbox.is-actual .lightbox__stage { place-items: start; }
.lightbox.is-actual .lightbox__frame { cursor: zoom-out; margin: auto; }
.lightbox.is-actual .lightbox__frame img { max-width: none; max-height: none; }
.lightbox.is-loading .lightbox__stage::before { content: 'Caricamento dell’immagine…'; position: absolute; font-family: var(--sans); font-size: var(--t-small); color: var(--on-album-dim); }
.lightbox.is-loading .lightbox__frame { opacity: 0; }

/* ristampe anastatiche dentro la scheda della prima edizione */
.edition-tag, .plate__badge { font-family: var(--sans); font-size: .75rem; font-weight: 600; letter-spacing: .02em; border-radius: 2px; padding: .05rem .4rem; white-space: nowrap; }
.edition-tag { color: var(--violet); border: 1px solid currentColor; margin-left: .4rem; }
.entry__reprints { font-family: var(--sans); font-size: var(--t-ui); margin: -.75rem 0 1.5rem; }
.reprints > .hint { max-width: 46em; }
.reprint { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr); gap: 2.5rem; padding: 2rem 0 0; margin-top: 1.5rem; border-top: 1px solid var(--rule); scroll-margin-top: 1.5rem; }
.reprint:target .reprint__text h3 { text-decoration: underline; text-decoration-color: var(--carmine); text-underline-offset: .2em; }
.reprint h3 { font-family: var(--serif); font-size: var(--t-h2); font-style: italic; font-weight: 500; margin: 0 0 .3rem; }
.reprint__publisher { font-size: var(--t-body); margin-bottom: 1rem; }
.mount--small { min-height: 0; padding: 8%; }
.mount--small .corner { width: 22px; height: 22px; }
.mount--small.mount--empty { aspect-ratio: 3 / 4; }
.reprint .image-admin { margin-top: 1rem; padding-top: .9rem; }
.plate__badge { align-self: flex-start; margin-top: .3rem; color: var(--on-album); border: 1px solid rgba(230, 223, 203, .45); font-weight: 500; }

/* trascinamento dell'immagine sul riquadro (admin) */
.mount__drop {
  position: absolute; inset: 0; z-index: 2; display: none; align-items: center; justify-content: center;
  background: rgba(242, 236, 221, .88); outline: 3px dashed var(--carmine); outline-offset: -14px;
  font-family: var(--sans); font-size: var(--t-ui); font-weight: 600; color: var(--carmine-deep);
}
.mount.is-dragover .mount__drop, .mount.is-uploading .mount__drop { display: flex; }
.mount.is-uploading .mount__drop { outline-style: solid; cursor: progress; }
#campi .field-list { list-style: none; padding-left: 0; margin-bottom: 1.25rem; }

@media (max-width: 760px) {
  .postcard {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "plate" "address" "message";
    padding: 2rem 1.5rem 2.25rem;
  }
  .postcard__nameplate { margin-bottom: 1rem; }
  .postcard__message { padding: 1.5rem 0 0; margin-top: 2rem; border-top: 1px solid var(--rule); }
  .postcard__message::after { display: none; }
  .postcard__message h1 { font-size: var(--t-h1); }
  .franking { height: 120px; }
  .postmark { width: 190px; right: 40px; }
  .line { grid-template-columns: 1fr; gap: .1rem; }
  .line > span { padding-bottom: 0; }
  .sheet { padding: 2rem 1.25rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .index__row { flex-wrap: wrap; }
  .index__leader { display: none; }
  .index__state { width: 100%; font-size: var(--t-ui); }
  .finder { grid-template-columns: 1fr; }
  .finder__img { padding-bottom: 0; }
  .plates { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 2rem 1.25rem; }
  .entry { grid-template-columns: 1fr; gap: 2rem; }
  /* su telefono: immagine, poi titolo e dati, poi (admin) il caricamento dell'immagine */
  .entry__figure { display: contents; }
  .entry__figure > .mount { order: 1; width: 100%; max-width: 26rem; justify-self: center; }
  .entry__figure > .entry__noimg { order: 2; margin-top: -1.25rem; }
  .entry__text { order: 3; }
  .entry__figure > .image-admin { order: 4; margin-top: 0; }
  .record { grid-template-columns: 1fr; gap: 0; }
  .record dt { font-size: var(--t-small); margin-top: .7rem; }
  .record dt:first-child { margin-top: 0; }
  .record > div:first-child dt { margin-top: 0; }
  /* tabelle impilate: ogni riga diventa una scheda con etichette */
  .ledger--stack thead { display: none; }
  .ledger--stack, .ledger--stack tbody, .ledger--stack tr, .ledger--stack td { display: block; width: 100%; }
  .ledger--stack tr { padding: .9rem 0; border-bottom: 1px solid var(--rule); }
  .ledger--stack td { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; border: 0; text-align: right; }
  .ledger--stack td::before { content: attr(data-label); color: var(--ink-dim); font-size: var(--t-small); text-align: left; flex: none; }
  .ledger--stack td.right { justify-content: flex-end; padding-top: .6rem; }
  .ledger--stack td.right::before { content: none; }
  .ledger--stack td:first-child { text-align: left; font-size: var(--t-body); }
  .ledger--stack td:first-child::before { content: none; }
  .lightbox__hint, .lightbox.is-actual .lightbox__hint--actual { display: none; }
  .reprint { grid-template-columns: 1fr; gap: 1.25rem; }
  .reprint__figure { max-width: 16rem; }
}

@media print {
  .protected img, .mount img { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .postmark { animation: none; }
}
