/* Copyright (c) 2026 D&J Corporate — Tutti i diritti riservati. */

:root {
  --sfondo: #f6f8fa;
  --carta: #ffffff;
  --bordo: #d6dce2;
  --testo: #1c2430;
  --tenue: #64707d;
  --accento: #17548a;
  --allarme: #b42318;
  --ok: #1a7f37;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--sfondo);
  color: var(--testo);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

body { display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; }

.tenue { color: var(--tenue); font-weight: 400; }

/* ---------------- barra ---------------- */

.barra {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 18px;
  background: var(--carta); border-bottom: 1px solid var(--bordo);
}
.titolo strong { display: block; font-size: 16px; }
.titolo .tenue { font-size: 13px; }

.bottone-cantiere {
  padding: 10px 16px; border: 0; border-radius: 8px;
  background: var(--accento); color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer;
}
.bottone-cantiere.attivo { background: var(--ok); }

/* ---------------- corpo ---------------- */

main { display: grid; grid-template-columns: 320px 1fr; min-height: 0; }

.laterale {
  display: flex; flex-direction: column; gap: 14px;
  padding: 16px; min-height: 0; overflow-y: auto;
  background: var(--carta); border-right: 1px solid var(--bordo);
}

.campo { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.campo span { color: var(--tenue); }
.campo select {
  padding: 9px 10px; border: 1px solid var(--bordo); border-radius: 7px;
  background: #fff; font-size: 15px;
}

.scheda-info {
  padding: 10px 12px; border: 1px solid var(--bordo); border-radius: 8px;
  background: #fbfcfd; font-size: 13px;
}
.scheda-info .riga { display: flex; justify-content: space-between; gap: 10px; }
.scheda-info .riga + .riga { margin-top: 5px; }
.scheda-info b { font-family: var(--mono); }
.scheda-info b.conforme { color: var(--ok); }
.scheda-info b.non-conforme { color: var(--allarme); }

.elenco { display: flex; flex-direction: column; gap: 5px; }

.voce {
  display: grid; grid-template-columns: 10px 1fr auto; gap: 9px;
  align-items: center; padding: 9px 10px;
  border: 1px solid var(--bordo); border-radius: 7px;
  background: #fff; cursor: pointer; text-align: left; font: inherit;
}
.voce:hover { border-color: var(--accento); }
.voce .pallino { width: 10px; height: 10px; border-radius: 50%; }
.voce .sigla { font-weight: 600; }
.voce .tipo { font-size: 12px; color: var(--tenue); }
.voce .stato {
  font-size: 11px; padding: 2px 6px; border-radius: 10px; background: #eef1f4;
}
.voce .stato.asfaltato { background: #fdecea; color: var(--allarme); }

/* ---------------- mappa ---------------- */

.mappa-contenitore { position: relative; min-height: 0; }
#mappa { position: absolute; inset: 0; }

/* ---------------- cantiere ---------------- */

.cantiere {
  position: absolute; right: 14px; top: 14px; bottom: 14px; width: min(340px, 92vw);
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  border-radius: 12px; background: var(--carta);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18); z-index: 5;
}
.cantiere header { display: flex; justify-content: space-between; align-items: center; }
.cantiere header button { border: 0; background: none; font-size: 22px; cursor: pointer; }

.vicini { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.vicino {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 11px 4px; border-bottom: 1px solid var(--bordo);
}
.vicino .distanza { font-family: var(--mono); font-size: 22px; font-weight: 700; }
.vicino.caldo .distanza { color: var(--ok); }

.avvertenza {
  margin: 0; padding: 9px 10px; border-radius: 7px;
  background: #fff8e6; border: 1px solid #f0d9a0;
  font-size: 12px; line-height: 1.4;
}

/* ---------------- scheda ---------------- */

dialog {
  border: 0; border-radius: 12px; padding: 0; max-width: min(560px, 94vw);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(15, 20, 25, .45); }
dialog article { padding: 18px 20px 22px; }
dialog header { display: flex; justify-content: space-between; align-items: start; }
dialog h2 { margin: 0 0 4px; font-size: 18px; }
dialog header button { border: 0; background: none; font-size: 24px; cursor: pointer; }

table.storico { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
table.storico th { text-align: left; color: var(--tenue); font-weight: 600; padding: 6px 4px; }
table.storico td { padding: 6px 4px; border-top: 1px solid var(--bordo); font-family: var(--mono); }

.coordinate { margin-top: 10px; padding: 10px; border-radius: 8px; background: #f2f5f8; }
.coordinate div { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 13px; }

/* ---------------- piede ---------------- */

.pie {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 18px; background: var(--carta);
  border-top: 1px solid var(--bordo); font-size: 12px; color: var(--tenue);
}

/* ---------------- telefono ---------------- */

@media (max-width: 720px) {
  main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .laterale { max-height: 38vh; border-right: 0; border-bottom: 1px solid var(--bordo); }
  .cantiere { left: 14px; width: auto; }
}

/* ==========================================================================
   Schermata di accesso — una tavola di rilievo.

   Tutte le classi hanno il prefisso tv- : senza, "voce" e "pannello"
   collidono con quelle dell'elenco manufatti, che hanno sfondo bianco, e il
   testo diventa bianco su bianco.
   ========================================================================== */

.tavola {
  --inchiostro: #0a2540;
  --inchiostro-fondo: #051624;
  --reticolo-linea: rgba(125, 211, 252, .12);
  --carta: #eef4f9;
  --carta-tenue: rgba(238, 244, 249, .6);
  --quota-colore: #7dd3fc;
  --segnale: #f5a524;
  --tratto: rgba(125, 211, 252, .32);

  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(370px, 470px);
  grid-template-rows: minmax(0, 1fr) auto;
  background:
    radial-gradient(125% 95% at 16% 8%, #123659 0%, var(--inchiostro) 44%, var(--inchiostro-fondo) 100%);
  color: var(--carta);
  font-family: "Space Grotesk", system-ui, sans-serif;
  overflow: auto;
}

.tv-reticolo {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--reticolo-linea) 1px, transparent 1px),
    linear-gradient(90deg, var(--reticolo-linea) 1px, transparent 1px),
    linear-gradient(rgba(125, 211, 252, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 211, 252, .05) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
  mask-image: radial-gradient(135% 110% at 18% -5%, #000 30%, transparent 92%);
}

/* ---------------------------------------------------------------- rilievo */

.tv-rilievo {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 26px 32px;
  min-width: 0;
  min-height: 0;
}

.tv-pianta { width: auto; height: 100%; max-height: 74vh; overflow: visible; }

.tv-bordo,
.tv-mezzeria {
  fill: none;
  stroke: var(--tratto);
  stroke-width: 1.4;
  stroke-dasharray: 620;
  stroke-dashoffset: 620;
  animation: tv-traccia 1.05s cubic-bezier(.22, .61, .36, 1) forwards;
}

.tv-mezzeria {
  stroke: rgba(238, 244, 249, .46);
  stroke-width: 2;
  stroke-dasharray: 26 20;
  opacity: 0;
  animation: tv-comparsa .7s ease .5s forwards;
}

/* La passata del drone. Scende una volta al caricamento, poi ogni tanto:
   e' il gesto che il prodotto compie davvero, non un effetto. */
.tv-passata {
  animation: tv-sorvolo 7.5s cubic-bezier(.45, 0, .55, 1) .85s infinite;
}

.tv-fronte {
  stroke: var(--quota-colore);
  stroke-width: 1.6;
  filter: drop-shadow(0 0 6px rgba(125, 211, 252, .7));
}

.tv-manufatto {
  opacity: 0;
  animation: tv-rileva .45s cubic-bezier(.2, .8, .3, 1) var(--ritardo) forwards;
}

.tv-manufatto circle,
.tv-manufatto rect {
  fill: rgba(125, 211, 252, .18);
  stroke: var(--quota-colore);
  stroke-width: 1.6;
}

/* Quello finito sotto l'asfalto si legge a colpo d'occhio. */
.tv-sepolto circle {
  fill: rgba(245, 165, 36, .2);
  stroke: var(--segnale);
  stroke-dasharray: 3 3;
  animation: tv-battito 2.6s ease-in-out infinite;
}
.tv-sepolto .tv-sigla,
.tv-sepolto .tv-quota { fill: var(--segnale); }

.tv-misura { stroke: var(--tratto); stroke-width: 1; stroke-dasharray: 2 4; }

.tv-sigla {
  font-family: "Space Grotesk", sans-serif;
  font-size: 13px; font-weight: 600; fill: var(--carta);
}

.tv-quota {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px; fill: var(--quota-colore);
}

.tv-strisce rect {
  fill: rgba(238, 244, 249, .7);
  opacity: 0;
  animation: tv-comparsa .35s ease var(--ritardo) forwards;
}
.tv-strisce rect:nth-child(2) { animation-delay: calc(var(--ritardo) + .09s); }
.tv-strisce rect:nth-child(3) { animation-delay: calc(var(--ritardo) + .18s); }

.tv-didascalia {
  margin: 0;
  display: flex; flex-direction: column; gap: 2px;
  text-align: center; font-size: 13px; color: var(--carta-tenue);
  opacity: 0;
  animation: tv-comparsa .6s ease 2.9s forwards;
}

.tv-tolleranza {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px; color: var(--quota-colore);
}

@keyframes tv-traccia { to { stroke-dashoffset: 0; } }
@keyframes tv-comparsa { to { opacity: 1; } }
@keyframes tv-rileva {
  from { opacity: 0; transform: scale(.76); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes tv-battito {
  0%, 100% { stroke-opacity: 1; }
  50%      { stroke-opacity: .35; }
}
/* La passata resta ferma in basso per buona parte del ciclo: il movimento
   deve farsi notare una volta, non tenere l'occhio occupato. */
@keyframes tv-sorvolo {
  0%   { transform: translateY(0); opacity: 0; }
  4%   { opacity: 1; }
  32%  { transform: translateY(620px); opacity: 1; }
  38%  { transform: translateY(620px); opacity: 0; }
  100% { transform: translateY(620px); opacity: 0; }
}

/* ---------------------------------------------------------------- pannello */

.tv-pannello {
  position: relative;
  display: flex; flex-direction: column; justify-content: center; gap: 24px;
  padding: 44px 44px;
  background: rgba(3, 14, 24, .5);
  border-left: 1px solid rgba(125, 211, 252, .16);
  backdrop-filter: blur(3px);
}

.tv-marchio { display: flex; flex-direction: column; gap: 9px; }

.tv-prodotto {
  font-size: 13px; font-weight: 600; letter-spacing: .04em;
  color: var(--quota-colore);
}

.tv-pannello h1 {
  margin: 0;
  font-size: clamp(25px, 2.6vw, 32px);
  font-weight: 600; line-height: 1.12; letter-spacing: -.02em;
}

.tv-occhiello {
  margin: 0; max-width: 44ch;
  font-size: 14.5px; line-height: 1.55; color: var(--carta-tenue);
}

#modulo-accesso { display: flex; flex-direction: column; gap: 15px; }

#modulo-accesso label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; color: var(--carta-tenue);
}

#modulo-accesso input {
  padding: 13px 14px;
  border: 1px solid rgba(125, 211, 252, .26);
  border-radius: 3px;
  background: rgba(2, 11, 20, .6);
  color: var(--carta);
  /* 16px: sotto questa misura iOS ingrandisce la pagina al fuoco. */
  font: 16px/1.2 "Space Grotesk", system-ui, sans-serif;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#modulo-accesso input::placeholder { color: rgba(238, 244, 249, .28); }
#modulo-accesso input:focus-visible {
  outline: none;
  border-color: var(--quota-colore);
  box-shadow: 0 0 0 3px rgba(125, 211, 252, .18);
}

#btn-accedi {
  margin-top: 5px; padding: 14px;
  border: 0; border-radius: 3px;
  background: var(--segnale); color: #1c1204;
  font: 600 16px "Space Grotesk", system-ui, sans-serif;
  cursor: pointer;
  transition: background .15s ease, transform .08s ease;
}
#btn-accedi:hover { background: #ffb838; }
#btn-accedi:active { transform: translateY(1px); }
#btn-accedi:focus-visible { outline: 3px solid var(--carta); outline-offset: 2px; }
#btn-accedi:disabled { background: rgba(245, 165, 36, .45); cursor: progress; }

.tv-errore {
  margin: 0; padding: 11px 13px;
  border-left: 3px solid var(--segnale);
  background: rgba(245, 165, 36, .12);
  font-size: 13.5px; line-height: 1.45;
}

.tv-riservato {
  margin: 0; font-size: 12.5px; line-height: 1.5;
  color: rgba(238, 244, 249, .46);
}
.tv-riservato a, .tv-piede a { color: var(--quota-colore); }

/* ------------------------------------------------------------------- piede */

.tv-piede {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; justify-content: space-between;
  gap: 18px 40px;
  padding: 20px 44px 22px;
  border-top: 1px solid rgba(125, 211, 252, .18);
  background: rgba(2, 11, 20, .55);
  font-size: 13px;
}

.tv-piede-identita,
.tv-piede-tecnico { display: flex; flex-direction: column; gap: 3px; }
.tv-piede-tecnico { text-align: right; }

.tv-piede strong { font-weight: 600; font-size: 14px; color: var(--carta); }
.tv-piede span { color: var(--carta-tenue); }
.tv-cifre { font-family: "IBM Plex Mono", monospace; font-size: 13.5px; }

/* ---------------------------------------------------------------- telefono */

@media (max-width: 900px) {
  /* Non piu' una griglia ad altezza fissa: dentro un contenitore alto
     quanto lo schermo, le righe "auto" si comprimono invece di far
     scorrere, e il contenuto centrato trabocca sopra e sotto. In colonna
     ogni blocco prende l'altezza che gli serve e la pagina scorre. */
  .tavola { display: flex; flex-direction: column; }
  .tv-rilievo, .tv-pannello { justify-content: flex-start; flex: none; }
  .tv-rilievo { padding: 22px 20px 0; }
  .tv-pianta { height: auto; width: min(320px, 100%); max-height: 38vh; }
  .tv-pannello { border-left: 0; padding: 28px 22px 32px; }
  .tv-piede { padding: 18px 22px 22px; }
  .tv-piede-tecnico { text-align: left; }
}

/* Anche sul telefono piu' piccolo la strada resta: e' la cosa che dice
   cosa fa il prodotto. Si accorcia, non si toglie. */
@media (max-width: 420px) {
  .tv-rilievo { padding: 16px 14px 0; gap: 10px; }
  .tv-pianta { width: min(240px, 78%); max-height: 27vh; }
  .tv-didascalia { font-size: 12px; }
}

/* Chi ha chiesto meno movimento vede la tavola gia' composta e ferma. */
@media (prefers-reduced-motion: reduce) {
  .tv-bordo, .tv-mezzeria, .tv-manufatto, .tv-strisce rect, .tv-didascalia {
    animation: none; opacity: 1; stroke-dashoffset: 0;
  }
  .tv-passata { display: none; }
  .tv-sepolto circle { animation: none; }
}

/* --------------------------------------------- barra dopo l'accesso */

.azioni-barra { display: flex; align-items: center; gap: 12px; }
.bottone-piano {
  padding: 9px 14px; border: 1px solid var(--bordo); border-radius: 8px;
  background: #fff; font-size: 14px; cursor: pointer;
}
