/* ===========================================
   SECTIONS — Контентные блоки и футер
   =========================================== */

/* === DIRECTIONS (Направления медицины) === */
.directions {
  background: transparent;
}

.directions__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
/* .section__header - общий класс (margin-bottom:48px, база.css), рассчитан
   на обычные секции, где он стоит сам и margin-bottom - это и есть отступ
   до контента. Здесь он сосед .tabs во flex-строке: его собственный
   margin-bottom всё равно входит в margin-box строки и держит высоту, даже
   когда margin-bottom самого .directions__head обнулён - поэтому гасим его
   ТОЛЬКО в этом месте (общий класс в других секциях не трогаем). */
.directions__head .section__header { margin-bottom: 0; }

.directions__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.directions__grid--secondary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
}

.directions__more {
  display: flex;
  justify-content: center;
  margin-top: var(--sp-8);
}

/* === CERTIFICATES (Справки и медосмотры) === */
.certificates {
  background: transparent;
}

.certificates__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-5);
  perspective: 1400px;
}

/* === PROGRAMS (Годовые программы) === */
.programs {
  background: transparent;
}

.programs__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-6);
  align-items: start;
  max-width: 1000px;
  margin: 0 auto;
}

/* === ABOUT (О поликлинике) === */
.about {
  background: transparent;
}

.about__content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-12);
  margin-bottom: var(--sp-4);
}

.about__text {
  font-size: var(--text-base);
  color: var(--slate-light);
  line-height: 1.8;
  max-width: 500px;
}

.about__text p {
  margin-bottom: var(--sp-4);
}

.about__badges {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  align-content: start;
}

.about__stats {
  display: flex;
  gap: var(--sp-5);
  justify-content: center;
}

.about__stat-box {
  background: var(--bg-section);
  border-radius: var(--radius-md);
  padding: var(--sp-5) var(--sp-6);
  text-align: center;
  min-width: 140px;
}

/* === SEARCH (Поиск по сценариям) === */
.search-section {
  background: transparent;
}

.search-section__bar {
  max-width: 800px;
  margin: 0 auto var(--sp-6);
  position: relative;
}

/* Только прямой потомок: внутри бара лежит ещё и выпадающий список подсказок */
.search-section__bar > svg {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--slate-pale);
}

.search-section__bar input {
  width: 100%;
  height: 56px;
  padding: 0 28px 0 56px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: var(--text-md);
  color: var(--slate);
  transition: all var(--t-base) var(--ease-out);
  box-shadow: var(--shadow-sm);
}

.search-section__bar input::placeholder {
  color: var(--slate-pale);
}

.search-section__bar input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(26,172,209,0.12), var(--shadow-md);
}

.search-section__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: center;
}

/* === DOCTORS (Наши лучшие врачи) === */
.doctors {
  background: transparent;
}

.doctors__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-8);
}

.doctors__more {
  display: flex;
  justify-content: center;
  margin-top: var(--sp-8);
}

/* === NEWS (Новости) === */
.news {
  background: transparent;
}

.news__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-8);
}

/* === PROMOS (Акции) === */
.promos {
  background: transparent;
}

.promos__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-8);
}

/* === ADVANTAGES (Преимущества) === */
.advantages {
  background: transparent;
  padding: var(--sp-16) 0;
}

.advantages__label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--slate-pale);
  margin-bottom: var(--sp-8);
}

.advantages__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-8);
}

/* === FOOTER === */
.footer {
  background: linear-gradient(135deg, #1a3766 0%, #244c8a 50%, #2f63ad 100%);
  color: rgba(255,255,255,0.7);
  padding: var(--sp-16) 0 var(--sp-8);
}

.footer__top {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-12);
  padding-bottom: var(--sp-10);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.footer__heading {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--white);
  margin-bottom: var(--sp-5);
}

.footer__list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.footer__link {
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.6);
  transition: color var(--t-fast);
}

.footer__link:hover {
  color: var(--sky);
}

.footer__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--sp-6);
  flex-wrap: wrap;
  gap: var(--sp-4);
}

.footer__copy {
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.4);
}

.footer__socials {
  display: flex;
  gap: var(--sp-3);
}

.footer__social {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.5);
  transition: all var(--t-fast);
  font-size: var(--text-xs);
  font-weight: 700;
}

.footer__social:hover {
  border-color: var(--sky);
  color: var(--sky);
  background: rgba(109,209,233,0.1);
}

/* === Decorative section dividers === */
.section-divider {
  position: relative;
  overflow: hidden;
}

.section-divider::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--sky));
  border-radius: 2px;
}

/* === THEME SWITCH === */
.theme-switch {
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-pill);
  padding: 2px;
  border: 1px solid rgba(255,255,255,0.1);
}
.theme-switch__btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.4);
  transition: all var(--t-base);
  cursor: pointer;
}
.theme-switch__btn:hover {
  color: rgba(255,255,255,0.8);
}
.theme-switch__btn--active {
  background: rgba(255,255,255,0.15);
  color: var(--white);
}
/* Icons */
.theme-switch__btn svg {
  width: 16px;
  height: 16px;
}

/* === Override серого текста на чёрный во всех секциях под hero === */
.section,
.section .dir-card__sub,
.section .cert-card__title,
.section .cert-card__text,
.section .cert-card__meta,
.section .cert-card__badge,
.section .program-card__text,
.section .about__text,
.section .advantages__label,
.section .advantage__text,
.section .section__subtitle,
.section .news__meta,
.section .news__excerpt,
.section .promo__text,
.section .doctor-card__spec,
.section .doctor-card__meta {
  color: #000;
}
/* Панели вкладок секции направлений */
.directions__panel { display: none; }
.directions__panel--active { display: block; }

/* Появление панели при переключении вкладки кликом (класс --anim ставит JS).
   CSS-анимации перезапускаются при display:none -> block, поэтому каскад
   отрабатывает на каждое переключение. При первой загрузке страницы класса
   нет - карточки появляются штатным scroll-reveal.
   fill-mode backwards (не both): после завершения анимация отпускает
   свойства, иначе она блокировала бы hover-transform карточек */
@keyframes dir-panel-in {
  from { opacity: 0; transform: translateY(12px); }
}

@keyframes dir-card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
}

.directions__panel--anim.directions__panel--active {
  animation: dir-panel-in 0.4s var(--ease-smooth) backwards;
}

.directions__panel--anim.directions__panel--active .dir-card {
  animation: dir-card-in 0.45s var(--ease-smooth) backwards;
}

/* Каскад: верхний ряд слева направо, нижний следом */
.directions__panel--anim .directions__grid .dir-card:nth-child(1) { animation-delay: 0.03s; }
.directions__panel--anim .directions__grid .dir-card:nth-child(2) { animation-delay: 0.08s; }
.directions__panel--anim .directions__grid .dir-card:nth-child(3) { animation-delay: 0.13s; }
.directions__panel--anim .directions__grid .dir-card:nth-child(4) { animation-delay: 0.18s; }
.directions__panel--anim .directions__grid--secondary .dir-card:nth-child(1) { animation-delay: 0.15s; }
.directions__panel--anim .directions__grid--secondary .dir-card:nth-child(2) { animation-delay: 0.20s; }
.directions__panel--anim .directions__grid--secondary .dir-card:nth-child(3) { animation-delay: 0.25s; }
.directions__panel--anim .directions__grid--secondary .dir-card:nth-child(4) { animation-delay: 0.30s; }

/* === Блок «Все направления от А до Я» (раскрывается кнопкой) === */
/* Высоту 0 -> scrollHeight -> auto анимирует JS (initAllDirections);
   visibility убирает скрытые ссылки из tab-порядка */
.directions__all {
  height: 0;
  opacity: 0;
  overflow: hidden;
  visibility: hidden;
  transition: height 0.55s var(--ease-smooth),
              opacity 0.45s var(--ease-smooth),
              visibility 0s linear 0.55s;
}

.directions__all--open {
  opacity: 1;
  visibility: visible;
  transition: height 0.55s var(--ease-smooth),
              opacity 0.45s var(--ease-smooth) 0.05s;
}

.directions__all-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-xl);
  color: var(--slate);
  padding-top: var(--sp-8);
  margin-bottom: var(--sp-5);
}

/* Вкладка «Направления» открывает список всех направлений БЕЗ видимой
   панели над ним (см. initTabs в app.js) - отступ здесь чуть теснее
   базового (выше), но тоже не нулевой. */
.directions--all-only .directions__head { margin-bottom: var(--sp-4); }
.directions--all-only .directions__all-title { padding-top: var(--sp-4); }

/* Колонки, а не grid: алфавит читается сверху вниз по колонке */
.directions__all-list {
  column-count: 4;
  column-gap: var(--sp-3);
}

/* Компактная карточка направления */
.dir-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  width: 100%;
  margin-bottom: var(--sp-3);
  padding: 11px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  break-inside: avoid;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--slate);
  transition: border-color var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out),
              transform var(--t-fast) var(--ease-out),
              color var(--t-fast) var(--ease-out);
}

.dir-mini svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--cyan);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--t-fast) var(--ease-out),
              transform var(--t-fast) var(--ease-out);
}

.dir-mini:hover {
  border-color: var(--cyan);
  color: var(--navy);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.dir-mini:hover svg {
  opacity: 1;
  transform: translateX(0);
}

/* Каскадное появление карточек при раскрытии: задержка по порядковому
   номеру --i из разметки; backwards - см. комментарий у dir-card-in */
@keyframes dir-mini-in {
  from { opacity: 0; transform: translateY(14px); }
}

.directions__all--open .dir-mini {
  animation: dir-mini-in 0.45s var(--ease-smooth) backwards;
  animation-delay: calc(var(--i, 0) * 16ms);
}

/* Шеврон кнопки «Все направления» */
#allDirectionsToggle .dirs-more-chevron {
  transition: transform var(--t-base) var(--ease-out);
}

#allDirectionsToggle.btn--dirs-open .dirs-more-chevron {
  transform: rotate(180deg);
}

/* Акцентный подзаголовок. !important нужен против
   ".container p { color:#000 !important }" из tableprice.css */
.section .section__subtitle--accent {
  font-weight: 700;
  color: rgb(246, 16, 125) !important;
}
.section .cert-card:hover .cert-card__title { color: #ffffff; }
.section .cert-card:hover .cert-card__text { color: rgba(255, 255, 255, 0.9); }
.section .cert-card:hover .cert-card__meta { color: rgba(255, 255, 255, 0.75); }
.section .cert-card:hover .cert-card__badge,
.section .cert-card:hover .cert-card__link { color: var(--sky); }
