/* Casa Curzolane: app per chi arriva a Roma (vent'anni, Erasmus, telefono in mano).
   Tasti grandi, schede che si sfogliano col pollice, barra in basso come un'app. */

:root {
  --bg: #f4efe7;
  --surface: #fffdf9;
  --surface-2: #ece5da;
  --ink: #17211f;
  --muted: #66706c;
  --brand: #12443d;
  --brand-ink: #f7f3ec;
  --accent: #e0603a;
  --accent-ink: #ffffff;
  --line: rgba(23, 33, 31, 0.09);
  --shadow: 0 1px 2px rgba(23, 33, 31, 0.05), 0 8px 24px -12px rgba(23, 33, 31, 0.18);
  --good: #2f8a57;
  --fair: #c8861d;
  --poor: #c2413b;
  --radius: 22px;
  --radius-s: 14px;
  --tabbar: 68px;
  /* compatibilità con l'area del proprietario */
  --card: var(--surface);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513;
    --surface: #17201d;
    --surface-2: #212c28;
    --ink: #eef2ef;
    --muted: #9aa8a2;
    --brand: #7cc4b4;
    --brand-ink: #0b1210;
    --accent: #ff7a52;
    --line: rgba(238, 242, 239, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px -14px rgba(0, 0, 0, 0.6);
  }
}

@view-transition { navigation: auto; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }
svg.i { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --- Testata ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
}
.topbar a, .topbar .brand { color: var(--ink); text-decoration: none; font-weight: 750; letter-spacing: -0.01em; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

.lang select {
  appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 7px 14px;
  width: auto;
  box-shadow: var(--shadow);
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 4px 16px calc(var(--tabbar) + 32px + env(safe-area-inset-bottom));
}
body:not(.tabs) .page { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }

/* --- Testi -------------------------------------------------------------- */

h1 { font-size: 2rem; line-height: 1.1; letter-spacing: -0.025em; margin: 8px 0 12px; font-weight: 800; }
h2 { font-size: 1.15rem; letter-spacing: -0.01em; margin: 28px 0 10px; font-weight: 750; }
h3 { font-size: 1rem; margin: 12px 0 4px; font-weight: 700; }
.hero { font-size: 2.3rem; margin: 6px 0 2px; }
.eyebrow { font-size: 0.78rem; font-weight: 750; letter-spacing: 0.09em; text-transform: uppercase; color: var(--accent); margin: 0; }
.lead { font-size: 1.1rem; color: var(--muted); }
.muted { color: var(--muted); }
.small, small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 28px 2px 10px; }
.section-title h2 { margin: 0; }
.section-title a { font-size: 0.9rem; font-weight: 650; text-decoration: none; }

/* --- Card --------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}
.card h2:first-child, .card h1:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 1rem; }
.card-head .i { color: var(--accent); }

.card.feature { background: var(--brand); color: var(--brand-ink); border: 0; }
.card.feature .muted, .card.feature small { color: color-mix(in srgb, var(--brand-ink) 72%, transparent); }

/* --- Schede da sfogliare (swipe) ---------------------------------------- */

.swipe {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 86%;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 16px;
  padding: 4px 16px 10px;
  margin: 0 -16px;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.swipe::-webkit-scrollbar { display: none; }
.swipe > * { scroll-snap-align: start; margin: 0; min-height: 100%; }
.swipe.narrow { grid-auto-columns: 72%; }
.dots { display: flex; justify-content: center; gap: 6px; margin: 2px 0 8px; }
.dots span { width: 6px; height: 6px; border-radius: 99px; background: var(--line); transition: width 0.25s, background 0.25s; }
.dots span.on { width: 18px; background: var(--accent); }

/* --- Tastoni ------------------------------------------------------------ */

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  min-height: 118px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  font-weight: 750;
  font-size: 1.02rem;
  line-height: 1.2;
  transition: transform 0.12s ease;
}
.tile:active, .row:active, .btn:active { transform: scale(0.97); }
.tile > span:first-child { font-size: 1.8rem; line-height: 1; }
.tile .ico {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--brand);
}
.tile.accent { background: var(--accent); color: var(--accent-ink); border: 0; }
.tile.accent .ico { background: rgba(255, 255, 255, 0.2); color: var(--accent-ink); }
.tile.dark { background: var(--brand); color: var(--brand-ink); border: 0; }
.tile.dark .ico { background: rgba(255, 255, 255, 0.12); color: var(--brand-ink); }
.page > .tile { margin: 16px 0; }
.tile.wide { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: center; justify-content: flex-start; gap: 14px; }

/* --- Elenchi a righe grandi --------------------------------------------- */

.list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card .list, .list.plain { background: none; border: 0; box-shadow: none; border-radius: 0; }
.list li { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li a { font-weight: 650; text-decoration: none; }
.list small { display: block; color: var(--muted); margin-top: 2px; }

.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 12px 16px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: transform 0.12s ease;
}
.rows li:last-child .row { border-bottom: 0; }
.row .emoji { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--surface-2); font-size: 1.3rem; flex: none; }
.row .body { flex: 1; min-width: 0; }
.row .body strong { display: block; font-weight: 650; }
.row .body small { display: block; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.row .chev { color: var(--muted); width: 20px; height: 20px; }

/* --- Etichette e tasti --------------------------------------------------- */

.pill { display: inline-block; font-size: 0.75rem; font-weight: 650; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); margin-left: 4px; vertical-align: middle; }
.pill.ok { background: var(--good); color: #fff; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  font: inherit;
  font-weight: 750;
  padding: 14px 22px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.dark { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.block { display: flex; width: 100%; margin: 16px 0; }
.btn.link { background: none; border: 0; box-shadow: none; color: var(--muted); text-decoration: underline; padding: 8px 0; min-height: 0; }

.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lang-btn { min-height: 60px; }

input, textarea, select { font: inherit; width: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface-2); color: var(--ink); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-weight: 700; margin: 10px 0 6px; }
.code { font-size: 1.6rem; letter-spacing: 0.16em; text-align: center; text-transform: uppercase; font-weight: 750; }
.error { color: var(--poor); font-weight: 650; }
.ok { border-color: var(--good); }

.back { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 6px; padding: 8px 14px 8px 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 650; font-size: 0.95rem; }
.photo { width: 100%; border-radius: var(--radius); margin: 8px 0; }

/* --- Guide passo per passo ---------------------------------------------- */

.steps { list-style: none; counter-reset: step; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: 16px 16px 16px 64px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 16px;
  top: 14px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

/* --- Meteo, aria, bus --------------------------------------------------- */

.big { font-size: 3.2rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1; margin: 4px 0 8px; }
.hours { display: flex; gap: 16px; overflow-x: auto; padding: 6px 0; scrollbar-width: none; }
.hours::-webkit-scrollbar { display: none; }
.hour { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 40px; font-weight: 650; }
.rain { color: var(--accent); }

.light { font-weight: 750; padding: 8px 14px; border-radius: 99px; color: #fff; display: inline-block; margin: 0 0 8px; }
.light.good { background: var(--good); }
.light.fair { background: var(--fair); }
.light.poor { background: var(--poor); }

.stop { padding: 12px 0; border-top: 1px solid var(--line); }
.stop:first-child { border-top: 0; padding-top: 0; }
.stop-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.stop-head strong { font-weight: 700; }
.stop-head small { color: var(--muted); white-space: nowrap; }
.departures { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.departures li { display: flex; align-items: center; gap: 10px; }
.line {
  display: inline-grid;
  place-items: center;
  min-width: 46px;
  height: 30px;
  padding: 0 8px;
  border-radius: 9px;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 800;
  font-size: 0.92rem;
}
.line.metro { color: #fff; border-radius: 50%; min-width: 30px; width: 30px; padding: 0; background: var(--accent); }
.line.metro.A { background: #e8432f; }
.line.metro.B, .line.metro.B1 { background: #1f62b4; }
.line.metro.C { background: #2fa04b; }
.line.tram { background: #8a5a2b; color: #fff; }
.departures .to { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.95rem; }
.departures .min { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.departures .min.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-right: 6px; vertical-align: middle; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

.event { display: flex; flex-direction: column; justify-content: space-between; gap: 14px; min-height: 150px; text-decoration: none; color: var(--ink); }
.event strong { font-size: 1.02rem; line-height: 1.3; font-weight: 700; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.event small { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.72rem; }

.skeleton { color: transparent; background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 10px; min-height: 22px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* --- Termostato ---------------------------------------------------------- */

.thermo { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0; }
.thermo-read { text-align: center; }
.thermo-read .big { margin: 0; }
.round { width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--ink); font-family: inherit; font-weight: 800; font-size: 1.8rem; line-height: 1; cursor: pointer; transition: transform 0.12s ease; }
.round:active { transform: scale(0.92); }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.chips .btn { min-height: 52px; padding: 10px; font-size: 0.92rem; }
.chips .btn:last-child { grid-column: 1 / -1; }
#heating[aria-busy="true"] button { opacity: 0.5; pointer-events: none; }

/* --- Barra in basso ----------------------------------------------------- */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 10;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(calc(100% - 20px), 520px);
  height: var(--tabbar);
  padding: 6px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(20px);
  backdrop-filter: saturate(1.6) blur(20px);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.35);
  view-transition-name: tabbar;
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.tabbar a[aria-current="page"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tabbar .i { width: 24px; height: 24px; }

@media (min-width: 700px) {
  .swipe { grid-auto-columns: 48%; }
  .swipe.narrow { grid-auto-columns: 40%; }
}

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