/* ============================================================
   Метеостанция Davis Vantage Vue — стили
   Тёмная тема по умолчанию через prefers-color-scheme,
   плюс ручное переключение через [data-theme].
   Палитра графиков — из проверенного набора data-viz.
   ============================================================ */

:root {
  /* surfaces & ink (light) */
  --plane: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #0b0f14;
  --text-2: #52596a;
  --muted: #8a8f9c;
  --grid: #e7eaf0;
  --axis: #c9cedb;
  --border: rgba(11, 15, 20, 0.08);
  --shadow: 0 1px 2px rgba(11, 15, 20, .04), 0 12px 32px rgba(11, 15, 20, .06);

  /* accent + status */
  --accent: #2a78d6;
  --good: #0ca30c;
  --warn: #eda100;
  --crit: #d03b3b;

  /* series (light) */
  --s-temp: #eb6834;
  --s-humidity: #2a78d6;
  --s-pressure: #4a3aa7;
  --s-wind: #eda100;
  --s-dewpoint: #1baf7a;

  /* aurora accents for background */
  --au-1: rgba(42, 120, 214, .20);
  --au-2: rgba(27, 175, 122, .16);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --plane: #0a0d12;
    --surface: #14181f;
    --surface-2: #1a1f28;
    --text: #f4f6fa;
    --text-2: #aab2c2;
    --muted: #7f8798;
    --grid: #232a35;
    --axis: #333b48;
    --border: rgba(255, 255, 255, 0.09);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 18px 44px rgba(0, 0, 0, .45);

    --accent: #3987e5;
    --good: #17c217;
    --warn: #f0b429;
    --crit: #e05656;

    --s-temp: #f0824f;
    --s-humidity: #3987e5;
    --s-pressure: #9085e9;
    --s-wind: #e6ad2a;
    --s-dewpoint: #21c98d;

    --au-1: rgba(57, 135, 229, .22);
    --au-2: rgba(27, 175, 122, .18);

    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --plane: #0a0d12;
  --surface: #14181f;
  --surface-2: #1a1f28;
  --text: #f4f6fa;
  --text-2: #aab2c2;
  --muted: #7f8798;
  --grid: #232a35;
  --axis: #333b48;
  --border: rgba(255, 255, 255, 0.09);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 18px 44px rgba(0, 0, 0, .45);

  --accent: #3987e5;
  --good: #17c217;
  --warn: #f0b429;
  --crit: #e05656;

  --s-temp: #f0824f;
  --s-humidity: #3987e5;
  --s-pressure: #9085e9;
  --s-wind: #e6ad2a;
  --s-dewpoint: #21c98d;

  --au-1: rgba(57, 135, 229, .22);
  --au-2: rgba(27, 175, 122, .18);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--plane);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
  min-height: 100%;
}

.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1100px 620px at 12% -8%, var(--au-1), transparent 60%),
    radial-gradient(900px 560px at 100% 0%, var(--au-2), transparent 55%);
  pointer-events: none;
}

/* ---------- layout ---------- */

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 20px 40px;
  display: grid;
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

/* ---------- topbar ---------- */

.topbar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), var(--s-dewpoint));
  box-shadow: 0 6px 18px rgba(42, 120, 214, .35);
  flex: none;
}

.topbar h1 { font-size: 18px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.subtitle { margin: 0; font-size: 12.5px; color: var(--muted); }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.status {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 999px;
}
.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(0,0,0,0);
}
.status.online .status-dot {
  background: var(--good);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 22%, transparent);
}
.status.offline .status-dot {
  background: var(--crit);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--crit) 22%, transparent);
}

.clock { font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.theme-toggle {
  width: 38px; height: 38px; border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer; display: grid; place-items: center;
  transition: color .15s, transform .15s;
}
.theme-toggle:hover { color: var(--text); transform: translateY(-1px); }
.theme-icon { width: 18px; height: 18px; display: block; background: currentColor;
  -webkit-mask: var(--icon) center/contain no-repeat; mask: var(--icon) center/contain no-repeat;
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z'/%3E%3C/svg%3E");
}

/* ---------- hero ---------- */

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 8px;
  padding: 26px 28px;
  align-items: stretch;
}

.hero-now { display: flex; align-items: center; gap: 24px; }
.hero-icon { width: 96px; height: 96px; flex: none; }
.hero-icon svg { width: 100%; height: 100%; }

.hero-temp {
  font-size: clamp(56px, 9vw, 88px);
  font-weight: 250;
  line-height: .95;
  letter-spacing: -.03em;
  display: flex; align-items: flex-start;
}
.hero-unit { font-size: .38em; font-weight: 400; color: var(--text-2); margin-top: .35em; }
.hero-cond { font-size: 20px; font-weight: 560; margin-top: 6px; }
.hero-meta { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.dot-sep { margin: 0 7px; opacity: .6; }

.hero-forecast {
  border-left: 1px solid var(--border);
  padding-left: 26px;
  display: flex; flex-direction: column; justify-content: center;
}
.fc-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.fc-headline { font-size: 17px; font-weight: 600; margin-top: 6px; }
.fc-text { font-size: 14px; color: var(--text-2); margin: 8px 0 0; }

/* ---------- stat tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.tile::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--muted); opacity: .8;
}
.tile[data-k="pressure"]::before { background: var(--s-pressure); }
.tile[data-k="humidity"]::before { background: var(--s-humidity); }
.tile[data-k="wind"]::before { background: var(--s-wind); }
.tile[data-k="rain"]::before { background: var(--s-humidity); }
.tile[data-k="uv"]::before { background: var(--s-temp); }
.tile[data-k="indoor"]::before { background: var(--s-dewpoint); }
.tile[data-k="sun"]::before { background: var(--warn); }
.tile[data-k="batt"]::before { background: var(--good); }

.tile-head { display: flex; align-items: center; justify-content: space-between; }
.tile-label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tile-value {
  font-size: 30px; font-weight: 350; margin-top: 8px; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 4px;
}
.tile-value-sm { font-size: 22px; }
.tile-unit { font-size: 14px; color: var(--text-2); font-weight: 400; }
.tile-sub { font-size: 13px; color: var(--text-2); margin-top: 4px; font-variant-numeric: tabular-nums; }
.sun-sep { color: var(--muted); }

/* wind tile + compass */
.tile-wind-body { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.compass { width: 66px; height: 66px; flex: none; }
.compass-face {
  position: relative; width: 100%; height: 100%; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2);
}
.compass-face span {
  position: absolute; font-size: 9px; color: var(--muted); transform: translate(-50%, -50%);
}
.compass-n { left: 50%; top: 11%; }
.compass-s { left: 50%; top: 89%; }
.compass-e { left: 89%; top: 50%; }
.compass-w { left: 11%; top: 50%; }
.compass-arrow {
  position: absolute; left: 50%; top: 50%; width: 3px; height: 42%;
  background: linear-gradient(var(--s-wind), transparent);
  transform-origin: bottom center;
  transform: translate(-50%, -100%) rotate(0deg);
  border-radius: 3px; transition: transform .5s ease;
}
.compass-arrow::after {
  content: ""; position: absolute; top: -2px; left: 50%; transform: translateX(-50%);
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-bottom: 7px solid var(--s-wind);
}

/* ---------- chart ---------- */

.chart-card { padding: 20px 22px 22px; }
.chart-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.chart-tabs, .chart-ranges { display: flex; gap: 6px; flex-wrap: wrap; }

.chart-tabs button, .chart-ranges button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit; font-size: 13px;
  padding: 7px 13px; border-radius: 999px; cursor: pointer;
  transition: all .15s;
}
.chart-tabs button:hover, .chart-ranges button:hover { color: var(--text); }
.chart-ranges button { padding: 7px 11px; font-variant-numeric: tabular-nums; }

.chart-tabs button[aria-selected="true"] {
  color: #fff; border-color: transparent;
  background: var(--tab-color, var(--accent));
}
.chart-ranges button[aria-selected="true"] {
  color: var(--text); border-color: var(--text-2);
  background: var(--surface);
}

.chart-title-row { display: flex; align-items: baseline; justify-content: space-between; margin: 16px 2px 6px; }
.chart-title { font-size: 15px; font-weight: 600; margin: 0; color: var(--text-2); }
.chart-readout { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.chart-wrap { position: relative; width: 100%; height: 320px; }
#chart { width: 100%; height: 100%; display: block; }

.chart-tooltip {
  position: absolute; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); border-radius: 10px;
  padding: 7px 11px; font-size: 12.5px; color: var(--text);
  transform: translate(-50%, -130%); white-space: nowrap;
  font-variant-numeric: tabular-nums; z-index: 3;
}
.chart-tooltip .tt-time { color: var(--muted); font-size: 11.5px; }
.chart-tooltip .tt-val { font-weight: 650; font-size: 15px; }

.chart-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 14px;
}
.chart-empty[hidden] { display: none; }   /* иначе display:grid перебивает [hidden] */

/* ---------- footer ---------- */

.footer {
  max-width: 1180px; margin: 0 auto; padding: 4px 22px 30px;
  color: var(--muted); font-size: 12px; text-align: center;
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; gap: 20px; }
  .hero-forecast { border-left: none; border-top: 1px solid var(--border); padding-left: 0; padding-top: 18px; }
  .hero-now { gap: 16px; }
  .hero-icon { width: 74px; height: 74px; }
  .topbar { flex-wrap: wrap; }
}

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