/*
  Che mi metto oggi?
  Un solo tema (scuro, sopra il video), un solo accento (l'arancio del sole del logo).
  Raggi: controlli a pillola, pannelli 20px, caselle delle ore 14px.
*/

:root {
  --bg: #0f141c;
  --text: #f4f6f9;
  --text-2: rgba(244, 246, 249, .8);
  --text-3: rgba(244, 246, 249, .62);
  --panel: rgba(13, 18, 26, .58);
  --panel-strong: rgba(13, 18, 26, .8);
  --line: rgba(255, 255, 255, .14);
  --line-strong: rgba(255, 255, 255, .3);
  --accent: #f5a524;
  --rain: #9fd0ff;
  --radius-panel: 20px;
  --radius-tile: 14px;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* Niente ritardo/zoom da doppio tocco sui controlli */
button, input { touch-action: manipulation; font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a { color: inherit; text-underline-offset: 2px; }

/* ---------- Sfondo video ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--bg);
}

.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.bg.on { opacity: 1; }

/* Velatura uniforme: il testo resta leggibile anche sui video di giorno più chiari */
.scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(10, 14, 20, .62) 0%, rgba(10, 14, 20, .46) 38%, rgba(10, 14, 20, .72) 100%);
}

/* ---------- Struttura ---------- */

.app {
  width: min(640px, 100%);
  margin-inline: auto;
  padding-inline: max(20px, env(safe-area-inset-left)) max(20px, env(safe-area-inset-right));
}

/* Prima ricerca: tutto al centro, solo logo e campo */
.search {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  padding-block: 40px;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.logo { width: 76px; height: 76px; color: var(--text); }

.brand h1 {
  margin: 0;
  font-size: clamp(1.9rem, 6.5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

/* Con un risultato: intestazione compatta in riga */
body.has-result .search {
  min-height: 0;
  gap: 14px;
  padding-block: calc(16px + env(safe-area-inset-top)) 0;
}

body.has-result .brand { flex-direction: row; align-items: center; gap: 8px; }
body.has-result .logo { width: 30px; height: 30px; }
body.has-result .brand h1 { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; }

/* ---------- Campo località ---------- */

.field { position: relative; display: grid; gap: 8px; }

.field-label { font-size: .95rem; font-weight: 500; color: var(--text-2); padding-left: 4px; }

body.has-result .field-label {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.field-box {
  position: relative;
  display: flex;
  align-items: center;
}

.field-box > .ph {
  position: absolute;
  z-index: 1;
  left: 20px;
  font-size: 1.25rem;
  color: var(--text-3);
  pointer-events: none;
}

.field input {
  width: 100%;
  height: 56px;
  padding: 0 60px 0 50px;
  font-size: 1.06rem;
  font-weight: 500;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  transition: border-color .2s, background .2s;
}

.field input::placeholder { color: var(--text-3); font-weight: 400; }

.field input:focus { border-color: var(--line-strong); background: var(--panel-strong); }

.locate {
  position: absolute;
  right: 6px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-size: 1.3rem;
  transition: background .2s, color .2s;
}

.locate:active { transform: scale(.94); }

.suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: rgba(16, 21, 30, .96);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: 0 24px 48px -24px rgba(4, 8, 14, .8);
}

.suggestions li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
}

.suggestions li span { font-weight: 600; }
.suggestions li small { color: var(--text-3); text-align: right; font-size: .85rem; }
.suggestions li[aria-selected="true"] { background: rgba(255, 255, 255, .1); }

.status {
  min-height: 1.4em;
  margin: 0;
  padding-left: 4px;
  color: var(--text-2);
  font-size: .95rem;
}

.status:empty { display: none; }

/* ---------- Consiglio ---------- */

.result { padding: 20px 0 48px; }

.verdict { text-wrap: pretty; }

.when {
  margin: 0 0 6px;
  font-size: .98rem;
  font-weight: 600;
  color: var(--accent);
}

.headline {
  margin: 0;
  font-size: clamp(2.5rem, 9.5vw, 3.7rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.02;
  text-wrap: balance;
}

.summary {
  margin: 12px 0 0;
  font-size: 1.22rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.advice {
  margin: 8px 0 0;
  max-width: 38ch;
  font-size: 1.04rem;
  line-height: 1.55;
  color: var(--text-2);
}

/* Il confronto con ieri si distingue dal consiglio senza cambiare colore */
.advice strong { color: var(--text); font-weight: 600; }

/* Condividi: solo un cerchio con l'icona, a destra del titolo (compare con il risultato) */
.share {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  margin-left: auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  font-size: 1.2rem;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  transition: background .2s, transform .15s var(--ease);
}

body:not(.has-result) .share { display: none; }
.share:active { transform: scale(.94); }

/* Avviso a scomparsa (pioggia in arrivo, testo copiato) */
.toast {
  position: fixed;
  z-index: 30;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  width: min(440px, calc(100% - 24px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px 12px 16px;
  background: rgba(16, 21, 30, .94);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 18px 40px -18px rgba(4, 8, 14, .9);
  transform: translate(-50%, -140%);
  opacity: 0;
  transition: transform .35s var(--ease), opacity .35s var(--ease);
}

.toast.show { transform: translate(-50%, 0); opacity: 1; }

.toast > .ph { font-size: 1.4rem; color: var(--accent); flex: 0 0 auto; }

.toast span { flex: 1; font-size: .98rem; font-weight: 500; line-height: 1.35; }

.toast button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font-size: 1.1rem;
}

.headline, .summary, .when, .advice {
  text-shadow: 0 1px 2px rgba(4, 8, 14, .35), 0 0 28px rgba(4, 8, 14, .3);
}

/* Note utili: un solo pannello, niente riquadri separati */
.notes {
  list-style: none;
  margin: 22px 0 0;
  padding: 6px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.notes:empty { display: none; }

.notes li {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  padding: 12px 0;
  line-height: 1.45;
}

.notes li + li { border-top: 1px solid var(--line); }

.notes .ph { font-size: 1.3rem; color: var(--accent); margin-top: 1px; }

/* ---------- Quando esci: giorni, ore, durata ---------- */

.planner {
  display: grid;
  gap: 10px;
}

.verdict { margin-top: 26px; }

.days,
.hours,
.place-chips {
  position: relative; /* offsetLeft delle celle misurato rispetto alla striscia */
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  -webkit-mask-image: linear-gradient(90deg, #000 90%, transparent);
  mask-image: linear-gradient(90deg, #000 90%, transparent);
}

.days::-webkit-scrollbar,
.hours::-webkit-scrollbar,
.place-chips::-webkit-scrollbar { display: none; }

/* ---------- Località salvate ---------- */

.place-chips button { display: inline-flex; align-items: center; gap: 5px; }
.place-chips button .ph { font-size: 1rem; }

.place-chips button.edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}

.places-edit {
  padding: 14px 16px 16px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
}

.places-edit .hint { margin: 0 0 10px; font-size: .9rem; color: var(--text-2); }

.places-edit ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.places-edit li { display: flex; align-items: center; gap: 8px; }

.places-edit .name { flex: 1; min-width: 0; display: grid; gap: 3px; }

.places-edit input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  font-size: 1rem;
  font-weight: 600;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}

.places-edit input:focus { border-color: var(--accent); }

.places-edit small {
  padding-left: 2px;
  font-size: .8rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.places-edit .remove {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
  font-size: 1.2rem;
  align-self: flex-start;
}

.places-edit .done {
  margin-top: 14px;
  min-height: 40px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
}

.days button,
.durations button,
.place-chips button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: .9rem;
  font-weight: 500;
  transition: background .2s, color .2s, border-color .2s, transform .15s var(--ease);
}

.days button[aria-pressed="true"],
.durations button[aria-pressed="true"],
.place-chips button[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  font-weight: 600;
}

.days button:active,
.durations button:active,
.place-chips button:active { transform: scale(.96); }

.durations {
  display: flex;
  align-items: center;
  gap: 6px;
}

.durations span { color: var(--text-2); font-size: .9rem; margin-right: 4px; }

.hour {
  flex: 0 0 auto;
  min-width: 60px;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 6px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-tile);
  font-variant-numeric: tabular-nums;
  scroll-snap-align: start;
  transition: background .2s, border-color .2s, transform .15s var(--ease);
}

.hour:active { transform: scale(.95); }

/* Ore comprese nell'uscita scelta; la prima è l'ora di partenza */
.hour.in { background: rgba(255, 255, 255, .17); border-color: var(--line-strong); }
.hour.start { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.hour.newday:not(:first-child) { margin-left: 10px; }

.hour .d { font-size: .72rem; font-weight: 600; color: var(--text-2); min-height: 1.2em; }
.hour .h { font-size: .82rem; color: var(--text-2); }
.hour .i { font-size: 1.4rem; line-height: 1.3; }
.hour .t { font-size: 1rem; font-weight: 600; }
.hour .p { font-size: .74rem; font-weight: 500; color: var(--rain); min-height: 1.2em; }

/* ---------- Il tempo: quattro numeri con icona ---------- */

.wx {
  list-style: none;
  margin: 28px 0 0;
  padding: 16px 6px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.wx li { display: grid; justify-items: center; gap: 2px; padding: 0 4px; text-align: center; }
.wx li + li { border-left: 1px solid var(--line); }
.wx .ph-duotone { font-size: 1.7rem; color: var(--accent); }
.wx strong { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.wx span { font-size: .8rem; color: var(--text-2); line-height: 1.25; }

.credits {
  margin: 24px 0 0;
  font-size: .82rem;
  color: var(--text-3);
}

/* ---------- Dispositivi con mouse ---------- */

@media (hover: hover) {
  .locate:hover { background: rgba(255, 255, 255, .1); color: var(--text); }
  .share:hover { background: var(--panel-strong); }
  .hour:hover { border-color: var(--line-strong); }
  .days button:hover,
  .durations button:hover,
  .place-chips button:hover { border-color: var(--line-strong); }
  .place-chips button.edit:hover { color: var(--text); border-color: transparent; }
  .places-edit .remove:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
}

/* ---------- Telefono ---------- */

@media (max-width: 640px) {
  .result { padding-top: 16px; }

  /* Le strisce di giorni e ore scorrono da bordo a bordo dello schermo */
  .days, .hours, .place-chips {
    margin-inline: -20px;
    padding-inline: 20px;
    scroll-padding-inline: 20px;
  }

  .days button, .place-chips button { min-height: 34px; padding: 0 12px; font-size: .86rem; }
  .durations button { min-height: 32px; padding: 0 12px; font-size: .84rem; }
  .durations span { font-size: .84rem; }

  .hour { min-width: 56px; padding: 6px 4px 8px; }
  .hour .i { font-size: 1.25rem; }
  .hour .t { font-size: .95rem; }

  .verdict { margin-top: 22px; }
  .notes { margin-top: 18px; padding: 4px 16px; }
  .wx { margin-top: 18px; grid-template-columns: repeat(2, 1fr); row-gap: 16px; }
  .wx li:nth-child(3) { border-left: 0; }
}

/* ---------- Accessibilità ---------- */

@media (prefers-reduced-transparency: reduce) {
  .field input, .notes, .wx, .hour, .days button, .durations button {
    background: var(--panel-strong);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

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