/* Componenti condivisi tra le pagine: neutri freddi, un blu di marca per azioni, link e
   batteria, rosso solo per ciò che manca e per gli errori. */

/* ---- Impaginazione ---- */
.wrap {
  max-width: calc(var(--page-max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.section {
  padding: var(--sp-8) 0;
  border-top: var(--rule);
}
.section:first-child {
  border-top: 0;
}

/* ---- Testata ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: var(--rule);
}
.site-header > .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-5);
  min-height: 4rem;
  padding-top: var(--sp-2);
  padding-bottom: var(--sp-2);
}
.site-name {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 600;
  font-size: var(--fs-l);
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
}
.site-name svg {
  flex: none;
}
.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1);
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav a {
  display: inline-block;
  color: var(--ink-2);
  font-size: var(--fs-s);
  font-weight: 500;
  text-decoration: none;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-s);
  transition:
    background-color 120ms ease-out,
    color 120ms ease-out;
}
.site-nav a:hover,
.site-nav a[aria-current='page'] {
  color: var(--ink);
  background: var(--band);
}
.site-nav .site-nav__cta a {
  margin-left: var(--sp-2);
  color: #ffffff;
  background: var(--blue);
}
.site-nav .site-nav__cta a:hover {
  background: var(--blue-strong);
}
@media (max-width: 40rem) {
  .site-header > .wrap {
    padding-bottom: 0;
  }
  .site-nav {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .site-nav ul {
    flex-wrap: nowrap;
    margin-inline: calc(-1 * var(--sp-3));
    padding-bottom: var(--sp-2);
    white-space: nowrap;
  }
  .site-nav .site-nav__cta a {
    margin-left: 0;
  }
}

/* ---- Livello delle spiegazioni: controllo a segmenti ---- */
.level-bar {
  background: var(--band);
  border-bottom: var(--rule);
  font-size: var(--fs-s);
}
.level-bar .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding-top: var(--sp-2);
  padding-bottom: var(--sp-2);
}
.level-bar__label {
  color: var(--ink-2);
}
.level-switch {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 2px;
  background: var(--line);
  border-radius: var(--radius);
}
.level-switch a {
  display: inline-block;
  padding: var(--sp-1) var(--sp-3);
  color: var(--ink-2);
  text-decoration: none;
  border-radius: var(--radius-s);
}
.level-switch a:hover {
  color: var(--ink);
}
.level-switch a[aria-current='true'] {
  color: var(--ink);
  font-weight: 500;
  background: var(--paper);
  box-shadow: var(--shadow-s);
}

/* Parti che compaiono solo da un certo livello in su (o solo al livello semplice). */
[data-livello='semplice'] .da-tecnico,
[data-livello='semplice'] .da-installatore,
[data-livello='tecnico'] .da-installatore,
[data-livello='tecnico'] .solo-semplice,
[data-livello='installatore'] .solo-semplice,
[data-livello='installatore'] .non-installatore {
  display: none !important;
}

/* ---- Piede ---- */
.site-footer {
  margin-top: var(--sp-9);
  padding: var(--sp-8) 0 var(--sp-7);
  background: var(--navy);
  color: #c7cfdd;
  font-size: var(--fs-s);
}
.site-footer .wrap {
  display: grid;
  gap: var(--sp-5) var(--sp-7);
}
@media (min-width: 48rem) {
  .site-footer .wrap {
    grid-template-columns: 5fr 7fr;
  }
}
.site-footer .site-name {
  color: #ffffff;
  margin-bottom: var(--sp-4);
}
.site-footer p {
  margin-bottom: var(--sp-2);
}
.site-footer a {
  color: #ffffff;
}
.footer-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--sp-5);
}
.site-footer .footer-nav__title {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9aa6ba;
}
.footer-links {
  display: grid;
  gap: var(--sp-1);
  list-style: none;
  padding: 0;
  margin: 0;
}
.footer-links a {
  display: inline-block;
  padding: var(--sp-1) 0;
  text-decoration: none;
}
.footer-links a:hover {
  text-decoration: underline;
}

/* ---- Etichette: intestazioni di colonna ---- */
.label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--sp-2);
}

.lead {
  font-size: var(--fs-l);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 34em;
}

.muted {
  color: var(--ink-2);
}

/* ---- Bottoni ---- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  min-height: 2.75rem;
  padding: 0.625rem 1.125rem;
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  background: var(--blue);
  color: #ffffff;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-s);
  transition:
    background-color 120ms ease-out,
    transform 100ms ease-out;
}
.button:hover {
  background: var(--blue-strong);
  border-color: var(--blue-strong);
}
.button:active {
  transform: translateY(1px);
}
.button--plain {
  background: var(--paper);
  border-color: var(--line-strong);
  color: var(--ink);
}
.button--plain:hover {
  background: var(--band);
  border-color: var(--line-strong);
}
.button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.text-button {
  font: inherit;
  color: var(--blue);
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  cursor: pointer;
}
.text-button:hover {
  text-decoration-color: currentColor;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3) var(--sp-4);
}

/* ---- Scheda: voce e valore ---- */
.spec {
  display: grid;
  grid-template-columns: minmax(8rem, 14rem) 1fr;
  border-top: var(--rule);
  margin: 0 0 var(--sp-5);
}
.spec dt,
.spec dd {
  margin: 0;
  padding: var(--sp-3) 0;
  border-bottom: var(--rule);
}
.spec dt {
  font-size: var(--fs-s);
  font-weight: 500;
  color: var(--ink-2);
  padding-right: var(--sp-4);
}
@media (max-width: 30rem) {
  .spec {
    grid-template-columns: 1fr;
  }
  .spec dt {
    border-bottom: 0;
    padding-bottom: 0;
  }
}

/* ---- Cifre in evidenza ---- */
.figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
  margin: 0 0 var(--sp-5);
}
@media (min-width: 40rem) {
  .figures {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.figure {
  padding: var(--sp-4);
  background: var(--band);
  border-radius: var(--radius);
}
.figure dd {
  margin: 0;
  font-weight: 600;
  font-size: var(--fs-xl);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.figure .unit {
  font-weight: 400;
  font-size: var(--fs-s);
  letter-spacing: 0;
  color: var(--ink-2);
}
.figure--alert {
  background: var(--red-tint);
}
.figure--alert dd {
  color: var(--red);
}

/* ---- Avvisi ---- */
.notice {
  padding: var(--sp-3) var(--sp-4);
  margin: 0 0 var(--sp-5);
  max-width: var(--measure);
  background: var(--band);
  border: var(--rule);
  border-radius: var(--radius);
}
/* l'errore della risposta prende il focus da solo (autofocus): non è un comando, niente anello */
.notice[tabindex='-1']:focus {
  outline: none;
}
.notice p:last-child {
  margin-bottom: 0;
}
.notice--error {
  background: var(--red-tint);
  border-color: #fecdca;
  color: #7a271a;
}
.notice--battery {
  background: var(--blue-tint);
  border-color: #c7d7fe;
}
.notice--ok {
  background: var(--green-tint);
  border-color: #abefc6;
  color: #054f31;
}

/* ---- Moduli ---- */
fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 var(--sp-6);
  min-width: 0;
}
legend {
  padding: 0;
  font-size: var(--fs-l);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: var(--sp-3);
}
.field {
  margin-bottom: var(--sp-5);
}
.field > label,
.field-label {
  display: block;
  font-size: var(--fs-s);
  font-weight: 500;
  margin-bottom: var(--sp-2);
}
.hint {
  display: block;
  font-size: var(--fs-s);
  color: var(--ink-2);
  margin-top: var(--sp-2);
  max-width: var(--measure);
}
input[type='text'],
input[type='search'],
input[type='number'],
input[type='email'],
input[type='password'],
select {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-s);
  padding: var(--sp-2) var(--sp-3);
  min-height: 2.75rem;
  max-width: 100%;
  transition:
    border-color 120ms ease-out,
    box-shadow 120ms ease-out;
}
select {
  padding-right: var(--sp-6);
}
input[type='number'] {
  font-family: var(--font-mono);
  width: 9rem;
}
input:hover,
select:hover {
  border-color: #98a2b3;
}
::placeholder {
  color: var(--ink-3);
  opacity: 1;
}
input:focus-visible,
select:focus-visible {
  outline: 0;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 22%, transparent);
}
input[aria-invalid='true'] {
  border-color: var(--red);
}
.with-unit {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.with-unit .unit {
  font-size: var(--fs-s);
  color: var(--ink-2);
}
.choice {
  display: flex;
  gap: var(--sp-3);
  align-items: baseline;
  margin-bottom: var(--sp-2);
}
.choice input {
  margin: 0;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--blue);
  flex: none;
  transform: translateY(0.15em);
}
.field-error {
  display: block;
  color: var(--red);
  font-size: var(--fs-s);
  margin-top: var(--sp-1);
}

/* ---- Tabelle ---- */
.table-scroll {
  overflow-x: auto;
  margin: 0 0 var(--sp-5);
}
.data-table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--fs-s);
  margin: 0;
}
.data-table caption {
  text-align: left;
  font-size: var(--fs-l);
  font-weight: 600;
  letter-spacing: -0.01em;
  padding-bottom: var(--sp-3);
}
.data-table th,
.data-table td {
  height: 2.25rem;
  padding: var(--sp-1) var(--sp-3);
  border-bottom: var(--rule);
  text-align: right;
  white-space: nowrap;
}
.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
  padding-left: 0;
}
.data-table thead th {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--ink-3);
  border-bottom: var(--rule-strong);
  vertical-align: bottom;
  line-height: 1.3;
}
.data-table tbody th {
  font-weight: 500;
}
.data-table td {
  font-family: var(--font-mono);
}
.data-table tr.is-worst td,
.data-table tr.is-worst th {
  background: var(--red-tint);
  color: var(--red);
  font-weight: 500;
}
.data-table tfoot td,
.data-table tfoot th {
  border-top: var(--rule-strong);
  border-bottom: 0;
  font-weight: 600;
}
.data-table .alert {
  color: var(--red);
}

/* ---- Grafici SVG ---- */
.chart {
  margin: 0 0 var(--sp-6);
}
.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart figcaption {
  font-size: var(--fs-s);
  color: var(--ink-2);
  margin-top: var(--sp-2);
  max-width: var(--measure);
}
.chart-title {
  font-size: var(--fs-m);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}
.chart text {
  font-family: var(--font-mono);
  font-size: 12px;
  fill: var(--ink-2);
}
.chart .tick-label {
  font-size: 11px;
}
/* Il grafico è disegnato largo 720 unità e rimpicciolito: su mobile servono caratteri
   più grandi in unità del disegno per restare leggibili (circa 11 px sullo schermo). */
@media (max-width: 40rem) {
  .chart text {
    font-size: 22px;
  }
  .chart .tick-label {
    font-size: 20px;
  }
}
.chart .direct-label {
  font-family: var(--font-sans);
  fill: var(--ink);
  /* Alone bianco: l'etichetta resta leggibile anche sopra barre e linee. */
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.chart .direct-label--accent {
  fill: var(--red);
}
.chart .grid {
  stroke: var(--line);
  stroke-width: 1;
}
.chart .axis {
  stroke: var(--ink);
  stroke-width: 1;
}
/* produzione in grigio scuro, batteria in blu, mancanza in rosso */
.chart .bar-produced {
  fill: #344054;
}
.chart .bar-produced-avg {
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 2;
}
.chart .line-demand {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-dasharray: 5 3;
}
.chart .bar-unmet {
  fill: var(--red-fill);
}
.chart .line-soc {
  fill: none;
  stroke: var(--blue);
  stroke-width: 1.75;
  stroke-linejoin: round;
}
.chart .line-limit {
  stroke: var(--ink);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}
.chart .band-shortage {
  fill: var(--red-tint);
}

/* ---- Caricamento ---- */
.progress {
  height: 2px;
  background: var(--line);
  overflow: hidden;
  margin: var(--sp-3) 0 var(--sp-5);
  max-width: 24rem;
}
.progress::after {
  content: '';
  display: block;
  height: 100%;
  width: 30%;
  background: var(--blue);
  animation: progress 1.4s ease-in-out infinite;
}
@keyframes progress {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}
@media (prefers-reduced-motion: reduce) {
  .progress::after {
    animation: none;
    width: 100%;
    opacity: 0.4;
  }
}

@media (max-width: 30rem) {
  .level-bar__label {
    display: none;
  }
  .level-switch {
    flex-wrap: nowrap;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
  }
}

/* Elenco di marche da spuntare (Progetta, listino) */
.brand-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0 var(--sp-4);
}

/* ---- Video «Come si fa»: il pulsante accanto a ogni strumento e la finestra del video ---- */
.help-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  flex: none;
  padding: var(--sp-1) var(--sp-3) var(--sp-1) var(--sp-1);
  font: inherit;
  font-size: var(--fs-s);
  font-weight: 500;
  line-height: 1.2;
  color: var(--blue-strong);
  background: var(--blue-tint);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.help-link:hover {
  background: color-mix(in srgb, var(--blue) 16%, var(--paper));
}
.help-link:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.help-link__icon {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
}
.help-video {
  width: min(60rem, calc(100vw - 2 * var(--sp-4)));
  max-height: calc(100vh - 2 * var(--sp-4));
  padding: 0;
  border: 0;
  border-radius: var(--radius-l);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 64px -16px rgb(11 21 48 / 0.45);
  overflow: auto;
}
.help-video::backdrop {
  background: rgb(11 21 48 / 0.62);
}
.help-video__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
}
.help-video__kicker {
  margin: 0 0 var(--sp-1);
  font: 600 var(--fs-xs) / 1.2 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
}
.help-video__title {
  margin: 0;
  font-size: var(--fs-l);
}
.help-video__close {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  color: var(--ink-2);
  background: none;
  border: var(--rule);
  border-radius: 50%;
  cursor: pointer;
}
.help-video__close:hover {
  color: var(--ink);
  background: var(--band);
}
.help-video__frame {
  background: var(--navy);
}
.help-video__player {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}
.help-video__text {
  padding: var(--sp-3) var(--sp-5) var(--sp-4);
  font-size: var(--fs-s);
}
.help-video__text summary {
  font-weight: 500;
  cursor: pointer;
}
.help-video__lines {
  list-style: none;
  padding: 0;
  margin: var(--sp-3) 0 0;
}
.help-video__line {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  gap: var(--sp-2);
  width: 100%;
  padding: var(--sp-1) 0;
  font: inherit;
  line-height: var(--lh-text);
  text-align: left;
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
}
.help-video__line:hover {
  color: var(--blue);
}
.help-video__at {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}
@media (prefers-reduced-motion: no-preference) {
  .help-video[open] {
    animation: help-video-in 0.18s ease-out;
  }
}
@keyframes help-video-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}
@media print {
  .help-link {
    display: none;
  }
}
.help-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  list-style: none;
  padding: 0;
  margin: 0 0 var(--sp-6);
}
.help-list li {
  margin: 0;
}
