/* ===== База ===== */
:root {
  --bg: #F2F3F5;
  --card: #FFFFFF;
  --ink: #111214;
  --muted: #6B7078;
  --soft: #F2F3F5;
  --accent: #FFC21A;
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  scroll-behavior: smooth;
  scroll-padding-top: 76px;
  background: var(--bg);
  /* Компактный дизайн: все отступы и высоты Tailwind (rem) на 12,5% меньше */
  font-size: 14px;
  /* Полосы прокрутки скрыты, сама прокрутка работает */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

body {
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Блокировка прокрутки при открытом окне — только на html.
   Если добавить overflow и на body, он станет отдельным контейнером прокрутки
   и sticky-шапка «уедет» наверх страницы */
html.lock {
  overflow: hidden;
  overscroll-behavior: none;
}

[hidden] {
  display: none !important;
}

/* Правило дизайна: без теней, свечений и обводок */
*,
*::before,
*::after {
  box-shadow: none !important;
  text-shadow: none !important;
}

:focus,
:focus-visible {
  outline: none;
}

::selection {
  background: #FFE38A;
  color: var(--ink);
}

/* ===== Клик / тап ===== */
a,
button,
[role='button'],
label,
.press {
  -webkit-tap-highlight-color: transparent;
}

.press {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition:
    transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1),
    background-color 0.2s ease,
    color 0.2s ease,
    opacity 0.2s ease;
}

/* Инлайн-ссылкам нужен блочный display, иначе scale не работает.
   :where() — нулевая специфичность, классы Tailwind (flex, hidden) важнее */
:where(a.press) {
  display: inline-block;
}

.press.is-pressed {
  transform: scale(0.96);
}

.press-soft.is-pressed {
  transform: scale(0.985);
}

.press:disabled,
.press[aria-disabled='true'] {
  cursor: not-allowed;
}

.press:focus-visible {
  filter: brightness(0.93);
}

/* ===== Поля ===== */
.field {
  display: block;
  width: 100%;
  background: var(--soft);
  border: 0;
  border-radius: 17px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 0.2s ease;
}

.field::placeholder {
  color: #9AA0A8;
}

.field:focus {
  background: #E8EAED;
}

.field.error {
  background: #FDECEC;
}

select.field {
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%23111214' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 8 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

textarea.field {
  resize: none;
  min-height: 88px;
}

/* ===== Опции (объём, способ получения, оплата) ===== */
.opt {
  background: var(--soft);
  color: var(--ink);
}

.opt.on {
  background: var(--ink);
  color: #fff;
}

.opt.on .opt-muted {
  color: rgba(255, 255, 255, 0.65);
}

.opt:disabled {
  opacity: 0.4;
}

/* ===== Первый экран: картинка растворяется в фоне снизу ===== */
.hero-img {
  -webkit-mask-image: linear-gradient(to bottom, #000 30%, rgba(0, 0, 0, 0.35) 62%, transparent 88%);
  mask-image: linear-gradient(to bottom, #000 30%, rgba(0, 0, 0, 0.35) 62%, transparent 88%);
}

@media (min-width: 1024px) {
  .hero-img {
    -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
  }
}

/* ===== Выпадающий список (оформление заказа) ===== */
.dd {
  position: relative;
}

.dd-chev {
  display: inline-flex;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

[aria-expanded='true'] .dd-chev {
  transform: rotate(180deg);
}

.dd-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  padding: 6px;
  border-radius: 18px;
  background: #E9EAED;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top center;
  transition:
    opacity 0.16s ease,
    transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1),
    visibility 0s linear 0.2s;
}

.dd.open .dd-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity 0.2s ease,
    transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
    visibility 0s;
}

.dd-opt {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  color: var(--ink);
  transition: background-color 0.15s ease;
}

.dd-opt:hover,
.dd-opt.on {
  background: #fff;
}

.dd-check {
  display: inline-flex;
  opacity: 0;
}

.dd-opt.on .dd-check {
  opacity: 1;
}

/* ===== Раскрывающийся блок (карта) — плавная высота через grid ===== */
.acc-body {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition:
    grid-template-rows 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.25s ease;
}

.acc-body.open {
  grid-template-rows: 1fr;
  opacity: 1;
}

.acc-body > div {
  min-height: 0;
  overflow: hidden;
}

/* ===== Карта Leaflet в стиле сайта ===== */
.leaflet-container {
  font: inherit;
  background: #E9EAED;
}

/* Tailwind preflight ограничивает img — ломает плитки карты */
.leaflet-container img {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-bar {
  border: 0 !important;
  border-radius: 12px !important;
  overflow: hidden;
}

.leaflet-bar a {
  border-bottom: 0 !important;
  color: var(--ink) !important;
}

.leaflet-control-attribution {
  font-size: 9px;
  border-radius: 8px 0 0 0;
}

.map-pin {
  background: transparent;
  border: 0;
}

.map-pin span {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
  margin: 4px;
  border-radius: 50% 50% 50% 0;
  background: var(--ink);
  transform: rotate(-45deg);
}

.map-pin span::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* ===== Горизонтальный скролл без полосы ===== */
.no-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* ===== Модальные окна: scale + fade из центра ===== */
.sheet {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 0.2s;
}

.sheet.open {
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.sheet__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(17, 18, 20, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease-in;
}

.sheet.open .sheet__backdrop {
  opacity: 1;
  transition: opacity 0.3s ease-out;
}

.sheet__panel {
  position: relative;
  width: 100%;
  max-width: 470px;
  max-height: 100%;
  background: #fff;
  border-radius: 34px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  opacity: 0;
  transform: scale(0.95);
  transition:
    opacity 0.2s ease-in,
    transform 0.2s ease-in;
}

.sheet__panel::-webkit-scrollbar {
  display: none;
}

.sheet.open .sheet__panel {
  opacity: 1;
  transform: scale(1);
  transition:
    opacity 0.3s ease-out,
    transform 0.3s ease-out;
}

.sheet__handle {
  display: none;
}

/* ===== Телефон: шторка снизу, закрывается свайпом за черту ===== */
@media (max-width: 767.98px) {
  .sheet {
    align-items: flex-end;
    padding: 0;
    padding-top: max(24px, env(safe-area-inset-top));
    transition: visibility 0s linear 0.45s;
  }

  .sheet__panel {
    max-width: none;
    border-radius: 28px 28px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    opacity: 1;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  }

  .sheet.open .sheet__panel {
    opacity: 1;
    transform: translateY(0);
    transition: transform 0.45s cubic-bezier(0.32, 0.72, 0, 1);
  }

  /* Пока палец тянет шторку — без анимации, она идёт ровно за пальцем */
  .sheet.dragging .sheet__panel,
  .sheet.dragging .sheet__backdrop {
    transition: none;
  }

  .sheet__handle {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    margin-bottom: -12px;
    background: #fff;
    touch-action: none;
    cursor: grab;
  }

  .sheet__handle span {
    width: 40px;
    height: 5px;
    border-radius: 99px;
    background: #D4D6DA;
  }

  /* Крестик на шторке не нужен — закрывается свайпом или тапом по фону */
  .sheet-x {
    display: none !important;
  }
}

/* ===== Аккордеоны (Preline) ===== */
.acc-icon {
  transition: transform 0.25s ease, background-color 0.2s ease;
}

.hs-accordion.active .acc-icon {
  transform: rotate(45deg);
  background: var(--ink);
  color: #fff;
}

/* ===== Уведомление ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 90;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* ===== Чат поддержки ===== */
.chat-launcher {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 20px;
  background: var(--accent);
  color: var(--ink);
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease;
}

.chat-launcher svg {
  width: 26px;
  height: 26px;
}

.chat-launcher.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}

.chat-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(17, 18, 20, 0.45);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.chat-scrim.is-open {
  opacity: 1;
}

@media (min-width: 721px) {
  .chat-scrim {
    display: none;
  }
}

.chat-panel {
  position: fixed;
  z-index: 61;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

/* Компьютер: карточка в углу */
@media (min-width: 721px) {
  .chat-panel {
    right: 20px;
    bottom: 20px;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 40px);
    border-radius: 28px;
    transform-origin: bottom right;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .chat-panel.is-open {
    opacity: 1;
    transform: none;
  }
}

/* Телефон: шторка снизу */
@media (max-width: 720px) {
  .chat-panel {
    left: 0;
    right: 0;
    bottom: 0;
    height: 86vh;
    height: 86dvh;
    border-radius: 28px 28px 0 0;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  }

  .chat-panel.is-open {
    transform: none;
  }

  .chat-panel.is-dragging {
    transition: none;
  }
}

.chat-grabber {
  display: none;
}

@media (max-width: 720px) {
  .chat-grabber {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 22px;
    touch-action: none;
  }

  .chat-grabber span {
    width: 40px;
    height: 5px;
    border-radius: 99px;
    background: #D4D6DA;
  }
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--ink);
  color: #fff;
}

@media (max-width: 720px) {
  .chat-head {
    touch-action: none;
  }
}

.chat-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--ink);
  flex-shrink: 0;
}

.chat-avatar svg {
  width: 20px;
  height: 20px;
}

.chat-head-copy {
  flex: 1;
  min-width: 0;
}

.chat-head-copy strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
}

.chat-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2BB673;
}

.chat-reset,
.chat-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

@media (max-width: 720px) {
  .chat-close {
    display: none;
  }
}

.chat-reset svg,
.chat-close svg {
  width: 18px;
  height: 18px;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: none;
}

.chat-log::-webkit-scrollbar {
  display: none;
}

.chat-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.5;
}

.chat-msg p {
  margin: 0;
  white-space: pre-line;
}

.chat-msg.is-support {
  align-self: flex-start;
  background: var(--soft);
  border-bottom-left-radius: 6px;
}

.chat-msg.is-user {
  align-self: flex-end;
  background: var(--ink);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.chat-msg.is-error {
  background: #FDECEC;
  color: #B42318;
}

.chat-typing {
  display: flex;
  gap: 4px;
  padding: 3px 1px;
}

.chat-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #B6BAC1;
  animation: chatDot 1s infinite ease-in-out;
}

.chat-typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chatDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.chat-field {
  flex: 1;
  min-width: 0;
}

.chat-input {
  width: 100%;
  background: var(--soft);
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}

.chat-input::placeholder {
  color: #9AA0A8;
}

.chat-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
}

.chat-send svg {
  width: 20px;
  height: 20px;
}

.chat-send:disabled {
  opacity: 0.4;
}

/* ===== Прогресс до бесплатной доставки ===== */
.bar {
  height: 6px;
  border-radius: 99px;
  background: #E4E6EA;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.35s ease;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .press,
  .sheet__panel,
  .sheet__backdrop {
    transition: none;
  }
}
