/* Cruscotto NGI — SEMPRE scuro (Reda, 25/11): il tema chiaro di Telegram si ignora.
   Forme, spazi e tipografia iOS (docs/ios-design-system.md): OLED nero, schede che schiariscono salendo. */

:root {
  color-scheme: dark;
  --bg: #000000;
  --card: #1c1c1e;
  --card-2: #2c2c2e;
  --ink: #ffffff;
  --hint: #98989f;
  --sep: rgba(84, 84, 88, 0.65);
  --accent: #e6c178;            /* oro NGI */
  --btn: #c9a460;
  --btn-text: #000000;

  /* stato: fissi, sempre con una parola accanto */
  --s-verde: #0ca30c;
  --s-giallo: #fab219;
  --s-rosso: #d03b3b;
  --s-grigio: #8e8e93;
  --vuoto: #3a3a3c;             /* giorno senza dati */

  --raggio: 14px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.35 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px calc(28px + env(safe-area-inset-bottom, 0px));
  transition: opacity 0.2s var(--ease);
}
main.ricarica { opacity: 0.6; }

/* ── (a) testata: eyebrow + barra d'accento, verdetto di oggi ── */
.testa { padding: 8px 4px 18px; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.barra { display: inline-block; width: 3px; height: 12px; margin-right: 8px; border-radius: 2px; background: var(--accent); }
.pillola-finto {
  margin-left: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--hint);
  letter-spacing: 0.02em;
  text-transform: none;
}
.verdetto {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 0;
  font-size: 28px;
  line-height: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.verdetto .pallino { width: 14px; height: 14px; }
.aggiornato {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: 13px;
  line-height: 18px;
  color: var(--hint);
  font-variant-numeric: tabular-nums;
}
.link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: 600 15px/20px var(--font);
  padding: 12px 8px;
  margin: -12px -8px;
  min-height: 44px;
  cursor: pointer;
}
.avviso {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(250, 178, 25, 0.16);
  font-size: 13px;
  line-height: 18px;
}
.avviso.leggero { background: var(--card); color: var(--hint); }

/* ── pallini ── */
.pallino { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; }
.v-verde { background: var(--s-verde); }
.v-giallo { background: var(--s-giallo); }
.v-rosso { background: var(--s-rosso); }
.v-grigio { background: var(--s-grigio); }
.v-attesa { background: transparent; box-shadow: inset 0 0 0 1.5px var(--hint); }

/* ── schede ── */
.scheda { background: var(--card); border-radius: var(--raggio); padding: 14px 16px 16px; margin: 0 0 26px; }
.sezione {
  margin: 0 0 7px 16px;
  font-size: 13px;
  line-height: 18px;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--hint);
}

/* ── (b) calendario ── */
.cal-testa { display: flex; align-items: center; justify-content: space-between; margin: -6px -8px 6px; }
.cal-testa h2 { margin: 0; font-size: 16px; line-height: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-freccia {
  appearance: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--accent);
  font: 400 28px/1 var(--font);
  cursor: pointer;
}
.cal-freccia:disabled { color: var(--vuoto); cursor: default; }
.cal-freccia:not(:disabled):active { background: var(--card-2); }
.cal-sett, .cal-griglia { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); column-gap: 6px; }
.cal-sett { margin-bottom: 6px; text-align: center; font-size: 11px; line-height: 14px; font-weight: 600; color: var(--hint); }
.cal-griglia { row-gap: 11px; }
.cella {
  position: relative;
  appearance: none;
  aspect-ratio: 1;
  width: 100%;
  border: 0;
  border-radius: 9px;
  padding: 0;
  font: 600 13px/1 var(--font);
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  cursor: pointer;
}
.cella.g-verde { background: var(--s-verde); }
.cella.g-giallo { background: var(--s-giallo); color: #1c1c1e; }
.cella.g-rosso { background: var(--s-rosso); }
.cella.g-grigio { background: var(--vuoto); color: var(--hint); }
.cella.futuro { background: transparent; color: #48484a; cursor: default; }
.cella.oggi { outline: 2px solid var(--ink); outline-offset: 2px; }
.cella.scelto::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 14px;
  height: 3px;
  margin-left: -7px;
  border-radius: 2px;
  background: var(--accent);
}
.cella:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.legenda {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  line-height: 16px;
  color: var(--hint);
}
.legenda li { display: inline-flex; align-items: center; gap: 5px; }
.chiave { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.chiave.g-verde { background: var(--s-verde); }
.chiave.g-giallo { background: var(--s-giallo); }
.chiave.g-rosso { background: var(--s-rosso); }
.chiave.g-grigio { background: var(--vuoto); }
.chiave.g-oggi { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink); }

.giorno { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--sep); }
.giorno h3 { margin: 0 0 8px; font-size: 15px; line-height: 20px; font-weight: 600; }
.giorno h3 span { color: var(--hint); font-weight: 400; }
.voci { margin: 0; padding: 0; list-style: none; }
.voci li { display: flex; align-items: baseline; gap: 10px; padding: 4px 0; font-size: 14px; line-height: 19px; }
.voci .pallino { position: relative; top: 1px; }
.voci li.attesa { color: var(--hint); }
.vuoto { margin: 0; font-size: 14px; color: var(--hint); }

/* ── (c) controlli: una riga ciascuno ── */
.lista { list-style: none; margin: 0 0 22px; padding: 0; background: var(--card); border-radius: var(--raggio); overflow: hidden; }
.riga { position: relative; }
.riga + .riga::before { content: ""; position: absolute; top: 0; left: 42px; right: 0; height: 1px; background: var(--sep); }
.riga-testa {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.riga-testa:active { background: var(--card-2); }
.riga-testa:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nome { flex: 1; min-width: 0; font-size: 16px; line-height: 21px; font-weight: 500; }
.breve { font-size: 14px; line-height: 19px; color: var(--hint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.breve.attenzione { color: var(--ink); }
.freccia {
  width: 8px;
  height: 13px;
  flex: none;
  margin-left: -6px;
  fill: none;
  stroke: var(--hint);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.6;
  transition: transform 0.25s var(--ease);
}
.riga-testa[aria-expanded="true"] .freccia { transform: rotate(90deg); }

.dettagli { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.28s var(--ease); }
.riga-testa[aria-expanded="true"] + .dettagli { grid-template-rows: 1fr; }
.dettagli-dentro { overflow: hidden; }
.dettagli-corpo { padding: 0 16px 14px 42px; }
.linea { margin: 0; font-size: 13px; line-height: 18px; color: var(--hint); font-variant-numeric: tabular-nums; }
.nota { margin: 8px 0 0; font-size: 13px; line-height: 18px; color: var(--hint); }
.kv { display: grid; grid-template-columns: fit-content(48%) minmax(0, 1fr); gap: 6px 16px; margin: 10px 0 0; font-size: 14px; line-height: 19px; }
.kv dt { color: var(--hint); min-width: 0; }
.kv dd { margin: 0; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: break-word; }
.kv dd.l-giallo, .kv dd.l-rosso { font-weight: 600; }
.kv dd .pallino { margin-right: 6px; width: 8px; height: 8px; vertical-align: 1px; }
.kv dt.lungo, .kv dd.lungo { grid-column: 1 / -1; }
.kv dd.lungo { margin-top: -4px; text-align: left; }

.piede { margin: 4px 16px 0; font-size: 12px; line-height: 16px; color: var(--hint); text-align: center; }

/* ── caricamento e blocco ── */
.carico { margin: 40vh 0 0; text-align: center; color: var(--hint); font-size: 15px; }
.blocco { min-height: 100vh; display: grid; place-items: center; padding: 32px 24px; }
.blocco-scheda { max-width: 340px; text-align: center; }
.blocco-icona { width: 44px; height: 44px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.blocco h1 { margin: 12px 0 0; font-size: 22px; line-height: 28px; font-weight: 700; }
.blocco p { margin: 8px 0 0; font-size: 15px; line-height: 21px; color: var(--hint); }
.bottone {
  appearance: none;
  margin-top: 20px;
  min-height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 12px;
  background: var(--btn);
  color: var(--btn-text);
  font: 600 16px/1 var(--font);
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
