/* ==================================================
   AETERNUM — THEME CORE (NECROLOGI)
   4 BLOCCHI: Reset/Vars → Base/Layout → Componenti → Fix
   NOTE:
   - Niente --gold (solo --gold-dark)
   - Blu medioevale presente (--blue-medieval)
   - Titoli centrati e NON invasivi
   - H1/H2: testo neutro, SOLO capolettera colorato
   - LUX: no rotate per evitare sgranature
================================================== */


/* ==================================================
   [1/4] RESET SAFE + VARIABILI
================================================== */

*, *::before, *::after{ box-sizing: border-box; }

html, body{
  margin: 0;
  padding: 0;
  height: 100%;
}

img{ max-width: 100%; display: block; }

ul{ list-style: none; padding: 0; margin: 0; }

/* ---- Theme tokens + LUX tokens (UNIFICATI) ---- */
:root{
  --bg-main: #fafaf7;
  --bg-card: #ffffff;
  --bg-soft: #f3f1ec;

  --text-main: #1f2a36;
  --text-muted: #6b7280;

  --accent: #7a1e2b;          /* rosso vinaccia */
  --gold-dark: #8b6b2e;       /* dark gold (UNICO ORO) */
  --blue-medieval: #1f4fa3;   /* blu medioevale */

  --border: rgba(0,0,0,.12);

  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.06);
  --shadow-hover: 0 18px 40px rgba(0,0,0,.08);

  --space-xs: .5rem;
  --space-sm: 1rem;
  --space-md: 1.75rem;
  --space-lg: 3rem;

  --container: 1180px;

  /* LUX (effetti globali premium) */
  --lux-push: -6px;
  --lux-shadow-hover: 0 26px 70px rgba(0,0,0,.10);

  --lux-ring: rgba(139,107,46,.16);        /* darkgold glow */
  --lux-ring-strong: rgba(139,107,46,.24);
}


/* ==================================================
   [2/4] BASE + LAYOUT (NON DISTRUTTIVO)
================================================== */

body{
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.65;

  min-height: 100%;
  display: flex;
  flex-direction: column;
}

main{ flex: 1 0 auto; }
footer{ margin-top: auto; }

p{ margin: 0 0 var(--space-sm); }

small, .text-muted{
  font-size: .75rem;
  letter-spacing: .08em;
  color: var(--text-muted);
}

/* Titoli globali: solo font/spacing (safe) */
h1, h2, h3{
  font-family: "Playfair Display", serif;
  letter-spacing: .04em;
  margin: 0;
  font-weight: 900;

  /* RIPRISTINO: centratura titoli */
  text-align: center;
}

/* H1 e H2 neutri: SOLO capolettera colorato */
h1, h2{
  color: var(--text-main);
  text-shadow:
    0 1px 0 rgba(255,255,255,.72),
    0 10px 26px rgba(0,0,0,.18);
}

/* H3 neutro */
h3{
  color: var(--text-main);
  text-shadow:
    0 1px 0 rgba(255,255,255,.65),
    0 8px 20px rgba(0,0,0,.16);
}

/* capolettera */
h1::first-letter{
  color: var(--accent);
  font-size: 1.22em;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .02em;
}

h2::first-letter{
  color: var(--blue-medieval);
  font-size: 1.18em;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .02em;
}

/* Container */
.layout, .container{
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* ==================================================
   SOTTOTITOLI (AETERNUM)
   - Font dedicato
   - Solo capolettera blu + più grande
================================================== */

.subtitle,
.page-subtitle{
  text-align: center;
  color: var(--text-main);

  font-family: "Cinzel", "Playfair Display", serif;  /* font subtitle */
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;

  text-shadow: 0 1px 0 rgba(255,255,255,.75);
}

/* capolettera deluxe */
.subtitle::first-letter,
.page-subtitle::first-letter{
  color: var(--blue-medieval);

  font-family: "Cinzel", serif; /* più “rituale” */
  font-size: 1.42em;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .04em;

  padding-right: 1px;

  text-shadow:
    0 1px 0 rgba(255,255,255,.80),
    0 6px 16px rgba(0,0,0,.18);
}
.subtitle,
.page-subtitle{
  margin-top: .75rem;
}



/* ==================================================
   HOME — FIX CARD LAYOUT VERTICALE (SAFE)
================================================== */

.home .necrologio-card > a{
  display: block !important;
  padding: 0 !important;
}

.home .necrologio-thumb{
  width: 100% !important;
  min-width: 0 !important;
  height: 180px;
  border-radius: 0 !important;
}

.home .necrologio-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home .necrologio-body{
  padding: var(--space-sm) !important;
}


/* ==================================================
   [3/4] COMPONENTI (FORM / BUTTON / CARD / GRID)
================================================== */

/* Links */
a{
  color: var(--accent);
  text-decoration: none;
}
a:hover{
  color: var(--gold-dark);
  text-decoration: underline;
}

/* BUTTON SYSTEM */
.btn,
button,
input[type="submit"]{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;

  height: 46px;
  padding: 0 1.1rem;

  border-radius: 10px;
  border: 1px solid transparent;

  font-weight: 800;
  font-size: .95rem;

  cursor: pointer;
  user-select: none;

  transition:
    transform .15s ease,
    box-shadow .2s ease,
    filter .2s ease,
    border-color .2s ease,
    background-color .2s ease;
}

/* Default button: vinaccia primary */
button,
input[type="submit"]{
  background: linear-gradient(#8a2633, #6d1f24);
  color: #fff;
  box-shadow: 0 12px 26px rgba(0,0,0,.10),
              inset 0 1px 0 rgba(255,255,255,.22);
}

button:hover,
input[type="submit"]:hover{
  filter: brightness(1.03);
  box-shadow: 0 16px 34px rgba(0,0,0,.10);
}

button:active,
input[type="submit"]:active,
.btn:active{ transform: translateY(1px); }

/* Varianti */
.btn-primary{
  background: linear-gradient(#8a2633, #6d1f24);
  color: #fff;
  box-shadow: 0 12px 26px rgba(0,0,0,.10),
              inset 0 1px 0 rgba(255,255,255,.12);
}

.btn-secondary,
.btn-ghost{
  background: rgba(139,107,46,.10);
  color: var(--accent);
  border-color: rgba(139,107,46,.22);
  box-shadow: none;
}

.btn-secondary:hover,
.btn-ghost:hover{
  background: rgba(139,107,46,.16);
  border-color: rgba(139,107,46,.34);
}

/* Focus accessibile */
:where(.btn, button, input[type="submit"], input, select, textarea):focus{
  outline: none;
  box-shadow: 0 0 0 3px rgba(139,107,46,.10);
}

/* BOX/CARD */
.box, .card{
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,.06);
}

.box-soft{
  background: var(--bg-soft);
  box-shadow: none;
}

/* FORM */
label{
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

input, select, textarea{
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-main);
  font-size: .95rem;
}

input, select{ height: 46px; padding: 0 .9rem; }
textarea{ min-height: 120px; padding: .75rem .9rem; resize: vertical; }

input:hover, select:hover, textarea:hover{ border-color: rgba(122,30,43,.30); }
input:focus, select:focus, textarea:focus{ border-color: rgba(139,107,46,.55); }


/* ==================================================
   SEARCH HOME (senza q) — Desktop + Mobile
================================================== */

.search-wrapper{
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: var(--space-md);
  max-width: 900px;
  margin: 0 auto var(--space-lg);
}

.search-main{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-areas:
    "nome cognome comune"
    "filters filters filters"
    "submit submit submit";
  gap: var(--space-sm);
  row-gap: 1.25rem;
}

/* campi base */
.search-main > input[name="nome"]{
  grid-area: nome;
}

.search-main > input[name="cognome"]{
  grid-area: cognome;
}

.search-main > .comune-autocomplete{
  grid-area: comune;
  position: relative;
}

/* filtri in riga */
.search-main > .filters-row{
  grid-area: filters;
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
}

/* dropdown coerenti */
.search-main > .filters-row select{
  flex: 0 0 260px;
  width: 260px;
  max-width: 100%;
}

/* submit full width */
.search-main > button{
  grid-area: submit;
  width: 100%;
}

/* ==================================================
   MOBILE
================================================== */

@media (max-width: 640px){
  .search-main{
    grid-template-columns: 1fr;
    grid-template-areas:
      "nome"
      "cognome"
      "comune"
      "filters"
      "submit";
  }

  .search-main > .filters-row{
    flex-direction: column;
    align-items: stretch;
  }

  .search-main > .filters-row select{
    width: 100%;
    flex-basis: auto;
  }
}


/* Autocomplete */
.autocomplete-box{
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;

  margin: 0;
  padding: 4px 0;

  list-style: none;
  background: #fff;

  border: 1px solid rgba(0,0,0,.18);
  border-radius: 10px;

  box-shadow: 0 14px 34px rgba(0,0,0,.10);
  z-index: 99999;

  max-height: 260px;
  overflow-y: auto;

  display: none;
}

.autocomplete-box:not(:empty){ display: block; }

.autocomplete-box li{
  padding: 10px 14px;
  color: var(--text-main) !important;
  font-size: .95rem;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
}
.autocomplete-box li:hover{ background: var(--bg-soft); }


/* GRID + CARD BASE */
.necrologi-list{
  max-width: var(--container);
  margin: 0 auto;

  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-md);
}

.necrologio-card{
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .35s ease, box-shadow .35s ease, filter .35s ease;
}

.necrologio-card:hover{
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
}

/* Thumb base */
.necrologio-thumb{
  height: 180px;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb-placeholder{
  font-size: .85rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(0,0,0,.45);
}

.necrologio-body{ padding: var(--space-sm); }

/* Nome defunto in card: darkgold */
.necrologio-body h2{
  font-size: 1.1rem;
  margin: 0 0 .4rem;
  color: var(--gold-dark);
  font-weight: 900;
  text-shadow:
    0 1px 0 rgba(255,255,255,.45),
    0 -1px 0 rgba(0,0,0,.10);
}

/* nessun dropcap nel titolo card */
.necrologio-body h2::first-letter{
  color: inherit !important;
  font-size: inherit !important;
  font-weight: inherit !important;
}

.necrologio-body .place{
  font-size: .75rem;
  color: var(--accent);
  margin: 0 0 .4rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.necrologio-body .snippet{
  font-size: .85rem;
  color: var(--text-muted);
  margin: 0;
}

.necrologio-body .date{
  font-size: .7rem;
  margin-top: .5rem;
  color: var(--text-muted);
}


/* FOOTER */
footer{ background: var(--bg-soft); }

.footer-inner{
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-md);
  text-align: center;
  font-size: .75rem;
  color: var(--text-muted);
}

.footer-links{ margin-top: .5rem; }

.footer-links a{
  margin: 0 .4rem;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.footer-links a:hover{
  color: var(--gold-dark);
  text-decoration: underline;
}


/* ==================================================
   [4/4] FIX “ANTI-ROTTURA”
================================================== */

/* no link blu/viola nelle card */
.necrologio-card > a,
.necrologio-card > a:link,
.necrologio-card > a:visited,
.necrologio-card > a:hover,
.necrologio-card > a:active{
  color: inherit !important;
  text-decoration: none !important;
  display: block;
}

.necrologio-card > a *{
  color: inherit !important;
  text-decoration: none !important;
}

/* hover nome */
.necrologio-card:hover .necrologio-body h2{
  color: var(--gold-dark) !important;
}

/* Publisher public page */
.publisher-public .publisher-meta a,
.publisher-public .publisher-meta a:visited{
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}
.publisher-public .publisher-meta a:hover{
  color: var(--gold-dark);
  text-decoration: underline;
}

/* Dashboard table */
.table{
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
  border: 1px solid rgba(0,0,0,.06);
}

.table th{
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  text-align: left;
  padding: .75rem;
  border-bottom: 1px solid rgba(0,0,0,.08);
}

.table td{
  padding: .85rem .75rem;
  border-bottom: 1px solid rgba(0,0,0,.08);
  font-size: .92rem;
}

.table tr:hover{ background: rgba(139,107,46,.06); }
.table tr:last-child td{ border-bottom: none; }

/* checkbox/radio non alterati */
input[type="checkbox"], input[type="radio"]{ transform: none; }


/* ==================================================
   SEARCH HOME — GRID + PULISCI (DESKTOP + MOBILE)
   - Nessun campo q
   - Pulisci dentro .filters-row
   - Layout stabile (no wrap casuale)
================================================== */

/* -------------------------------
   GRID PRINCIPALE (DESKTOP)
-------------------------------- */

.search-main{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-areas:
    "nome cognome comune"
    "filters filters filters"
    "submit submit submit";
  gap: var(--space-sm);
  row-gap: 1.25rem;
}

/* campi */
.search-main > input[name="nome"]{ grid-area: nome; }
.search-main > input[name="cognome"]{ grid-area: cognome; }
.search-main > .comune-autocomplete{
  grid-area: comune;
  position: relative;
}

/* submit */
.search-main > button[type="submit"]{
  grid-area: submit;
  width: 100%;
}

/* -------------------------------
   FILTRI + PULISCI (DESKTOP)
-------------------------------- */

.search-main > .filters-row{
  grid-area: filters;

  display: grid;
  grid-template-columns: 260px 260px 1fr auto; /* tipo | periodo | spacer | pulisci */
  gap: var(--space-sm);
  align-items: end;
}

/* select coerenti */
.search-main > .filters-row select{
  width: 100%;
  max-width: 100%;
}

/* pulsante Pulisci */
.search-main > .filters-row .search-clear{
  justify-self: end;
  align-self: end;

  height: 46px;
  padding: 0 1.1rem;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  white-space: nowrap;
  text-decoration: none;
}

/* ==================================================
   MOBILE
================================================== */

@media (max-width: 640px){

  /* grid principale */
  .search-main{
    grid-template-columns: 1fr;
    grid-template-areas:
      "nome"
      "cognome"
      "comune"
      "filters"
      "submit";
  }

  /* filtri + pulisci in colonna */
  .search-main > .filters-row{
    grid-template-columns: 1fr;
  }

  .search-main > .filters-row .search-clear{
    width: 100%;
    justify-self: stretch;
  }
}

/* ==================================================
   AETERNUM LUX — GLOBAL LIFT / PUSH (NO ROTATE)
   Applica a: card + manifesti
   FIX: evita sgranature
================================================== */

.necrologio-card,
.manifest-preview{
  position: relative;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;

  transform: translateZ(0);
  will-change: transform, box-shadow, filter;

  transition:
    transform .22s ease,
    box-shadow .28s ease,
    filter .28s ease;
}

/* glow premium */
.necrologio-card::after,
.manifest-preview::after{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity .28s ease;

  box-shadow:
    0 0 0 3px var(--lux-ring),
    0 0 32px var(--lux-ring-strong);
}

/* hover LUX */
.necrologio-card:hover,
.manifest-preview:hover{
  transform: translateY(var(--lux-push));
  box-shadow: var(--lux-shadow-hover);
  filter: brightness(1.02) contrast(1.02);
}

.necrologio-card:hover::after,
.manifest-preview:hover::after{
  opacity: 1;
}

/* Active */
.necrologio-card:active,
.manifest-preview:active{
  transform: translateY(-2px);
}

/* mobile safety */
@media (max-width: 640px){
  .necrologio-card:hover,
  .manifest-preview:hover{
    transform: translateY(-3px);
  }
}


/* ==================================================
   CENTRATURA — SOLO nome defunto (card + pagina)
================================================== */

.necrologio-header .necrologio-nome{
  text-align: center;
}

.necrologio-body h2,
.necrologio-body h3{
  text-align: center;
}

/* ==================================================
   Pagination
================================================== */

.pagination {
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:8px;
  margin:30px 0;
}

.pagination a {
  min-width:42px;
  height:42px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:10px;
  border:1px solid #ddd;
  text-decoration:none;
  font-weight:600;
  color:#7a1e2b;
  background:#fff;
}

.pagination a.active {
  background:#b59b5b;
  color:#111;
  border-color:#b59b5b;
}

.pagination .ellipsis {
  padding:0 6px;
  opacity:.5;
}

/* ===============================
   HOME — ALLINEAMENTO CONTENUTO
================================ */

.necrologi-list{
  max-width: 1200px;
  margin: 40px auto 0;
  padding: 0 16px;
}

/* Griglia centrata */
.necrologi-list{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 360px));
  gap: 26px;
  justify-content: center;
}

/* Paginazione centrata e separata */
.pagination{
  width: 100%;
  max-width: 1200px;
  margin: 10px auto 30px;
  padding: 0 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Pulsanti pagina */
.pagination a{
  min-width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #ddd;
  text-decoration: none;
  font-weight: 700;
  color: #7a1e2b;
  box-shadow: 0 4px 12px rgba(0,0,0,.05);
}

.pagination a.active{
  background: #b59b5b;
  color: #fff;
  border-color: #b59b5b;
}

.pagination .ellipsis{
  padding: 0 6px;
  opacity: .6;
  font-weight: 700;
}  

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    text-decoration: none;
    border: none;
    background: linear-gradient(135deg, #7b1e22, #5e1619);
    color: #ffffff;
    box-shadow: 0 6px 14px rgba(123, 30, 34, 0.10);
    transition: all .18s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(123, 30, 34, 0.10);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 4px 10px rgba(123, 30, 34, 0.10);
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 10px;
    flex-wrap: wrap;
}

/* Dashboard spacing upgrade */
main.dashboard {
  padding: 2.6rem 2rem 3.2rem;
}

.dashboard .card {
  padding: 1.8rem;
  border-radius: 16px;
}

.btn-danger {
  background: linear-gradient(#c0392b, #a93226);
  color: #fff;
  box-shadow: 0 10px 22px rgba(0,0,0,.08);
}

.btn-danger:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  background: #f4f1ed;
  border: 1px solid #ded6cf;
  color: var(--accent);
  box-shadow: none;
}

.btn-ghost:hover {
  background: #ebe6e0;
}

.dashboard-form h2 {
  font-size: 1.15rem;
  font-weight: 700;
  text-align: left;
  margin-top: 2.4rem;
  margin-bottom: 1rem;
  padding-left: .7rem;
  border-left: 4px solid var(--accent);
}

.toolbar {
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e6e1db;
}

.breadcrumb {
  margin: 10px 0 20px;
  font-size: .9rem;
  color: rgba(0,0,0,.65);
}

.breadcrumb a {
  text-decoration: none;
  color: #8b6b2e;
}

.breadcrumb span {
  margin: 0 6px;
  opacity: .5;
}
