/* WeatherLab 2.0 — стилі.
   Ідея: сторінка атласу. Головний візуальний елемент — календар як теплова карта:
   колір клітинки = температура, тією самою шкалою, що в легенді й на графіку.
   Усе інше — спокійне, щоб карта читалась. Інлайн-стилів у розмітці немає (CSP). */

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url(fonts/nunito-cyrillic-wght-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url(fonts/nunito-latin-wght-normal.woff2) format("woff2");
  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: "Unbounded";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url(fonts/unbounded-cyrillic-wght-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url(fonts/unbounded-latin-wght-normal.woff2) format("woff2");
  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;
}

:root {
  --ink: #12263a;
  --ink-2: #44586b;
  --paper: #eef3f4;
  --sheet: #ffffff;
  --contour: #c7d5da;
  --contour-2: #dde6e9;
  --focus: #0b5cad;
  --sun: #f2a900;
  --danger: #b3261e;
  --radius: 14px;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Unbounded", "Nunito", system-ui, sans-serif;
  color-scheme: light;
}

html.hc {
  --ink: #000;
  --ink-2: #000;
  --paper: #fff;
  --contour: #000;
  --contour-2: #000;
  --focus: #0000d6;
  --danger: #8a0000;
}
html.lg { font-size: 125%; }
html.rf {
  --font-body: Verdana, Tahoma, "Trebuchet MS", Arial, sans-serif;
  --font-display: Verdana, Tahoma, Arial, sans-serif;
}
html.rf body { letter-spacing: 0.02em; word-spacing: 0.1em; line-height: 1.7; }
html.simple .chart-card,
html.simple .stats-card,
html.simple .rose-card { display: none; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p, ul, dl, dd, fieldset { margin: 0; padding: 0; }
ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
[hidden] { display: none !important; }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--sheet); color: var(--ink); padding: 0.6rem 1rem;
  border: 2px solid var(--ink); border-radius: 8px; font-weight: 800;
}
.skip:focus { top: 8px; }
.wrap { max-width: 1180px; margin: 0 auto; padding-left: clamp(12px, 3vw, 28px); padding-right: clamp(12px, 3vw, 28px); }
.grow { flex: 1 1 auto; }
.noscript { padding: 1rem; text-align: center; font-weight: 800; }

/* ─── банер про сховище ─── */
.banner {
  background: var(--danger); color: #fff; padding: 0.7rem clamp(12px, 3vw, 28px);
  font-weight: 700; text-align: center;
}

/* ─── шапка ─── */
.top { background: var(--ink); color: #fff; padding-top: env(safe-area-inset-top); }
html.hc .top { border-bottom: 4px solid #fff; }
.top-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 44px; height: 44px; flex: none; }
.wordmark { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; letter-spacing: -0.01em; line-height: 1.1; }
.tagline { font-size: 0.85rem; opacity: 0.85; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0.4rem 1rem;
  border: 2px solid rgba(255, 255, 255, 0.55); border-radius: 999px;
  background: transparent; color: #fff; font-weight: 700; cursor: pointer;
}
.pill:hover { background: rgba(255, 255, 255, 0.14); }
.top :focus-visible { outline-color: #fff; }
.seg { display: inline-flex; border: 2px solid rgba(255, 255, 255, 0.55); border-radius: 999px; overflow: hidden; }
.seg button {
  min-height: 40px; min-width: 48px; padding: 0 0.8rem; border: 0; background: transparent;
  color: #fff; font-weight: 800; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); }

/* ─── розкладка ─── */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 20px; padding-bottom: 20px; }
.col-main, .col-side { display: grid; gap: 20px; align-content: start; min-width: 0; }
@media (min-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); }
}
.card {
  background: var(--sheet); border: 1px solid var(--contour); border-radius: var(--radius);
  padding: clamp(14px, 2.2vw, 22px);
}
html.hc .card { border-width: 2px; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 1rem; margin-bottom: 12px; }
.hint { color: var(--ink-2); font-size: 0.95rem; }
.hint.small { font-size: 0.85rem; margin-top: 8px; }

/* ─── кнопки ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0.5rem 1.1rem; border: 2px solid var(--ink); border-radius: 999px;
  background: var(--sheet); color: var(--ink); font-weight: 800; cursor: pointer; text-align: center;
}
.btn:hover:not(:disabled) { background: var(--contour-2); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1f3d59; }
html.hc .btn-primary:hover:not(:disabled) { background: #222; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-small { min-height: 40px; padding: 0.3rem 0.9rem; font-size: 0.9rem; }
.round {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 2px solid var(--ink); border-radius: 50%; background: var(--sheet); color: var(--ink);
  font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.round:hover:not(:disabled) { background: var(--contour-2); }
.round:disabled { opacity: 0.35; cursor: default; }

/* ─── календар (головний елемент) ─── */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.month-title {
  flex: 1 1 auto; text-align: center; font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.25rem, 3.6vw, 2rem); letter-spacing: -0.02em; line-height: 1.15;
}
.cal { border-collapse: separate; border-spacing: 4px; table-layout: fixed; margin: 0 -4px; width: calc(100% + 8px); }
.cal th { font-size: 0.8rem; font-weight: 800; color: var(--ink-2); padding: 2px 0 4px; text-align: center; }
.cal abbr { text-decoration: none; cursor: help; }
.cal td { padding: 0; }
.day {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  width: 100%; height: clamp(58px, 9.2vw, 90px); padding: 5px 3px 4px;
  border: 1px dashed var(--contour); border-radius: 10px; background: var(--sheet); color: var(--ink); cursor: pointer;
}
html.hc .day { border: 2px solid #000; }
.day:hover:not(:disabled) { border-color: var(--ink); border-style: solid; }
.day .d { align-self: flex-start; padding-left: 3px; font-weight: 800; font-size: 0.78rem; line-height: 1; }
.day .s { font-size: clamp(1.05rem, 2.7vw, 1.65rem); line-height: 1; }
.day .v { font-family: var(--font-display); font-weight: 600; font-size: clamp(0.6rem, 1.5vw, 0.8rem); line-height: 1; white-space: nowrap; }
.day.has { background: var(--bg); color: var(--fg); border: 1px solid transparent; }
html.hc .day.has { border: 2px solid #000; }
.day.today { box-shadow: 0 0 0 3px var(--sun); }
html.hc .day.today { box-shadow: 0 0 0 3px #fff, 0 0 0 6px #000; }
.day:disabled { opacity: 0.4; cursor: default; border-style: solid; }

.legend { margin-top: 14px; }
.legend-caption { font-size: 0.85rem; color: var(--ink-2); margin-bottom: 6px; }
.legend-bar { height: 12px; border-radius: 6px; border: 1px solid var(--contour); }
.legend-ticks { position: relative; height: 1.3rem; margin-top: 4px; font-size: 0.78rem; font-weight: 700; color: var(--ink-2); }
.legend-ticks span { position: absolute; transform: translateX(-50%); }
.cal-card .hint { margin-top: 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* ─── графік ─── */
.chart-svg { display: block; width: 100%; height: auto; }
.ch-grid line { stroke: var(--contour-2); stroke-width: 1; }
html.hc .ch-grid line { stroke: #999; }
.ch-y, .ch-x text { font-size: 12px; fill: var(--ink-2); font-family: var(--font-body); font-weight: 700; }
.ch-freeze { stroke: #3b6fc4; stroke-width: 1.5; stroke-dasharray: 2 4; }
.ch-mine { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.ch-real { fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-dasharray: 6 5; }
.ch-real-dot { fill: var(--sheet); stroke: var(--ink-2); stroke-width: 2; }
.ch-dot { stroke: var(--ink); stroke-width: 1.5; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 0.88rem; color: var(--ink-2); font-weight: 700; }
.chart-legend li { display: inline-flex; align-items: center; gap: 8px; }
.lg-line, .lg-dash, .lg-freeze { display: inline-block; width: 26px; height: 0; border-top: 3px solid var(--ink); }
.lg-dash { border-top: 3px dashed var(--ink-2); }
.lg-freeze { border-top: 2px dotted #3b6fc4; }
.chart-data { margin-top: 12px; }
.chart-data summary { cursor: pointer; font-weight: 800; padding: 6px 0; }
.table-scroll { overflow-x: auto; }

table.data, table.mini { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin-top: 8px; }
table.data th, table.data td, table.mini th, table.mini td { padding: 6px 8px; border-bottom: 1px solid var(--contour); text-align: left; vertical-align: top; }
table.data th, table.mini thead th { font-weight: 800; white-space: nowrap; }
table.mini tbody th { font-weight: 700; }

/* ─── бічна колонка ─── */
.place-name { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.02em; }
.place-sub { color: var(--ink-2); }
.place-coords { margin: 6px 0 14px; font-variant-numeric: tabular-nums; font-weight: 700; }

.mean {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px;
  background: var(--bg); color: var(--fg); margin-bottom: 14px;
}
.mean-num { font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 1.1; letter-spacing: -0.02em; }
.mean-lbl { font-weight: 700; font-size: 0.9rem; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; }
.stats dt { color: var(--ink-2); }
.stats dd { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }

.rose-svg { display: block; width: min(100%, 260px); height: auto; margin: 0 auto; }
.rose-ring { fill: none; stroke: var(--contour); stroke-width: 1; }
.rose-axis { stroke: var(--contour); stroke-width: 1; }
.rose-shape { fill: rgba(59, 111, 196, 0.35); stroke: #2a3f9a; stroke-width: 2; stroke-linejoin: round; }
html.hc .rose-shape { fill: rgba(0, 0, 0, 0.25); stroke: #000; }
.rose-lbl { font-size: 11px; font-weight: 800; fill: var(--ink); font-family: var(--font-body); }
.rose-lbl.minor { font-weight: 600; fill: var(--ink-2); font-size: 10px; }

.badges { display: grid; gap: 8px; }
.badge { display: flex; align-items: center; gap: 12px; opacity: 0.5; }
.badge.got { opacity: 1; }
.b-emo {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--contour-2); font-size: 1.4rem; filter: grayscale(1);
}
.badge.got .b-emo { background: #fff3cf; filter: none; box-shadow: 0 0 0 2px var(--sun); }
.b-txt { display: flex; flex-direction: column; font-weight: 800; line-height: 1.25; }
.b-txt small { font-weight: 600; color: var(--ink-2); }

.foot { padding-top: 8px; padding-bottom: 32px; color: var(--ink-2); font-size: 0.85rem; }

/* ─── діалоги ─── */
dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  padding: 0; border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink); overflow: auto;
}
dialog::backdrop { background: rgba(18, 38, 58, 0.6); }
.dlg-body { padding: clamp(16px, 3vw, 24px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dlg-head h2, dialog h2 { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; line-height: 1.3; }
dialog h3 { font-size: 1rem; font-weight: 800; margin: 16px 0 6px; }
.dlg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 18px; }
#confirm-text { margin-top: 8px; }

.field { display: grid; gap: 4px; margin-bottom: 12px; align-content: start; }
.field label, .field legend { font-weight: 800; font-size: 0.95rem; }
.field legend { padding: 0; margin-bottom: 6px; }
input[type="number"], input[type="time"], input[type="text"], input[type="search"], select, textarea {
  width: 100%; min-height: 44px; padding: 0.55rem 0.7rem; background: #fff; color: var(--ink);
  border: 2px solid var(--contour); border-radius: 8px;
}
html.hc input, html.hc select, html.hc textarea { border-color: #000; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--focus); outline-offset: 0; }
textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
@media (max-width: 420px) { .row2 { grid-template-columns: minmax(0, 1fr); } }
.search-row { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 8px; }
.search-row .btn { margin-bottom: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip-face {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 64px; min-height: 60px; padding: 6px 8px; border: 2px solid var(--contour); border-radius: 12px;
  background: #fff; text-align: center;
}
html.hc .chip-face { border-color: #000; }
.chip .emo { font-size: 1.5rem; line-height: 1.1; }
.chip .lbl { font-size: 0.78rem; font-weight: 800; line-height: 1.2; }
.chip:hover .chip-face { border-color: var(--ink); }
.chip input:checked + .chip-face { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip input:focus-visible + .chip-face { outline: 3px solid var(--focus); outline-offset: 2px; }

.switch { display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; cursor: pointer; font-weight: 800; }
.switch input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--ink); }
.switch small { display: block; font-weight: 600; color: var(--ink-2); }
.about p { margin-bottom: 6px; }
.credits { display: grid; gap: 4px; margin-bottom: 8px; }
.credits a { color: var(--focus); font-weight: 800; }

.real-box { margin-top: 6px; padding: 12px; border: 1px solid var(--contour); border-radius: 10px; background: var(--paper); }
.real-box h3 { margin-top: 0; }

.results { display: grid; gap: 8px; margin-top: 8px; }
.result {
  display: grid; width: 100%; gap: 2px; text-align: left; padding: 10px 12px; cursor: pointer;
  border: 2px solid var(--contour); border-radius: 10px; background: #fff;
}
.result:hover { border-color: var(--ink); }
.result span, .result small { color: var(--ink-2); }
#btn-geo { margin-bottom: 8px; }

.plist { display: grid; gap: 8px; margin: 12px 0; }
.prow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 2px solid var(--contour); border-radius: 12px; }
.prow.on { border-color: var(--ink); }
.prow .av { font-size: 1.7rem; }
.prow .pname { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.prow .pname strong { overflow-wrap: anywhere; }
.prow .pname small { color: var(--ink-2); }
.profile-form { margin-top: 18px; padding-top: 6px; border-top: 2px solid var(--contour); }
.profile-form h3 { margin-top: 12px; }

/* ─── тост ─── */
.toast {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 2000;
  transform: translateX(-50%); max-width: min(92vw, 560px); padding: 0.75rem 1.1rem;
  background: var(--ink); color: #fff; border-radius: 12px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
html.hc .toast { border: 2px solid #fff; }
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ─── друк ─── */
.print-only { display: none; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #000; }
  body > *:not(#print-report) { display: none !important; }
  .print-only { display: block !important; }
  #print-report h1 { font-family: var(--font-display); font-size: 1.4rem; margin-bottom: 4px; }
  #print-report .pmeta { margin: 4px 0 12px; }
  #print-report .chart-svg { width: 100%; max-height: 230px; margin-bottom: 12px; }
  #print-report table.data { font-size: 0.8rem; margin-bottom: 12px; }
  #print-report table.data tr { break-inside: avoid; }
  #print-report .stats { margin-bottom: 12px; break-inside: avoid; }
}
