/* The bento grid that assembles on scroll. Colours in :root (the Playground palette). */
:root {
  --fondo: #fafafa;
  --tessera: #ffffff;
  --inchiostro: #0b0b0f;
  --secondario: #71717a;
  --bordo: rgba(10, 10, 20, 0.08);
  --accento: #4f46e5;
  --accento-tenue: #eef0ff;
  --verde: #16a34a;
  --ombra: 0 1px 2px rgba(10, 10, 20, 0.04), 0 12px 32px -12px rgba(10, 10, 20, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--fondo); }
body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.corsa { position: relative; height: 340vh; }
.palco {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3vh, 28px);
  padding: clamp(12px, 4vh, 40px) clamp(14px, 4vw, 48px);
  overflow: hidden;
}

.testa { text-align: center; }
.testa__nota {
  font-size: clamp(11px, 1.6vh, 13px);
  font-weight: 500;
  color: var(--accento);
  margin-bottom: 6px;
}
.testa__titolo {
  font-size: clamp(18px, min(4.2vw, 5.4vh), 40px);
  font-weight: 640;
  font-stretch: 105%;
  letter-spacing: -0.025em;
  line-height: 1.05;
}
.testa__titolo span { color: var(--secondario); }

.bento {
  position: relative;
  width: min(100%, 960px, calc((100vh - 140px) * 1.75));
  flex: 0 1 auto;
  height: min(calc(100vh - 150px), 520px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  grid-template-areas:
    'a a b c'
    'a a d d'
    'e e f f';
  gap: clamp(8px, 1.4vh, 14px);
}

.tessera {
  position: relative;
  min-width: 0;
  min-height: 0;
  will-change: transform, opacity;
}
.tessera__dentro {
  height: 100%;
  background: var(--tessera);
  border: 1px solid var(--bordo);
  border-radius: clamp(12px, 2vh, 20px);
  box-shadow: var(--ombra);
  padding: clamp(10px, 2vh, 18px);
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1vh, 10px);
  overflow: hidden;
  transform-origin: 50% 60%;
}
.tessera--grafico { grid-area: a; }
.tessera--persone { grid-area: b; }
.tessera--interruttore { grid-area: c; }
.tessera--numero { grid-area: d; }
.tessera--ricerca { grid-area: e; }
.tessera--mappa { grid-area: f; }

.riga { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.riga--alto { align-items: flex-end; height: 100%; }
.etichetta { font-size: clamp(10px, 1.5vh, 13px); font-weight: 500; color: var(--secondario); }
.nota { font-size: clamp(10px, 1.45vh, 12.5px); color: var(--secondario); }
.nota--destra { font-variant-numeric: tabular-nums; }
.cifra { font-variant-numeric: tabular-nums; font-weight: 620; letter-spacing: -0.02em; }
.cifra--grande { font-size: clamp(18px, 4vh, 34px); line-height: 1; }
.cifra--media { font-size: clamp(18px, 3.6vh, 30px); line-height: 1.1; display: flex; }

.variazione {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: clamp(10px, 1.45vh, 12px); font-weight: 600;
  color: var(--verde);
  background: #ecfdf3; border-radius: 999px; padding: 2px 7px 2px 5px;
}
.variazione svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* chart */
.grafico { position: relative; flex: 1; min-height: 0; }
.grafico svg { width: 100%; height: 100%; display: block; overflow: visible; }
.griglia-linee path { stroke: var(--bordo); stroke-width: 1; vector-effect: non-scaling-stroke; fill: none; }
.area { fill: url(#area); }
.linea { fill: none; stroke: var(--accento); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.cursore { stroke: var(--inchiostro); stroke-opacity: 0.18; stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; opacity: 0; }
.suggerimento {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column; gap: 1px;
  background: var(--inchiostro); color: #fff;
  font-size: clamp(10px, 1.45vh, 12px); font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 5px 8px; border-radius: 8px;
  box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.35);
  opacity: 0; pointer-events: none; white-space: nowrap;
}
.suggerimento__data { font-weight: 450; opacity: 0.6; }

/* people */
.volti { display: flex; align-items: center; flex: 1; }
.volto {
  width: clamp(24px, 4.6vh, 36px); height: clamp(24px, 4.6vh, 36px);
  border-radius: 50%;
  background: var(--c);
  border: 2px solid var(--tessera);
  display: grid; place-items: center;
  font-size: clamp(8px, 1.3vh, 11px); font-weight: 650; color: #3f3f46;
  margin-left: calc(clamp(24px, 4.6vh, 36px) * -0.28);
}
.volto:first-child { margin-left: 0; }
.volto--altri { background: var(--inchiostro); color: #fff; }

/* switch */
.tessera--interruttore .tessera__dentro { justify-content: space-between; }
.interruttore {
  position: relative; flex: none;
  width: clamp(34px, 6vh, 44px); height: clamp(20px, 3.5vh, 26px);
  border: 0; border-radius: 999px; background: #e4e4e7; cursor: pointer;
  transition: box-shadow 0.2s;
}
.interruttore:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }
.interruttore__pomello {
  position: absolute; top: 2px; left: 2px;
  width: calc(clamp(20px, 3.5vh, 26px) - 4px); height: calc(clamp(20px, 3.5vh, 26px) - 4px);
  border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* uptime */
.colonna { display: inline-block; height: 1.1em; overflow: hidden; }
.colonna__nastro { display: flex; flex-direction: column; }
.colonna__nastro span { height: 1.1em; line-height: 1.1em; }
.barre { display: flex; align-items: flex-end; gap: 2px; height: clamp(24px, 8vh, 72px); flex: 0 1 56%; min-width: 0; }
.barra { flex: 1; min-width: 2px; height: 100%; background: var(--accento); border-radius: 2px; transform-origin: 50% 100%; opacity: 0.85; }
.barra--giu { background: #f59e0b; }

/* search */
.campo {
  display: flex; align-items: center; gap: 8px;
  height: clamp(28px, 5vh, 40px);
  padding: 0 10px;
  border: 1px solid var(--bordo); border-radius: 10px;
  background: var(--fondo);
  font-size: clamp(11px, 1.7vh, 14px);
}
.campo > svg { width: 15px; height: 15px; fill: none; stroke: var(--secondario); stroke-width: 1.6; stroke-linecap: round; flex: none; }
.campo__testo { white-space: nowrap; overflow: hidden; }
.campo__cursore { width: 1.5px; height: 1.1em; background: var(--accento); margin-left: 1px; }
.campo kbd {
  margin-left: auto; flex: none;
  display: inline-flex; align-items: center; gap: 2px;
  font: inherit; font-size: 0.78em; color: var(--secondario);
  border: 1px solid var(--bordo); border-radius: 6px; padding: 1px 5px; background: #fff;
}
.campo kbd svg { width: 0.9em; height: 0.9em; fill: none; stroke: currentColor; stroke-width: 1.3; }
.risultati { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.risultati li {
  display: flex; align-items: center; gap: 8px;
  font-size: clamp(10px, 1.5vh, 13px);
  padding: clamp(3px, 0.7vh, 6px) 6px; border-radius: 8px;
  opacity: 0;
}
.risultati li:first-child { background: var(--accento-tenue); }
.risultati__icona svg { width: 14px; height: 14px; fill: none; stroke: var(--accento); stroke-width: 1.3; stroke-linejoin: round; display: block; }
.risultati__nota { margin-left: auto; color: var(--secondario); font-size: 0.9em; }

/* map */
.mappa { flex: 1; min-height: 0; width: 100%; display: block; }
.mappa__fondo rect { fill: #e4e4e7; }
.rotta { fill: none; stroke: var(--accento); stroke-width: 1.6; stroke-linecap: round; }
.nodo { fill: var(--tessera); stroke: var(--accento); stroke-width: 1.6; }

.piede { padding: 5vh 24px; text-align: center; color: var(--secondario); font-size: 14px; }

@media (hover: hover) {
  .tessera__dentro { transition: box-shadow 0.35s, border-color 0.35s; }
  .tessera:hover .tessera__dentro { border-color: rgba(79, 70, 229, 0.22); box-shadow: 0 1px 2px rgba(10, 10, 20, 0.05), 0 18px 40px -14px rgba(79, 70, 229, 0.25); }
}

/* phone: two columns, still inside the box */
@media (max-width: 640px) {
  .palco { gap: 10px; padding: 12px 14px; }
  .testa__nota { margin-bottom: 3px; }
  .bento {
    width: 100%;
    height: min(calc(100vh - 92px), 560px);
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1.45fr 1.05fr 0.95fr 1.25fr;
    grid-template-areas:
      'a a'
      'b c'
      'd d'
      'e f';
    gap: 8px;
  }
  .tessera__dentro { padding: 8px 10px; gap: 3px; border-radius: 12px; }
  .cifra--grande { font-size: 19px; }
  .volto { width: 22px; height: 22px; margin-left: -6px; font-size: 8px; }
  .volti { flex: 0 0 auto; margin: 2px 0; }
  .tessera--persone .tessera__dentro { justify-content: space-between; }
  .tessera--persone .etichetta { display: none; }
  .suggerimento, .cursore { display: none; }
  .campo { font-size: 11px; padding: 0 8px; gap: 6px; height: 28px; }
  .risultati li:nth-child(2) { display: none; }
  .campo kbd { display: none; }
  .tessera--ricerca .risultati__nota { display: none; }
}
