/* UniPosto styles.
 *
 * One markup tree, five skins selected by <html data-style="...">:
 * Chiaro, Scuro, Papiro, Portale, Gazzetta. Shared structure lives in the base
 * rules; each [data-style=...] block restyles it. The controls, result count,
 * and links are present and operable in every style — only look and layout
 * change (cards / citation list / register table).
 *
 * Chiaro and Scuro are TWINS: structurally and behaviourally identical (glassy
 * surfaces, card hover lift, heading/link treatment); they differ ONLY in their
 * colour tokens. Chiaro reuses the base light palette below; Scuro overrides it
 * with a dark one. The base :root IS the Chiaro palette.
 */

/* ----------------------------------------------------------------- tokens */
:root {
  --max: 1100px;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1d21;
  --muted: #5b6470;
  --border: #d9dde3;
  --accent: #1a5fb4;
  --accent-contrast: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 24, 31, 0.08), 0 1px 2px rgba(20, 24, 31, 0.06);
  --gap: 1rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-head: var(--font);
  --badge-open-bg: #e6f4ea; --badge-open-fg: #1c7c3c;
  --badge-closed-bg: #fdecec; --badge-closed-fg: #b3261e;
  --badge-nodeadline-bg: #eef1f4; --badge-nodeadline-fg: #5b6470;
  --badge-bozza-bg: #fdeecb; --badge-bozza-fg: #6a4b00;
}

/* ------------------------------------------------------------------- base */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

a { color: var(--accent); }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.5rem 0.75rem;
  z-index: 10;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

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

.site-header {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem 1rem 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: flex-end;
  justify-content: space-between;
}
.brand { min-width: 0; }
.masthead {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
}
.site-header h1 {
  margin: 0.1rem 0;
  font-family: var(--font-head);
  font-size: 2rem;
  line-height: 1.1;
}
.tagline { margin: 0; color: var(--muted); font-size: 0.95rem; }

.style-switch { display: flex; flex-direction: column; gap: 0.25rem; }
.style-switch label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.style-switch select { min-width: 12rem; }

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1rem;
}

/* controls — identical in every style */
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.field-search { grid-column: 1 / -1; }
.field label { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.controls input,
.controls select,
.style-switch select {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.result-meta {
  max-width: var(--max);
  margin: 1rem auto 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.notice { padding: 2rem 0; color: var(--muted); text-align: center; }

/* badges — shared semantics across styles */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-open { background: var(--badge-open-bg); color: var(--badge-open-fg); }
.badge-closed { background: var(--badge-closed-bg); color: var(--badge-closed-fg); }
.badge-nodeadline { background: var(--badge-nodeadline-bg); color: var(--badge-nodeadline-fg); }
.badge-bozza { background: var(--badge-bozza-bg); color: var(--badge-bozza-fg); }

/* layout: cards */
.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: var(--gap);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.card .institution { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.card .title { margin: 0; font-size: 1rem; line-height: 1.3; font-family: var(--font-head); }
.card .meta { margin: 0; display: grid; gap: 0.25rem; font-size: 0.85rem; }
.card .meta div { display: flex; gap: 0.4rem; }
.card .meta dt { color: var(--muted); min-width: 5.5rem; }
.card .meta dd { margin: 0; }

/* layout: citation list */
.entry-list { margin: 0; padding-left: 1.5rem; display: grid; gap: 1rem; }
.entry .title { font-weight: 600; }
.entry .cite { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.9rem; }

/* layout: register table */
.register { width: 100%; border-collapse: collapse; font-size: 0.88rem; background: var(--surface); }
.register th, .register td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.register thead th { position: sticky; top: 0; background: var(--surface); border-bottom: 2px solid var(--text); }
.register .num { color: var(--muted); text-align: right; }

.site-footer {
  max-width: var(--max);
  margin: 2rem auto;
  padding: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer .disclaimer { font-size: 0.8rem; }

/* feeds page */
.feed-intro { color: var(--muted); margin: 0 0 1rem; }
.feed-intro code { font-size: 0.9em; }
.feed-links { margin: 0; font-size: 0.95rem; }
.feed-back { font-size: 0.85rem; text-decoration: none; }

/* =====================================================================
   STYLES 1 & 2 — Chiaro / Scuro: one style, two palettes.
   The colour tokens live in each block; everything structural and
   behavioural is shared in the combined block below so the two stay in
   lock-step "up to colours".
   ===================================================================== */

/* Chiaro — the light twin (default). Inherits the base :root light palette;
   only the colours that the shared EFFECTS need are introduced here:
     --surface  becomes translucent white so the glass/backdrop-blur reads;
     --bg-gradient / --glow / --hover-shadow are palette-compatible (accent
     blue, neutral shadows) and keep AA contrast for the dark text on top. */
[data-style="chiaro"] {
  --radius: 14px;
  --surface: rgba(255, 255, 255, 0.66);
  --bg-gradient:
    radial-gradient(1200px 600px at 80% -10%, rgba(26, 95, 180, 0.07), transparent),
    radial-gradient(900px 500px at -10% 20%, rgba(120, 90, 255, 0.06), transparent);
  --glow: rgba(26, 95, 180, 0.20);
  /* A clearly-visible soft elevation shadow for the card hover lift. Neutral
     dark tones (palette-compatible, no contrast impact) in two layers for
     depth, plus a 1px accent ring for definition. */
  --hover-shadow:
    0 16px 32px rgba(20, 24, 31, 0.22),
    0 6px 12px rgba(20, 24, 31, 0.16),
    0 0 0 1px var(--accent);
}

/* Scuro — the dark twin (was "Futuristico"). */
[data-style="scuro"] {
  --bg: #0a0e1a;
  --surface: rgba(22, 30, 52, 0.6);
  --text: #e7ecff;
  --muted: #8ea0c8;
  --border: rgba(120, 160, 255, 0.25);
  --accent: #29e0d8;
  --accent-contrast: #03121a;
  --radius: 14px;
  --shadow: 0 0 0 1px rgba(120, 160, 255, 0.12), 0 8px 30px rgba(0, 0, 0, 0.45);
  --font-head: "Segoe UI", system-ui, sans-serif;
  --badge-open-bg: rgba(41, 224, 216, 0.16); --badge-open-fg: #2ff2c8;
  --badge-closed-bg: rgba(255, 86, 120, 0.16); --badge-closed-fg: #ff7a90;
  --badge-nodeadline-bg: rgba(142, 160, 200, 0.16); --badge-nodeadline-fg: #aebbe0;
  --badge-bozza-bg: rgba(255, 196, 84, 0.18); --badge-bozza-fg: #ffce7a;
  --bg-gradient:
    radial-gradient(1200px 600px at 80% -10%, rgba(41, 224, 216, 0.12), transparent),
    radial-gradient(900px 500px at -10% 20%, rgba(120, 90, 255, 0.14), transparent);
  --glow: rgba(41, 224, 216, 0.45);
  --hover-shadow: 0 0 0 1px var(--accent), 0 12px 40px rgba(41, 224, 216, 0.18);
}

/* Shared structure + behaviour for BOTH twins (colour comes from the tokens). */
[data-style="chiaro"],
[data-style="scuro"] {
  background: var(--bg-gradient), var(--bg);
}
[data-style="chiaro"] .site-header h1,
[data-style="scuro"] .site-header h1 {
  letter-spacing: 0.02em;
  text-shadow: 0 0 18px var(--glow);
}
[data-style="chiaro"] .card,
[data-style="chiaro"] .controls,
[data-style="chiaro"] .register,
[data-style="scuro"] .card,
[data-style="scuro"] .controls,
[data-style="scuro"] .register { backdrop-filter: blur(8px); }
[data-style="chiaro"] .card,
[data-style="scuro"] .card { transition: transform 0.18s ease, box-shadow 0.18s ease; }
[data-style="chiaro"] .card:hover,
[data-style="scuro"] .card:hover {
  transform: translateY(-3px);
  box-shadow: var(--hover-shadow);
}
[data-style="chiaro"] a,
[data-style="scuro"] a { text-decoration: none; }
[data-style="chiaro"] a:hover,
[data-style="scuro"] a:hover { text-shadow: 0 0 12px var(--glow); }

/* =====================================================================
   STYLE 3 — Papiro: scholarly, serif, parchment (was "Accademico")
   ===================================================================== */
[data-style="papiro"] {
  --bg: #faf8f3;
  --surface: #fffdf8;
  --text: #211d17;
  --muted: #6b6150;
  --border: #ddd5c4;
  --accent: #6a2e1f;
  --radius: 4px;
  --shadow: none;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-head: var(--font);
}
[data-style="papiro"] body { line-height: 1.6; }
[data-style="papiro"] .site-header { border-bottom: 2px solid var(--text); padding-bottom: 1rem; }
[data-style="papiro"] .site-header h1 { font-weight: 700; font-style: normal; }
[data-style="papiro"] .masthead { font-variant: small-caps; letter-spacing: 0.05em; }
[data-style="papiro"] .controls { box-shadow: none; }
[data-style="papiro"] .entry .title { color: var(--accent); }
[data-style="papiro"] .badge { font-weight: 600; border: 1px solid currentColor; background: transparent; }

/* =====================================================================
   STYLE 4 — Portale Istituzionale: InPA / Bootstrap-Italia look
   ===================================================================== */
[data-style="portale"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #17324d;
  --muted: #5a768a;
  --border: #c5d3dd;
  --accent: #06c;
  --accent-contrast: #ffffff;
  --radius: 4px;
  --shadow: 0 2px 6px rgba(0, 43, 85, 0.1);
  --font: "Titillium Web", "Segoe UI", system-ui, sans-serif;
  --font-head: var(--font);
  --badge-open-bg: #00cc85; --badge-open-fg: #08301f;
  --badge-closed-bg: #fce4e4; --badge-closed-fg: #a31515;
  --badge-nodeadline-bg: #e3eef6; --badge-nodeadline-fg: #17324d;
  --badge-bozza-bg: #fff0cc; --badge-bozza-fg: #6a4b00;
}
[data-style="portale"] .site-header {
  max-width: none;
  background: var(--accent);
  color: #fff;
  padding: 1.25rem max(1rem, calc((100% - var(--max)) / 2));
  align-items: center;
}
[data-style="portale"] .site-header h1 { color: #fff; }
[data-style="portale"] .masthead,
[data-style="portale"] .tagline { color: rgba(255, 255, 255, 0.85); }
[data-style="portale"] .style-switch label { color: rgba(255, 255, 255, 0.85); }
[data-style="portale"] .card { border-top: 4px solid var(--accent); }
[data-style="portale"] .card .title a { text-decoration: none; }
[data-style="portale"] .card .title a:hover { text-decoration: underline; }
[data-style="portale"] .badge { border-radius: 4px; }

/* =====================================================================
   STYLE 5 — Gazzetta Ufficiale: dense, formal register, print-like
   ===================================================================== */
[data-style="gazzetta"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #111111;
  --muted: #444444;
  --border: #999999;
  --accent: #6a1b1b;
  --radius: 0;
  --shadow: none;
  --max: 1000px;
  --font: "Times New Roman", Georgia, serif;
  --font-head: var(--font);
  --badge-open-bg: transparent; --badge-open-fg: #1c5e2e;
  --badge-closed-bg: transparent; --badge-closed-fg: #8a1212;
  --badge-nodeadline-bg: transparent; --badge-nodeadline-fg: #444;
  --badge-bozza-bg: transparent; --badge-bozza-fg: #7a5a00;
}
[data-style="gazzetta"] .site-header {
  display: block;
  text-align: center;
  border-bottom: 3px double var(--text);
  padding-bottom: 1rem;
}
[data-style="gazzetta"] .site-header h1 {
  font-size: 2.4rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
[data-style="gazzetta"] .masthead { font-variant: small-caps; letter-spacing: 0.2em; }
[data-style="gazzetta"] .style-switch { margin: 0.75rem auto 0; align-items: center; }
[data-style="gazzetta"] .controls { box-shadow: none; border-width: 1px 0; border-radius: 0; }
[data-style="gazzetta"] .register { font-size: 0.85rem; }
[data-style="gazzetta"] .register thead th { border-bottom: 2px solid var(--text); text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.03em; }
[data-style="gazzetta"] .register tbody tr:nth-child(even) { background: #f4f1ec; }
[data-style="gazzetta"] .badge { border: 1px solid currentColor; padding: 0 0.35rem; font-weight: 600; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 640px) {
  .site-header { align-items: flex-start; }
  .register { display: block; overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) {
  [data-style="chiaro"] .card,
  [data-style="scuro"] .card { transition: none; }
}
