:root {
  --container: 1224px;
  --container-wide: 1320px;
  --gutter: 16px;
  --green: #73d13d;
  --green-hover: #52c41a;
  --text: #262626;
  --white: #ffffff;
  --off-white: #f0f5ff;
  --line: #d9d9d9;
  --bg: #ffffff;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --header-offset: 128px;
  /* На сколько поднять hero под плавающую шапку (≈ её зарезервированная высота). */
  --hero-pull: 87px;
}

*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

/* Sticky-footer: страница занимает минимум весь экран, футер прижат к низу.
   Высота футера нигде не хардкодится — корректно при любой его высоте.
   Исключаем hero-страницы (.page-flush): hero сам уходит под шапку за счёт
   схлопывания margin, а flex-контейнер делает .site-main новым контекстом
   форматирования и это схлопывание ломает. Такие страницы всегда высокие
   (hero ≥ 100vh), поэтому sticky-footer им и не нужен. */
body:not(.page-flush) {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Учитываем высоту админ-бара (его поля html), чтобы не было лишней прокрутки. */
.admin-bar:not(.page-flush) { min-height: calc(100vh - 32px); }

@media screen and (max-width: 782px) {
  .admin-bar:not(.page-flush) { min-height: calc(100vh - 46px); }
}

body.menu-open { overflow: hidden; }
a { color: inherit; }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; cursor: pointer; }

/* ---------------------------------------------------------------------------
 * Анимации: появление при скролле + лёгкий параллакс.
 * Прячем только при активном JS (html.js), чтобы без JS контент был виден.
 * ------------------------------------------------------------------------- */
html.js [data-reveal] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  will-change: opacity, transform;
}

html.js [data-reveal].is-revealed {
  opacity: 1;
  transform: none;
}

img[data-parallax] {
  top: -16%;
  height: 132%;
  bottom: auto;
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  html.js [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }

  img[data-parallax] {
    top: 0;
    height: 100%;
    transform: none !important;
  }
}

.container {
  width: min(calc(100% - (var(--gutter) * 2)), var(--container));
  margin-inline: auto;
}

/* ---------------------------------------------------------------------------
 * Gutenberg content width.
 * Обычные блоки держим в контейнере; .alignwide / .alignfull (full-width
 * Lazy Blocks) могут выходить шире.
 * ------------------------------------------------------------------------- */
.entry-content > * {
  width: min(calc(100% - (var(--gutter) * 2)), var(--container));
  margin-inline: auto;
}

.entry-content > .alignwide {
  width: min(calc(100% - (var(--gutter) * 2)), var(--container-wide));
}

.entry-content > .alignfull {
  width: 100%;
  max-width: none;
  margin-inline: 0;
}

/* ---------------------------------------------------------------------------
 * Header
 * ------------------------------------------------------------------------- */
.site-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 24px;
  height: 80px;
  padding: 16px 24px;
  background: var(--white);
  border-radius: 20px;
}

.header-bar__left {
  display: flex;
  align-items: center;
  gap: 40px;
  min-width: 0;
}

.header-logo {
  display: block;
  flex-shrink: 0;
}

.header-logo img,
.header-logo svg {
  display: block;
  height: 36px;
  width: auto;
}

.header-nav__menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-nav__menu a {
  font-weight: 500;
  font-size: 16px;
  line-height: normal;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.header-nav__menu a:hover { color: var(--green); }

/* Пункты с вложенным меню (десктоп) */
.header-nav__menu .menu-item-has-children { position: relative; }

.header-nav__menu .menu-item-has-children > a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.header-nav__menu .menu-item-has-children > a::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.15s ease;
}

.header-nav__menu .menu-item-has-children:hover > a::after,
.header-nav__menu .menu-item-has-children:focus-within > a::after {
  transform: translateY(1px) rotate(-135deg);
}

/* Невидимый «мостик», чтобы курсор доходил до выпадающего меню. */
.header-nav__menu .menu-item-has-children::after {
  content: "";
  position: absolute;
  top: 100%;
  left: -16px;
  right: -16px;
  height: 18px;
}

.header-nav__menu .sub-menu {
  position: absolute;
  top: calc(100% + 14px);
  left: -16px;
  z-index: 10;
  min-width: 264px;
  margin: 0;
  padding: 8px;
  list-style: none;
  background: var(--white);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}

.header-nav__menu .menu-item-has-children:hover > .sub-menu,
.header-nav__menu .menu-item-has-children:focus-within > .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.header-nav__menu .sub-menu li { display: block; }

.header-nav__menu .sub-menu a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--text);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.header-nav__menu .sub-menu a:hover {
  background: var(--off-white);
  color: var(--green);
}

.header-bar__right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.header-contacts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.header-phone {
  font-weight: 500;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.header-email {
  font-weight: 500;
  font-size: 14px;
  color: #595959;
  text-decoration: none;
  white-space: nowrap;
}

.header-email:hover { text-decoration: underline; }

.header-max {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--green);
  color: var(--green);
  font-weight: 600;
  font-size: 14px;
  line-height: normal;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.header-max:hover {
  background: var(--green);
  color: var(--off-white);
}

.header-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--green);
  color: var(--off-white);
  font-weight: 600;
  font-size: 14px;
  line-height: normal;
  text-decoration: none;
  white-space: nowrap;
  border: 0;
  transition: background-color 0.15s ease;
}

.header-cta:hover { background: var(--green-hover); }

.header-burger {
  display: none;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--text);
  flex-shrink: 0;
}

.header-burger svg,
.mobile-menu__close svg {
  display: block;
  width: 24px;
  height: 24px;
}

/* По умолчанию отбиваем контент вниз на высоту плавающей шапки. */
.site-main { padding-top: var(--header-offset); }

/* На страницах со sticky-footer тянем main, прижимая футер к низу. */
body:not(.page-flush) .site-main { flex: 1 0 auto; }

/* Страницы, начинающиеся с hero (full-bleed под шапкой), отступ не нужен —
   hero сам уходит под шапку. Класс ставится в torgtara_body_class(). */
.page-flush .site-main { padding-top: 0; }

/* Сдвиг плавающей шапки и мобильного меню под админ-бар (для авторизованных). */
.admin-bar .site-header { top: 32px; }
.admin-bar .mobile-menu { top: 32px; }

@media screen and (max-width: 782px) {
  .admin-bar .site-header { top: 46px; }
  .admin-bar .mobile-menu { top: 46px; }
}

/* ---------------------------------------------------------------------------
 * Mobile off-canvas menu
 * ------------------------------------------------------------------------- */
.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--white);
  overflow-y: auto;
}

.mobile-menu__panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  min-height: 100%;
  padding: 16px;
}

.mobile-menu__top {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.mobile-menu__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-menu__head .header-logo img,
.mobile-menu__head .header-logo svg { height: 26px; }

.mobile-menu__close {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--text);
}

.mobile-menu__nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mobile-menu__nav a {
  font-weight: 500;
  font-size: 24px;
  line-height: normal;
  color: var(--text);
  text-decoration: none;
}

/* Пункты с вложенным меню (мобильное) */
.mobile-menu__nav .menu-item-has-children {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.mobile-menu__nav .menu-item-has-children > a { margin-right: auto; }

.mobile-menu__submenu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: -8px -8px -8px 0;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--text);
  flex-shrink: 0;
}

.mobile-menu__submenu-toggle svg {
  display: block;
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.mobile-menu__nav .menu-item-has-children.is-open .mobile-menu__submenu-toggle svg {
  transform: rotate(180deg);
}

.mobile-menu__nav .sub-menu {
  flex-basis: 100%;
  list-style: none;
  margin: 16px 0 4px;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-left: 2px solid var(--line);
}

.mobile-menu__nav .sub-menu a {
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}

/* С активным JS подменю сворачиваем; без JS оно остаётся раскрытым. */
html.js .mobile-menu__nav .sub-menu { display: none; }
html.js .mobile-menu__nav .menu-item-has-children.is-open .sub-menu { display: flex; }

.mobile-menu__bottom {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mobile-menu__contact {
  font-weight: 500;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
}

.mobile-menu__cta {
  width: 100%;
  height: 52px;
  font-size: 16px;
  color: var(--white);
}

/* ---------------------------------------------------------------------------
 * 404
 * ------------------------------------------------------------------------- */
/* Глобальный sticky-footer (см. body выше) уже прижимает футер к низу и
   растягивает .site-main. На 404 дополнительно растягиваем саму секцию,
   чтобы её содержимое центрировалось по всей высоте экрана. */
body.error404 .site-main {
  display: flex;
  flex-direction: column;
}

.error-404 {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  /* Верхний отступ под шапку даёт .site-main. */
  padding-block: 64px;
  background: var(--off-white);
}

.error-404__inner {
  text-align: center;
}

.error-404__code {
  margin: 0;
  font-weight: 700;
  font-size: clamp(96px, 18vw, 200px);
  line-height: 1;
  color: var(--green);
  letter-spacing: -0.02em;
}

.error-404__title {
  margin: 16px 0 0;
  font-weight: 700;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.2;
  color: var(--text);
}

.error-404__text {
  max-width: 520px;
  margin: 16px auto 0;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.6;
  color: rgba(38, 38, 38, 0.7);
}

.error-404__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px 24px;
  margin-top: 32px;
}

.error-404__btn {
  height: 52px;
  padding: 0 28px;
  font-size: 16px;
}

.error-404__link {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.error-404__link:hover {
  color: var(--green);
  border-color: var(--green);
}

/* ---------------------------------------------------------------------------
 * Blog: индекс записей и архивы рубрик
 * ------------------------------------------------------------------------- */
.blog-archive { padding-bottom: 80px; }

.archive-header {
  margin-bottom: 40px;
  padding-top: 8px;
}

.archive-header__eyebrow {
  margin: 0 0 8px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--green);
}

.archive-header__title {
  margin: 0;
  font-weight: 700;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.15;
  color: var(--text);
}

.archive-header__desc {
  max-width: 720px;
  margin-top: 16px;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.6;
  color: rgba(38, 38, 38, 0.7);
}

.archive-header__desc p { margin: 0 0 8px; }
.archive-header__desc p:last-child { margin-bottom: 0; }

.blog-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

.blog-card {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.blog-card:hover {
  border-color: transparent;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.blog-card__media {
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--off-white);
}

.blog-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.blog-card:hover .blog-card__media img { transform: scale(1.04); }

.blog-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 12px;
  padding: 24px;
}

.blog-card__title {
  margin: 0;
  font-weight: 700;
  font-size: 20px;
  line-height: 1.3;
}

.blog-card__title a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}

.blog-card__title a:hover { color: var(--green); }

.blog-card__excerpt {
  font-weight: 400;
  font-size: 15px;
  line-height: 1.55;
  color: rgba(38, 38, 38, 0.7);
}

.blog-card__excerpt p { margin: 0; }

.blog-card__link {
  margin-top: auto;
  align-self: flex-start;
  font-weight: 600;
  font-size: 15px;
  color: var(--green);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.blog-card__link:hover { border-color: var(--green); }

.blog-empty {
  margin: 0;
  font-size: 18px;
  color: rgba(38, 38, 38, 0.7);
}

/* Пагинация (the_posts_pagination) */
.pagination { margin-top: 48px; }

.pagination .nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--white);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.pagination a.page-numbers:hover {
  color: var(--green);
  border-color: var(--green);
}

.pagination .page-numbers.current {
  background: var(--green);
  border-color: var(--green);
  color: var(--white);
}

.pagination .page-numbers.dots {
  border-color: transparent;
  background: transparent;
}

/* Доступность: визуально скрытый текст (заголовки навигации и т.п.). */
.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 1024px) {
  .blog-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }
}

@media (max-width: 680px) {
  .blog-list { grid-template-columns: 1fr; }
  .blog-archive { padding-bottom: 56px; }
  .archive-header { margin-bottom: 28px; }
}

/* ---------------------------------------------------------------------------
 * Footer
 * ------------------------------------------------------------------------- */
.site-footer {
  background: var(--text);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 100px;
  padding-block: 16px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.footer-logo {
  display: block;
  flex-shrink: 0;
}

.footer-logo img,
.footer-logo svg {
  display: block;
  height: 36px;
  width: auto;
}

.footer-copy {
  margin: 0;
  font-weight: 400;
  font-size: 12px;
  line-height: 1.4;
  color: var(--white);
}

.footer-privacy {
  font-weight: 400;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.5);
  text-decoration: underline;
}

/* ---------------------------------------------------------------------------
 * Tablet / mobile header
 * ------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .header-bar {
    margin-top: 16px;
    height: 50px;
    padding: 0 16px;
    border-radius: 10px;
  }

  .header-bar__left { gap: 0; }

  .header-logo img,
  .header-logo svg { height: 26px; }

  .header-nav,
  .header-bar__right { display: none; }

  .header-burger { display: block; }

  :root {
    --header-offset: 82px;
    --hero-pull: 66px;
  }
}

@media (max-width: 768px) {
  .footer-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    min-height: 0;
    padding-block: 24px;
  }

  .footer-left {
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .footer-logo img,
  .footer-logo svg { height: 26px; }

  .footer-copy__rights { display: none; }

  .footer-privacy { text-align: center; }
}
