/* Е-Пептиды: справочник /spravochnik/ (inc/spravochnik.php) и блок рубрик «По действующим свойствам»
   (template-parts/ep-cats-grid.php, раздел «Блок рубрик» ниже — классы ep-cats-*, переносится отдельно).
   Крошки, H1 и лид — ep-pages.css; токены, кнопка Telegram и «Подробнее →» — ep-base.css. */

/* ===== Справочник ===== */

:root:has(.ep-spr) { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  :root:has(.ep-spr) { scroll-behavior: auto; }
}

.ep-spr__intro { max-width: 68ch; margin-bottom: 32px; }
.ep-spr__intro .ep-lead { margin-bottom: 14px; }
.ep-spr__intro p:last-child { margin-bottom: 0; color: var(--ep-ink-2); }

/* Разделы: переход к группе. На ПК прилипает к верху окна, пока листаете плитки. */
.ep-spr__nav {
  position: sticky; top: 0; z-index: 5; margin: 0 -20px; padding: 12px 20px;
  background: var(--ep-bg); border-bottom: 1px solid var(--ep-line);
}
.ep-spr__nav-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ep-spr__nav a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--ep-line); border-radius: var(--ep-radius);
  color: var(--ep-ink); font-size: 15px; text-decoration: none; white-space: nowrap;
  transition: border-color .15s var(--ep-ease);
}
.ep-spr__nav a span { color: var(--ep-muted); font-variant-numeric: tabular-nums; }
.ep-spr__nav a:hover { border-color: var(--ep-ink-2); }

/* Группа: заголовок раздела и плитки */
.ep-spr__group { padding-top: 40px; scroll-margin-top: 72px; }
.ep-spr__group-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 24px; margin-bottom: 18px; }
.ep-spr__group-h { margin: 0; font-size: var(--ep-h2); }

.ep-spr__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
/* Разделы идут сеткой той же колонки, что и плитки: большой раздел на всю ширину, маленькие (1–3 товара) встают в ряд. */
.ep-spr__groups { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 20px; }
.ep-spr__group { grid-column: 1 / -1; min-width: 0; display: flex; flex-direction: column; }
.ep-spr__group .ep-spr__grid { flex: 1 0 auto; } /* в ряду маленьких разделов плитки тянутся до самой высокой, кнопки внизу */
.ep-spr__group--n1 { grid-column: span 1; }
.ep-spr__group--n2 { grid-column: span 2; }
.ep-spr__group--n3 { grid-column: span 3; }
.ep-spr__group--n1 .ep-spr__grid { grid-template-columns: minmax(0, 1fr); }
.ep-spr__group--n2 .ep-spr__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ep-spr__group--n3 .ep-spr__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Плитка: фото, название, что это, характеристики, внизу цена и действия. */
.ep-spr__card {
  display: flex; flex-direction: column; min-width: 0; padding: 0 0 20px;
  border: 1px solid var(--ep-line); border-radius: var(--ep-radius); background: var(--ep-bg);
  scroll-margin-top: 72px;
}
.ep-spr__media {
  position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden;
  border-radius: var(--ep-radius) var(--ep-radius) 0 0; background: var(--ep-soft);
}
.ep-spr__img { position: absolute; inset: 8% 0; width: 100%; height: 84%; object-fit: contain; transition: transform .4s var(--ep-ease); }
.ep-spr__noimg { display: block; width: 100%; height: 100%; }

.ep-spr__name { margin: 16px 18px 0; font-size: 18px; line-height: 1.3; }
.ep-spr__name a { color: var(--ep-ink); text-decoration: none; }
.ep-spr__name a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.ep-spr__kind { color: var(--ep-ink-2); font-weight: 400; }
.ep-spr__alt { color: var(--ep-muted); font-weight: 400; font-size: 16px; }

.ep-spr__def {
  margin: 10px 18px 0; color: var(--ep-ink-2); font-size: 15px; line-height: 1.55;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; line-clamp: 5; overflow: hidden;
}

.ep-spr__spec { display: grid; gap: 4px; margin: 14px 18px 0; padding-top: 12px; border-top: 1px solid var(--ep-line); font-size: 14px; line-height: 1.45; }
.ep-spr__spec > div { display: grid; grid-template-columns: 104px minmax(0, 1fr); column-gap: 12px; }
.ep-spr__spec dt { color: var(--ep-muted); }
.ep-spr__spec dd { margin: 0; color: var(--ep-ink); overflow-wrap: anywhere; }
.ep-spr__part { display: block; }
.ep-spr__part + .ep-spr__part { margin-top: 2px; }
.ep-spr__part-h { color: var(--ep-ink-2); font-weight: 700; }

.ep-spr__buy { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: auto 18px 0; padding-top: 18px; }
.ep-spr__price { flex: 1 0 100%; margin: 0; font-size: 21px; line-height: 1.2; }
.ep-spr__order { flex: none; }
.ep-spr__more { min-height: 44px; font-size: 16px; }

@media (hover: hover) and (pointer: fine) {
  .ep-spr__card:hover .ep-spr__img { transform: scale(1.04); }
}

.ep-spr__empty { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 32px 0; color: var(--ep-ink-2); }

@media (max-width: 1199px) {
  .ep-spr__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ep-spr__groups { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  .ep-spr__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ep-spr__groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ep-spr__group--n3 { grid-column: 1 / -1; }
  .ep-spr__group--n3 .ep-spr__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .ep-spr__nav { position: static; margin: 0; padding: 0 0 4px; border-bottom: 0; overflow-x: auto; }
  .ep-spr__nav-list { flex-wrap: nowrap; padding-bottom: 8px; }
  .ep-spr__group { padding-top: 32px; scroll-margin-top: 12px; }
  .ep-spr__grid, .ep-spr__group[class*="--n"] .ep-spr__grid { grid-template-columns: 1fr; gap: 16px; }
  .ep-spr__groups { display: block; }
  .ep-spr__name { margin: 14px 16px 0; font-size: 18px; }
  .ep-spr__def { margin: 8px 16px 0; }
  .ep-spr__spec { margin: 12px 16px 0; }
  .ep-spr__spec > div { grid-template-columns: 104px minmax(0, 1fr); }
  .ep-spr__buy { margin: auto 16px 0; }
  .ep-spr__order { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .ep-spr__img, .ep-spr__nav a { transition: none; }
}

/* ===== Блок рубрик «По действующим свойствам» (template-parts/ep-cats-grid.php) =====
   Переносимый: только классы ep-cats-*, токены из ep-base.css. */

.ep-cats { margin-top: 72px; }
.ep-cats__head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px;
  margin-bottom: 20px;
}
.ep-cats__h { margin: 0; font-size: var(--ep-h2); }
.ep-cats__more { min-height: 44px; }

.ep-cats__grid {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 24px 20px;
  margin: 0; padding: 0; list-style: none;
}
.ep-cats__item { position: relative; display: flex; flex-direction: column; min-width: 0; }

/* Подложка как у плитки товара; флаконы стоят на одной линии, главный впереди и выше. */
.ep-cats__media {
  position: relative; aspect-ratio: 1; margin-bottom: 12px; overflow: hidden;
  background: var(--ep-soft); border-radius: var(--ep-radius);
}
.ep-cats__img {
  position: absolute; bottom: 9%; left: 50%; width: auto; height: 80%; max-width: none;
  object-fit: contain; translate: -50% 0;
  transition: scale .4s var(--ep-ease), translate .4s var(--ep-ease);
  transform-origin: 50% 100%;
}
.ep-cats__img--c { z-index: 2; }
.ep-cats__media--2 .ep-cats__img { height: 74%; }
.ep-cats__media--2 .ep-cats__img--c { left: 40%; }
.ep-cats__media--2 .ep-cats__img--l { left: 62%; z-index: 1; }
.ep-cats__media--3 .ep-cats__img--c { height: 78%; }
.ep-cats__media--3 .ep-cats__img--l { left: 31%; height: 64%; z-index: 1; }
.ep-cats__media--3 .ep-cats__img--r { left: 69%; height: 64%; z-index: 1; }

.ep-cats__name { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.3; text-wrap: balance; }
.ep-cats__link { color: var(--ep-ink); text-decoration: none; }
/* Растянутая ссылка: вся плитка ведёт в рубрику. */
.ep-cats__link::after { content: ""; position: absolute; inset: 0; z-index: 3; }
.ep-cats__link:focus-visible { outline: none; }
.ep-cats__link:focus-visible::after { outline: 2px solid var(--ep-tg); outline-offset: 4px; border-radius: var(--ep-radius); }
.ep-cats__count { margin: 2px 0 0; color: var(--ep-muted); font-size: var(--ep-small); font-variant-numeric: tabular-nums; }

@media (hover: hover) and (pointer: fine) {
  .ep-cats__item:hover .ep-cats__link { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
  .ep-cats__item:hover .ep-cats__img--c { scale: 1.04; }
  .ep-cats__item:hover .ep-cats__img--l { translate: -56% 0; }
  .ep-cats__item:hover .ep-cats__img--r { translate: -44% 0; }
}

@media (max-width: 1023px) {
  .ep-cats__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .ep-cats { margin-top: 48px; }
  .ep-cats__head { margin-bottom: 16px; }
  .ep-cats__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
  .ep-cats__media { margin-bottom: 10px; }
  .ep-cats__name { font-size: 16px; }
}

/* ===== Страница вещества /spravochnik/<слаг>/ (single-ep_substance.php) =====
   Верх — как у карточки товара (ep-product.css): заглушка вместо фото, «Нет в наличии» вместо цены.
   Сразу под ним «Рекомендуем», описание — в самом конце. */
.ep-sub__lat { color: var(--ep-muted); font-weight: 400; }
.ep-sub__ph-box {
  aspect-ratio: 1 / 1; display: grid; place-content: center; gap: 8px; padding: 32px;
  text-align: center; background: var(--ep-soft); border: 1px solid var(--ep-line); border-radius: var(--ep-radius);
}
.ep-sub__ph-name { font-size: clamp(30px, 4vw, 46px); font-weight: 700; line-height: 1.1; color: var(--ep-ink-2); overflow-wrap: anywhere; }
.ep-sub__ph-lat { font-size: 17px; color: var(--ep-muted); }
.ep-sub__out { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; font-weight: 700; color: var(--ep-muted); }
.ep-sub__lead { margin: 0 0 16px; max-width: 46ch; font-size: 16px; line-height: 1.5; color: var(--ep-ink-2); }
.ep-sub__jump { max-width: 520px; margin: 0 0 12px; }
.ep-sub__jump a {
  display: flex; align-items: center; justify-content: center; min-height: 54px; padding: 0 24px;
  border: 1.5px solid var(--ep-ink); border-radius: var(--ep-radius); color: var(--ep-ink);
  font-weight: 700; font-size: 17px; text-decoration: none;
  transition: background-color .2s var(--ep-ease), transform .12s var(--ep-ease);
}
.ep-sub__jump a:hover { background: var(--ep-soft); }
.ep-sub__jump a:active { transform: scale(.98); }
.ep-sub__rel { margin-top: 56px; scroll-margin-top: 24px; }
.ep-sub__rel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; margin-bottom: 20px; }
.ep-sub__rel-head h2 { margin: 0; font-size: var(--ep-h2); }
.ep-sub__rel .ep-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } /* 4 товара — одна полная строка */
.ep-sub__body { margin-top: 64px; padding-top: 40px; border-top: 1px solid var(--ep-line); }
.ep-sub__text { max-width: 70ch; font-size: 17px; line-height: 1.65; }
.ep-sub__src { max-width: 70ch; margin-top: 32px; }
@media (max-width: 1023px) {
  .ep-sub__rel .ep-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .ep-sub__ph-box { aspect-ratio: 3 / 1; padding: 16px; }
  .ep-sub__ph-name { font-size: 26px; }
  .ep-sub__rel { margin-top: 40px; }
  .ep-sub__body { margin-top: 44px; padding-top: 28px; }
}

/* Список веществ без товара на /spravochnik/ */
.ep-spr__other { margin-top: 64px; padding-top: 40px; border-top: 1px solid var(--ep-line); }
.ep-spr__other-h { margin: 0 0 8px; font-size: var(--ep-h2); }
.ep-spr__other-note { margin: 0 0 28px; max-width: 70ch; color: var(--ep-ink-2); }
.ep-spr__other-group + .ep-spr__other-group { margin-top: 28px; }
.ep-spr__other-gh { margin: 0 0 12px; font-size: 18px; }
.ep-spr__other-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 24px; margin: 0; padding: 0; list-style: none; }
.ep-spr__other-list a { color: var(--ep-ink); text-underline-offset: 3px; }
.ep-spr__other-p { color: var(--ep-muted); font-size: 14px; }
@media (max-width: 1023px) { .ep-spr__other-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) { .ep-spr__other { margin-top: 44px; } .ep-spr__other-list { grid-template-columns: 1fr; } }

/* Карточка вещества без товара: состояние вместо цены */
.ep-sub__status { display: inline-flex; align-items: center; gap: 8px; margin: 16px 0 0; color: var(--ep-muted); font-size: 15px; font-weight: 700; }
.ep-sub__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .5; }
.ep-sub__alias { margin: 0; font-size: 15px; color: var(--ep-ink-2); }
