/* CR1 Eventi — stile condiviso da agenda, pagine evento, modulo e anteprima redazione.
   Token e font allineati a rsvp-cr1 (Fira Sans self-hosted, blu CR1). Niente stili inline: la CSP lo vieta. */

:root {
  --brand: #005fa8;
  --brand-dark: #04355f;
  --brand-mid: #07599e;
  --brand-soft: #e6f0f8;
  --gray: #a5a8ab;
  --shine: #9cc8ee;
  --ink: #051221;
  --muted: #5d6670;
  --line: #dfe4ea;
  --paper: #f4f6f8;
  --warm: #eef1f4;
  --ok: #255b34;
  --ok-soft: #e8f1ea;
  --warn: #8a5a00;
  --warn-soft: #fff4dd;
  --error: #b71c1c;
  --error-soft: #fff3f1;
  --sans: 'Fira Sans', Arial, Helvetica, sans-serif;
  --ease: cubic-bezier(.2, .75, .2, 1);
  --shadow: 0 1px 4px rgba(5, 18, 33, 0.08);
  --shadow-hover: 0 10px 26px -12px rgba(5, 18, 33, 0.35);
  --radius: 3px;
  --wrap: 1180px;
}

@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(/assets/fonts/fira-sans-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fira Sans'; font-style: italic; font-weight: 400; font-display: swap; src: url(/assets/fonts/fira-sans-latin-400-italic.woff2) format('woff2'); }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(/assets/fonts/fira-sans-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url(/assets/fonts/fira-sans-latin-700-normal.woff2) format('woff2'); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body, h1, h2, h3, h4, p, ul, li, dl, dd, figure { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body:has(dialog[open]) { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
img { max-width: 100%; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--shine); outline-offset: 2px; }
.wrap { width: min(var(--wrap), calc(100% - 40px)); margin-inline: auto; }

/* ===== Topline e header ===== */
.topline {
  height: 32px;
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 max(20px, calc((100vw - var(--wrap)) / 2));
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.topline a { color: #fff; text-decoration: none; }
.topline a:hover { text-decoration: underline; }
.header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  width: min(var(--wrap), calc(100% - 40px));
  margin: 0 auto;
  padding: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.logo-link { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.logo-img { height: 40px; width: auto; display: block; }
.logo-tag {
  background: var(--brand);
  color: #fff;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  border-radius: 2px;
  line-height: 1;
}
.header-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.header-nav { display: flex; gap: 18px; font-size: 14px; font-weight: 600; }
.header-nav a { color: var(--muted); text-decoration: none; }
.header-nav a:hover, .header-nav a[aria-current] { color: var(--brand); }

.cta-button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--brand);
  border-radius: 2px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: background-color .2s, box-shadow .25s, transform .15s;
  box-shadow: 0 8px 18px -14px var(--brand);
}
.cta-button:hover, .btn-primary:hover { background: var(--brand-dark); }
.cta-button:active, .btn:active { transform: scale(.98); }
.cta-button svg { flex-shrink: 0; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-secondary { background: #fff; color: var(--brand); box-shadow: none; }
.btn-secondary:hover { background: var(--brand-soft); }
.btn-ghost { background: var(--paper); color: var(--ink); border-color: var(--line); box-shadow: none; }
.btn-ghost:hover { background: var(--warm); }
.btn-link { color: var(--muted); padding: 10px 4px; text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }
.btn:disabled, .cta-button:disabled { opacity: .6; cursor: wait; }

/* ===== Hero ===== */
.hero {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 36px 0 28px;
}
.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: end;
}
.eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  margin: 0 0 12px;
}
.hero h1 {
  font-size: clamp(32px, 4.6vw, 52px);
  font-weight: 700;
  letter-spacing: -.025em;
  color: var(--ink);
  margin-bottom: 10px;
}
.hero h1 em { font-style: normal; color: var(--brand); }
.hero .lead { color: var(--muted); font-size: 16px; max-width: 760px; }
.hero-panel {
  background: var(--paper);
  border-left: 3px solid var(--brand);
  padding: 16px 20px;
  min-width: 200px;
}
.hero-count { display: block; font-size: 38px; font-weight: 700; line-height: 1; color: var(--brand); font-variant-numeric: tabular-nums; }
.hero-count-label { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.hero-date {
  display: block;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.quick-filters { margin: 20px auto 0; display: flex; gap: 8px; flex-wrap: wrap; }
.quick-filter {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: background .15s, color .15s, border-color .15s;
}
.quick-filter:hover { background: var(--brand-soft); border-color: var(--shine); }
.quick-filter.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ===== Filtri ===== */
.filters {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  position: sticky;
  top: 65px;
  z-index: 50;
}
.filter-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.filters-inner { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-input, .filter-select, .field input, .field select, .field textarea {
  padding: 8px 12px;
  border: 1px solid #c3ccd5;
  border-radius: var(--radius);
  background: #fff;
  font-size: 15px;
  height: 40px;
}
.filter-input { min-width: 240px; flex: 1; max-width: 340px; }
.filter-input:focus, .filter-select:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px #005fa814;
}
.stats { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: 600; }
.filters-reset { background: none; border: 0; color: var(--brand); font-size: 13px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ===== Agenda ===== */
.container { padding: 28px 0 60px; }
.grid { display: flex; flex-direction: column; gap: 12px; }

.thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
  color: var(--brand);
  font-weight: 700;
  font-size: 30px;
  background: linear-gradient(135deg, #e6f0f8, #d7e6f3);
  opacity: 0;
  pointer-events: none;
}
.is-placeholder .thumb-fallback, .is-fallback .thumb-fallback { opacity: 1; }
.is-fallback img { visibility: hidden; }

.featured {
  display: grid;
  grid-template-columns: minmax(280px, 42%) minmax(0, 1fr);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 18px 40px -28px rgba(5, 18, 33, .5);
  text-decoration: none;
  color: inherit;
  transition: transform .15s var(--ease), box-shadow .15s;
}
.featured:hover { transform: translateY(-2px); box-shadow: 0 24px 46px -26px rgba(5, 18, 33, .55); }
.featured-media { position: relative; min-height: 260px; background: var(--brand-soft); display: block; overflow: hidden; }
.featured-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.featured-media .thumb-fallback { font-size: 84px; }
.featured-body { padding: 28px 30px; display: flex; flex-direction: column; justify-content: center; min-width: 0; gap: 10px; }
.featured-label { color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.featured-title { display: block; font-size: clamp(26px, 3vw, 36px); font-weight: 700; line-height: 1.08; letter-spacing: -.02em; color: var(--ink); }
.featured-desc { display: block; color: var(--muted); font-size: 15px; }

.card {
  display: flex;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  min-height: 136px;
  transition: transform .15s var(--ease), box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.card-date {
  width: 104px;
  flex: 0 0 104px;
  background: var(--brand);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px 10px;
}
.card-date.is-missing { background: var(--gray); color: var(--ink); }
.card-date-weekday, .card-date-month { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .9; }
.card-date-day { font-size: 38px; font-weight: 700; line-height: 1; margin: 3px 0; font-variant-numeric: tabular-nums; }
.card-date-time { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, .4); font-size: 12px; font-weight: 700; }
.card-body { padding: 16px 18px; flex: 1; min-width: 0; display: flex; gap: 18px; align-items: flex-start; }
.card-main { min-width: 0; flex: 1; display: block; }
.card-badges { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 8px; }
.card-category, .modal-cat {
  display: inline-flex;
  align-items: center;
  background: var(--brand-soft);
  color: var(--brand-dark);
  padding: 4px 9px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  border-radius: 2px;
}
.modal-cat { background: var(--brand); color: #fff; margin-bottom: 12px; }
.card-title { display: block; font-size: 20px; font-weight: 700; line-height: 1.2; margin-bottom: 8px; color: var(--ink); }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.card-meta-item { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.card-meta-item svg { flex-shrink: 0; color: var(--brand); opacity: .75; }
.card-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}
.card-thumb {
  position: relative;
  display: block;
  width: 132px;
  aspect-ratio: 4 / 3;
  flex: 0 0 132px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--paper);
}
.card-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card.no-thumb .card-thumb { display: none; }

/* ===== Dettaglio evento (dialog e pagina) ===== */
.evento-dialog {
  width: min(840px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: #fff;
  overflow: auto;
  box-shadow: 0 30px 80px -30px rgba(5, 18, 33, .7);
}
.evento-dialog::backdrop { background: rgba(5, 18, 33, .66); }
.evento-dialog[open] { animation: dialog-in .2s var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px); } }
.evento-cover { position: relative; aspect-ratio: 16 / 9; max-height: 420px; background: var(--paper); overflow: hidden; }
.evento-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.evento-cover.is-placeholder { aspect-ratio: auto; height: 72px; }
.evento-cover .thumb-fallback { font-size: 40px; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(5, 18, 33, .6);
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.modal-close:hover { background: rgba(5, 18, 33, .85); }
.evento-body { padding: 28px 32px 32px; }
.evento-title { font-size: clamp(26px, 3.4vw, 34px); font-weight: 700; letter-spacing: -.02em; margin-bottom: 14px; }
.evento-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.evento-meta span { display: inline-flex; align-items: center; gap: 6px; }
.evento-meta svg { color: var(--brand); }
.evento-section { margin-bottom: 22px; }
.evento-section-label { font-size: 11px; text-transform: uppercase; color: var(--brand); letter-spacing: .14em; margin-bottom: 8px; font-weight: 700; }
.evento-desc { font-size: 16px; line-height: 1.65; }
.evento-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 28px; font-size: 14px; }
.evento-grid dt { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .08em; font-weight: 600; margin-bottom: 2px; }
.evento-gallery { display: flex; gap: 10px; flex-wrap: wrap; }
.evento-gallery a { display: block; width: 120px; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--paper); }
.evento-gallery img { width: 100%; height: 100%; object-fit: cover; }
.evento-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }

/* pagina /evento/<slug> */
.page { padding: 28px 0 60px; }
.page-back { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; margin-bottom: 16px; text-decoration: none; }
.page-back:hover { text-decoration: underline; }
.page .evento { background: #fff; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; max-width: 860px; }

/* ===== Stati ===== */
.empty, .loading { text-align: center; padding: 72px 20px; color: var(--muted); }
.empty h3 { font-size: 22px; color: var(--ink); margin-bottom: 8px; }
.empty p { margin-bottom: 18px; }
.loading p { margin-top: 14px; }
.error, .notice {
  background: var(--warn-soft);
  border: 1px solid #f2dcae;
  border-radius: 6px;
  color: var(--warn);
  padding: 20px 24px;
  margin: 24px 0;
  line-height: 1.6;
}
.notice-ok { background: var(--ok-soft); border-color: #c5dcc9; color: var(--ok); }
.notice-error { background: var(--error-soft); border-color: #f0c5c0; color: var(--error); }
.spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(5, 18, 33, .1);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== CTA segnalazione e footer ===== */
.submit-cta { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 48px 0; }
.submit-cta-inner { max-width: 720px; margin: 0 auto; text-align: center; }
.submit-cta h2 { font-size: 30px; margin-bottom: 10px; color: var(--brand-dark); }
.submit-cta p { color: var(--muted); font-size: 16px; margin-bottom: 22px; }
.submit-cta-note { margin-top: 14px; font-size: 13px; color: var(--muted); }
.footer { border-top: 4px solid var(--brand); background: var(--ink); color: #d9e1ea; font-size: 13px; }
.footer-inner { min-height: 90px; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 20px 0; flex-wrap: wrap; }
.footer a { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 22px; }

/* ===== Moduli (segnala) ===== */
.form-card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 28px 32px; max-width: 760px; }
.field { display: block; margin-bottom: 18px; }
.field > span { display: block; font-size: 12px; font-weight: 700; letter-spacing: .04em; margin-bottom: 6px; }
.field input, .field select { width: 100%; }
.field textarea { width: 100%; height: auto; min-height: 110px; padding: 10px 12px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.field-hint { font-size: 13px; color: var(--muted); margin: -10px 0 18px; }
.trap { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-message { margin-top: 16px; font-size: 14px; }
.form-message:empty { display: none; }

/* ===== Redazione ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: var(--paper); position: sticky; top: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: var(--warm); color: var(--ink); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-error { background: var(--error-soft); color: var(--error); }
.badge-brand { background: var(--brand-soft); color: var(--brand-dark); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 18px 0; }

/* ===== Mobile ===== */
@media (max-width: 760px) {
  .wrap, .header-inner { width: min(100% - 32px, 640px); }
  .topline { padding: 0 16px; }
  .header-nav { display: none; }
  .logo-img { height: 34px; }
  .hero { padding: 26px 0 20px; }
  .hero-inner { display: block; }
  .hero-panel { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; min-width: 0; }
  .hero-date { margin-top: 0; padding-top: 0; border-top: 0; text-align: right; }
  .filters { position: static; padding: 14px 0; }
  .filter-toggle { display: flex; }
  .filters-inner { display: none; margin-top: 10px; }
  .filters-inner.is-open { display: flex; }
  .filter-input { min-width: 100%; max-width: none; }
  .filter-select { flex: 1 1 calc(50% - 6px); min-width: 0; }
  .stats { margin-left: 0; width: 100%; }
  .featured { grid-template-columns: 1fr; }
  .featured-media { min-height: 170px; aspect-ratio: 16 / 9; }
  .featured-body { padding: 18px 18px 22px; }
  .card { flex-direction: column; border-left-width: 0; border-top: 4px solid var(--brand); min-height: 0; }
  .card-date { width: 100%; flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 9px; padding: 10px 16px; }
  .card-date-day { font-size: 30px; margin: 0; }
  .card-date-time { margin: 0 0 0 auto; padding: 0 0 0 12px; border-top: 0; border-left: 1px solid rgba(255, 255, 255, .4); }
  .card-body { padding: 14px 16px 16px; gap: 12px; }
  .card-thumb { width: 92px; flex-basis: 92px; }
  .card-title { font-size: 18px; }
  .evento-dialog { width: calc(100% - 16px); max-height: calc(100vh - 16px); }
  .evento-body { padding: 20px 18px 24px; }
  .evento-grid { grid-template-columns: 1fr; }
  .evento-actions .btn { flex: 1 1 auto; }
  .submit-cta { padding: 36px 0; }
  .submit-cta h2 { font-size: 24px; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .form-card { padding: 22px 18px; }
  .field-row { grid-template-columns: 1fr; }
}

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