/* Справочник декоративных растений — Калининград */
:root {
  --bg: #f7f6f1;
  --bg-soft: #ffffff;
  --bg-alt: #eeece4;
  --ink: #1e241f;
  --ink-soft: #4d574e;
  --ink-mute: #5f6a61;
  --line: #d9d6ca;
  --accent: #2f6b4f;
  --accent-soft: #e3efe7;
  --accent-2: #8a5a2b;
  --warn: #a15c14;
  --warn-bg: #fdf2e2;
  --bad: #a33a34;
  --bad-bg: #fbeceb;
  --ok: #2c6a4a;
  --ok-bg: #e7f2ea;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(30, 36, 31, .06), 0 8px 24px rgba(30, 36, 31, .06);
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --max: 1180px;
  --space-section: 48px;
  --space-hero: 40px;
  --scroll-offset: 80px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181a;
    --bg-soft: #1b2124;
    --bg-alt: #232a2d;
    --ink: #e8ece7;
    --ink-soft: #b7c1b9;
    --ink-mute: #9aa79c;
    --line: #313a3c;
    --accent: #7fc9a2;
    --accent-soft: #1e3029;
    --accent-2: #d8a468;
    --warn: #e0a75c;
    --warn-bg: #2e2618;
    --bad: #e08a83;
    --bad-bg: #2f1f1e;
    --ok: #8ed3ac;
    --ok-bg: #1a2b22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .3);
  }
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

.latin-lead { font-style: italic; color: var(--ink-mute); }
.card-link { text-decoration: none; color: inherit; }
.value-sm { font-size: 1rem; }

html { scroll-behavior: smooth; scroll-padding-top: var(--scroll-offset); }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.62;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

img, svg { max-width: 100%; }
sup { line-height: 0; font-size: .72em; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: clamp(1.65rem, 3.4vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 2.3vw, 1.72rem); }
h3 { font-size: 1.1rem; }
h4 { font-size: .98rem; }
p { margin: 0 0 .85em; }
ul, ol { margin: 0 0 .9em; padding-left: 1.25em; }
li { margin-bottom: .3em; }
small { font-size: .82rem; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 20px; }
main > .wrap { padding-bottom: 56px; }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -.02em;
}
.brand .mark {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 9px;
  background: var(--accent-soft);
  display: grid; place-items: center;
  color: var(--accent);
}
.brand small { display: block; font-weight: 500; color: var(--ink-mute); font-size: .72rem; letter-spacing: 0; }

.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: .9rem;
  padding: 8px 11px;
  border-radius: 999px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}
.nav a:hover, .nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

/* ---------- hero ---------- */
.hero { padding: 40px 0 0; }
.hero > * { margin-block: 0; }
.hero > * + * { margin-top: 14px; }
.hero-text > * { margin-block: 0; }
.hero-text > * + * { margin-top: 14px; }
.hero-split { display: grid; gap: 24px; align-items: start; }
.hero-split .hero-media { margin: 0; }
.hero-media img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-alt);
}
.hero-media figcaption {
  margin-top: 8px;
  font-size: .74rem;
  color: var(--ink-mute);
}
@media (min-width: 901px) {
  .hero-split { grid-template-columns: minmax(0, 1fr) 380px; }
}
.hero .kicker {
  display: inline-block;
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 11px;
  border-radius: 10px;
  font-weight: 600;
  max-width: 100%;
}
.hero .kicker + h1 { margin-top: 12px; }
.hero p.lead { font-size: 1.06rem; color: var(--ink-soft); max-width: 74ch; }
.hero p.lead + p.lead { margin-top: 4px; }

.meta-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: .8rem;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink-soft);
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.chip b { color: var(--ink); font-weight: 600; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: 34px;
  padding: 0 0 64px;
  align-items: start;
}
.layout > * { min-width: 0; }
.toc {
  position: sticky;
  top: var(--scroll-offset);
  font-size: .875rem;
  border-left: 1px solid var(--line);
  padding-left: 15px;
  max-height: calc(100vh - var(--scroll-offset) - 28px);
  overflow: auto;
}
.toc p { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-mute); margin-bottom: 8px; font-weight: 700; }
.toc ol { list-style: none; padding: 0; margin: 0; counter-reset: toc; }
.toc li { margin: 0; }
.toc a {
  display: block;
  padding: 6px 0 6px 22px;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 6px;
  position: relative;
}
.toc a::before {
  counter-increment: toc;
  content: counter(toc);
  position: absolute;
  left: 0;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  font-size: .78rem;
}
.toc a:hover, .toc a.active { color: var(--accent); background: var(--accent-soft); }

.content > section { scroll-margin-top: 0; }

/* ---------- vertical rhythm ----------
   Один шаг между блоками, один шаг между секциями. Раньше интервал
   складывался из margin у p, .note-box и утилит .mt-*, поэтому соседние
   блоки получали то 16, то 29, то 40 px. */
main > .wrap > section,
.content > section { margin: 0; }
main > .wrap > section:not(.hero) > *,
.content > section > * { margin-block: 0; }
main > .wrap > section:not(.hero) > * + *,
.content > section > * + * { margin-top: 20px; }
main > .wrap > section + section,
.content > section + section { margin-top: var(--space-section); }

main > .wrap > .hero + section,
main > .wrap > .hero + .layout,
.content > .hero + section { margin-top: var(--space-hero); }

.content > section > .prev-next { margin-top: 28px; }

.content h2 {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

/* Страницы разделов идут без сайдбара: держим длину строки читаемой,
   таблицы при этом остаются на всю ширину. */
main > .wrap > section:not(.hero) > p,
main > .wrap > section:not(.hero) > ul,
main > .wrap > section:not(.hero) > ol,
main > .wrap > section:not(.hero) > .note-box { max-width: 82ch; }

/* ---------- cards ---------- */
.card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 15px;
  box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card > h3 { margin-bottom: .45em; }
.card ul, .card ol { margin-bottom: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }

.stat { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 15px; }
.stat .label, .stat .value, .stat .note { display: block; }
.stat .label { font-size: .76rem; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 1.28rem; font-weight: 680; letter-spacing: -.02em; margin-top: 2px; }
.stat .note { font-size: .78rem; color: var(--ink-mute); }

/* ---------- tables ---------- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  max-width: 100%;
  position: relative;
}
/* Подсказка о горизонтальной прокрутке: правый край «затухает»,
   пока таблица не докручена до конца (классы ставит app.js). */
.table-scroll::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 30px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
  background: linear-gradient(90deg, transparent, var(--bg-soft) 78%);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.table-scroll.is-scrollable::after { opacity: 1; }
.table-scroll.is-at-end::after { opacity: 0; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  text-align: left;
  background: var(--bg-alt);
  font-weight: 650;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-soft);
  padding: 10px 15px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
tbody td { padding: 10px 15px; border-bottom: 1px solid var(--line); vertical-align: top; }
/* заголовок строки в таблице «ключ — значение» (паспорт культуры) */
tbody th {
  padding: 10px 15px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  font-weight: 650;
  font-size: .85rem;
  color: var(--ink-soft);
  width: 34%;
}
tbody tr:last-child th { border-bottom: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-alt) 45%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.muted { color: var(--ink-mute); text-align: center; }
/* ссылка в ячейке делает кликабельной всю ячейку, а не только текст */
tbody td > a {
  display: block;
  margin: -10px -15px;
  padding: 10px 15px;
}
table.compact tbody td > a { margin: -8px -15px; padding: 8px 15px; }
tbody td:first-child { color: var(--ink); }
table.compact { font-size: .85rem; }
table.compact thead th, table.compact tbody td, table.compact tbody th { padding: 8px 15px; }
/* «ключ — значение» без шапки: первая колонка работает как заголовок строки */
table.kv tbody td:first-child {
  width: 34%;
  font-weight: 650;
  font-size: .85rem;
  color: var(--ink-soft);
}

/* ---------- badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.7;
}
.badge.verified { background: var(--ok-bg); color: var(--ok); }
.badge.estimate { background: var(--warn-bg); color: var(--warn); }
.badge.check { background: var(--bad-bg); color: var(--bad); }
.badge.neutral { background: var(--bg-alt); color: var(--ink-soft); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .84rem; color: var(--ink-soft); margin: 10px 0 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- callouts ---------- */
.note-box {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 12px 15px 12px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0;
}
.note-box.warn { border-color: var(--warn); background: var(--warn-bg); }
.note-box.bad { border-color: var(--bad); background: var(--bad-bg); }
.note-box p:last-child { margin-bottom: 0; }
.note-box strong { display: block; margin-bottom: 3px; }

/* ---------- catalog ---------- */
.filters {
  display: grid;
  grid-template-columns: minmax(200px, 1.4fr) repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 12px 0 0;
}
.filters-box > summary {
  display: none;
  cursor: pointer;
  list-style: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 9px 14px;
  margin: 0 0 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  font-size: .92rem;
  font-weight: 600;
}
.filters-box > summary::-webkit-details-marker { display: none; }
.filters-box > summary::after {
  content: "";
  width: 8px; height: 8px;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: rotate(45deg);
  transition: transform .15s ease;
  flex: 0 0 8px;
}
.filters-box[open] > summary::after { transform: rotate(-135deg); }
.filters-hint { color: var(--ink-mute); font-weight: 500; font-size: .82rem; }
.filters-box > summary .filters-hint { margin-left: auto; text-align: right; }
.filters-box[open] > summary { margin-bottom: 0; }
.filters label { display: block; font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-mute); margin-bottom: 4px; font-weight: 650; }
select, input[type="search"] {
  width: 100%;
  min-height: 44px;
  font: inherit;
  font-size: .92rem;
  color: var(--ink);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
}
input[type="search"] { -webkit-appearance: none; }
select:focus-visible, input:focus-visible, a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.filters-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
}
.filters-actions { margin-top: 12px; }
.result-line { font-size: .85rem; color: var(--ink-mute); margin: 0; }
.chip-button {
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
}
.chip-button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.plant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 16px; }
.plant-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .16s ease, border-color .16s ease;
}
.plant-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.plant-card .card-media {
  display: block;
  aspect-ratio: 3 / 2;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.plant-card .card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transition: opacity .2s ease;
}
.plant-card:hover .card-media img { opacity: .94; }
.plant-card .card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px 18px;
}
.plant-card h3 { margin: 0; font-size: 1.06rem; }
.plant-card .latin { font-style: italic; color: var(--ink-mute); font-size: .84rem; margin-top: -4px; }
.plant-card .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; }
.plant-card .tags span { font-size: .72rem; background: var(--bg-alt); color: var(--ink-soft); padding: 3px 8px; border-radius: 999px; }
.plant-card .hl { font-size: .87rem; color: var(--ink-soft); }
.plant-card .hl b { color: var(--ink); }

.empty { padding: 26px; text-align: center; color: var(--ink-mute); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- misc ---------- */
.breadcrumbs { font-size: .84rem; color: var(--ink-mute); margin: 0; padding: 18px 0 0; }
.breadcrumbs a { color: var(--ink-soft); }
.breadcrumbs span { margin: 0 6px; opacity: .6; }

.page-foot {
  border-top: 1px solid var(--line);
  padding: 24px 0 40px;
  font-size: .85rem;
  color: var(--ink-mute);
}
.page-foot .wrap { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; }

.prev-next { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.prev-next a {
  flex: 1 1 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  text-decoration: none;
  color: var(--ink);
  background: var(--bg-soft);
  min-height: 44px;
}
.prev-next a small { display: block; color: var(--ink-mute); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }

.checklist { list-style: none; padding: 0; }
.checklist li { padding-left: 26px; position: relative; margin-bottom: .5em; }
.checklist li::before {
  content: "";
  position: absolute;
  left: 0; top: .42em;
  width: 15px; height: 15px;
  border: 1.5px solid var(--accent);
  border-radius: 4px;
}

.sources { font-size: .87rem; }
.sources ol { padding-left: 1.2em; }
.sources li { margin-bottom: .5em; color: var(--ink-soft); }
.sources a { word-break: break-word; }

.skip-link {
  position: absolute; left: -9999px;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0; z-index: 100;
}
.skip-link:focus { left: 0; top: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 18px; }
  .toc {
    position: static;
    border-left: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-soft);
    padding: 14px 16px;
    max-height: none;
  }
  .toc ol { columns: 2; column-gap: 18px; }
  .toc a { padding-left: 20px; }
}

@media (max-width: 560px) {
  :root { --space-section: 32px; --space-hero: 24px; --scroll-offset: 98px; }
  .wrap { padding: 0 15px; }
  .site-header .wrap { gap: 6px 10px; padding-top: 6px; padding-bottom: 6px; min-height: 0; }
  .site-header { position: sticky; overflow: hidden; }
  .brand small { display: none; }
  .brand { font-size: .95rem; }
  .nav {
    margin-left: 0;
    width: 100%;
    gap: 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }
  .site-header::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    width: 34px;
    height: 44px;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--bg) 72%);
    opacity: 0;
  }
  .site-header::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 28px;
    height: 44px;
    pointer-events: none;
    background: linear-gradient(270deg, transparent, var(--bg) 72%);
    opacity: 0;
  }
  .site-header.is-scrollable::after { opacity: 1; }
  .site-header.is-scrolled-left::before { opacity: 1; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; font-size: .82rem; padding: 7px 9px; min-height: 34px; scroll-snap-align: start; }
  .toc { padding: 12px 14px; }
  .toc ol { columns: 2; column-gap: 12px; }
  .toc a { padding-left: 18px; }
  .hero { padding: 14px 0 0; }
  .hero .kicker { font-size: .68rem; letter-spacing: .05em; padding: 4px 9px; }
  .hero h1 { margin-bottom: 8px; }
  .hero p.lead { font-size: .93rem; line-height: 1.5; }
  .meta-row { gap: 6px; }
  .chip { font-size: .74rem; padding: 3px 8px; }
  .chip-optional { display: none; }
  .filters { grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 0; }
  .filters > div:first-child { grid-column: 1 / -1; }
  .filters-box > summary { display: flex; }
  .filters-actions { margin-top: 10px; }
  #catalog-title { margin-bottom: 0; }
  #catalog-title + p { display: none; }
  .filters label { font-size: .68rem; margin-bottom: 2px; }
  select, input[type="search"] { min-height: 40px; font-size: .88rem; padding: 6px 9px; }
  .result-line { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .card { padding: 15px; }
}

@media print {
  .site-header, .toc, .prev-next, .skip-link { display: none !important; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  .layout, main > .wrap, .hero { display: block; padding: 0; margin: 0; }
  .wrap { max-width: none; padding: 0; }
  .card, .stat, .table-scroll { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  main > .wrap > section + section,
  .content > section + section { margin-top: 18px; }
  .content > section { break-inside: auto; }
  .hero + section, .hero + .layout { margin-top: 18px; }
  h2 { break-after: avoid; }
  a { color: #000; text-decoration: none; }
  .sources a::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .plant-card { transition: none; }
}
