/* Tabata Timer: fondo scuro, un colore per fase, numeri enormi da leggere a due metri. */

@font-face {
  font-family: "Oswald";
  src: url("../fonts/oswald-latin.woff2") format("woff2");
  font-weight: 200 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Oswald";
  src: url("../fonts/oswald-latin-ext.woff2") format("woff2");
  font-weight: 200 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --fondo: #121212;
  --fondo-2: #1c1c1e;
  --fondo-3: #2a2a2d;
  --riga: #38383c;
  --testo: #f2f2f2;
  --grigio: #8e8e93;
  --inchiostro: #0d0d0d;
  --giallo: #f2e641;
  --verde: #7ed348;
  --rosso: #ef4a3c;
  --blu: #2b9be4;
  --blu-testo: #36a7f0;
  --font: "Oswald", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  background: #000;
  color: var(--testo);
  font-family: var(--font);
  font-weight: 500;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; text-transform: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .35; }
:focus-visible { outline: 2px solid var(--giallo); outline-offset: 2px; }
svg { display: block; }
.cifre { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- Guscio ---------- */

.app {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  background: var(--fondo);
  overflow: hidden;
}
main { min-height: 0; display: grid; }
.vista { min-height: 0; }

.testa {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  padding: max(8px, env(safe-area-inset-top)) 12px 6px;
}
.icona-testa { width: 44px; height: 44px; display: grid; place-items: center; color: var(--giallo); justify-self: start; }
.icona-testa:last-child { justify-self: end; }
.icona-testa svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icona-testa.tonda { background: var(--fondo-3); border-radius: 50%; }
.icona-testa.tonda svg { width: 24px; height: 24px; stroke-width: 2.2; }
.titolo { display: grid; justify-items: center; line-height: 1.1; color: var(--giallo); }
.titolo span:first-child { font-size: 17px; font-weight: 600; letter-spacing: .04em; }
#totale { font-size: 24px; font-weight: 600; }

/* ---------- Timer ---------- */

.timer {
  display: grid;
  grid-template-rows: auto minmax(0, 2.15fr) minmax(0, 1fr) auto;
  grid-template-areas: "testa" "fase" "prossima" "comandi";
}
.timer .testa { grid-area: testa; }
.timer .comandi { grid-area: comandi; }
.pannello { display: grid; align-content: center; justify-items: center; color: var(--inchiostro); background: var(--fondo-3); min-height: 0; overflow: hidden; transition: background-color .25s; }
.pannello[data-colore="giallo"] { background: var(--giallo); }
.pannello[data-colore="verde"] { background: var(--verde); }
.pannello[data-colore="rosso"] { background: var(--rosso); }
.pannello[data-colore="blu"] { background: var(--blu); }
.pannello[data-colore="fine"] { background: var(--fondo-3); color: var(--testo); }

.fase { grid-area: fase; gap: 0; padding: 4px 8px 0; }
.fase-nome { font-size: clamp(34px, min(12vw, 8.5vh), 84px); font-weight: 600; line-height: 1; letter-spacing: .01em; }
.fase-tempo { font-size: clamp(80px, min(33vw, 21vh), 230px); font-weight: 600; line-height: .95; letter-spacing: -.01em; }
.prossima { grid-area: prossima; padding: 4px 8px; }
.pross-nome { font-size: clamp(15px, min(4.6vw, 3vh), 26px); font-weight: 500; line-height: 1.1; }
.pross-tempo { font-size: clamp(40px, min(15vw, 9.5vh), 104px); font-weight: 600; line-height: 1; }

.comandi {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 8px;
  padding: 14px 10px 10px;
}
.conta { display: grid; justify-items: center; text-align: center; line-height: 1.05; }
.conta b { font-size: clamp(44px, min(13vw, 8vh), 76px); font-weight: 600; line-height: 1; }
.conta span { font-size: clamp(13px, 3.9vw, 18px); font-weight: 500; color: var(--testo); margin-top: 6px; }
.conta.blu b { color: var(--blu-testo); }
.conta.giallo b { color: var(--giallo); }

.avvia { display: grid; justify-items: center; gap: 6px; color: var(--giallo); font-size: 19px; font-weight: 600; letter-spacing: .03em; }
.anello {
  width: clamp(76px, 22vw, 104px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--giallo);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 7px var(--giallo), inset 0 0 0 9.5px var(--inchiostro);
  transition: transform .12s;
}
.avvia:active .anello { transform: scale(.95); }
.anello svg { width: 42%; height: 42%; fill: var(--inchiostro); grid-area: 1 / 1; }
.anello .pausa, .in-corso .anello .play { display: none; }
.in-corso .anello .pausa { display: block; }
.anello .play { transform: translateX(6%); }

/* ---------- Cronometro ---------- */

.crono { display: grid; grid-template-rows: auto minmax(0, 1.25fr) auto minmax(0, 1fr); }
.crono-pannello { background: var(--fondo-2); color: var(--testo); padding: 8px; }
.crono.in-corso .crono-pannello { background: var(--verde); color: var(--inchiostro); }
.crono-tempo { font-size: clamp(62px, min(21vw, 14vh), 150px); font-weight: 600; line-height: 1; }
.crono-giro { font-size: clamp(22px, 6vw, 36px); font-weight: 500; opacity: .75; min-height: 1.2em; }
.crono .comandi { align-items: center; }
.tasto-crono {
  justify-self: center;
  width: clamp(70px, 20vw, 96px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--fondo-3);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .03em;
}
.tasto-crono.vuoto { background: none; }
.giri { list-style: none; margin: 0; padding: 0 16px 12px; overflow-y: auto; min-height: 0; }
.giri li { display: grid; grid-template-columns: 1fr auto auto; gap: 18px; padding: 10px 4px; border-bottom: 1px solid var(--riga); font-size: 20px; }
.giri li span:first-child { color: var(--grigio); }
.giri li span:last-child { color: var(--grigio); }
.giri li.migliore span:nth-child(2) { color: var(--verde); }
.giri li.peggiore span:nth-child(2) { color: var(--rosso); }

/* ---------- Altro ed editor: elenchi ---------- */

.altro { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.scorre { overflow-y: auto; min-height: 0; padding-bottom: 24px; }
.sezione {
  margin: 18px 0 0;
  padding: 10px 16px;
  background: var(--fondo-3);
  color: #c7c7cc;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: .04em;
  text-align: center;
}
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li { border-bottom: 1px solid var(--riga); }
.riga {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 10px 14px 10px 16px;
  text-align: left;
  background: var(--fondo-2);
}
.punto { width: 16px; height: 16px; border-radius: 50%; background: var(--giallo); }
.punto.verde { background: var(--verde); }
.punto.rosso { background: var(--rosso); }
.punto.blu { background: var(--blu); }
.riga-testo { display: grid; justify-items: start; gap: 3px; min-width: 0; text-align: left; }
.riga-testo b { font-size: 21px; font-weight: 500; line-height: 1.1; }
.riga-testo small { font-size: 13.5px; color: #b9b9be; font-weight: 400; line-height: 1.2; }
.riga-valore { font-size: 34px; font-weight: 600; line-height: 1; }
.freccia { width: 14px; height: 14px; fill: none; stroke: var(--grigio); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.x { width: 40px; height: 40px; display: grid; place-items: center; color: var(--grigio); }
.x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.vuoto-lista { padding: 18px 16px; color: var(--grigio); font-size: 15px; text-transform: none; background: var(--fondo-2); }

.salva-come { display: grid; gap: 1px; background: var(--riga); }
.tasto-riga { width: 100%; padding: 16px; background: var(--fondo-2); color: var(--giallo); font-size: 17px; letter-spacing: .03em; text-align: left; }
.tasto-riga.piccolo { color: var(--grigio); font-size: 14px; text-align: center; }

.impostazioni label { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; padding: 14px 16px; background: var(--fondo-2); cursor: pointer; }
.impostazioni span { display: grid; gap: 3px; font-size: 20px; line-height: 1.1; }
.impostazioni small { font-size: 13.5px; color: #b9b9be; font-weight: 400; text-transform: none; }
.impostazioni input { position: absolute; opacity: 0; pointer-events: none; }
.impostazioni i { width: 52px; height: 32px; border-radius: 16px; background: var(--fondo-3); position: relative; transition: background .15s; }
.impostazioni i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #e5e5ea; transition: transform .15s; }
.impostazioni input:checked + i { background: var(--verde); }
.impostazioni input:checked + i::after { transform: translateX(20px); }
.impostazioni input:focus-visible + i { outline: 2px solid var(--giallo); outline-offset: 2px; }

.nota { margin: 12px 16px 0; color: var(--grigio); font-size: 14px; font-weight: 400; text-transform: none; line-height: 1.35; }
.nota.totale { text-align: center; font-size: 16px; text-transform: uppercase; font-weight: 500; }
.piede { margin: 28px 16px 0; color: var(--grigio); font-size: 13px; font-weight: 400; text-transform: none; text-align: center; }
.piede a { color: inherit; }

/* ---------- Schede in basso ---------- */

.schede {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 4px max(6px, env(safe-area-inset-bottom));
  background: var(--fondo-2);
  border-top: 1px solid var(--riga);
}
.schede button { display: grid; justify-items: center; gap: 3px; padding: 4px 0; color: var(--grigio); font-size: 11px; font-weight: 500; letter-spacing: .03em; }
.schede svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.schede [aria-current="page"] { color: var(--testo); }
.schede button.attivo-dietro::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--giallo); margin-top: -1px; }

/* ---------- Lampo al cambio di fase ---------- */

.lampo { position: fixed; inset: 0; z-index: 50; background: #fff; opacity: 0; pointer-events: none; }
.lampo.on { animation: lampo .32s ease-out; }
@keyframes lampo { 0% { opacity: .85; } 100% { opacity: 0; } }

/* ---------- Editor degli intervalli ---------- */

.editor { position: fixed; inset: 0; z-index: 20; display: grid; grid-template-rows: auto minmax(0, 1fr); max-width: 560px; margin: 0 auto; background: var(--fondo); }
.editor-testa { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: max(10px, env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--riga); }
.editor-testa h1 { margin: 0; font-size: 22px; font-weight: 600; }
.editor-annulla { justify-self: start; color: #c7c7cc; font-size: 20px; padding: 8px 0; }
.editor-salva { justify-self: end; color: var(--verde); font-size: 20px; font-weight: 600; padding: 8px 0; }
.campi .riga { grid-template-columns: auto 1fr auto auto; }

/* ---------- Rotelle ---------- */

.picker { position: fixed; inset: 0; z-index: 30; display: grid; align-items: end; background: rgba(0, 0, 0, .6); }
.picker-foglio { width: min(560px, 100%); margin: 0 auto; padding: 16px 16px max(16px, env(safe-area-inset-bottom)); background: var(--fondo-2); border-radius: 16px 16px 0 0; }
.picker-foglio h3, .nome-dlg h3 { margin: 0 0 8px; text-align: center; font-size: 20px; font-weight: 600; }
.ruote { position: relative; display: flex; justify-content: center; align-items: center; gap: 6px; }
.ruote::before {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  top: calc(50% - 12px);
  height: 52px;
  transform: translateY(-50%);
  border-top: 1px solid var(--riga);
  border-bottom: 1px solid var(--riga);
  background: rgba(255, 255, 255, .04);
  pointer-events: none;
}
.colonna { display: grid; justify-items: center; gap: 4px; }
.colonna small { font-size: 13px; color: var(--grigio); }
.ruota {
  height: 260px;
  width: 100px;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent);
  mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent);
  touch-action: pan-y;
}
.ruota::-webkit-scrollbar { display: none; }
.ruota ol { list-style: none; margin: 0; padding: 104px 0; }
.ruota li { height: 52px; display: grid; place-items: center; scroll-snap-align: center; font-size: 38px; font-weight: 500; font-variant-numeric: tabular-nums; }
.due-punti { font-size: 38px; font-weight: 600; margin-top: -24px; }
.picker-azioni { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.picker-azioni button { padding: 14px; border-radius: 10px; background: var(--fondo-3); font-size: 18px; font-weight: 600; }
.picker-azioni .ok { background: var(--giallo); color: var(--inchiostro); }

.picker-azioni.uno { grid-template-columns: 1fr; }
.installa-icona { display: block; width: 72px; height: 72px; margin: 6px auto 12px; }
.installa-testo { margin: 0 8px 4px; color: #c7c7cc; font-size: 17px; font-weight: 400; line-height: 1.4; text-align: center; text-transform: none; }

.nome-dlg { width: min(420px, calc(100vw - 32px)); padding: 18px; border: 0; border-radius: 14px; background: var(--fondo-2); color: var(--testo); }
.nome-dlg::backdrop { background: rgba(0, 0, 0, .6); }
.nome-dlg input { width: 100%; padding: 12px; border: 1px solid var(--riga); border-radius: 10px; background: var(--fondo); color: var(--testo); font: 500 20px var(--font); }

/* ---------- Telefono in orizzontale ---------- */

@media (orientation: landscape) and (max-height: 560px) {
  .app { max-width: none; grid-template-rows: minmax(0, 1fr) auto; }
  .timer {
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 2fr) minmax(0, 1fr);
    grid-template-areas: "testa testa" "fase comandi" "prossima comandi";
  }
  .fase-tempo { font-size: min(30vh, 17vw); }
  .fase-nome { font-size: min(11vh, 7vw); }
  .pross-tempo { font-size: min(13vh, 8vw); }
  .timer .comandi { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; align-content: center; align-items: center; }
  .timer .comandi .avvia { grid-column: 1 / -1; grid-row: 1; }
  .schede { padding-top: 2px; padding-bottom: 2px; }
  .schede svg { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .lampo.on { animation-duration: .01s; }
  .pannello { transition: none; }
}
