/* Каталог «Библиотека здоровья» — health-library/index.html
 *
 * Все правила скоупим под .health-library-page: style.css / style-new.css
 * глобальные и шарятся всеми страницами сайта. В частности .tabs и
 * .button_outline трогать нельзя — на них держатся промо, новости и врачи.
 *
 * Токены продублированы с донорского лендинга (donor-landing.css) под
 * префиксом --hl-: общего файла токенов в проекте нет, каждая страница в
 * новой стилистике самодостаточна. Шкала отступов 4px, брейкпоинты
 * 576 / 768 / 992 / 1200, mobile-first. Анимации — только transform/opacity. */

.health-library-page {
  /* ── цвет ── */
  --hl-brand: #00acc4;
  --hl-brand-deep: #007587;   /* Контрастный контур клавиатурного фокуса. */
  --hl-brand-soft: #ebf7ff;
  --hl-brand-tint: #c6f1f8;
  --hl-ink: #292929;
  --hl-body: #474747;
  --hl-muted: #6e6e6e;        /* проектный #7c7c7c даёт лишь 4.17:1 */
  --hl-line: #e4eaee;
  --hl-surface: #fff;
  --hl-surface-soft: #f5fbfe;

  /* ── типографика ── */
  /* Ритм заголовка и лида совпадает с другими каталогами сайта. */
  --hl-fs-display: 32px;
  --hl-fs-h3: clamp(19px, calc(17px + 0.5vw), 23px);
  --hl-fs-feature: clamp(22px, calc(19px + 0.9vw), 30px);
  --hl-fs-lead: 16px;
  --hl-fs-base: 16px;
  --hl-fs-sm: 15px;
  --hl-fs-xs: 14px;
  --hl-fs-2xs: 13px;

  --hl-lh-tight: 1.15;
  --hl-lh-snug: 1.35;
  --hl-lh-base: 1.6;

  --hl-ls-display: -0.025em;
  --hl-ls-head: -0.015em;

  /* ── отступы (сетка 4px) ── */
  --hl-sp-1: 4px;
  --hl-sp-2: 8px;
  --hl-sp-3: 12px;
  --hl-sp-4: 16px;
  --hl-sp-5: 20px;
  --hl-sp-6: 24px;
  --hl-sp-7: 28px;
  --hl-sp-8: 32px;
  --hl-sp-10: 40px;
  --hl-sp-12: 48px;
  --hl-sp-16: 64px;
  --hl-sp-20: 80px;

  --hl-sp-section: var(--hl-sp-12);
  --hl-gap-grid: var(--hl-sp-4);
  --hl-feature-split: 42%;

  /* ── формы ── */
  --hl-radius: 10px;
  --hl-radius-lg: 20px;

  /* ── стекло ── */
  --hl-glass-bg: rgba(255, 255, 255, 0.58);
  --hl-glass-border: rgba(255, 255, 255, 0.7);

  /* ── движение ── */
  --hl-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --hl-dur-fast: 180ms;
  --hl-dur: 320ms;
  --hl-dur-slow: 560ms;

  background: var(--hl-surface);
}

/* Без backdrop-filter стекло выглядит грязным пятном — делаем плашки плотнее. */
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .health-library-page { --hl-glass-bg: rgba(255, 255, 255, 0.93); }
}

.health-library-page .hl {
  color: var(--hl-body);
  font-size: var(--hl-fs-base);
  line-height: var(--hl-lh-base);
}

.health-library-page .hl :focus-visible {
  outline: 3px solid var(--hl-brand-deep);
  outline-offset: 4px;
}

/* в style.css крошки заданы цветом #bcbcbc — это 1.9:1, ниже любого порога */
.health-library-page .breadcrumbs { font-size: var(--hl-fs-xs); }
.health-library-page .breadcrumbs li a,
.health-library-page .breadcrumbs li:last-child,
.health-library-page .breadcrumbs li:last-child a { color: var(--hl-muted); }
.health-library-page .breadcrumbs li a:hover { color: var(--hl-brand); }

/* ═══════════════════════════════ шапка ═════════════════════════════════ */

.health-library-page .hl-section { padding: var(--hl-sp-8) 0 var(--hl-sp-section); }

.health-library-page .hl-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--hl-sp-3) var(--hl-sp-4);
  align-items: center;
  justify-content: flex-start;
  margin-bottom: var(--hl-sp-3);
}

.health-library-page .hl-title {
  min-width: 0;
  overflow-wrap: break-word;
  margin: 0;
  color: var(--hl-ink);
  font-size: var(--hl-fs-display);
  font-weight: 600;
  letter-spacing: var(--hl-ls-display);
  line-height: var(--hl-lh-tight);
  text-wrap: balance;
}

.health-library-page .hl-count {
  flex: 0 0 auto;
  padding: var(--hl-sp-2) var(--hl-sp-4);
  border-radius: 999px;
  background: var(--hl-brand-soft);
  color: var(--hl-brand);
  font-size: var(--hl-fs-xs);
  font-weight: 600;
  white-space: nowrap;
}

.health-library-page .hl-lead {
  max-width: 65ch;
  margin: 0 0 var(--hl-sp-6);
  font-size: var(--hl-fs-lead);
  line-height: var(--hl-lh-base);
}

/* ════════════════════════ переключатель категорий ══════════════════════ */

/* Свой блок, а не глобальный .tabs: тот шарится с промо и врачами. */
.health-library-page .hl-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--hl-sp-3) var(--hl-sp-4);
  margin-bottom: var(--hl-sp-6);
}

.health-library-page .hl-tabs__list {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: var(--hl-sp-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.health-library-page .hl-tabs__list a {
  display: block;
  padding: 7px var(--hl-sp-3);
  border: 1px solid var(--hl-line);
  border-radius: 999px;
  background: var(--hl-surface);
  color: var(--hl-body);
  font-size: var(--hl-fs-xs);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--hl-dur-fast) var(--hl-ease),
    border-color var(--hl-dur-fast) var(--hl-ease),
    color var(--hl-dur-fast) var(--hl-ease);
}

.health-library-page .hl-tabs__list a.is-active {
  border-color: transparent;
  background: var(--hl-brand);
  color: #fff;
}

/* ════════════════════════════ сетка карточек ═══════════════════════════ */

.health-library-page .hl-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--hl-gap-grid);
  align-items: stretch;
}

/* Кнопка «Показать больше» — прямой потомок грида: el-pagination вставляет
   новый фрагмент на место старого контейнера, поэтому обёртку сетки держим
   в index.html, а не во фрагменте. */
.health-library-page .endless_container {
  grid-column: 1 / -1;
  margin-top: var(--hl-sp-4);
  text-align: center;
}

.health-library-page .endless_more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: var(--hl-sp-4) var(--hl-sp-10);
  border: 1px solid var(--hl-brand);
  border-radius: var(--hl-radius);
  background: var(--hl-surface);
  color: var(--hl-brand);
  font-size: var(--hl-fs-base);
  font-weight: 600;
  text-decoration: none;
  transition:
    background-color var(--hl-dur-fast) var(--hl-ease),
    box-shadow var(--hl-dur) var(--hl-ease),
    transform var(--hl-dur-fast) var(--hl-ease);
}

/* глобальный .button_outline рисует ::after-иконку — здесь она лишняя */
.health-library-page .endless_more::after,
.health-library-page .endless_more::before { content: none; }

.health-library-page .endless_more:active { transform: scale(0.985); }

.health-library-page .endless_loading {
  padding: var(--hl-sp-4);
  color: var(--hl-muted);
  font-size: var(--hl-fs-sm);
}

/* ═════════════════════════════ карточка ════════════════════════════════ */

.health-library-page .hl-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  overflow: hidden;
  border: 1px solid var(--hl-line);
  border-radius: var(--hl-radius-lg);
  background: var(--hl-surface);
  transition:
    box-shadow var(--hl-dur) var(--hl-ease),
    transform var(--hl-dur) var(--hl-ease);
}

.health-library-page .hl-card__img {
  position: relative;
  display: block;
  flex: 0 0 auto;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--hl-brand-soft);
}

.health-library-page .hl-card__img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.health-library-page .hl-card__info {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  padding: var(--hl-sp-5);
}

.health-library-page .hl-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--hl-sp-2) var(--hl-sp-3);
  align-items: center;
  margin-bottom: var(--hl-sp-3);
}

.health-library-page .hl-card__cat {
  padding: var(--hl-sp-1) var(--hl-sp-3);
  border-radius: 999px;
  background: var(--hl-brand-soft);
  color: var(--hl-brand);
  font-size: var(--hl-fs-2xs);
  font-weight: 600;
}

.health-library-page .hl-card__date {
  color: var(--hl-muted);
  font-size: var(--hl-fs-2xs);
}

.health-library-page .hl-card__title {
  margin: 0 0 var(--hl-sp-3);
  color: var(--hl-ink);
  font-size: var(--hl-fs-h3);
  font-weight: 600;
  letter-spacing: var(--hl-ls-head);
  line-height: var(--hl-lh-snug);
}

.health-library-page a:hover .hl-card__title { color: var(--hl-brand); }

.health-library-page .hl-card__text {
  display: -webkit-box;
  overflow: hidden;
  margin: 0 0 var(--hl-sp-5);
  color: var(--hl-body);
  font-size: var(--hl-fs-sm);
  line-height: var(--hl-lh-base);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

/* margin-top:auto выравнивает ссылки по нижнему краю во всех карточках ряда */
.health-library-page .hl-card__link {
  margin-top: auto;
  color: var(--hl-brand);
  font-size: var(--hl-fs-sm);
  font-weight: 600;
  text-decoration: none;
}

.health-library-page .hl-card__link:hover { text-decoration: underline; }

/* ═══════════════════════════ пустое состояние ══════════════════════════ */

.health-library-page .hl-empty {
  grid-column: 1 / -1;
  padding: var(--hl-sp-16) var(--hl-sp-6);
  border: 1px dashed var(--hl-line);
  border-radius: var(--hl-radius-lg);
  background: var(--hl-surface-soft);
  text-align: center;
}

.health-library-page .hl-empty__title {
  margin: 0 0 var(--hl-sp-2);
  color: var(--hl-ink);
  font-size: var(--hl-fs-lead);
  font-weight: 600;
}

.health-library-page .hl-empty p {
  margin: 0 0 var(--hl-sp-5);
  color: var(--hl-muted);
  font-size: var(--hl-fs-sm);
}

.health-library-page .hl-empty a {
  color: var(--hl-brand);
  font-weight: 600;
}

@media (min-width: 768px) {
  .health-library-page { --hl-gap-grid: var(--hl-sp-6); --hl-sp-section: var(--hl-sp-20); }
  .health-library-page .hl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .health-library-page .hl-card__info { padding: var(--hl-sp-6); }
}

@media (min-width: 992px) {
  .health-library-page .hl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.health-library-page .hl-tabs__list { flex-wrap: wrap; }
.health-library-page .hl-tabs__list a { white-space: normal; min-height: 36px; }
.health-library-page .hl-card__link { display: inline-flex; align-items: center; min-height: 44px; }

@media (max-width: 767.98px) {
  .health-library-page .hl-section { padding-top: var(--hl-sp-6); }
  .health-library-page .hl-head { flex-direction: column; align-items: flex-start; }
  .health-library-page .endless_more { width: 100%; }
}

/* ── микровзаимодействия: только там, где есть настоящий курсор ── */

@media (hover: hover) and (pointer: fine) {
  .health-library-page .hl-card:hover {
    box-shadow: 0 14px 36px rgba(0, 86, 102, 0.16);
    transform: translateY(-3px);
  }



  .health-library-page .hl-tabs__list a:not(.is-active):hover {
    border-color: var(--hl-brand-tint);
    background: var(--hl-brand-soft);
    color: var(--hl-brand);
  }

  .health-library-page .endless_more:hover {
    background: var(--hl-brand-soft);
    box-shadow: 0 8px 22px rgba(0, 86, 102, 0.12);
    color: var(--hl-brand);
    text-decoration: none;
  }
}

/* ═══════════════════════════════ анимации ══════════════════════════════ */

/* Класс hl-anim вешает JS. Без него (и у краулеров) контент виден сразу. */
.hl-anim .hl-reveal {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity var(--hl-dur-slow) var(--hl-ease),
    transform var(--hl-dur-slow) var(--hl-ease);
  transition-delay: calc(var(--i, 0) * 70ms);
  will-change: opacity, transform;
}

.hl-anim .hl-reveal.is-in {
  opacity: 1;
  transform: none;
  will-change: auto;
}

/* ─────────────────────── уважение к настройкам ОС ──────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .health-library-page *,
  .health-library-page *::before,
  .health-library-page *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }

  .hl-anim .hl-reveal { opacity: 1; transform: none; }
}
