/* Gestione sito: chiara, grande, senza sorprese */
@font-face {
  font-family: "Bodoni Moda";
  src: url("../fonts/bodoni-moda-latin-standard-normal.woff2") format("woff2-variations");
  font-weight: 400 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("../fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 200 800; font-style: normal; font-display: swap;
}

:root {
  --green: #1f5a3e;
  --green-deep: #143d2a;
  --green-tint: #e2ebe4;
  --linen: #f2f2ee;
  --paper: #ffffff;
  --ink: #161816;
  --ink-2: #50544f;
  --rule: #d7d8d1;
  --red: #a3221b;
  --red-tint: #f7e4e2;
  --gold: #cfae5a;
  --tone-cobalt: #24478f; --tone-ruby: #8f2234; --tone-amber: #a8701a;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --display: "Bodoni Moda", Georgia, serif;
  --text: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: #b9bbb3 var(--linen); }
body { margin: 0; background: var(--linen); color: var(--ink); font: 400 1.0625rem/1.55 var(--text); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
::selection { background: var(--green); color: #fff; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; border-radius: 3px; }
a { color: var(--green); text-underline-offset: 0.2em; }
img { max-width: 100%; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.i { width: 22px; height: 22px; flex: none; }
.i--lg { width: 32px; height: 32px; }
.muted { color: var(--ink-2); margin: 0; }
.tone-cobalt { --tone: var(--tone-cobalt); } .tone-ruby { --tone: var(--tone-ruby); } .tone-amber { --tone: var(--tone-amber); }

/* ---------- Struttura ---------- */
.has-nav { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--green); color: #f2f2ee; display: flex; flex-direction: column; padding: 24px 16px;
}
.side__brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; padding: 4px 12px 28px; }
.side__brand .i { color: var(--gold); width: 28px; height: 28px; }
.side__brand span { font: 600 1.25rem/1.15 var(--display); }
.side__brand small { display: block; font: 400 0.875rem var(--text); color: #c4d8ca; margin-top: 2px; }
.side__nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side__nav a, .side__foot a, .side__foot button {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 12px 14px; border-radius: 6px; color: inherit; text-decoration: none;
  font: 500 1.0625rem var(--text); background: none; border: 0; cursor: pointer; text-align: left;
  transition: background-color 150ms ease;
}
.side__nav a[aria-current="page"] { background: #f2f2ee; color: var(--green-deep); font-weight: 700; }
@media (hover: hover) and (pointer: fine) {
  .side__nav a:not([aria-current]):hover, .side__foot a:hover, .side__foot button:hover { background: rgb(255 255 255 / 0.1); }
}
.side__foot { margin-top: auto; padding-top: 24px; border-top: 1px solid rgb(255 255 255 / 0.18); display: grid; gap: 2px; }
.side__foot form { margin: 0; }
.side__user { margin: 12px 14px 0; font-size: 0.875rem; color: #c4d8ca; }
.topbar { display: none; }

.main { padding: 40px clamp(20px, 4vw, 56px) 96px; max-width: 1240px; width: 100%; }
.is-auth .main { max-width: none; padding: 0; }

.page-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
.page-top h1 { margin: 0 0 6px; font: 500 clamp(2rem, 1.6rem + 1.4vw, 2.75rem)/1.05 var(--display); letter-spacing: -0.015em; }
.back { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 600; text-decoration: none; }

/* ---------- Bottoni ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 20px; border-radius: 6px; border: 1px solid transparent;
  font: 600 1.0625rem var(--text); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform 140ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, opacity 150ms ease;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn--primary { background: var(--green); color: #fff; }
.btn--ghost { background: var(--paper); color: var(--ink); border-color: var(--rule); }
.btn--danger { color: var(--red); }
.btn--sm { min-height: 40px; padding: 0 12px; font-size: 0.9375rem; }
.btn--block { width: 100%; }
.btn.is-busy { opacity: 0.7; pointer-events: none; }
@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover { background: var(--green-deep); }
  .btn--ghost:hover { border-color: #a9aba3; }
  .btn--danger:hover { background: var(--red-tint); border-color: #e5b8b4; }
}

/* ---------- Campi ---------- */
.field { display: grid; align-content: start; gap: 6px; margin-bottom: 20px; }
.label { font-weight: 700; font-size: 1rem; }
.optional { font-weight: 400; color: var(--ink-2); font-size: 0.9375rem; margin-left: 4px; }
.hint { margin: 0; color: var(--ink-2); font-size: 0.9375rem; }
.error { margin: 0; color: var(--red); font-weight: 600; font-size: 0.9375rem; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  font: 400 1.0625rem/1.4 var(--text); color: var(--ink);
  background: var(--paper); border: 1px solid #bfc1b9; border-radius: 6px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #6f736d; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgb(31 90 62 / 0.2); }
.input--title { font: 500 1.625rem/1.2 var(--display) !important; min-height: 60px !important; }
.has-error input, .has-error textarea, .has-error .drop { border-color: var(--red) !important; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9375rem; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--green); }
.stack { display: grid; gap: 4px; }
.choices { border: 0; padding: 0; margin: 0 0 20px; display: grid; gap: 12px; }
.choices .check { align-items: flex-start; }
.choices .check input { margin-top: 2px; flex: none; }
.choices small { display: block; color: var(--ink-2); font-size: 0.9375rem; }
.row2, .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; margin-bottom: 6px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 48px; height: 28px; border-radius: 99px; background: #c3c5bd; position: relative; flex: none; transition: background-color 180ms ease; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); transition: transform 200ms var(--ease-out); }
.switch input:checked + .switch__track { background: var(--green); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--green); outline-offset: 2px; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; margin: 0 0 24px; background: var(--red-tint); color: #7d1913; border: 1px solid #e5b8b4; border-radius: 6px; font-weight: 600; }

/* ---------- Riquadri ---------- */
.box { background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: 22px; margin-bottom: 20px; }
.box h2 { margin: 0 0 16px; font: 700 1.125rem var(--text); }
.box h2 small { font-weight: 400; color: var(--ink-2); font-size: 0.9375rem; margin-left: 6px; }
.box--wide { max-width: 900px; }
.box .field:last-child { margin-bottom: 0; }
.box .btn--block + .btn--block { margin-top: 10px; }
.box .switch + .hint { margin-bottom: 16px; }
.actions-row { margin: 8px 0 32px; }

.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.edit-side { position: sticky; top: 24px; }
.savebar { display: none; }

/* foto */
.drop { position: relative; border: 2px dashed #bfc1b9; border-radius: 8px; padding: 16px; display: grid; gap: 12px; justify-items: center; text-align: center; background: var(--linen); transition: border-color 150ms ease, background-color 150ms ease; }
.drop.is-over { border-color: var(--green); background: var(--green-tint); }
.drop__preview { width: 100%; max-height: 220px; object-fit: cover; border-radius: 4px; }
.drop__empty { display: grid; justify-items: center; gap: 6px; color: var(--ink-2); }
.drop__empty p { margin: 0; }
.drop.has-image .drop__empty { display: none; }
.drop__actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }
.drop label.btn { cursor: pointer; }
.drop label.btn:focus-within { outline: 3px solid var(--green); outline-offset: 2px; }

/* ---------- Bacheca ---------- */
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 32px; }
.quick__item {
  display: grid; gap: 4px; padding: 22px; border-radius: 8px; text-decoration: none; color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule);
  transition: transform 140ms var(--ease-out), border-color 150ms ease, box-shadow 200ms ease;
}
.quick__item .i { color: var(--green); margin-bottom: 8px; }
.quick__item strong { font: 500 1.375rem/1.15 var(--display); }
.quick__item span { color: var(--ink-2); font-size: 0.9375rem; }
.quick__item:first-child { background: var(--green); color: #fff; border-color: var(--green); }
.quick__item:first-child .i { color: var(--gold); }
.quick__item:first-child span { color: #c4d8ca; }
.quick__item:active { transform: scale(0.98); }
@media (hover: hover) and (pointer: fine) { .quick__item:hover { box-shadow: 0 6px 18px -8px rgb(0 0 0 / 0.25); } }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel { background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 0; }
.panel__head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 20px 10px; }
.panel__head h2 { margin: 0; font: 700 1.125rem var(--text); }
.panel__head a { font-weight: 600; font-size: 0.9375rem; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows a { display: flex; gap: 14px; align-items: center; padding: 12px 20px; color: var(--ink); text-decoration: none; border-top: 1px solid #ecece7; transition: background-color 150ms ease; }
.rows strong { display: block; font-weight: 600; }
.rows small { color: var(--ink-2); font-size: 0.9375rem; }
@media (hover: hover) and (pointer: fine) { .rows a:hover { background: var(--linen); } }
.datebox { display: grid; place-items: center; width: 52px; height: 52px; flex: none; border: 1px solid var(--rule); border-radius: 6px; font-size: 0.75rem; text-transform: uppercase; font-weight: 700; color: var(--red); line-height: 1; }
.datebox b { font: 500 1.375rem var(--display); color: var(--ink); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.8125rem; font-weight: 700; background: #ecece7; color: var(--ink-2); flex: none; }
.tag--event { background: var(--green-tint); color: var(--green-deep); }
.tag--news { background: #ece6f1; color: #4a2963; }
.tag--draft { background: #fbefd4; color: #7a5410; }
.empty-state { padding: 20px; color: var(--ink-2); margin: 0; }
.empty-state--big { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 64px 20px; background: var(--paper); border: 1px dashed #bfc1b9; border-radius: 8px; }
.empty-state--big .i { color: var(--green); }
.empty-state--big p { margin: 0; font-size: 1.125rem; }

/* ---------- Elenchi ---------- */
.search { position: relative; max-width: 420px; margin-bottom: 20px; }
.search .i { position: absolute; left: 14px; top: 13px; color: var(--ink-2); pointer-events: none; }
.search input { padding-left: 46px !important; }
.list { list-style: none; margin: 0; padding: 0; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.list__row { display: flex; align-items: center; gap: 12px; padding-right: 14px; border-top: 1px solid #ecece7; }
.list__row:first-child { border-top: 0; }
.list__row.is-past { opacity: 0.68; }
.list__main { flex: 1; display: flex; gap: 16px; align-items: center; padding: 14px 18px; color: var(--ink); text-decoration: none; min-width: 0; }
.list__main img, .list__noimg { width: 72px; height: 54px; object-fit: cover; border-radius: 4px; flex: none; }
.list__noimg { display: grid; place-items: center; background: var(--linen); color: var(--ink-2); }
.list__main strong { display: block; font-size: 1.125rem; font-weight: 600; overflow-wrap: anywhere; }
.list__main small { color: var(--ink-2); font-size: 0.9375rem; }
.list__actions { display: flex; gap: 8px; }
.list__actions form { margin: 0; }
@media (hover: hover) and (pointer: fine) { .list__main:hover strong { color: var(--green); text-decoration: underline; } }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: #e4e5df; border-radius: 8px; margin-bottom: 24px; }
.seg a { padding: 10px 18px; border-radius: 6px; color: var(--ink); text-decoration: none; font-weight: 600; transition: background-color 150ms ease; }
.seg a[aria-current="page"] { background: var(--paper); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.seg a[class*="tone-"]::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--tone); margin-right: 8px; }

/* ---------- Orari ---------- */
.church-box h2 { padding-bottom: 12px; border-bottom: 4px solid var(--tone); font: 500 1.5rem var(--display); }
.mass-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.mass-row { display: grid; grid-template-columns: 170px 130px minmax(0, 1fr) auto; gap: 8px; align-items: center; transition: opacity 180ms ease, transform 180ms var(--ease-out); }
.mass-row.is-leaving { opacity: 0; transform: translateX(-8px); }
.mass-row .btn { min-height: 48px; }

/* ---------- Slider ---------- */
.slides { list-style: none; margin: 0 0 28px; padding: 0; display: grid; gap: 16px; max-width: 1000px; }
.slide-item { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: 16px; }
.slide-item img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 4px; }
.slide-item__form .field { margin-bottom: 12px; }
.slide-item__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.slide-item__actions label { cursor: pointer; }
.slide-item__actions label:focus-within { outline: 3px solid var(--green); outline-offset: 2px; }
.spacer { flex: 1; }
.add-slide { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 24px; align-items: start; }

/* ---------- Accesso ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--green); }
.auth__card { width: min(100%, 440px); background: var(--paper); border-radius: 10px; padding: 40px 36px; box-shadow: 0 30px 60px -30px rgb(0 0 0 / 0.5); }
.auth__mark { width: 40px; height: 40px; color: var(--green); }
.auth h1 { margin: 12px 0 8px; font: 500 2rem/1.1 var(--display); }
.auth .muted { margin-bottom: 24px; }
.auth__back { margin: 20px 0 0; text-align: center; }

/* ---------- Avvisi ---------- */
.toast {
  position: fixed; z-index: 50; left: 50%; bottom: 24px;
  display: flex; gap: 10px; align-items: center; padding: 14px 20px; max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; border-radius: 8px; font-weight: 600;
  box-shadow: 0 12px 32px -12px rgb(0 0 0 / 0.5);
  transform: translateX(-50%); opacity: 1;
  transition: transform 400ms var(--ease-out), opacity 300ms ease;
  animation: toast-in 400ms var(--ease-out);
}
.toast--ok .i { color: #8fd6a8; }
.toast--err { background: var(--red); }
.toast.is-leaving { opacity: 0; transform: translate(-50%, 12px); transition-duration: 200ms; pointer-events: none; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 100%); } }

/* ---------- Editor ---------- */
.tox.tox-tinymce { border: 1px solid #bfc1b9 !important; border-radius: 6px !important; }
.tox .tox-toolbar__primary, .tox .tox-editor-header { background: #fafaf8 !important; }

/* ---------- Telefono e tablet ---------- */
@media (max-width: 1100px) {
  .edit-grid { grid-template-columns: 1fr; }
  .edit-side { position: static; }
  .savebar { display: block; position: sticky; bottom: 0; z-index: 20; margin: 0 -20px; padding: 12px 20px; background: rgb(242 242 238 / 0.94); backdrop-filter: blur(8px); border-top: 1px solid var(--rule); }
}
.savebar--always { display: block; position: sticky; bottom: 0; z-index: 20; margin: 0 -20px; padding: 12px 20px; background: rgb(242 242 238 / 0.94); backdrop-filter: blur(8px); border-top: 1px solid var(--rule); max-width: 940px; }
@media (max-width: 860px) {
  .has-nav { display: block; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 30; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--green); color: #fff; }
  .topbar__brand { display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; font: 600 1.125rem var(--display); }
  .topbar__brand .i { color: var(--gold); }
  .topbar__menu { display: inline-flex; gap: 8px; align-items: center; min-height: 44px; padding: 0 14px; background: transparent; color: #fff; border: 1px solid rgb(255 255 255 / 0.4); border-radius: 6px; font: 600 1rem var(--text); cursor: pointer; }
  .side { position: fixed; z-index: 40; top: 64px; left: 0; right: 0; height: auto; max-height: calc(100vh - 64px); transform: translateY(-8px); opacity: 0; visibility: hidden; transition: opacity 200ms var(--ease-out), transform 220ms var(--ease-out), visibility 0s 220ms; box-shadow: 0 20px 40px -20px rgb(0 0 0 / 0.4); }
  .side.is-open { opacity: 1; transform: none; visibility: visible; transition: opacity 200ms var(--ease-out), transform 220ms var(--ease-out); }
  .side__brand { display: none; }
  .main { padding: 24px 20px 80px; }
  .quick, .cols, .row2, .grid2, .add-slide { grid-template-columns: 1fr; }
  .slide-item { grid-template-columns: 1fr; }
  .mass-row { grid-template-columns: 1fr 1fr auto; padding-bottom: 12px; border-bottom: 1px solid #ecece7; }
  .mass-row input[type="text"] { grid-column: 1 / 3; grid-row: 2; }
  .mass-row .btn { grid-row: 1 / 3; grid-column: 3; align-self: stretch; }
  .list__row { flex-wrap: wrap; padding: 0 14px 14px; }
  .list__main { padding: 14px 0 0; flex-basis: 100%; }
  .list__actions { margin-left: 88px; }
  .page-top .btn--primary { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; transition: opacity 200ms ease; }
  .mass-row, .side, .switch__track::after { transition: none; }
}
