/* ============================================================
   «Благо» — стиль каталога treecode.
   Тёплая бумага + глубокий зелёный; программы — тёмные карточки
   с лаймовым акцентом. Моно-шрифт для служебных подписей.
   Перенос с дизайн-макета (SSR): правки помечены «правка».
   ============================================================ */

:root {
  --bg: #F6F4EE;
  --bg-soft: #EFEBE1;
  --card: #FFFDF8;
  --ink: #1B1A15;
  --ink-soft: #57544A;
  --ink-faint: #8C887B;
  --line: #E4E0D4;

  --accent: #2F6B4F;
  --accent-ink: #265238;
  --accent-soft: #E3ECE2;

  --amber: #96660F;
  --amber-soft: #F3E7C9;
  --red: #A43E35;
  --red-soft: #F4E0DB;
  --indigo: #48549E;
  --indigo-soft: #E4E6F4;
  --gray: #6F6B5E;
  --gray-soft: #ECE8DC;
  --star: #DFA32E;

  --dark: #1B1913;
  --dark-line: #302D23;
  --lime: #C9E265;
}

/* ---------- База ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(640px 480px at 82% -60px, rgba(47, 107, 79, 0.10), transparent 70%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  overflow-x: clip;
}

h1, h2, h3, p { margin: 0; }

::selection { background: rgba(47, 107, 79, 0.18); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

.mono { font-family: "JetBrains Mono", ui-monospace, "Cascadia Mono", monospace; }

main { display: block; min-height: 55vh; }

/* правка: невидимый h1 для семантики главной страницы */
.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;
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 1;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: none;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: transform .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
}
.btn-primary { background: var(--accent); color: #FBFAF4; }
.btn-primary:hover { background: var(--accent-ink); transform: translateY(-1px); }
.btn-ghost { border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-sm { padding: 9px 15px; font-size: 12px; }
.btn-lg { padding: 14px 24px; font-size: 13.5px; }

/* ---------- Навигация ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(246, 244, 238, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.logo {
  font-family: "Lora", Georgia, serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .01em;
  text-decoration: none;
  color: var(--ink);
}
.logo-dot { color: var(--accent); }
.nav-links { display: flex; gap: 26px; }
.nav-links a {
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color .2s ease;
}
.nav-links a:hover { color: var(--ink); }

/* ---------- Секции ---------- */
.section { padding-top: 56px; }
.section-first { padding-top: 36px; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  margin-bottom: 18px;
}
.section-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink);
}
.section-title::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
}
.section-title .count { color: var(--ink-faint); letter-spacing: .02em; }
.section-note {
  font-size: 12px;
  color: var(--ink-faint);
}

/* правка: аккуратное пустое состояние секции (карточек ещё нет) */
.empty {
  grid-column: 1 / -1;
  padding: 34px 24px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  color: var(--ink-faint);
  text-align: center;
}

/* ---------- Фильтр по статусам ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.chip {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.chip:hover { border-color: var(--ink-faint); color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip-n { margin-left: 6px; font-size: 11px; opacity: .55; }

/* ---------- Сетки и карточки ---------- */
.grid { display: grid; gap: 18px; align-items: stretch; }
.services-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.programs-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.repos-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.card.hidden { display: none; }

.service-card { cursor: pointer; }
.service-card:hover, .repo-card:hover {
  transform: translateY(-3px);
  border-color: #CFC9B8;
  box-shadow: 0 12px 32px -18px rgba(25, 24, 19, .25);
}
/* правка: spoiler=false — карточка не раскрывается, не кликается и не приподнимается */
.service-card.no-toggle { cursor: default; }
.service-card.no-toggle:hover {
  transform: none;
  border-color: var(--line);
  box-shadow: none;
}
.service-card.open {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 18px 44px -20px rgba(47, 107, 79, .28);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.head-right { display: inline-flex; align-items: center; gap: 8px; }

.card-ico {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: 20px;
  flex-shrink: 0;
  overflow: hidden;
}
.ico-dark { background: var(--dark); color: var(--lime); }
.ico-sm { width: 36px; height: 36px; border-radius: 10px; font-size: 17px; }
.ico-big { width: 60px; height: 60px; border-radius: 16px; font-size: 26px; }

/* правка: иконка типа вместо буквы — размеры svg и картинки в аватаре */
.card-ico svg { width: 20px; height: 20px; display: block; }
.ico-sm svg { width: 17px; height: 17px; }
.ico-big svg { width: 26px; height: 26px; }
.card-ico img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.card-name {
  font-family: "Lora", Georgia, serif;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
}
.card-tagline { font-size: 14px; color: var(--ink-soft); }

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-top: 16px;
  margin-bottom: 18px;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-faint);
  white-space: nowrap;
}

/* Кнопка раскрытия */
.card-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: auto;
  padding: 12px 2px 2px;
  background: none;
  border: none;
  border-top: 1px dashed var(--line);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .2s ease;
}
.card-toggle:hover { color: var(--accent-ink); }
.chev { display: inline-flex; transition: transform .3s ease; }
.service-card.open .chev { transform: rotate(180deg); }

/* Раскрывающаяся часть (анимация через grid-rows) */
.card-more {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .45s cubic-bezier(.33, 0, .2, 1);
}
.card-more-inner {
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .3s ease, transform .35s ease;
}
.card.open .card-more { grid-template-rows: 1fr; }
.card.open .card-more-inner { opacity: 1; transform: none; transition-delay: .08s; }

.card-desc { font-size: 14px; color: var(--ink-soft); margin-top: 16px; }
.card-actions { margin-top: 16px; }
/* правка: spoiler=false — действия сразу в карточке, прижаты к низу как кнопка «подробнее» */
.service-card > .card-actions { margin-top: auto; padding-top: 16px; }

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 9px 16px;
  text-decoration: none;
  transition: background .2s ease, color .2s ease;
}
.card-link:hover { background: var(--accent); color: #FCFBF5; }

.card-note {
  display: inline-block;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-faint);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 9px 13px;
}

/* ---------- Статусы ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  white-space: nowrap;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.st-online      { color: var(--accent-ink); background: var(--accent-soft); }
.st-online .dot { background: var(--accent); animation: pulse 2.2s ease-out infinite; }
.st-maintenance      { color: var(--amber); background: var(--amber-soft); }
.st-maintenance .dot { background: var(--amber); }
.st-offline      { color: var(--red); background: var(--red-soft); }
.st-offline .dot { background: var(--red); }
.st-beta      { color: var(--indigo); background: var(--indigo-soft); }
.st-beta .dot { background: var(--indigo); }
.st-soon      { color: var(--gray); background: var(--gray-soft); }
.st-soon .dot { background: var(--gray); }

/* правка: неизвестный статус — нейтральный серый, а не «работает» */
.st-unknown      { color: var(--gray); background: var(--gray-soft); }
.st-unknown .dot { background: var(--gray); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(47, 107, 79, .35); }
  70%  { box-shadow: 0 0 0 6px rgba(47, 107, 79, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 107, 79, 0); }
}

/* ---------- Отзывы ---------- */
.reviews { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.reviews-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink-faint);
  margin-bottom: 14px;
}
.rev-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.rev-score { font-family: "Lora", Georgia, serif; font-size: 34px; line-height: 1; color: var(--accent-ink); }
.rev-score-meta { display: flex; flex-direction: column; gap: 3px; }
.rev-count { font-size: 12px; color: var(--ink-faint); }
.rev-empty { font-size: 13px; color: var(--ink-faint); }

.review {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.review + .review { margin-top: 8px; }
.review-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.review-author { font-size: 13px; font-weight: 600; }
.review-meta { display: inline-flex; align-items: center; gap: 8px; }
.review-date { font-size: 11px; color: var(--ink-faint); }
.review-text { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

.stars {
  position: relative;
  display: inline-block;
  font-size: 12px;
  line-height: 1;
  letter-spacing: 1.5px;
  color: #DFDAC9;
}
/* правка: у незаполненных звёзд явное правило (в макете работало случайно) */
.stars-bg { color: #DFDAC9; }
.stars-fill {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--star);
}

/* ---------- Карточки программ (тёмный стиль) ---------- */
.program-card {
  display: block;
  background: var(--dark);
  border: 1px solid var(--dark-line);
  color: #EFECE0;
  text-decoration: none;
}
.program-card:hover {
  transform: translateY(-3px);
  border-color: rgba(201, 226, 101, .5);
  box-shadow: 0 16px 40px -18px rgba(25, 23, 17, .5);
}
.program-card .card-ico { background: rgba(201, 226, 101, .10); color: var(--lime); }
.program-card .card-name { color: #F3F0E5; }
.program-card .card-tagline { color: #A9A596; margin-bottom: 18px; }

.prog-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--dark-line);
}
.prog-platforms { font-size: 11.5px; letter-spacing: .02em; color: #7E7A6C; }
.prog-open {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #A9A596;
  transition: color .25s ease, transform .25s ease;
}
.program-card:hover .prog-open { color: var(--lime); transform: translateX(4px); }

/* ---------- Карточки репозиториев ---------- */
.repo-name { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.repo-card .card-tagline { margin-bottom: 18px; }
.repo-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-faint);
}
.repo-open {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--accent-ink);
  text-decoration: none;
  transition: color .2s ease, transform .2s ease;
}
.repo-open:hover { color: var(--accent); transform: translateX(3px); }

/* ---------- Принципы ---------- */
.principles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 28px;
}
.principle { border-top: 1px solid var(--line); padding-top: 20px; }
.p-num { font-size: 12px; color: var(--accent-ink); }
.principle h3 { font-family: "Lora", Georgia, serif; font-size: 19px; font-weight: 600; margin: 12px 0 8px; }
.principle p { font-size: 14px; color: var(--ink-soft); }

/* ---------- Подвал ---------- */
.footer { margin-top: 100px; border-top: 1px solid var(--line); }
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-top: 36px;
}
.footer-slogan {
  font-family: "Lora", Georgia, serif;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 500;
  letter-spacing: -.01em;
  margin-top: 10px;
}
.footer-slogan em { font-style: italic; color: var(--accent); }
.footer-links { display: flex; gap: 22px; }
.footer-links a { font-size: 12.5px; color: var(--ink-soft); text-decoration: none; transition: color .2s ease; }
.footer-links a:hover { color: var(--accent-ink); }
.footer-fine {
  font-size: 11.5px;
  color: var(--ink-faint);
  opacity: .85;
  margin-top: 30px;
  padding-bottom: 28px;
}

/* ---------- Страница программы ---------- */
/* правка: контент рендерится на сервере — контейнер-класс вместо #program-root */
.program-page { padding-top: 40px; }
.program-page h2 {
  font-family: "Lora", Georgia, serif;
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 16px;
}

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-faint);
  text-decoration: none;
  transition: color .2s ease;
}
.backlink:hover { color: var(--ink); }
.backlink svg { display: block; }

.program-head { display: flex; gap: 20px; align-items: flex-start; margin-top: 26px; }
.program-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.program-title-row h1 {
  font-family: "Lora", Georgia, serif;
  font-size: clamp(32px, 4.5vw, 44px);
  font-weight: 600;
  letter-spacing: -.01em;
}
.program-tagline { font-size: 17px; color: var(--ink-soft); margin: 10px 0 12px; max-width: 56ch; }
.program-meta { font-size: 12px; letter-spacing: .02em; color: var(--ink-faint); }

.download-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 28px; }
.dl-note { font-size: 11.5px; color: var(--ink-faint); margin-top: 14px; }

.program-grid {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 52px;
  margin-top: 56px;
}
.program-about p { font-size: 15px; color: var(--ink-soft); margin-bottom: 14px; }
.program-about p:last-child { margin-bottom: 0; }

.program-reviews { margin-top: 60px; max-width: 780px; }
.program-reviews .reviews { border-top: none; padding-top: 0; margin-top: 14px; }

.program-others { margin-top: 60px; }
.others-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.other-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: inherit;
  text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.other-card:hover {
  transform: translateY(-2px);
  border-color: #CFC9B8;
  box-shadow: 0 10px 26px -16px rgba(27, 25, 19, .3);
}
.other-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.other-name { font-family: "Lora", Georgia, serif; font-size: 16px; font-weight: 600; }
.other-tag {
  font-size: 12.5px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.other-arrow { margin-left: auto; display: inline-flex; color: var(--ink-faint); transition: color .2s ease, transform .2s ease; }
.other-card:hover .other-arrow { color: var(--accent-ink); transform: translateX(3px); }

/* Страница «не найдено» */
.notfound { padding: 90px 0 40px; max-width: 480px; }
.nf-code { font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 16px; }
.notfound h1 { font-family: "Lora", Georgia, serif; font-size: 40px; font-weight: 600; margin-bottom: 12px; }
.notfound-text { font-size: 15px; color: var(--ink-soft); margin-bottom: 28px; }

/* ---------- Появление при скролле ----------
   Скрываем только когда JS работает (html.js): без JS всё видно сразу. */
html.js .reveal { opacity: 0; }
html.js .reveal.in { animation: rise .6s cubic-bezier(.22, .61, .36, 1) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Приподнятая карточка: открыта поверх сетки ----------
   Блок стоит после анимаций появления, чтобы его правила
   (animation: none, transform) их уверенно перекрывали. */
body.no-scroll { overflow: hidden; }

.card-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(27, 25, 19, .40);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.card-backdrop.visible { opacity: 1; pointer-events: auto; }

.card.lifted {
  position: fixed;
  margin: 0;
  z-index: 70;
  animation: none;
  opacity: 1;
  transform: translateY(-4px) scale(1.01);
  transform-origin: 50% 0;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  scrollbar-width: none; /* скроллбар не показываем — вместо него стрелка внизу */
  border-color: var(--accent);
  box-shadow: 0 34px 90px -28px rgba(25, 24, 19, .5), 0 10px 28px -14px rgba(25, 24, 19, .22);
  transition: top .4s cubic-bezier(.22, .61, .36, 1), transform .3s ease,
              box-shadow .3s ease, border-color .3s ease;
}
.card.lifted:hover { transform: translateY(-4px) scale(1.01); }
.card.lifted::-webkit-scrollbar { display: none; }

/* Стрелка «есть ещё контент» у нижней кромки раскрытой карточки */
.scroll-hint { display: none; }
.card.lifted.has-scroll .scroll-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  bottom: 10px;
  align-self: center;
  flex-shrink: 0; /* переполненная карточка не должна её сплющивать */
  width: 28px;
  height: 28px;
  margin-top: -28px; /* не добавляет пустоту в конец контента */
  color: var(--ink);
  z-index: 2;
  cursor: pointer;
  animation: hint-bob 2.2s ease-in-out infinite;
}
.scroll-hint svg {
  display: block;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
@keyframes hint-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(3px); }
}

/* ---------- Адаптив ---------- */
@media (max-width: 960px) {
  .section-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .program-grid { grid-template-columns: 1fr; gap: 40px; }
  .principles { grid-template-columns: 1fr; gap: 26px; }
}

@media (max-width: 640px) {
  .container { padding: 0 18px; }
  .nav-links { display: none; }
  .section { padding-top: 64px; }
  .footer { margin-top: 72px; }
  .footer-inner { flex-direction: column; gap: 22px; }
  .download-row { align-items: flex-start; }
}
