@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400;
  font-display: optional;
  src: url('/static/fonts/manrope-400.woff2') format('woff2');
}

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 700;
  font-display: optional;
  src: url('/static/fonts/manrope-700.woff2') format('woff2');
}

:root {
  --color-brand: #F26522;
  --color-brand-dark: #C74E12;
  --color-asphalt-900: #111315;
  --color-ok: #15803D;
  --color-danger: #DC2626;
  --radius-card: 12px;
  --radius-ctrl: 8px;
  --shadow-card: 0 1px 3px rgb(17 19 21 / .06);
  --font-sans: 'Manrope', system-ui, sans-serif;
  --header-height: 64px;
}

[x-cloak] {
  display: none !important;
}

.htmx-indicator {
  display: none !important;
  pointer-events: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: flex !important;
  pointer-events: auto;
}

/* ── Масштаб изображений (референс-база) ─────────────────────────────
   Роль экрана задаёт aspect и оптический fill. Контейнеры «плитка» —
   белый фон + граница, чтобы объект не «плавал» на светлом фоне. */
.photo {
  position: relative;
  overflow: hidden;
  background: #FFFFFF;
  border: 1px solid #E7E9EE;
  border-radius: 12px;
}
.photo > img {
  position: absolute;
  inset: 0;
  margin: auto;
  object-fit: contain;
}
/* Лента и аналоги: квадрат, объект крупно (≈82%) */
.photo--card { aspect-ratio: 1 / 1; width: 100%; }
.photo--card > img { width: 100%; height: 100%; }

/* Товар (hero): 4:3, объект ≈70%, потолок по высоте панели */
.photo--hero { aspect-ratio: 1 / 1; max-height: min(640px, 68vh); border-radius: 16px; }
.photo--hero > img { width: 92%; height: 100%; object-fit: contain; }

/* Бренд → карточка модели: 4:3, фото вторично (≈64%), потолок 240px */
.photo--mid { aspect-ratio: 4 / 3; max-height: 240px; }
.photo--mid > img { width: 78%; height: auto; max-height: 100%; }

/* Сервисные контейнеры (строки размеров, корзина, сравнение): ≈88% */
.photo--id { aspect-ratio: 1 / 1; }
.photo--id > img { width: 100%; height: 100%; }

/* Критические размеры, не зависящие от пересборки Tailwind */
.chip-thumb { width: 24px; height: 24px; object-fit: contain; flex: 0 0 auto; }
.photo--id-sm { width: 56px; height: 56px; }
.photo--id-md { width: 72px; height: 72px; }

/* Минимальная типографика SEO-текста (без плагина typography) */
.prose { color: #3F444B; line-height: 1.65; }
.prose p { margin: 0 0 0.75rem; }
.prose h2, .prose h3 { font-weight: 700; color: #111315; margin: 1rem 0 0.5rem; }
.prose ul { list-style: disc; padding-left: 1.25rem; margin: 0 0 0.75rem; }

/* Мобильный sticky-бар покупки (цена + CTA всегда под пальцем) */
.mobile-buybar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  background: #FFFFFF; border-top: 1px solid #E7E9EE;
  padding: 12px 16px; box-shadow: 0 -2px 10px rgb(17 19 21 / .06);
}
@media (min-width: 1024px) { .mobile-buybar { display: none; } }
.page-with-buybar { padding-bottom: 96px; }
@media (min-width: 1024px) { .page-with-buybar { padding-bottom: 0; } }

/* Выпадающее мега-меню.
   padding-top вместо margin-top — это «мост»: курсор идёт от кнопки к панели,
   не покидая обёртку, поэтому меню не закрывается на пути. */
.menu-panel { position: absolute; left: 0; top: 100%; padding-top: 8px; z-index: 50; }
.menu-panel__box {
  min-width: 34rem;
  max-width: 60rem;
  background: #fff;
  border: 1px solid #E7E5E4;
  border-radius: var(--radius-card);
  box-shadow: 0 12px 32px rgb(17 19 21 / .14);
  padding: 1rem;
}
.menu-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #8A8A8A;
  margin-bottom: .5rem;
}
.menu-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .375rem .5rem;
  border-radius: var(--radius-ctrl);
  color: #3F3F46;
  transition: background-color .15s, color .15s;
}
.menu-link:hover { background: #F5F5F4; color: var(--color-brand); }
.menu-link:hover svg { color: var(--color-brand); }
.menu-link.is-current { color: var(--color-brand); font-weight: 600; }
.menu-chip {
  display: inline-flex;
  align-items: center;
  padding: .25rem .625rem;
  border: 1px solid #E7E5E4;
  border-radius: 999px;
  font-size: 12px;
  color: #3F3F46;
  transition: border-color .15s, color .15s;
}
.menu-chip:hover { border-color: var(--color-brand); color: var(--color-brand); }
.mobile-menu summary { list-style: none; cursor: pointer; }
.mobile-menu summary::-webkit-details-marker { display: none; }
.menu-caret { transition: transform .15s; }
.mobile-menu details[open] > summary .menu-caret { transform: rotate(180deg); }

/* ── Поиск: оверлей-мини-SERP и фасет-ссылки (контур A) ──────────────── */
.search-overlay-host {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 60;
  padding: 0 16px; pointer-events: none;
}
.search-overlay-host:empty { display: none; }
.search-overlay {
  pointer-events: auto;
  max-width: 1200px; margin: 8px auto 0;
  display: grid; grid-template-columns: 260px 1fr; grid-template-rows: 1fr auto;
  max-height: 78vh; background: #fff;
  border: 1px solid #E7E9EE; border-radius: 12px;
  box-shadow: 0 12px 32px rgb(17 19 21 / .12); overflow: hidden;
  animation: search-ov-in 140ms ease-out;
}
@keyframes search-ov-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.search-overlay__facets { overflow-y: auto; padding: 16px; border-right: 1px solid #E7E9EE; background: #F9FAFB; }
.search-overlay__results { overflow-y: auto; padding: 16px; }
.search-overlay__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.search-overlay__footer {
  grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-top: 1px solid #E7E9EE; background: #fff;
}
.search-overlay__filters { display: none; }
.search-overlay__intent { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; font-size: 11px; color: #8A8A8A; }
.search-overlay__intent b { font-weight: 600; color: var(--color-brand); background: rgb(242 101 34 / .08); border-radius: 999px; padding: 2px 7px; }
.search-overlay__intent-hint { margin-left: auto; font-size: 10px; color: #B0B4BC; }
@media (max-width: 768px) {
  .search-overlay { grid-template-columns: 1fr; }
  .search-overlay__facets { display: none; }
  .search-overlay__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-overlay__footer { position: sticky; bottom: 0; }
  .search-overlay__filters { display: block; margin-bottom: 8px; }
  .search-overlay__filters > summary {
    cursor: pointer; font-size: 13px; font-weight: 600; color: var(--color-brand);
    list-style: none;
  }
  .search-overlay__filters > summary::-webkit-details-marker { display: none; }
}

.search-card { display: block; border: 1px solid #E7E9EE; border-radius: 12px; padding: 8px; background: #fff; transition: box-shadow .15s; }
.search-card:hover { box-shadow: var(--shadow-card); }
.search-card.is-cursor { outline: 2px solid var(--color-brand); }
.search-card__name { font-size: 13px; font-weight: 600; margin-top: 6px; color: var(--color-asphalt-900); }
.search-card__size { font-size: 12px; color: #8A8A8A; }
.search-card__price-row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.search-card__price { font-size: 16px; font-weight: 700; color: var(--color-asphalt-900); }
.search-card__buy { width: 32px; height: 32px; border-radius: 8px; background: var(--color-brand); color: #fff; display: grid; place-items: center; }
.search-card__attrs { font-size: 10px; line-height: 1.35; color: #9CA3AF; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-card__stock { font-size: 11px; margin-top: 4px; color: var(--color-ok); }
.search-card__stock.is-out { color: #8A8A8A; }

.facet-group { margin-bottom: 16px; }
.facet-group__title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #8A8A8A; margin-bottom: 6px; }
.facet-link { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; padding: 4px 6px; border-radius: 8px; font-size: 14px; color: var(--color-asphalt-900); }
.facet-link:hover { background: #F5F6F8; }
.facet-link__count { font-size: 12px; color: #9CA3AF; }
.facet-link.is-active { background: rgb(242 101 34 / .08); color: var(--color-brand); font-weight: 600; }
.facet-link.is-zero { color: #C4C7CE; pointer-events: none; }

/* iOS Safari: поля с font-size < 16px вызывают автоматический зум. */
@media (max-width: 640px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Ссылки в тексте должны отличаться не только цветом (WCAG 1.4.1). */
a.text-brand,
a.text-brand-700 {
  text-decoration: underline;
  text-underline-offset: 2px;
}
a[class*="rounded-ctrl"].text-brand,
a[class*="rounded-pill"].text-brand {
  text-decoration: none;
}

.benefit-line {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: #5b5450;
  background: #f7f4f1;
  border-radius: 10px;
  padding: 8px 12px;
}

/* Карточка товара: 7/5 без arbitrary-классов Tailwind (иначе сетка падает в 1 колонку). */
.product-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 1023px) {
  .product-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
}
