/* =========================================================================
   Počasí Strakonice — style.css
   Vzhled: "Home Assistant / Mushroom" dashboard, dark-first.
   Veškeré barvy a rozměry jsou v CSS proměnných níže — stačí měnit :root.
   ========================================================================= */

:root {
  /* --- Plochy --- */
  --bg: #121212;
  --bg-elevated: #1e1e1e;
  --bg-elevated-2: #262626;
  --bg-inset: #171717;
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .14);

  /* --- Text --- */
  --text: #f2f4f7;
  --text-dim: #a8b0bb;
  --text-faint: rgba(255, 255, 255, .38);

  /* --- Akcenty --- */
  --accent: #4fc3f7;
  --accent-soft: rgba(79, 195, 247, .16);
  --up: #4caf50;          /* tendence: rust */
  --down: #ef5350;        /* tendence: pokles */
  --steady: #e0e0e0;      /* tendence: stala hodnota */
  --warn: #ffb300;
  --danger: #e53935;

  /* --- SPA (stupne povodnove aktivity) --- */
  --spa-0: #2e7d32;       /* bez ohrozeni */
  --spa-1: #cddc39;       /* 1. SPA bdelost */
  --spa-2: #ff9800;       /* 2. SPA pohotovost */
  --spa-3: #e53935;       /* 3. SPA ohrozeni */
  --spa-x: #7b1fa2;       /* extremni povoden */

  /* --- Geometrie --- */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --gap: 12px;
  --pad: 16px;
  --nav-h: 64px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .45);

  /* --- Typografie --- */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior-y: none;
}

body {
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  /* Jemna atmosfericka zare nahore, aby dashboard nepusobil ploche */
  background-image: radial-gradient(120% 60% at 50% -10%, rgba(79, 195, 247, .10), transparent 60%);
  background-attachment: fixed;
}

svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.filled { fill: currentColor; stroke: none; }

/* ============================ HLAVICKA ============================ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-t) + 14px) var(--pad) 6px;
}
.app-header h1 {
  margin: 0;
  font-size: clamp(19px, 5.2vw, 26px);
  font-weight: 700;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header__sub { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }
.app-header__side { display: flex; gap: 8px; flex: none; }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  padding: 9px;
}
.icon-btn:active { background: var(--bg-elevated-2); transform: scale(.94); }
.icon-btn.is-spinning svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ STAVOVY PRUH ============================ */
.status-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 2px var(--pad) 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.status-bar__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.status-bar[data-state="live"] .status-bar__dot { background: var(--up); box-shadow: 0 0 8px var(--up); }
.status-bar[data-state="stale"] .status-bar__dot { background: var(--warn); }
.status-bar[data-state="offline"] .status-bar__dot { background: var(--down); }

/* ============================ LAYOUT ============================ */
main { padding: 0 var(--pad); max-width: 720px; margin: 0 auto; }
.view { display: flex; flex-direction: column; gap: var(--gap); animation: fade .22s ease; }
.view[hidden] { display: none; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
@media (max-width: 340px) { .grid-2 { grid-template-columns: 1fr; } }

/* ============================ KARTA ============================ */
.card {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
  box-shadow: var(--shadow);
  overflow: hidden;      /* chrani pred pretekanim obrich fontu a pozadovych sipek */
  min-width: 0;
}
.card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 10px;
}
.card__title {
  font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card__value {
  font-size: clamp(26px, 8vw, 40px); font-weight: 700; letter-spacing: -.02em;
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.card__unit { font-size: .5em; font-weight: 600; color: var(--text-dim); margin-left: 3px; }
.card__note { font-size: 12px; color: var(--text-dim); margin-top: 4px; min-height: 1em; }

/* Paticka zdroju dat — spolecna pro kazdy tab (scrolluje s obsahem) */
.tab-sources {
  text-align: center;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-faint);
  padding: 18px 4px 8px;
  margin-top: 4px;
}
.tab-sources a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.tab-sources a:active { color: var(--text-dim); }

/* Uzke shrnuti zdravi / ovzdusi mezi hero a senzory */
.health-summary {
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-dim);
}
.health-summary strong { color: var(--text); font-weight: 600; }

/* Obri jemna sipka tendence na pozadi dlazdice */
.tile { position: relative; }
.tile__arrow {
  position: absolute;
  right: -14px; bottom: -22px;
  width: 108px; height: 108px;
  opacity: .13;
  pointer-events: none;
  z-index: 0;
}
.tile__arrow svg { stroke-width: 2.2; }
.tile > *:not(.tile__arrow) { position: relative; z-index: 1; }
.trend-up { color: var(--up); }
.trend-down { color: var(--down); }
.trend-steady { color: var(--steady); }

/* ============================ CHIPY / ODZNAKY ============================ */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis;
}
.chip svg, .chip .ico { width: 16px; height: 16px; flex: none; }
.chip strong { color: var(--text); font-weight: 600; }
.chip--bio { border-color: currentColor; }
.chip--uv { border-color: rgba(255, 202, 40, .35); color: #ffca28; }
.chip--aqi { border-color: rgba(129, 199, 132, .35); color: #81c784; }
.bio-1 { color: #66bb6a; } .bio-2 { color: #d4e157; }
.bio-3 { color: #ffb300; } .bio-4 { color: #ff7043; }

/* ============================ VYSTRAHA CHMU ============================ */
.alert {
  display: flex; gap: 12px; align-items: center;
  border-radius: var(--radius);
  padding: 12px 14px 16px;
  position: relative;
  border: 1px solid transparent;
  background: linear-gradient(135deg, rgba(229, 57, 53, .22), rgba(229, 57, 53, .07));
  border-color: rgba(229, 57, 53, .45);
  overflow: hidden;
}
.alert--yellow { background: linear-gradient(135deg, rgba(255, 193, 7, .2), rgba(255, 193, 7, .06)); border-color: rgba(255, 193, 7, .45); }
.alert--orange { background: linear-gradient(135deg, rgba(255, 112, 67, .22), rgba(255, 112, 67, .07)); border-color: rgba(255, 112, 67, .5); }
.alert__icon { width: 26px; height: 26px; flex: none; color: var(--warn); }
.alert--red .alert__icon { color: var(--danger); }
.alert__body { min-width: 0; flex: 1; }
.alert__title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
/* Text vystrahy se nezkracuje — je vodorovne posuvny bez viditelneho scrollbaru */
.alert__text {
  font-size: 13px; color: var(--text);
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.alert__text::-webkit-scrollbar { display: none; }
.alert__meta { font-size: 11px; color: var(--text-dim); margin-top: 3px; }

/* ============================ HERO ============================ */
.hero { display: flex; align-items: center; gap: 14px; }
.hero__left { min-width: 0; flex: 1; }
.hero__temp {
  font-size: clamp(58px, 21vw, 108px);
  font-weight: 200;
  line-height: .95;
  letter-spacing: -.045em;
  display: flex; align-items: flex-start;
  white-space: nowrap;
}
.hero__temp sup { font-size: .32em; font-weight: 400; margin-top: .28em; }
.hero__cond { font-size: 15px; color: var(--text); margin-top: 6px; }
.hero__feels { font-size: 13px; color: var(--text-dim); }
.hero__icon { width: clamp(72px, 26vw, 116px); height: clamp(72px, 26vw, 116px); flex: none; }
.hero__extra { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--text-dim); }
.hero__extra b { color: var(--text); font-weight: 600; }

/* ============================ VNORENE TABY (pilulky) ============================ */
.subtabs {
  display: flex; gap: 6px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.subtabs::-webkit-scrollbar { display: none; }
.subtabs__btn {
  flex: 1 0 auto;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
}
.subtabs__btn.is-active { background: var(--accent-soft); color: var(--accent); }
.subpanel[hidden] { display: none; }

/* Filtracni pilulky (modely, vrstvy) */
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-dim);
  font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.pill__dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.pill.is-on { color: var(--text); border-color: currentColor; background: rgba(255, 255, 255, .06); }
.pill.is-off { opacity: .5; }
.pill:disabled { opacity: .3; cursor: not-allowed; }

/* Checkbox filtr modelu predpovedi */
.checkbox-filter {
  display: flex; gap: 10px 14px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.checkbox-filter__item {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600;
  color: var(--model-color, var(--text));
  cursor: pointer;
  user-select: none;
}
.checkbox-filter__item.is-off { opacity: .45; }
.checkbox-filter__item input {
  width: 15px; height: 15px; margin: 0; accent-color: var(--model-color, var(--accent));
  cursor: pointer;
}
.checkbox-filter__item input:disabled { cursor: not-allowed; opacity: .35; }
.checkbox-filter__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--model-color, var(--accent)); flex: none;
}

/* ============================ CAROUSEL 24h ============================ */
.scroller {
  display: flex; gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--pad));
  padding: 2px var(--pad) 10px;
}
.scroller::-webkit-scrollbar { display: none; }
.hour {
  flex: none;
  width: 62px;
  scroll-snap-align: start;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 9px 4px;
  text-align: center;
}
.hour--now { border-color: var(--accent); background: var(--accent-soft); }
.hour__time { font-size: 11.5px; color: var(--text-dim); }
.hour__icon { width: 30px; height: 30px; margin: 5px auto 3px; }
.hour__temp { font-size: 15px; font-weight: 700; }
.hour__rain { font-size: 10.5px; color: var(--accent); min-height: 1em; }

/* ============================ RADAR ============================ */
.radar { padding: 0; }
.radar__img {
  display: block; width: 100%; height: auto;
  background: #0b1218;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  cursor: zoom-in;
}
.radar__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px var(--pad) 16px;
}

/* ============================ TABULKY ============================ */
.table-wrap { overflow-x: auto; scrollbar-width: thin; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 7px 6px; text-align: right; white-space: nowrap; }
table.data th { color: var(--text-dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
table.data td:first-child, table.data th:first-child { text-align: left; position: sticky; left: 0; background: var(--bg-elevated); }
table.data tbody tr { border-top: 1px solid var(--border); }
table.data tr.is-daybreak { border-top: 1px solid var(--border-strong); }
.t-hot { color: #ff8a65; } .t-cold { color: #4fc3f7; }
.cell-icon { width: 22px; height: 22px; display: inline-block; vertical-align: -5px; }

/* Dlouhodoba predpoved — striktni CSS Grid (ikona + teplota pod sebou) */
.forecast-grid-wrap { overflow-x: auto; scrollbar-width: thin; margin: 0 -4px; }
.forecast-grid { display: flex; flex-direction: column; gap: 0; min-width: min(100%, 520px); }
.forecast-grid__row {
  display: grid;
  align-items: center;
  gap: 0;
  font-size: 13px;
}
.forecast-grid__row--head {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.forecast-grid__row:not(.forecast-grid__row--head) {
  border-top: 1px solid var(--border);
  padding: 7px 0;
}
.forecast-grid__row.is-daybreak { border-top-color: var(--border-strong); }
.forecast-grid__cell { padding: 0 6px; text-align: right; white-space: nowrap; }
.forecast-grid__cell--day,
.forecast-grid__cell--time { text-align: left; }
.forecast-grid__cell--model {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; text-align: center; min-width: 56px;
}
.forecast-grid__cell--model .cell-icon { width: 24px; height: 24px; }
.forecast-grid__temp { font-weight: 700; font-variant-numeric: tabular-nums; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* ============================ GRAFY ============================ */
.chart-box { position: relative; width: 100%; height: 300px; }
.chart-box--sm { height: 210px; }
.chart-hint { font-size: 11px; color: var(--text-faint); margin-top: 6px; }
.sparkline-wrap { position: relative; margin-top: 8px; }
.sparkline { display: block; width: 100%; height: 42px; }
.sparkline-hit { pointer-events: all; }
.sparkline-tip {
  position: absolute;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(30, 30, 30, .96);
  border: 1px solid rgba(255, 255, 255, .12);
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}

/* ============================ SPA LEGENDA ============================ */
.spa-legend { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 10px; font-size: 11.5px; color: var(--text-dim); }
.spa-legend span { display: inline-flex; align-items: center; gap: 5px; }
.spa-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.spa-badge {
  display: inline-block; padding: 3px 9px; border-radius: var(--radius-pill);
  font-size: 11.5px; font-weight: 700; color: #fff;
}

/* ============================ SLUNCE / MESIC ============================ */
.sun-arc { display: block; width: 100%; height: auto; }
.moon-wrap { display: flex; gap: 16px; align-items: center; }
.moon-canvas { width: 116px; height: 116px; flex: none; border-radius: 50%; background: radial-gradient(circle at 50% 50%, #101820, #05080c); }
.moon-info { min-width: 0; flex: 1; }
.disclaimer { font-size: 10.5px; color: var(--text-faint); margin-top: 12px; line-height: 1.35; }

/* ============================ SPODNI NAVIGACE ============================ */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(24, 24, 24, .92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  z-index: 50;
}
.bottom-nav__item {
  border: 0; background: transparent; color: var(--text-dim);
  font: inherit; font-size: 10.5px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer;
  padding: 6px 2px;
}
.bottom-nav__item svg { width: 23px; height: 23px; }
.bottom-nav__item.is-active { color: var(--accent); }
.bottom-nav__item.is-active svg { filter: drop-shadow(0 0 6px var(--accent-soft)); }
.bottom-nav__item:active { transform: scale(.93); }

/* ============================ MODAL ============================ */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .94);
  display: flex; flex-direction: column;
}
.modal[hidden] { display: none; }
.modal__bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 10px) var(--pad) 10px;
  color: var(--text);
}
.modal__title { font-size: 14px; font-weight: 600; }
.modal__body { flex: 1; display: grid; place-items: center; overflow: auto; padding: 8px; }
.modal__body img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ============================ TOAST ============================ */
.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  z-index: 120;
  box-shadow: var(--shadow);
  animation: fade .2s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast[hidden] { display: none; }

/* ============================ SKELETONY ============================ */
.skeleton {
  background: linear-gradient(100deg, #1e1e1e 30%, #2a2a2a 50%, #1e1e1e 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { to { background-position: -220% 0; } }
.skeleton--hero { height: 168px; }
.skeleton--tile { height: 104px; }
.skeleton--chip { height: 30px; width: 128px; border-radius: var(--radius-pill); }
.skeleton-host { min-height: 30px; }

.empty { color: var(--text-dim); font-size: 13px; padding: 6px 0; }

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