/*
 * Новая шапка сайта (компьютер), нижний таббар (телефон), строка поиска,
 * страница результатов поиска и «Ничего не найдено» / «Корзина пуста».
 * Разметка: template-parts/lt-header.php, template-parts/lt-search-form.php,
 * плагин lasertech-search (страница результатов), woocommerce/cart/cart-empty.php.
 * Скрипт: js/lt-header.js. Подключается в functions.php (lasertech_scripts).
 */

/* ===== Новый хедер (десктоп) ===== */
.lth { /* высота плашки = лого 36 + 2×20; полное скругление = половина высоты; по бокам отступ больше из-за круглых краёв */
  --pad: 20px; --padx: 30px; --radius: 38px; --panel-pad: 22px; --glass: rgba(255, 255, 255, .72); --glass-open: rgba(255, 255, 255, .92);
  position: fixed; top: 8px; left: 0; right: 0; z-index: 96; pointer-events: none;
  transition: transform .35s ease; font-family: Montserrat, sans-serif; }
.lth.out { transform: translateY(calc(-100% - 24px)); }
/* Прогрессивный блюр под хедером: 2 слоя размытия + белый градиент, уезжает вместе с хедером */
.lth__fade { position: absolute; left: 0; right: 0; top: -8px; height: calc(100% + 8px + 36px); z-index: -1;
  pointer-events: none; contain: strict;
  background: linear-gradient(to bottom, rgba(255, 255, 255, .85) 0%, rgba(255, 255, 255, .5) 50%, rgba(255, 255, 255, 0) 100%); }
.lth__fade i { position: absolute; inset: 0; }
.lth__fade i:nth-child(1) { -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent 100%); mask-image: linear-gradient(to bottom, #000 45%, transparent 100%); }
.lth__fade i:nth-child(2) { -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 55%); mask-image: linear-gradient(to bottom, #000 0%, transparent 55%); }
.lth__row { max-width: 1330px; margin: 0 auto; padding: 0 15px; display: flex; gap: 10px; align-items: stretch; }
.lth__pill { pointer-events: auto; background: var(--glass);
  -webkit-backdrop-filter: blur(15px) saturate(1.3); backdrop-filter: blur(15px) saturate(1.3);
  border-radius: var(--radius); box-shadow: 0 4px 24px rgba(0, 0, 0, .08);
  transition: background .2s, border-radius .2s, box-shadow .2s; }

/* Левая плашка: лого слева, пункты меню по центру оставшегося места (от лого до края плашки) */
.lth__main { flex: 1; min-width: 0; position: relative; display: grid; grid-template-columns: auto 1fr;
  align-items: center; padding: var(--pad) var(--padx); }
.lth__logo { display: block; justify-self: start; }
.lth__logo img { display: block; height: 36px; width: auto; }
/* Центр меню — посередине между правым краем лого и правым краем плашки */
/* Расстояние между пунктами растёт с шириной экрана, но всегда меньше, чем от лого до меню */
.lth__nav { display: flex; align-items: center; justify-self: center; gap: clamp(28px, calc(28px + (100vw - 900px) * .16), 96px); margin: 0 calc(-1 * var(--padx)) 0 0; padding: 0; list-style: none; }
.lth__link { position: relative; z-index: 0; font-size: 18px; font-weight: 500; color: #000; text-decoration: none; cursor: pointer;
  background: none; border: 0; padding: 10px 0; font-family: inherit; line-height: 20px; }
/* Активный пункт (текущая страница или открытый «Каталог») — тёмная «пилюля» на ::before, как в таббаре;
   при наведении — та же пилюля, но светлее. Ширина пилюли не влияет на соседние пункты. */
.lth__link::before { content: ''; position: absolute; z-index: -1; top: -10px; bottom: -10px; left: -30px; right: -30px;
  border-radius: 50em; background: rgba(0, 0, 0, .11); opacity: 0; transform: scale(.92);
  transition: opacity .2s, transform .2s; }
.lth__link:hover::before { opacity: .45; transform: none; }
.lth__link.is-current::before, .lth__link.is-open::before { opacity: 1; transform: none; }
/* Пока открыт «Каталог», подсвечен только он */
.lth__main.is-open .lth__link.is-current:not(.is-open)::before { opacity: 0; }
/* Пункты меню и «Корзина» — с заглавной буквы (в админке хранятся заглавными) */
.lth__link, .lth__cart-text { display: inline-block; text-transform: lowercase; }
.lth__link::first-letter, .lth__cart-text::first-letter { text-transform: uppercase; }

/* Плашка корзины: та же высота, те же отступы */
.lth__cart { display: flex; align-items: center; gap: 10px; padding: var(--pad) 28px; text-decoration: none; color: #000; }
.lth__cart img { width: 32px; height: 34px; display: block; }
.lth__cart-text { font-size: 18px; font-weight: 500; }
/* Счётчик корзины — красный «значок» с цифрой; пустая корзина — серый */
/* Счётчик в плашке корзины на компьютере скрыт */
.lth__cart-num { display: none !important; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 14px; font-weight: 700; line-height: 1; color: #fff;
  background: linear-gradient(53.19deg, #7D0000 14.23%, #BE0000 45.48%, #FF0000 85.39%); box-shadow: 0 3px 10px rgba(190, 0, 0, .35); font-variant-numeric: tabular-nums;
  transition: transform .2s; }
.lth__cart-num.is-empty { background: #e6e6eb; color: #8a8a8f; box-shadow: none; }
.lth__cart:hover .lth__cart-num { transform: scale(1.08); }

/* Меню «Каталог»: продолжение левой плашки, без зазора */
.lth__main.is-open { background: var(--glass-open); border-radius: var(--radius) var(--radius) 0 0; box-shadow: none; }
.lth__drop { position: absolute; left: 0; right: 0; top: 100%;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s; }
.lth__main.is-open .lth__drop { opacity: 1; visibility: visible; transform: none; }
.lth__panel { background: var(--glass-open); -webkit-backdrop-filter: blur(15px) saturate(1.3); backdrop-filter: blur(15px) saturate(1.3);
  border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 18px 40px rgba(0, 0, 0, .14);
  border-top: 1px solid rgba(0, 0, 0, .06); padding: var(--panel-pad) var(--panel-pad) 26px;
  max-height: calc(100vh - 130px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
/* Радиус поля поиска = радиус панели − отступ панели (38 − 22 = 16) */
.lth__panel[data-lt-scroll] { }

/* Поиск: заметное поле с лупой */
.lth-search { display: flex; gap: 10px; margin-bottom: 24px; }
.lth-search__field { position: relative; flex: 1; min-width: 0; }
/* Лупа — отдельным слоем поверх поля (z-index) и без transform: Safari на iPhone рисовал поле поверх неё */
.lth-search__icon { position: absolute; z-index: 2; left: 18px; top: 50%; width: 22px; height: 22px; margin-top: -11px;
  color: #be0000; pointer-events: none; display: block; }
.lth-search__input { position: relative; z-index: 1; width: 100%; height: 58px; padding: 0 20px 0 52px; border: 2px solid #d4d4da; outline: none;
  border-radius: calc(var(--radius, 38px) - var(--panel-pad, 22px)); background: #fff; font: 500 17px Montserrat, sans-serif; color: #000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .06); transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; }
.lth-search__input::placeholder { color: #8a8a8f; }
.lth-search__input:hover { border-color: #bdbdc4; }
.lth-search__input:focus { border-color: #be0000; box-shadow: 0 0 0 4px rgba(190, 0, 0, .12); }
.lth-search__input::-webkit-search-cancel-button { cursor: pointer; }

/* Кнопка: серая → красная плавно (серый слой гаснет за 0.18 с) */
/* Кнопка — слоем выше поля (поле поднято, чтобы лупа была видна в Safari), иначе на телефоне её закрывает поле */
.lth-search__btn { position: relative; z-index: 3; overflow: hidden; height: 58px; padding: 0 34px; border: 0; border-radius: calc(var(--radius, 38px) - var(--panel-pad, 22px));
  color: #fff; font: 600 17px Montserrat, sans-serif; cursor: pointer; background: linear-gradient(53.19deg, #7D0000 14.23%, #BE0000 45.48%, #FF0000 85.39%); isolation: isolate; }
.lth-search__btn::before { content: ''; position: absolute; inset: 0; background: #d9d9d9; opacity: 0; z-index: -1;
  transition: opacity .18s ease; }
.lth-search__btn:disabled { cursor: default; }
.lth-search__btn:disabled::before { opacity: 1; }
.lth-search__btn:not(:disabled):hover { filter: brightness(1.08); }

/* Разделы каталога — как в нынешнем меню */
.lth-cats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 22px 16px; }
.lth-cat { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: #000; }
/* Как в оригинале: скруглённый квадрат повёрнут на 25°, фото внутри повёрнуто обратно и стоит ровно */
.lth-cat__img { width: 100%; max-width: 160px; aspect-ratio: 1; border-radius: 46%; overflow: hidden;
  background: #f3f3f3; transform: rotate(25deg); transition: box-shadow .25s; display: block; margin: 8px 0 4px; }
.lth-cat__img img { width: 100%; height: 100%; object-fit: contain; display: block; transform: rotate(-25deg) scale(1.1); }
.lth-cat:hover .lth-cat__img { box-shadow: 0 0 0 2px #b01e1e; }
.lth-cat__title { margin-top: 12px; font-size: 14px; font-weight: 600; text-align: center; transition: color .2s; }
.lth-cat:hover .lth-cat__title, .lth-cat.is-red .lth-cat__title { color: #be0000; }


@media (max-width: 1100px) { .lth { --pad: 18px; --padx: 24px; --radius: 36px; } .lth__logo img { height: 30px; } .lth__link, .lth__cart-text { font-size: 16px; } .lth__link::before { left: -14px; right: -14px; } .lth-cats { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 899px) { .lth { display: none; } }

/* ===== Мобильный таббар в стиле iOS 26 ===== */
.ltm, .ltm-fade { display: none; }
@media (max-width: 899px) {

  /* Прогрессивный блюр под таббаром: всего 2 слоя размытия (дёшево для телефона) + белый градиент.
     Слой 1 — слабое размытие на всю высоту, слой 2 — сильнее, только у самого низа. */
  .ltm-fade { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 100; pointer-events: none;
    height: calc(100px + env(safe-area-inset-bottom)); contain: strict;
    background: linear-gradient(to top, rgba(255, 255, 255, .85) 0%, rgba(255, 255, 255, .5) 45%, rgba(255, 255, 255, 0) 100%);
    transition: opacity .3s; }
  .ltm-fade i { position: absolute; inset: 0; }
  .ltm-fade i:nth-child(1) { -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    -webkit-mask-image: linear-gradient(to top, #000 40%, transparent 100%); mask-image: linear-gradient(to top, #000 40%, transparent 100%); }
  .ltm-fade i:nth-child(2) { -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    -webkit-mask-image: linear-gradient(to top, #000 0%, transparent 50%); mask-image: linear-gradient(to top, #000 0%, transparent 50%); }
  /* Пока открыт каталог, полосу не рисуем — её всё равно закрывает затемнение */
  .ltm-fade.is-hidden { opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s; }

  .ltm { --bar: 68px; --gap: 6px; --edge: 6px; --r: 34px; --pad: 12px; --search: 50px; --pr: calc(var(--search) / 2 + var(--pad)); /* внешний радиус панели = радиус поиска + отступ */ --ease: cubic-bezier(.22, .8, .24, 1);
    --glass: rgba(255, 255, 255, .7); --glass-open: rgba(255, 255, 255, .84);
    display: block; position: fixed; left: var(--edge); right: var(--edge);
    bottom: calc(6px + env(safe-area-inset-bottom)); z-index: 101; font-family: Montserrat, sans-serif; }
  .ltm__bar { position: relative; display: flex; gap: var(--gap); transition: gap .35s var(--ease); }
  /* Общая тень цельного таббара (в открытом состоянии) — одна на всю ширину, без наложений */
  .ltm__bar::before { content: ''; position: absolute; inset: 0; border-radius: 0 0 var(--r) var(--r);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .14); opacity: 0; transition: opacity .3s; pointer-events: none; }
  .ltm__glass { position: relative; background: var(--glass);
    -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .14), inset 0 0 0 1px rgba(255, 255, 255, .55);
    transition: border-radius .35s var(--ease), background .35s, box-shadow .3s; }
  .ltm__tabs { flex: 1 1 0; min-width: 0; height: var(--bar); border-radius: var(--r); display: flex; padding: 4px 6px;
    transition: border-radius .35s var(--ease), background .35s, box-shadow .3s, padding .35s var(--ease); }
  /* Круг корзины — такой же «стеклянный» div, как основная плашка (одинаковое размытие) */
  .ltm__cartwrap { flex: 0 0 var(--bar); height: var(--bar); border-radius: 50%; display: flex; padding: 4px;
    transition: border-radius .35s var(--ease), background .35s, box-shadow .3s, flex-basis .35s var(--ease); }
  .ltm__tab { position: relative; z-index: 0; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; color: #000; text-decoration: none; background: none; border: 0; padding: 0;
    cursor: pointer; font: 500 10px/1.1 Montserrat, sans-serif; -webkit-tap-highlight-color: transparent; }
  /* Подписи: из админки приходят заглавными — показываем «Главная», «Корзина» */
  .ltm__tab > span:not(.ltm__badge) { display: block; text-transform: lowercase; white-space: nowrap; }
  .ltm__tab > span:not(.ltm__badge)::first-letter { text-transform: uppercase; }
  .ltm__tab { flex: 1; min-width: 0; }
  .ltm__tab img { width: 27px; height: 27px; object-fit: contain; display: block; }
  /* Активный пункт: тёмная «пилюля» на ::before — чуть шире пункта и не сдвигает соседей */
  .ltm__tab::before { content: ''; position: absolute; z-index: -1; top: 0; bottom: 0; left: -5px; right: -5px;
    border-radius: 50em; background: rgba(0, 0, 0, .11); opacity: 0; transform: scale(.92);
    transition: opacity .25s, transform .25s var(--ease); }
  .ltm__tab:first-child::before { left: -2px; }
  .ltm__tab:last-child::before { right: -2px; }
  .ltm__tab.is-current::before, .ltm__tab.is-active::before { opacity: 1; transform: none; }
  .ltm__tab.is-active span { font-weight: 600; }
  .ltm.is-open .ltm__tab.is-current:not(.is-active)::before { opacity: 0; }
  /* У корзины в таббаре подложки нет */
  .ltm__cartwrap .ltm__cart::before { display: none; }
  .ltm__badge { position: absolute; top: 0; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center; font: 700 10px/1 Montserrat, sans-serif; color: #fff;
    background: linear-gradient(53.19deg, #7D0000 14.23%, #BE0000 45.48%, #FF0000 85.39%); box-shadow: 0 2px 6px rgba(190, 0, 0, .35); }
  .ltm__badge.is-empty { display: none; }

  /* Открыт каталог: две плашки сливаются в одну, панель стыкуется сверху */
  .ltm.is-open .ltm__bar { gap: 0; }
  .ltm.is-open .ltm__bar::before { opacity: 1; }
  .ltm.is-open .ltm__glass { background: var(--glass-open); box-shadow: none; }
  .ltm.is-open .ltm__tabs { border-radius: 0 0 0 var(--r); padding: 4px 0; }
  .ltm.is-open .ltm__cartwrap { border-radius: 0 0 var(--r) 0; flex-basis: 20%; padding: 4px 0; }
  .ltm.is-open .ltm__tabs .ltm__tab:first-child::before { left: 4px; }

  /* Окно, из-за нижнего края которого выезжает панель; высота — 70% доступной */
  .ltm__clip { position: absolute; left: 0; right: 0; bottom: 100%;
    height: calc((100dvh - var(--bar) - 6px - env(safe-area-inset-bottom) - 16px - env(safe-area-inset-top)) * .85);
    overflow: hidden; border-radius: var(--pr) var(--pr) 0 0; pointer-events: none; visibility: hidden;
    transition: visibility 0s linear .42s; }
  .ltm.is-open .ltm__clip { pointer-events: auto; visibility: visible; transition: visibility 0s; }
  .ltm__panel { position: absolute; inset: 0; background: var(--glass-open);
    -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6);
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    transform: translateY(100%); transition: transform .42s var(--ease); display: flex; flex-direction: column; }
  .ltm.is-open .ltm__panel { transform: none; transition: transform .45s var(--ease) .04s; }
  .ltm__scroll { flex: 1; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch; padding: 0 var(--pad) 18px; }
  /* Поиск закреплён вверху панели; под ним градиент из цвета панели в прозрачный,
     разделы каталога прокручиваются под поиском и плавно исчезают */
  .ltm__head { --fade: 22px; --head-bg: rgba(255, 255, 255, .96); position: sticky; top: 0; z-index: 2;
    margin: 0 calc(-1 * var(--pad)) -8px; padding: var(--pad) var(--pad) var(--fade); pointer-events: none;
    background: linear-gradient(to bottom, var(--head-bg) 0, var(--head-bg) calc(100% - var(--fade)), rgba(255, 255, 255, 0) 100%); }
  .ltm__head > * { pointer-events: auto; }

  /* Поиск: кнопка «Найти» внутри поля, всё максимально скруглено */
  .ltm__panel .lth-search { position: relative; display: block; margin: 0; }
  .ltm__panel .lth-search__field { display: block; }
  .ltm__panel .lth-search__input { height: var(--search); font-size: 16px; border-radius: calc(var(--search) / 2); padding: 0 100px 0 42px;
    border: 1.5px solid #d4d4da; box-shadow: none; }
  .ltm__panel .lth-search__input:focus { border-color: #be0000; box-shadow: none; }
  .ltm__panel .lth-search__icon { left: 15px; width: 19px; height: 19px; margin-top: -9.5px; }
  /* Кнопка внутри поля: радиус кнопки = радиус поля − отступ (5 px) */
  .ltm__panel .lth-search__btn { position: absolute; top: 5px; right: 5px; bottom: 5px; height: auto; padding: 0 18px;
    font-size: 15px; border-radius: calc(var(--search) / 2 - 5px); }
  .ltm__panel .lth-cats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 10px; }
  .ltm__panel .lth-cat { min-width: 0; }
  .ltm__panel .lth-cat__img { width: 82%; }
  .ltm__panel .lth-cat__title { font-size: 12px; margin-top: 8px; }
}

/* Отступ под фиксированной шапкой на компьютере. Раньше его давал невидимый блок старого
   мобильного каталога (104 px), сейчас — явно. На телефоне шапки сверху нет. */
.lt-header-spacer { display: none; }
@media (min-width: 900px) { .lt-header-spacer { display: block; height: 104px; } }

/* Старые скрипты (main.js) прячут таббар классом hidden, пока открыто окно заказа */
.ltm.hidden { display: none !important; }

/* ===== Единый заголовок: «Результаты поиска», «Ничего не найдено», «Корзина пуста» =====
   Одинаковые шрифт и выравнивание; отступ сверху подобран так, чтобы на обеих раскладках
   (как раздел каталога и как пустая корзина) заголовок стоял на одной высоте:
   компьютер — 150 px от верха страницы, телефон — 40 px. */
.lt-page-title, .cart-empty__title.lt-page-title, .categories__title.lt-page-title {
  display: block; width: 100%; max-width: none; margin: 16px 0 22px; padding: 0;
  font: 700 32px/1.25 Montserrat, sans-serif; text-transform: uppercase; text-align: center; white-space: nowrap; }
.cart-empty__heading .lt-page-title { margin-top: 46px; }
@media (max-width: 899px) {
  /* !important — чтобы перебить встроенное правило сайта для «Корзина пуста» (30 px, влево, !important) */
  .lt-page-title, .cart-empty__title.lt-page-title, .categories__title.lt-page-title {
    margin: 10px 0 16px !important; font-size: 26px !important; text-align: center !important;
    white-space: normal !important; overflow-wrap: anywhere; }
  .cart-empty__heading .lt-page-title { margin-top: 40px !important; }
}

/* ===== Страница результатов поиска ===== */
/* Шапка страницы в теме — flex-строка; для поиска выстраиваем блоки столбиком по центру */
.woocommerce-products-header.lts-head { display: block !important; width: 100%; margin-bottom: 28px; text-align: center; }
/* Поиск — как в меню «Каталог» на компьютере, не шире половины страницы */
.lts-form { width: 50%; min-width: 520px; margin: 0 auto 12px; text-align: left; }
.lts-form .lth-search { margin: 0; }
.lts-meta { font-size: 16px; font-weight: 500; color: #555; margin: 0 0 6px; text-align: center; }
.lts-meta b { color: #000; font-weight: 700; }
.lts-note { display: inline-block; margin: 6px 0 0; padding: 8px 14px; border-radius: 12px; background: #fff3f3; color: #7d0000; font-size: 14px; font-weight: 500; }
.lts-empty-head { margin-bottom: 10px; text-align: center; }
/* Страница 404: поиск под текстом «Извините…» — на компьютере по ширине колонки с текстом */
.lts-form.lt-404-search { width: 100%; min-width: 0; margin: 28px 0 0; }
@media (max-width: 899px) { .lts-form.lt-404-search { width: calc(100vw - 46px); margin: 20px auto 0; } }
/* Пагинация результатов: в каталоге она лежит внутри списка карточек (flex по центру),
   на странице поиска — после списка, поэтому центрируем её явно */
.lts-head ~ .woocommerce-pagination { display: flex; justify-content: center; align-self: center; }
@media (max-width: 899px) {
  /* Одинаковая ширина поиска на всех страницах: по сетке карточек (контейнер 15 px + 8 px отступ карточек) */
  .lts-form { width: calc(100vw - 46px); min-width: 0; max-width: 100%; }
  /* Как поиск в мобильном меню: полностью скруглённое поле, «Найти» внутри */
  .lts-form .lth-search { position: relative; display: block; }
  .lts-form .lth-search__field { display: block; }
  .lts-form .lth-search__input { height: 50px; font-size: 16px; border-radius: 25px; padding: 0 100px 0 42px; border: 1.5px solid #d4d4da; box-shadow: none; }
  .lts-form .lth-search__input:focus { box-shadow: none; }
  .lts-form .lth-search__icon { left: 15px; width: 19px; height: 19px; margin-top: -9.5px; }
  .lts-form .lth-search__btn { position: absolute; top: 5px; right: 5px; bottom: 5px; height: auto; padding: 0 18px; font-size: 15px; border-radius: 20px; }
}
