/* IL POLIMATE — foglio di stile della PWA
 *
 * Mobile-first: riferimento 390 px, regge da 320 a 1600 px.
 * Palette e caratteri sono quelli dell'edizione cartacea (CONTRACT.md):
 * carta #f5efe2 · inchiostro #191510 · rosso #9d1c1c · crema #ece3cc · filetti #c3b795
 * Contrasti verificati AA (inchiostro/carta 16:1, rosso/carta 7:1, muted/carta 5,2:1).
 */

:root {
  --paper: #f5efe2;
  --ink: #191510;
  --muted: #6d6353;
  --hair: #c3b795;
  --hard: #241f18;
  --red: #9d1c1c;
  --cream: #ece3cc;

  --font-title: 'Playfair Display', 'Iowan Old Style', 'Times New Roman', serif;
  --font-body: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-ui: Archivo, system-ui, -apple-system, 'Segoe UI', sans-serif;

  --col: 720px;          /* colonna di lettura su desktop */
  --gutter: 18px;
  --duration: 300ms;     /* deve combaciare con ANIM_MS in app.js */
  --ease: cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-reduced-motion: reduce) {
  :root { --duration: 1ms; }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { margin: 0; }

.wrap {
  width: 100%;
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

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

.skip-link {
  position: absolute;
  top: -60px;
  left: 8px;
  z-index: 20;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 12px 16px;
  text-decoration: none;
}

.skip-link:focus { top: 8px; }

/* ------------------------------------------------------------------ *
 * testata
 * ------------------------------------------------------------------ */

.site-head {
  background: var(--paper);
  border-top: 5px solid var(--red);
  padding-top: 10px;
}

.strap {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin: 0;
  padding: 6px 0 9px;
  border-bottom: 1px solid var(--hair);
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

.strap span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.masthead {
  text-align: center;
  padding: 18px 0 12px;
}

.masthead-pre {
  margin: 0 0 9px;
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--muted);
}

.masthead-title {
  font-family: var(--font-title);
  font-weight: 900;
  font-size: clamp(46px, 18vw, 88px);
  line-height: .9;
  letter-spacing: .012em;
}

.masthead-note {
  margin: 12px auto 0;
  max-width: 32em;
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--muted);
}

.rule-double {
  border-top: 3px solid var(--hard);
  border-bottom: 1px solid var(--hard);
  height: 5px;
}

.edition-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 12px;
}

.edition-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.edition-select {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 8px 34px 8px 11px;
  border: 1.5px solid var(--hard);
  border-radius: 0;
  background-color: var(--cream);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M0 0h12L6 8z' fill='%239d1c1c'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
  -webkit-appearance: none;
  appearance: none;
}

/* ------------------------------------------------------------------ *
 * stato, frasi del giorno, feed
 * ------------------------------------------------------------------ */

.status {
  margin: 16px 0 0;
  font-family: var(--font-ui);
  font-size: 12.5px;
  letter-spacing: .04em;
  color: var(--muted);
}

.status:empty { display: none; }

.status--notice {
  padding: 13px 14px;
  border: 1px dashed var(--hair);
  background: var(--cream);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--ink);
}

.highlights {
  margin: 18px 0 0;
  padding: 14px 15px;
  border: 1.5px solid var(--hard);
  background: var(--cream);
}

.highlight-item {
  margin: 0;
  font-family: var(--font-title);
  font-style: italic;
  font-weight: 700;
  font-size: 16.5px;
  line-height: 1.38;
}

.highlight-item + .highlight-item {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dotted var(--hair);
}

.feed { margin: 6px 0 0; }

/* ------------------------------------------------------------------ *
 * card (accordion)
 * ------------------------------------------------------------------ */

.card {
  border-bottom: 1px solid var(--hair);
}

.card--lead {
  margin: 16px 0 20px;
  padding: 0 15px;
  border: 1.5px solid var(--hard);
  background: var(--cream);
}

.card--lead .card-title-text { font-size: clamp(27px, 8.4vw, 36px); }

.card--flat { border-bottom-style: dotted; }

.card-title { font-size: 1em; font-weight: inherit; }

.card-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 16px 2px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.card-head--static { cursor: default; }

.card-head-text { display: block; min-width: 0; }

.card-kicker {
  display: block;
  margin-bottom: 7px;
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
  line-height: 1.35;
  color: var(--red);
}

.card-kicker::before {
  content: "▪ ";
  font-size: .8em;
}

.card--lead .card-kicker { font-size: 11px; }

.card-title-text {
  display: block;
  font-family: var(--font-title);
  font-weight: 900;
  font-size: clamp(23px, 6.6vw, 30px);
  line-height: 1.06;
  letter-spacing: -.005em;
}

.card-sub {
  display: block;
  margin-top: 8px;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.34;
}

.card-mark {
  position: relative;
  width: 24px;
  height: 24px;
  margin-top: 2px;
  flex: 0 0 auto;
}

.card-mark::before,
.card-mark::after {
  content: "";
  position: absolute;
  top: 11px;
  left: 3px;
  right: 3px;
  height: 2px;
  background: var(--red);
}

/* chiusa: il segno è un "+" — aperta: ruota e diventa un "−" */
.card-mark::after {
  transform: rotate(90deg);
  transition: transform var(--duration) var(--ease);
}

.card.is-open .card-mark::after {
  transform: rotate(0deg);
}

/* corpo della card: si anima l'altezza, il padding sta dentro così lo 0 è davvero zero */
.card-body {
  overflow: hidden;
}

.card-body[hidden] { display: none; }

.card-body.is-animating {
  transition: height var(--duration) var(--ease);
}

.card-body-inner { padding: 0 2px 18px; }

.card--lead .card-body-inner { padding-bottom: 18px; }

.card--lead .card-p:first-child { margin-top: 0; }

.card-p {
  margin: 0 0 12px;
  font-size: 16.5px;
  line-height: 1.62;
}

.card-p:last-child { margin-bottom: 0; }

.card-p b, .card-sub b, .card-credit b { font-weight: 700; }

.card-credit {
  margin: 16px 0 0;
  padding-top: 10px;
  border-top: 1px dotted var(--hair);
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.42;
  color: var(--muted);
}

.card--compact .card-head { padding: 13px 2px; }
.card--compact .card-title-text { font-size: 21px; }
.card--compact .card-sub { font-size: 14.5px; }

.quote {
  margin: 16px 0;
  padding: 4px 0 4px 14px;
  border-left: 3px solid var(--red);
}

.quote-text {
  margin: 0;
  font-family: var(--font-title);
  font-style: italic;
  font-weight: 700;
  font-size: 19px;
  line-height: 1.34;
}

.quote-text p { margin: 0; }

.quote-who {
  margin-top: 9px;
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

.databox {
  margin: 16px 0;
  padding: 12px 14px 11px;
  border: 1.5px solid var(--hard);
  background: var(--cream);
}

.databox-title {
  margin: 0 0 8px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--red);
}

.databox-rows { margin: 0; }

.databox-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dotted var(--hair);
}

.databox-row:last-child { border-bottom: 0; padding-bottom: 0; }

.databox-label {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.38;
}

.databox-value {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.38;
  text-align: right;
}

.databox-note {
  margin: 9px 0 0;
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.42;
  color: var(--muted);
}

/* ------------------------------------------------------------------ *
 * divisori di sezione, striscia numeri, box metodo/fonti, colophon
 * ------------------------------------------------------------------ */

.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 30px 0 4px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--ink);
}

.section-head::before,
.section-head::after {
  content: "";
  flex: 1 1 auto;
  min-width: 10px;
  border-top: 2px solid var(--hard);
}

.section-head-label {
  /* flex-basis auto + shrink: le etichette lunghe ("I tuoi numeri · letti
     stamattina") vanno a capo invece di sbordare dai 320 px */
  flex: 0 1 auto;
  min-width: 0;
  text-align: center;
}

.numbers {
  margin: 34px 0 0;
  border-top: 2px solid var(--hard);
}

.numbers .section-head { margin-top: 14px; }

.numbers-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--hair);
  border-top: 0;
}

.number-item {
  padding: 12px 12px 13px;
  min-width: 0;
}

.number-item:nth-child(even) { border-left: 1px solid var(--hair); }
.number-item:nth-child(n+3) { border-top: 1px solid var(--hair); }

.number-value {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 900;
  font-size: 24px;
  line-height: 1.05;
}

.number-caption {
  margin: 5px 0 0;
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--muted);
}

.metabox {
  margin: 26px 0 0;
  padding: 14px 15px 15px;
  border: 1.5px solid var(--hard);
  border-left-width: 6px;
  background: var(--cream);
}

.metabox-title {
  margin: 0 0 8px;
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--red);
}

.metabox-body {
  font-size: 14.5px;
  line-height: 1.55;
}

.metabox-body p { margin: 0 0 9px; }
.metabox-body p:last-child { margin-bottom: 0; }

.site-foot {
  margin-top: 34px;
  padding-bottom: 36px;
}

.foot-line {
  margin: 14px 0 0;
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  text-align: center;
  color: var(--muted);
}

.foot-note {
  margin: 8px 0 0;
  font-style: italic;
  font-size: 12px;
  text-align: center;
  color: var(--muted);
}

/* ------------------------------------------------------------------ *
 * superfici coperte dalle dita e dagli schermi grandi
 * ------------------------------------------------------------------ */

@media (hover: hover) and (pointer: fine) {
  .card-head:hover { background: rgba(195, 183, 149, .16); }
  .card--lead .card-head:hover { background: rgba(195, 183, 149, .28); }
  .card-head--static:hover { background: none; }
  .edition-select:hover { background-color: var(--paper); }
}

@media (min-width: 420px) {
  :root { --gutter: 22px; }
}

@media (min-width: 560px) {
  .numbers-grid { grid-template-columns: repeat(3, 1fr); }
  .number-item:nth-child(3n) { border-left: 0; }
  .number-item:nth-child(n+4) { border-top: 1px solid var(--hair); }
  .number-item:nth-child(-n+3) { border-top: 0; }
}

@media (min-width: 760px) {
  :root { --gutter: 28px; }
  body { font-size: 17.5px; }
  .card-p { font-size: 17px; }
  .card--lead { padding: 0 20px; }
  .card-head { padding: 18px 4px; }
  .card--lead .card-head { padding: 20px 4px; }
  .card-body-inner { padding: 0 4px 20px; }
  .strap { font-size: 11px; }
}

@media (min-width: 1100px) {
  .masthead { padding: 24px 0 14px; }
  .card-title-text { font-size: 30px; }
  .card--lead { padding: 0 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .card-body.is-animating { transition: none; }
  .card-mark::after { transition: none; }
}

@media (forced-colors: active) {
  .card-mark::before, .card-mark::after { background: CanvasText; }
  .status--notice, .databox, .highlights, .metabox { border-color: CanvasText; }
}
