/* Навигация между разделами сайта и в интернет-магазин.
   1) CHUNK-119. Полоса над шапкой на всех страницах, кроме развилки «/» (разметка и JS — section-switch.php):
      переключатель «Для личных хозяйств / Для производителей»; при листании вверх полоса выезжает закреплённой.
      CHUNK-120: в разделе ЛПХ справа — ссылка на интернет-магазин (на телефоне скрыта, места хватает только переключателю).
   2) CHUNK-120. Кнопка-баннер интернет-магазина рядом с жёлтой кнопкой первого экрана /home/ (index.php).

   Размеры в единицах сайта: main.css сжимает страницу (html { zoom: .75 }) на экранах до 1600 px
   и возвращает zoom: 1 на телефонах (до 750 px), поэтому «десктопные» значения здесь в 1,33 раза крупнее
   привычных: на ноутбуке полоса выглядит высотой около 50 px, подписи — около 13 px.
   Файл подключается раньше main.css (wp_head стоит до него), поэтому у всех правил свои классы nest-aud и nest-shop. */

:root {
  --na-ink: #303439;
  --na-ink-soft: #55606A;
  --na-green: #599E31;
  --na-green-ink: #3D6A24;
  --na-green-deep: #2D5A1C;
  --na-mint: #EDF3E9;
  --na-line: #E8ECE5;
  --na-ease: cubic-bezier(.16, 1, .3, 1);
}

/* ========== Полоса разделов ========== */
/* Полоса стоит в потоке перед шапкой. .header — position: absolute без top и встаёт сразу под полосой,
   первый экран сдвигается на ту же высоту: шапка и заголовки страниц по-прежнему не наезжают друг на друга. */
.nest-aud {
  background: #fff;
}

.nest-aud__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 0 12px;
  border-bottom: 1px solid var(--na-line);
}

.nest-aud__switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--na-mint);
}

.nest-aud__opt {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 22px 0 16px;
  border-radius: 10px;
  color: var(--na-ink-soft);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: color .3s var(--na-ease), background-color .3s var(--na-ease);
}

.nest-aud__opt svg {
  flex: none;
  width: 22px;
  height: 22px;
}

a.nest-aud__opt:hover {
  color: var(--na-green-deep);
  background: rgba(255, 255, 255, .65);
}

.nest-aud__opt.is-active {
  color: var(--na-green-deep);
  font-weight: 700;
  background: #fff;
  box-shadow: 0 1px 2px rgba(45, 90, 28, .14), 0 6px 14px -6px rgba(45, 90, 28, .3);
}

.nest-aud__short {
  display: none;
}

.nest-aud__shop {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--na-green-deep);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.nest-aud__shop-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--na-mint);
  color: var(--na-green-ink);
  transition: background-color .3s var(--na-ease), color .3s var(--na-ease);
}

.nest-aud__shop-icon svg {
  width: 22px;
  height: 22px;
}

.nest-aud__shop-host {
  color: var(--na-ink-soft);
  font-weight: 500;
}

.nest-aud__shop-arrow {
  width: 16px;
  height: 16px;
  margin-left: -4px;
  transition: transform .35s var(--na-ease);
}

.nest-aud__shop:hover {
  color: var(--na-green-deep);
}

.nest-aud__shop:hover .nest-aud__shop-icon {
  background: var(--na-green);
  color: #fff;
}

.nest-aud__shop:hover .nest-aud__shop-label {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.nest-aud__shop:hover .nest-aud__shop-arrow {
  transform: translate(2px, -2px);
}

/* ----- Поле-кнопка поиска между переключателем и магазином (CHUNK-126, доработка 2) -----
   Это button.nest-search-open: клик открывает оверлей поиска (обработчик — assets/js/search.js), лупа в шапке остаётся.
   search.css подключается позже этого файла, а у .nest-search-open там свои размеры лупы шапки (57×57 px, мятный фон),
   поэтому все селекторы из двух классов. Высота и скругление — как у .nest-aud__switch (42 + 2×4 px, 14 px).
   Растягивается по свободному месту до max-width; без ссылки магазина (раздел СПХ) уходит к правому краю. */
.nest-aud .nest-aud__search {
  flex: 1 1 0;
  min-width: 0;
  max-width: 760px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  height: 50px;
  margin: 0;
  padding: 0 12px 0 16px;
  border: 2px solid var(--na-green);
  border-radius: 14px;
  background: #fff;
  color: var(--na-ink);
  font: 600 18px/1 "Manrope", sans-serif;
  text-align: left;
  cursor: pointer;
  transition: border-color .3s var(--na-ease), box-shadow .3s var(--na-ease);
}

.nest-aud .nest-aud__search:hover {
  background: #fff;
  border-color: var(--na-green-ink);
  box-shadow: 0 0 0 4px rgba(89, 158, 49, .16);
}

.nest-aud .nest-aud__search svg {
  flex: none;
  display: block;
  width: 24px;
  height: 24px;
  color: var(--na-green-ink);
}

.nest-aud__search-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--na-ink-soft);
}

.nest-aud__search-short,
.nest-aud__search-word {
  display: none;
}

.nest-aud__search-kbd {
  flex: none;
  padding: 5px 10px;
  border: 1px solid #D7E1D2;
  border-bottom-width: 2px;
  border-radius: 8px;
  background: var(--na-mint);
  color: var(--na-ink-soft);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

/* подсказка клавиш не нужна на сенсорных экранах */
@media (pointer: coarse) {
  .nest-aud__search-kbd {
    display: none;
  }
}

/* Подпись по свободному месту. Брейкпоинты — ширина окна: при ≤1600 px html { zoom: .75 }, поэтому место в единицах сайта —
   (окно − полоса прокрутки) / .75 минус переключатель (528), магазин (349, без адреса 246) и два зазора по 24.
   Нужно для кнопки: «Поиск: препарат, …» + Ctrl K — 578, «Поиск по сайту» + Ctrl K — 275, без Ctrl K — 201, «Поиск» — 122;
   пороги взяты с запасом около 20 и полосой прокрутки 17 px. Обрезка с многоточием в .nest-aud__search-text — страховка
   на случай другого шрифта или масштаба текста. Положение «хвоста» по ЛПХ/СПХ разное, потому что у СПХ нет магазина. */
@media (max-width: 1089px) {
  .nest-aud--lpx .nest-aud__search-long {
    display: none;
  }

  .nest-aud--lpx .nest-aud__search-short {
    display: inline;
  }
}

@media (max-width: 889px) {
  .nest-aud--cpx .nest-aud__search-long {
    display: none;
  }

  .nest-aud--cpx .nest-aud__search-short {
    display: inline;
  }
}

@media (max-width: 859px) {
  .nest-aud--lpx .nest-aud__search-kbd {
    display: none;
  }
}

@media (max-width: 799px) {
  .nest-aud--lpx .nest-aud__search-short {
    display: none;
  }

  .nest-aud--lpx .nest-aud__search-word {
    display: inline;
  }
}

/* на планшетных ширинах контейнер сайта доходит до краёв экрана — убираем адрес, оставляем «Интернет-магазин ↗» */
@media (max-width: 1250px) {
  .nest-aud__shop-host {
    display: none;
  }
}

/* ----- Закрепление при листании вверх (классы ставит скрипт в section-switch.php) ----- */
/* is-fixed: полоса вынута из потока (высоту .nest-aud держит скрипт) и спрятана над экраном;
   is-shown: выехала; is-anim: анимация включается только после того, как полоса спрятана,
   иначе при вынимании из потока она бы видимо уезжала вверх.
   Место — от верха экрана либо сразу под баннером объявления, если он выведен на странице (класс nest-aud--notice
   ставит сервер: notice.css со своим --nest-notice-h подключён и на странице объявления, где баннера нет)
   и не закрыт (html.nest-notice-off). Сдвиги под админ-панель WordPress — как в notice.css: 32/46/0 px.
   Высоты в CSS, а не из скрипта: getBoundingClientRect() при html { zoom: .75 } отдаёт уже уменьшенные значения.
   Слой 1030: ниже баннера объявления (1040), лайтбокса fancybox (1050), .modal-window (10000) и меню (100000). */
.nest-aud.is-fixed .nest-aud__bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  background: #fff;
  box-shadow: 0 10px 24px -14px rgba(28, 52, 18, .45);
  /* спрятана выше экрана с запасом на баннер, админ-панель и тень */
  transform: translateY(calc(-100% - 140px));
}

.nest-aud--notice.is-fixed .nest-aud__bar {
  top: var(--nest-notice-h, 0px);
}

html.nest-notice-off .nest-aud--notice.is-fixed .nest-aud__bar {
  top: 0;
}

.nest-aud--adminbar.is-fixed .nest-aud__bar {
  top: 32px;
}

.nest-aud--adminbar.nest-aud--notice.is-fixed .nest-aud__bar {
  top: calc(var(--nest-notice-h, 0px) + 32px);
}

html.nest-notice-off .nest-aud--adminbar.nest-aud--notice.is-fixed .nest-aud__bar {
  top: 32px;
}

@media (max-width: 782px) {
  .nest-aud--adminbar.is-fixed .nest-aud__bar {
    top: 46px;
  }

  .nest-aud--adminbar.nest-aud--notice.is-fixed .nest-aud__bar {
    top: calc(var(--nest-notice-h, 0px) + 46px);
  }

  html.nest-notice-off .nest-aud--adminbar.nest-aud--notice.is-fixed .nest-aud__bar {
    top: 46px;
  }
}

/* до 600 px админ-панель уезжает с прокруткой (position: absolute) — как баннер, встаём без её сдвига */
@media (max-width: 600px) {
  .nest-aud--adminbar.is-fixed .nest-aud__bar {
    top: 0;
  }

  .nest-aud--adminbar.nest-aud--notice.is-fixed .nest-aud__bar {
    top: var(--nest-notice-h, 0px);
  }

  html.nest-notice-off .nest-aud--adminbar.nest-aud--notice.is-fixed .nest-aud__bar {
    top: 0;
  }
}

/* top — плавный подъём к верху экрана, когда посетитель закрыл баннер объявления */
.nest-aud.is-fixed.is-anim .nest-aud__bar {
  transition: transform .4s var(--na-ease), top .4s var(--na-ease);
}

.nest-aud.is-fixed.is-shown .nest-aud__bar {
  transform: none;
}

/* спрятанная полоса выезжает при фокусе с клавиатуры (Tab), иначе фокус ушёл бы за край экрана.
   Только :focus-visible: после щелчка мышью по «Интернет-магазин» (новая вкладка) фокус остаётся на ссылке,
   и с :focus-within полоса переставала бы уезжать. Отдельным правилом: браузер без :has() отбросит только его */
.nest-aud.is-fixed:has(:focus-visible) .nest-aud__bar {
  transform: none;
}

/* .sorting-date (/articles/, /efficiency/) в main.css — z-index 10000 и проходила бы поверх закреплённой полосы;
   такое же правило есть в notice.css, но он подключается только при активном объявлении */
.sorting-row .sorting-date {
  z-index: 1020;
}

.nest-aud.is-fixed .nest-aud__inner {
  border-bottom-color: transparent;
}

@media (max-width: 750px) {
  /* ширина как у контейнера шапки на телефоне (main.css: .header .container { max-width: 305px }) */
  .nest-aud .container {
    max-width: 305px;
  }

  .nest-aud__inner {
    padding: 8px 0 2px;
    border-bottom: 0;
  }

  .nest-aud__switch {
    display: flex;
    width: 100%;
    gap: 3px;
    padding: 3px;
    border-radius: 12px;
  }

  .nest-aud__opt {
    flex: 1 1 0;
    justify-content: center;
    height: 38px;
    padding: 0 6px;
    border-radius: 9px;
    font-size: 13px;
  }

  .nest-aud__opt svg,
  .nest-aud__full,
  .nest-aud__shop {
    display: none;
  }

  .nest-aud__short {
    display: inline;
  }

  .nest-aud.is-fixed .nest-aud__inner {
    padding: 6px 0;
  }

  /* переключатель занимает всю ширину полосы (305 px), поле поиска рядом не помещается; в шапке телефона есть лупа (44 px) */
  .nest-aud .nest-aud__search {
    display: none;
  }
}

/* ========== Кнопка-баннер интернет-магазина на первом экране /home/ ========== */
.first-screen-home .first-screen__btn {
  vertical-align: top;
}

.nest-shop {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  vertical-align: top;
  height: 108px;
  margin-left: 26px;
  padding: 0 22px 0 22px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(28, 52, 18, .12), 0 20px 44px -18px rgba(28, 52, 18, .5);
  color: var(--na-ink);
  transition: transform .45s var(--na-ease), box-shadow .45s var(--na-ease);
}

.nest-shop__icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--na-green);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12);
  color: #fff;
}

.nest-shop__icon svg {
  width: 32px;
  height: 32px;
}

.nest-shop__body {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.nest-shop__title {
  color: var(--na-ink);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.nest-shop__text {
  color: var(--na-ink-soft);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.35;
}

.nest-shop__go {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--na-mint);
  color: var(--na-green-ink);
  transition: background-color .3s var(--na-ease), color .3s var(--na-ease);
}

.nest-shop__go svg {
  width: 22px;
  height: 22px;
  transition: transform .45s var(--na-ease);
}

.nest-shop:hover {
  color: var(--na-ink);
  transform: translateY(-3px);
  box-shadow: 0 3px 8px rgba(28, 52, 18, .14), 0 28px 54px -18px rgba(28, 52, 18, .55);
}

.nest-shop:hover .nest-shop__go {
  background: var(--na-green);
  color: #fff;
}

.nest-shop:hover .nest-shop__go svg {
  transform: translateX(3px);
}

@media (max-width: 750px) {
  .first-screen-home .first-screen__btn {
    margin-bottom: 12px;
  }

  .nest-shop {
    display: flex;
    width: 100%;
    height: auto;
    min-height: 72px;
    margin: 0 0 27px;
    padding: 12px 12px 12px 12px;
    gap: 12px;
    border-radius: 10px;
  }

  .nest-shop__icon {
    width: 44px;
    height: 44px;
    border-radius: 11px;
  }

  .nest-shop__icon svg {
    width: 24px;
    height: 24px;
  }

  .nest-shop__body {
    flex: 1 1 auto;
    min-width: 0;
    gap: 3px;
  }

  /* замер в Manrope: заголовок 14px — 199 px, пояснение 12px — 204 px при 220 px места; круг со стрелкой не помещается */
  .nest-shop__title {
    font-size: 14px;
    line-height: 1.3;
  }

  .nest-shop__text {
    font-size: 12px;
    line-height: 1.35;
  }

  .nest-shop__go,
  .nest-shop__long {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nest-aud__opt,
  .nest-aud .nest-aud__search,
  .nest-aud__shop-icon,
  .nest-aud__shop-arrow,
  .nest-aud.is-fixed.is-anim .nest-aud__bar,
  .nest-shop,
  .nest-shop__go,
  .nest-shop__go svg {
    transition: none;
  }

  .nest-shop:hover {
    transform: none;
  }
}
