/* curcuraci.net — foglio di stile unico, nessun JavaScript richiesto. */

/* ------------------------------------------------------------------ token */

:root {
  --bg: #f6f3ed;
  --surface: #ffffff;
  --surface-2: #efe9df;
  --text: #1f2328;
  --muted: #5d636c;
  --border: #e0d9cc;
  --accent: #1d5fa8;
  --accent-strong: #154a85;
  --accent-soft: #e3edf8;
  --warm: #a84e2a;
  --shadow: 0 1px 2px rgb(31 35 40 / .06), 0 8px 24px rgb(31 35 40 / .08);

  --font-text: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Iowan Old Style", Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --wrap: 72rem;
  --measure: 42rem;
  --radius: 14px;
  --gutter: clamp(1rem, 4vw, 2rem);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --surface: #1b1f25;
    --surface-2: #232830;
    --text: #e8e4dd;
    --muted: #a5abb4;
    --border: #2e343c;
    --accent: #82b4ee;
    --accent-strong: #a9cbf4;
    --accent-soft: #1d2a3a;
    --warm: #e39169;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .35);
  }
}

/* ------------------------------------------------------------------ base */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: clamp(1.0625rem, 1rem + .3vw, 1.1875rem);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-strong); text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: .6rem 1rem;
  background: var(--surface);
  color: var(--accent);
  font-family: var(--font-ui);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.skip-link:focus { top: 1rem; }

/* Comparsa graduale della pagina (sostituisce il "fade" in jQuery). */
@media (prefers-reduced-motion: no-preference) {
  .site-header, .page, .site-footer { animation: fade-in .6s ease-out both; }
  .page { animation-delay: .12s; }
  .site-footer { animation-delay: .24s; }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ header */

.site-header {
  /* Sopra a .page, che con l'animazione crea un proprio contesto di sovrapposizione. */
  position: relative;
  z-index: 20;
  width: min(100% - 2 * var(--gutter), var(--wrap));
  margin: var(--gutter) auto 0;
}

.banner {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: clamp(9rem, 22vw, 14rem);
  padding: clamp(1rem, 3vw, 2rem);
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  color: #fff;
  text-decoration: none;
  background:
    linear-gradient(180deg, rgb(10 30 60 / 0) 30%, rgb(10 30 60 / .65)),
    url("../images/header_bg.jpg") center 40% / cover no-repeat,
    #2b5f93;
}
.banner:hover { color: #fff; }

.banner-title {
  font-size: clamp(2.2rem, 1.4rem + 4vw, 3.8rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.01em;
  text-shadow: 0 2px 12px rgb(0 0 0 / .45);
}
.banner-sub {
  margin-top: .4rem;
  font-family: var(--font-ui);
  font-size: clamp(.85rem, .8rem + .3vw, 1rem);
  opacity: .92;
  text-shadow: 0 1px 6px rgb(0 0 0 / .5);
}

/* ------------------------------------------------------------------ menu */

.site-nav {
  position: relative;
  z-index: 10;
  background: var(--accent);
  border-radius: 0 0 var(--radius) var(--radius);
  font-family: var(--font-ui);
  font-size: 1rem;
}
@media (prefers-color-scheme: dark) {
  .site-nav { background: #22436b; }
}

.menu {
  list-style: none;
  margin: 0;
  padding: .35rem;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
}
.menu > li { position: relative; }

.menu summary {
  list-style: none;
  cursor: pointer;
  padding: .55rem .9rem;
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
  user-select: none;
  display: flex;
  align-items: center;
  gap: .45rem;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after {
  content: "";
  width: .45em;
  height: .45em;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: translateY(-.15em) rotate(45deg);
  transition: transform .2s;
  opacity: .8;
}
.menu details[open] > summary::after { transform: translateY(.1em) rotate(-135deg); }
.menu summary:hover,
.menu details[open] > summary { background: rgb(255 255 255 / .16); }
.menu summary.is-current { box-shadow: inset 0 -3px 0 rgb(255 255 255 / .75); }

.menu details ul {
  list-style: none;
  margin: .35rem 0 0;
  padding: .4rem;
  position: absolute;
  left: 0;
  min-width: 15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
@media (prefers-reduced-motion: no-preference) {
  .menu details[open] ul { animation: drop .18s ease-out; }
}
@keyframes drop {
  from { opacity: 0; transform: translateY(-4px); }
}

.menu details a {
  display: block;
  padding: .5rem .75rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  line-height: 1.3;
}
.menu details a:hover { background: var(--accent-soft); color: var(--accent-strong); }
.menu details a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

/* Su schermi stretti i sottomenu occupano tutta la larghezza della barra. */
@media (max-width: 40rem) {
  .menu { flex-wrap: nowrap; justify-content: space-around; gap: 0; }
  .menu > li { position: static; }
  .menu summary { padding: .55rem .6rem; font-size: .95rem; }
  .menu details ul { left: .35rem; right: .35rem; min-width: 0; }
}

/* ------------------------------------------------------------------ pagina */

.page {
  flex: 1;
  width: min(100% - 2 * var(--gutter), var(--wrap));
  margin: clamp(1.5rem, 4vw, 2.5rem) auto;
}

.prose {
  max-width: var(--measure);
  margin-inline: auto;
  hyphens: auto;
  overflow-wrap: break-word;
}

.prose > * { margin-block: 0; }
.prose > * + * { margin-top: 1.1em; }

.kicker {
  margin: 0;
  font-family: var(--font-ui);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--warm);
}

h1, h2, h3 {
  line-height: 1.2;
  letter-spacing: -.01em;
  text-wrap: balance;
}
.prose h1 {
  margin: .2em 0 .8em;
  font-size: clamp(2rem, 1.5rem + 2.2vw, 2.9rem);
}
.prose h2 {
  margin-top: 2em;
  font-size: clamp(1.4rem, 1.2rem + .9vw, 1.75rem);
  scroll-margin-top: 1rem;
}
.prose h3 { margin-top: 1.6em; font-size: 1.2rem; }

.lead {
  font-size: 1.15em;
  color: var(--muted);
}

.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: .35em; }
.prose li::marker { color: var(--warm); }

blockquote {
  margin-inline: 0;
  padding: .8em 1.2em;
  border-left: 4px solid var(--warm);
  background: var(--surface-2);
  border-radius: 0 10px 10px 0;
  font-style: italic;
}

.signoff { text-align: right; font-style: italic; }

.note {
  padding: 1em 1.2em;
  background: var(--accent-soft);
  border-radius: 10px;
  font-family: var(--font-ui);
  font-size: .95em;
}

/* Indice dei paragrafi in testa agli articoli lunghi. */
.contents {
  padding: 1em 1.3em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: var(--font-ui);
  font-size: .95em;
}
.contents h2 { margin: 0 0 .4em; font-size: 1rem; }
.contents ol { margin: 0; }

.back-to-top {
  display: block;
  text-align: right;
  font-family: var(--font-ui);
  font-size: .85em;
}

/* ------------------------------------------------------------------ immagini */

.photo {
  margin-inline: auto;
  width: fit-content;
  max-width: 100%;
}
.photo figcaption,
.lightbox figcaption {
  margin-top: .5em;
  font-family: var(--font-ui);
  font-size: .85rem;
  color: var(--muted);
  text-align: center;
  max-width: 30rem;
  margin-inline: auto;
}

button.zoom {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
button.zoom img { transition: transform .35s ease, opacity .2s; }
button.zoom:hover img { transform: scale(1.04); opacity: .9; }

button.zoom-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--accent);
  text-decoration: underline dotted 1px;
  text-underline-offset: .18em;
  cursor: zoom-in;
}
button.zoom-link:hover { color: var(--accent-strong); text-decoration-style: solid; }

/* Lightbox con l'API popover: si apre col pulsante, si chiude con Esc o clic fuori. */
.lightbox {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 96vw;
  max-height: 96vh;
  overflow: visible;
}
.lightbox figure { margin: 0; }
.lightbox img {
  width: auto;
  height: auto;
  max-width: 96vw;
  max-height: 86vh;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgb(0 0 0 / .5);
}
.lightbox figcaption { color: #e8e8e8; }
.lightbox::backdrop { background: rgb(8 12 18 / .85); }

.lightbox-close {
  position: absolute;
  top: -.75rem;
  right: -.75rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #1f2328;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgb(0 0 0 / .4);
}
@media (max-width: 40rem) {
  .lightbox-close { top: .5rem; right: .5rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .lightbox, .lightbox::backdrop {
    transition: opacity .25s, transform .25s, overlay .25s allow-discrete, display .25s allow-discrete;
  }
  .lightbox { opacity: 0; transform: scale(.96); }
  .lightbox::backdrop { opacity: 0; }
  .lightbox:popover-open { opacity: 1; transform: none; }
  .lightbox:popover-open::backdrop { opacity: 1; }
  @starting-style {
    .lightbox:popover-open { opacity: 0; transform: scale(.96); }
    .lightbox:popover-open::backdrop { opacity: 0; }
  }
}

.not-found { margin-inline: auto; width: min(100%, 28rem); }

/* ------------------------------------------------------------------ tabelle */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: .9rem;
  line-height: 1.45;
}
caption {
  padding: .8rem 1rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
th, td { padding: .55rem 1rem; text-align: left; vertical-align: top; }
thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
tbody tr + tr { border-top: 1px solid var(--border); }
tbody td:first-child { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--warm); white-space: nowrap; }

/* ------------------------------------------------------------------ elenchi di articoli */

.toc {
  list-style: none;
  padding: 0 !important;
  display: grid;
  gap: .6rem;
}
.toc li { margin: 0 !important; }
.toc a {
  display: block;
  font-weight: 600;
}
.toc span {
  display: block;
  font-family: var(--font-ui);
  font-size: .9rem;
  color: var(--muted);
}

.cards {
  list-style: none;
  padding: 0 !important;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
}
.cards li { margin: 0 !important; }
.cards a {
  display: block;
  height: 100%;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.cards a:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }
.cards strong { display: block; color: var(--accent); font-size: 1.1rem; }
.cards span { display: block; margin-top: .3rem; font-family: var(--font-ui); font-size: .9rem; color: var(--muted); }

/* ------------------------------------------------------------------ moduli */

form {
  display: grid;
  gap: 1.1rem;
  font-family: var(--font-ui);
  font-size: 1rem;
}
.field { display: grid; gap: .35rem; }
.field label { font-weight: 600; }
.field small { color: var(--muted); }

input[type="search"] {
  width: 100%;
  padding: .7rem .85rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
input:focus-visible { outline-offset: 0; border-color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.button, button[type="submit"] {
  padding: .7rem 1.3rem;
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
@media (prefers-color-scheme: dark) {
  .button, button[type="submit"] { color: #10161d; }
}
.button.secondary { background: transparent; color: var(--accent); }
.button:hover, button[type="submit"]:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
@media (prefers-color-scheme: dark) {
  .button:hover, button[type="submit"]:hover { color: #10161d; }
}

.search-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.search-row input { flex: 1 1 16rem; }

/* ------------------------------------------------------------------ navigazione articoli */

.pager {
  max-width: var(--measure);
  margin: 3rem auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  font-family: var(--font-ui);
}
.pager a {
  display: block;
  padding: .9rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  line-height: 1.3;
}
.pager a:hover { border-color: var(--accent); }
.pager span {
  display: block;
  margin-bottom: .2rem;
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.pager .prev span::before { content: "← "; }
.pager .next { grid-column: 2; text-align: right; }
.pager .next span::after { content: " →"; }

/* ------------------------------------------------------------------ footer */

.site-footer {
  width: min(100% - 2 * var(--gutter), var(--wrap));
  margin: 0 auto var(--gutter);
  padding: 1.1rem 1.4rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5rem 1.5rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: .9rem;
  color: var(--muted);
}
.site-footer p { margin: 0; }

/* ------------------------------------------------------------------ stampa */

@media print {
  .site-nav, .pager, .skip-link, .back-to-top, .lightbox { display: none !important; }
  .banner { min-height: 0; background: none; color: #000; padding: 0; }
  .banner-title, .banner-sub { text-shadow: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .prose { max-width: none; }
  a { color: inherit; }
}
