/*
 * Каркас темы «Территория здоровья».
 * Переменные --tz-* приходят из PHP (tz_css_variables(tz_design_tokens())) — один источник правды,
 * значения описаны в design.md. Здесь только поведение: сетка, шапка, меню, подвал, 404.
 * Верстаем сразу в двух форматах: десктоп 1440/1200 и телефон 390 (проверка на 360).
 */

/* --- Запасные значения на случай, если inline-переменные не доехали ---------- */
:root {
  --tz-color-bg: #fff;
  --tz-color-ink: #2f4c54;
  --tz-color-primary: #816cd7;
  --tz-layout-content: 1136px;
  --tz-layout-header: 76px;
  --tz-layout-header-sm: 64px;
  --tz-layout-gutter: 32px;
  --tz-layout-gutter-sm: 16px;
  --tz-header-h: var(--tz-layout-header);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--tz-header-h) + 16px);
}

body.tz-body {
  margin: 0;
  background: var(--tz-color-bg);
  color: var(--tz-color-ink);
  font-family: var(--tz-font-sans, "Manrope", system-ui, sans-serif);
  font-size: 18px;
  line-height: 1.5;
  overflow-x: hidden; /* на 360px ничего не должно уезжать вбок */
}

img, svg, video { max-width: 100%; height: auto; }
a { color: inherit; }
a:hover { color: var(--tz-color-primary); }

h1, h2 {
  font-family: var(--tz-font-serif, "Times New Roman", serif);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin: 0 0 var(--tz-space-5, 24px);
}

h1, .tz-h1 { font-size: clamp(32px, 4.6vw, 55px); font-family: var(--tz-font-serif, "Times New Roman", serif); font-weight: 400; text-transform: uppercase; line-height: 1.05; }
h2 { font-size: clamp(28px, 3.4vw, 40px); }
h3 { font-size: clamp(22px, 2.4vw, 30px); font-weight: 500; line-height: 1.2; margin: 0 0 var(--tz-space-3, 12px); }

.tz-lead { font-size: clamp(17px, 1.6vw, 20px); color: var(--tz-color-ink); }
.tz-muted { color: var(--tz-color-muted, #92a1a7); }

:where(a, button, input, [tabindex]):focus-visible {
  outline: 3px solid var(--tz-color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%);
  white-space: nowrap;
}

.tz-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--tz-color-primary);
  color: #fff;
  padding: 12px 20px;
  border-radius: 0 0 8px 0;
}
.tz-skip-link:focus { left: 0; color: #fff; }

/* --- Сетка ------------------------------------------------------------------ */
.tz-container {
  width: 100%;
  /* 1136 + 32 + 32 = 1200 — ровно как в макете */
  max-width: calc(var(--tz-layout-content, 1136px) + var(--tz-layout-gutter, 32px) * 2);
  margin-inline: auto;
  padding-inline: var(--tz-layout-gutter, 32px);
}

.tz-section { padding-block: var(--tz-space-9, 96px); }
.tz-main { display: block; }

/* --- Кнопки ----------------------------------------------------------------- */
.tz-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;           /* ≥44px — правило G24 */
  padding: 12px 24px;
  border: 0;
  border-radius: var(--tz-radius-pill, 999px);
  font: 500 16px/1.2 var(--tz-font-sans, "Manrope", sans-serif);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}

.tz-btn--primary { background: var(--tz-color-primary); color: var(--tz-color-on-primary, #fff); }
.tz-btn--primary:hover { background: var(--tz-color-primary-hover, #6e58cc); color: #fff; }
.tz-btn--ghost { background: transparent; color: var(--tz-color-ink); box-shadow: inset 0 0 0 1px var(--tz-color-tint, #e8edfb); }
.tz-btn--block { width: 100%; }

.tz-icon { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.5; fill: none; flex: none; }
.tz-icon--sm { width: 16px; height: 16px; }

/* --- Шапка: закреплена, размер не меняется --------------------------------- */
/* Содержимое, уезжающее под шапку, размывается и слегка затемняется (как в iOS). */
.tz-header[data-tz-sticky] {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--tz-header-h);
  background: rgba(255, 255, 255, .72);
  border-bottom: 1px solid rgba(47, 76, 84, .08);
  -webkit-backdrop-filter: blur(16px) saturate(140%) brightness(.96);
  backdrop-filter: blur(16px) saturate(140%) brightness(.96);
}

@supports not (backdrop-filter: blur(4px)) {
  .tz-header[data-tz-sticky] { background: #fff; }
}

.tz-header__inner {
  display: flex;
  align-items: center;
  gap: var(--tz-space-5, 24px);
  height: 100%;
}

.tz-logo { display: inline-flex; align-items: center; flex: none; }
.tz-logo__img { display: block; width: auto; height: 34px; }

/* Меню шапки: строка пунктов + кнопка «Ещё» для тех, кому места не хватило.
   Контейнер шире 1200 px не растёт, поэтому длинное меню не «поместится само»
   ни на 1920, ни на 2560 — лишнее уводится под «Ещё» скриптом site.js. */
.tz-header__nav {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tz-nav__list {
  display: flex;
  flex-wrap: nowrap;        /* меню шапки всегда в одну строку: высота шапки не меняется */
  align-items: center;
  gap: clamp(8px, 1vw, 18px);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Страховка на случай, когда скрипт не отработал: лишний пункт обрезается по
   рамке меню, а не рисуется поверх телефона. Поля с отрицательным полем —
   чтобы обрезка не съедала кольцо фокуса у крайних пунктов. */
.tz-header__nav .tz-nav__list {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  padding: 6px 4px;
  margin: -6px -4px;
}

.tz-nav__more { position: relative; flex: none; }
.tz-nav__more[hidden] { display: none; }

.tz-nav__more-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: inherit;
  font: 500 15px/1.2 var(--tz-font-sans, "Manrope", sans-serif);
  white-space: nowrap;
  cursor: pointer;
}
.tz-nav__more-btn:hover { color: var(--tz-color-primary); }
.tz-nav__more-icon { transition: transform .15s ease; }
.tz-nav__more-btn[aria-expanded="true"] .tz-nav__more-icon { transform: rotate(180deg); }

.tz-nav__panel {
  position: absolute;
  inset-block-start: calc(100% + 10px);
  inset-inline-end: 0;
  z-index: 101;
  min-width: 200px;
  margin: 0;
  padding: 8px 0;
  list-style: none;
  background: var(--tz-color-bg, #fff);
  border-radius: var(--tz-radius-md, 16px);
  box-shadow: 0 14px 34px rgba(47, 76, 84, .16);
}
.tz-nav__panel[hidden] { display: none; }
.tz-nav__panel .tz-nav__link { display: block; padding: 10px 20px; font-size: 15px; }
.tz-nav__panel .tz-nav__link:hover { background: var(--tz-color-surface, #f6f6fb); }

.tz-nav__link {
  display: inline-block;
  padding: 6px 2px;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.tz-header__actions { display: flex; align-items: center; gap: var(--tz-space-4, 16px); flex: none; }

.tz-phone { font-size: 15px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.tz-phone--lg { font-family: var(--tz-font-serif, "Times New Roman", serif); font-size: clamp(28px, 4vw, 45px); }

.tz-header__cta { white-space: nowrap; }

/* Бургер — только на телефоне и планшете */
.tz-burger {
  display: none;
  width: 48px; height: 48px;
  align-items: center; justify-content: center;
  background: transparent; border: 0; cursor: pointer;
  margin-inline-start: auto;
}
.tz-burger__icon { display: grid; gap: 5px; width: 24px; }
.tz-burger__icon span { display: block; height: 2px; background: var(--tz-color-ink); border-radius: 2px; }

/* --- Мобильное меню --------------------------------------------------------- */
.tz-menu {
  position: fixed;
  inset: var(--tz-header-h) 0 0;
  z-index: 99;
  background: var(--tz-color-bg, #fff);
  overflow-y: auto;
  padding: var(--tz-space-6, 32px) 0 var(--tz-space-8, 64px);
}
.tz-menu[hidden] { display: none; }
.tz-menu__inner { max-width: 600px; margin-inline: auto; padding-inline: var(--tz-layout-gutter-sm, 16px); }

.tz-nav__list--mobile { flex-direction: column; align-items: stretch; gap: 0; }
.tz-nav__list--mobile > li { border-bottom: 1px solid var(--tz-color-tint, #e8edfb); }
.tz-nav__list--mobile .tz-nav__link { display: block; padding: 16px 4px; font-size: 20px; white-space: normal; }

.tz-menu__contacts { margin-top: var(--tz-space-6, 32px); display: grid; gap: var(--tz-space-4, 16px); justify-items: start; }
.tz-menu__hours { margin: 0; color: var(--tz-color-muted, #92a1a7); font-size: 15px; }
body.tz-menu-open { overflow: hidden; }

/* --- Карточки и списки ------------------------------------------------------ */
.tz-list { display: grid; gap: var(--tz-space-5, 24px); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.tz-card { background: var(--tz-color-card, #f2f4ff); border-radius: var(--tz-radius-lg, 24px); padding: var(--tz-space-5, 24px); }
.tz-card__title { font-size: clamp(20px, 2vw, 26px); margin: 0 0 8px; font-family: var(--tz-font-sans, sans-serif); font-weight: 500; text-transform: none; }
.tz-prose { max-width: 75ch; }
.tz-prose :where(p, ul, ol) { font-size: 18px; }

/* --- Поиск ------------------------------------------------------------------ */
.tz-search { display: flex; flex-wrap: wrap; gap: 12px; max-width: 560px; }
.tz-search__input {
  flex: 1 1 220px;
  min-height: 48px;
  padding: 12px 20px;
  border: 1px solid var(--tz-color-tint, #e8edfb);
  border-radius: var(--tz-radius-pill, 999px);
  background: var(--tz-color-surface, #f6f6fb);
  font: 400 16px/1.3 var(--tz-font-sans, sans-serif);
  color: var(--tz-color-ink);
}
.tz-search__input::placeholder { color: var(--tz-color-muted, #92a1a7); }

/* --- 404 -------------------------------------------------------------------- */
.tz-404__inner { display: grid; gap: var(--tz-space-5, 24px); max-width: 760px; }
.tz-404__code {
  margin: 0;
  font-family: var(--tz-font-serif, "Times New Roman", serif);
  font-size: clamp(64px, 12vw, 140px);
  line-height: 1;
  color: var(--tz-color-tint, #e8edfb);
}
.tz-404__links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 12px; }
.tz-404__link {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 10px 20px;
  background: var(--tz-color-card, #f2f4ff);
  border-radius: var(--tz-radius-pill, 999px);
  text-decoration: none; font-size: 16px; font-weight: 500;
}
.tz-404__phone { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }

/* --- Подвал ----------------------------------------------------------------- */
.tz-footer {
  margin-top: var(--tz-space-9, 96px);
  padding-block: var(--tz-space-8, 64px) var(--tz-space-6, 32px);
  background: var(--tz-color-card-alt, #f2f0fb);
  font-size: 16px;
}
.tz-footer > .tz-container { display: grid; gap: var(--tz-space-6, 32px); }
.tz-footer > .tz-container > * { min-width: 0; }              /* ничего не выпирает вбок на 360px */
.tz-footer__list a, .tz-footer__stub { overflow-wrap: anywhere; }

.tz-footer__top { display: flex; flex-wrap: wrap; gap: var(--tz-space-6, 32px); justify-content: space-between; align-items: flex-start; }
.tz-footer__logo .tz-logo__img { height: 40px; }
.tz-footer__tagline { margin: 12px 0 0; color: var(--tz-color-muted, #92a1a7); }

.tz-footer__contacts { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.tz-footer__contacts li { display: flex; align-items: center; gap: 12px; }
.tz-footer__contacts a { text-decoration: none; }
.tz-footer__bubble {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex: none;
  border-radius: 50%; background: var(--tz-color-bg, #fff); color: var(--tz-color-primary);
}

.tz-footer__columns { display: grid; gap: var(--tz-space-5, 24px); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tz-footer__title { font-size: 16px; font-family: var(--tz-font-sans, sans-serif); text-transform: none; margin: 0 0 12px; font-weight: 600; }
.tz-footer__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tz-footer__list a { text-decoration: none; }
.tz-footer__stub { color: var(--tz-color-muted, #92a1a7); font-size: 14px; margin: 0; }

.tz-footer__strip, .tz-footer__licenses, .tz-footer__disclaimer, .tz-footer__bottom {
  padding-top: var(--tz-space-5, 24px);
  border-top: 1px solid rgba(47, 76, 84, .1);
}
.tz-footer__disclaimer p, .tz-footer__bottom p { margin: 0 0 8px; font-size: 14px; color: var(--tz-color-muted, #92a1a7); }
.tz-footer__legal { display: flex; flex-wrap: wrap; gap: 2px 10px; font-weight: 600; color: var(--tz-color-ink) !important; }
/* Клиника и юрлицо стоят рядом: имя, которое знает пациент, и то, что в документах. */
.tz-footer__entity { font-weight: 400; color: var(--tz-color-muted, #92a1a7); }
.tz-footer__bottom { display: flex; flex-wrap: wrap; gap: 8px 32px; justify-content: space-between; }

/* --- Планшет и телефон ------------------------------------------------------ */
/* Контейнер шире 1200 не растёт, поэтому на всех десктопных ширинах
   меню, телефон и кнопка живут в одной уплотнённой строке. */
@media (min-width: 1200px) {
  .tz-header__inner { gap: 12px; }
  .tz-header__actions { gap: 12px; }
  .tz-nav__list { gap: 6px; }
  .tz-nav__link { font-size: 14px; }
  .tz-header__phone { font-size: 14px; }
  .tz-header__cta { padding-inline: 14px; font-size: 15px; }
}

/* Меню в строку помещается только на макетной ширине 1200+. Ниже — бургер. */
@media (max-width: 1199px) {
  .tz-header__nav, .tz-header__phone { display: none; }
  .tz-burger { display: inline-flex; }
  .tz-header__actions { margin-inline-start: auto; }
}

@media (max-width: 760px) {
  :root { --tz-header-h: var(--tz-layout-header-sm, 64px); }

  .tz-container { padding-inline: var(--tz-layout-gutter-sm, 16px); }
  .tz-section { padding-block: var(--tz-space-7, 48px); }
  body.tz-body { font-size: 16px; }

  .tz-header__cta { display: none; }   /* на телефоне кнопка записи живёт в меню */
  .tz-header__actions { gap: 8px; }
  .tz-logo__img { height: 28px; }

  .tz-footer__bottom { flex-direction: column; }
  .tz-footer__columns { grid-template-columns: 1fr; }
  .tz-list { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .tz-search { flex-direction: column; }
  .tz-search__input { flex: none; width: 100%; }  /* иначе flex-basis уходит в высоту */
  .tz-search__submit { width: 100%; }
}

/* Пользователь просил меньше движения — убираем плавный скролл и переходы. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
