/* Д-74: общий слой сайта: шрифт, фокус клавиатуры, движение. Подключается после tailwind.css. */

/* Inter, самохостинг (SIL OFL, static/fonts/Inter-OFL.txt): кириллица и латиница, три начертания */
@font-face { font-family: Inter; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/inter-cyrillic-400-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Inter; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/inter-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Inter; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/inter-cyrillic-700-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Inter; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/inter-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Inter; font-style: normal; font-weight: 800; font-display: swap; src: url("../fonts/inter-cyrillic-800-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Inter; font-style: normal; font-weight: 800; font-display: swap; src: url("../fonts/inter-latin-800-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-fast: 150ms; /* hover, нажатие */
  --dur-base: 200ms; /* выпадающие меню, раскрытия */
  --dur-slow: 280ms; /* выезжающая панель, окно */
  --focus: #0060af;
}

html { scroll-behavior: smooth; }

body { font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }

/* Цены, остатки и артикулы: цифры одной ширины */
.tnum, [data-tnum] { font-variant-numeric: tabular-nums; }

/* Фокус клавиатуры: двойное кольцо (белый зазор + синее кольцо) читается и на светлом, и на тёмном фоне */
:where(a, button, summary, select, textarea, input, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #fff;
}
/* Поле в «таблетке»: кольцо рисует обёртка, а не вложенный input */
.field-pill:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 2px #fff; }
.field-pill input:focus-visible { outline: none; box-shadow: none; }
:where(input[type="checkbox"], input[type="radio"]):focus-visible { box-shadow: none; }

/* Область нажатия не меньше 44 px у компактных ссылок и кнопок: вид не меняется, зона нажатия шире */
.hit { position: relative; }
.hit::after { content: ""; position: absolute; left: -6px; right: -6px; top: 50%; height: 100%; min-height: 44px; transform: translateY(-50%); }

/* Нажатие кнопки «проседает», красная кнопка при наведении темнеет (а не просвечивает) */
.tap { transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform 100ms var(--ease); }
.tap:active { transform: scale(0.97); }
.tap-red:hover { background-color: #b01f25; }

/* Стрелка на кнопке сдвигается на 3 px при наведении */
.arrow-nudge .arrow { transition: transform var(--dur-fast) var(--ease); }
.arrow-nudge:hover .arrow { transform: translateX(3px); }

/* Карточки товаров поднимаются на 2 px */
.lift { transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease); }
.lift:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14); }

/* Раскрытие склада <details>: стрелка поворачивается */
.chev { transition: transform var(--dur-base) var(--ease); }
details[open] > summary .chev { transform: rotate(180deg); }

/* Тост «товар добавлен» */
.toast { position: fixed; left: 50%; bottom: 84px; z-index: 70; max-width: calc(100vw - 32px); transform: translate(-50%, 8px); opacity: 0; pointer-events: none; transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

/* Загрузка: серые блоки без мерцания */
.skeleton { background: #e5e5e5; border-radius: 12px; }

/* Уважение к настройке «уменьшить движение»: состояние меняется, движения нет */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
  }
}

.container-main { width: min(100% - 32px, 1280px); margin-inline: auto; }

/* Меню: до 1280 px выезжающая панель справа, от 1280 px полоса над шапкой */
.menu-link { display: block; margin-inline: -12px; border-radius: 12px; padding: 12px; font-size: 16px; font-weight: 600; color: #fff; }
.menu-link:hover { background: rgba(255, 255, 255, 0.1); }
@media (max-width: 1279.98px) {
  .menu-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 60; width: min(88vw, 360px);
    overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(100%); visibility: hidden;
    transition: transform var(--dur-slow) var(--ease), visibility 0s linear var(--dur-slow);
  }
  .menu-panel.is-open { transform: none; visibility: visible; transition-delay: 0s; }
  .menu-scrim {
    position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.55); opacity: 0; visibility: hidden;
    transition: opacity var(--dur-slow) var(--ease), visibility 0s linear var(--dur-slow);
  }
  .menu-scrim.is-open { opacity: 1; visibility: visible; transition-delay: 0s; }
}
@media (min-width: 1280px) {
  .menu-scrim { display: none; }
  .menu-inner { width: min(100% - 32px, 1280px); margin-inline: auto; padding-inline: 0; }
}

/* Нижняя панель навигации (до 1280 px): 5 вкладок по 64 px; страница получает нижний отступ */
.tabbar { display: none; }
@media (max-width: 1279.98px) {
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr);
    border-top: 1px solid rgba(255, 255, 255, 0.12); background: rgba(0, 0, 0, 0.96); backdrop-filter: blur(8px);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 56px; background: transparent; border: 0; color: #d4d4d8; font-size: 12px; font-weight: 600; cursor: pointer;
    transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
  }
  .tab svg { width: 24px; height: 24px; }
  .tab:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
  .tab[aria-current="page"] { color: #fff; box-shadow: inset 0 2px 0 #c9252b; }
  .tab-badge {
    position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; padding: 0 4px; border-radius: 9999px;
    background: #c9252b; color: #fff; font-size: 12px; font-weight: 700; line-height: 18px; text-align: center;
  }
  body:has(.tabbar) { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
}

/* Фильтры-«чипы» каталога и выпадающие списки на <details> */
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 9999px;
  border: 1px solid #d4d4d8; background: #fff; color: #111; font-size: 14px; font-weight: 600; cursor: pointer; list-style: none;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.chip:hover { border-color: #c9252b; color: #c9252b; }
.chip-on { background: #111; border-color: #111; color: #fff; }
.chip-on:hover { background: #111; color: #fff; border-color: #111; }
summary::-webkit-details-marker { display: none; }
summary { list-style: none; }
.popover {
  position: absolute; left: 0; top: calc(100% + 8px); z-index: 30; width: min(300px, calc(100vw - 32px)); max-height: 320px; overflow: auto;
  padding: 8px; border: 1px solid #e4e4e7; border-radius: 16px; background: #fff; color: #111; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
}
.popover-form { padding: 16px; }
details[open] > .popover { animation: pop-in var(--dur-base) var(--ease) both; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.popover-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: 14px;
}
a.popover-item:hover { background: #f4f4f4; }
.suggest-item { display: flex; align-items: baseline; gap: 10px; width: 100%; min-height: 48px; padding: 8px 12px; border-radius: 12px; text-align: left; font-size: 15px; cursor: pointer; }
.suggest-item:hover, .suggest-item[aria-selected="true"] { background: #f4f4f4; }
.suggest-item mark { background: #fde8e8; color: inherit; border-radius: 3px; }
.suggest-kind { flex: none; width: 96px; font-size: 12px; color: #5f6368; }
.pager {
  display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 44px; padding: 0 12px; border-radius: 9999px;
  border: 1px solid #d4d4d8; background: #fff; color: #111; font-weight: 600;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
a.pager:hover { border-color: #c9252b; color: #c9252b; }
.pager-on { background: #111; border-color: #111; color: #fff; }

/* Счётчик количества: кнопки 44 px, поле между ними */
.stepper { display: inline-flex; align-items: center; border: 1px solid #767676; border-radius: 9999px; background: #fff; }
.stepper button { width: 44px; height: 48px; border-radius: 9999px; color: #5f6368; font-size: 22px; line-height: 1; cursor: pointer; transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease); }
.stepper button:hover { color: #111; background: #f4f4f4; }
.stepper input { width: 56px; height: 48px; border: 0; background: transparent; text-align: center; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 2px #fff; }
.stepper input:focus-visible { outline: none; box-shadow: none; }

/* Липкая панель «цена · В корзину» в карточке товара на телефоне: выезжает, когда основная кнопка ушла с экрана */
.buybar { display: none; }
@media (max-width: 1023.98px) {
  .buybar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #e4e4e7; box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(110%); transition: transform var(--dur-base) var(--ease);
  }
  .buybar.is-on { transform: none; }
  body:has(.buybar) .toast { bottom: 88px; }
}

/* Номер шага в корзине */
.step-no {
  display: inline-flex; width: 28px; height: 28px; flex: none; align-items: center; justify-content: center; border-radius: 9999px;
  background: #111; color: #fff; font-size: 14px; font-weight: 700;
}

/* Этап 8: спокойные отклики (только opacity/transform/цвет) */
.city-tab { box-shadow: inset 0 -3px 0 transparent; transition: color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease); }
.city-tab.text-brand-red { box-shadow: inset 0 -3px 0 #c9252b; }

/* Тень шапки появляется только после прокрутки */
#siteHeader { transition: box-shadow var(--dur-fast) var(--ease); }
#siteHeader.is-stuck { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28); }

/* Кнопка поиска: пока грузится выдача, текст заменяется спиннером */
.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border: 2px solid #fff; border-right-color: transparent; border-radius: 9999px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Отзывы: звёзды. Показ — серые звёзды, сверху жёлтые на ширину оценки (4,3 из 5 = 86%) */
.stars { position: relative; display: inline-block; line-height: 1; letter-spacing: 0.08em; color: #d4d4d4; white-space: nowrap; }
.stars::before, .stars-fill::before { content: "★★★★★"; }
.stars-fill { position: absolute; inset: 0 auto 0 0; overflow: hidden; color: #f59e0b; }
/* Ввод оценки: обычные radio, порядок 5…1 развёрнут, чтобы «~» красил звёзды слева от выбранной */
.rate { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; }
.rate input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.rate label { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; font-size: 2rem; line-height: 1; color: #d4d4d4; cursor: pointer; transition: color var(--dur-fast) var(--ease); }
.rate input:checked ~ label { color: #f59e0b; }
.rate:hover input:checked ~ label { color: #d4d4d4; }
.rate:hover label:hover, .rate:hover label:hover ~ label { color: #f59e0b; }
.rate input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: -4px; border-radius: 10px; }
