/* ════════════════════════════════════════════════════════════════════
   Витрина «Мебель и оборудование для магазина»

   Дизайн: тёплый издательский минимализм — EB Garamond + Onest,
   тёплая бумага, терракотовый акцент, мягкие радиусы, hairline-линейки.
   Mobile-first: компактная шапка, крупные зоны нажатия, нижняя шторка.
   Переработано 2026-07-10 по решению владельца — сознательный отход
   от крафт-эстетики design_handoff_vitrina (механика — по хендоффу).
   ════════════════════════════════════════════════════════════════════ */

:root {
  --paper: #FAF7F2;
  --ink: #1C1712;
  --ink-soft: #3A3127;
  --muted: #8B8073;
  --faint: #BFB4A4;
  --accent: #9E5430;            /* терракота; тёмный ховер: #7E401F */
  --accent-dark: #7E401F;
  --hairline: rgba(50, 35, 20, .14);
  --hairline-strong: rgba(50, 35, 20, .34);
  --photo-bg: #F1ECE4;
  --ghost: rgba(90, 60, 35, .11);

  --font-display: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-ui: 'Onest', system-ui, -apple-system, sans-serif;

  /* Форма фото в карточке каталога. 3/4 — вертикальная, под фото мебели
     в полный рост (шкафы, стеллажи, витрины снимают вертикально). */
  --photo-ar: 3/4;
  --ease: cubic-bezier(.22, .9, .32, 1);
}

html { -webkit-text-size-adjust: 100%; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: var(--ink); }
::selection { background: rgba(158, 84, 48, .18); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.modal-open { overflow: hidden; }

.wrap {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  padding-left: clamp(18px, 3.5vw, 32px);
  padding-right: clamp(18px, 3.5vw, 32px);
}

/* ── Анимации ─────────────────────────────────────────────────────── */

@keyframes v-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes v-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes v-sheet {
  from { opacity: .6; transform: translateY(48px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ── Шапка (на телефоне — компактная) ─────────────────────────────── */

.site-header {
  padding-top: clamp(16px, 4vw, 52px);
  padding-bottom: clamp(10px, 2vw, 24px);
  animation: v-up .55s var(--ease) both;
}

.header-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.overline {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
}

.avito-top {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 1px solid var(--hairline-strong);
  padding-bottom: 2px;
}
.avito-top:hover { border-bottom-color: var(--accent); color: var(--accent); }

.site-header h1 {
  margin: clamp(8px, 1.8vw, 16px) 0 clamp(8px, 1.8vw, 14px);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(28px, 7vw, 60px);
  line-height: 1.06;
  letter-spacing: -.01em;
  text-wrap: balance;
  max-width: 14em;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.header-meta .dot { color: var(--faint); }

.header-meta a.phone {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 1px solid rgba(158, 84, 48, .35);
  padding-bottom: 1px;
}
.header-meta a.phone:hover { color: var(--accent-dark); border-bottom-color: var(--accent-dark); }

.ruler {
  margin-top: clamp(12px, 2.5vw, 22px);
  height: 0;
  border-top: 1px solid var(--hairline-strong);
}

/* ── Фильтры ──────────────────────────────────────────────────────── */

.filters {
  position: sticky;
  top: 0;
  z-index: 40;
  /* Непрозрачный фон вместо backdrop-filter: blur ломает position:sticky
     на iOS Safari (панель «отлипает» и дёргается при прокрутке). */
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
}

.filters-scroll {
  display: flex;
  gap: clamp(20px, 3vw, 34px);
  overflow-x: auto;
  padding-top: 0;
  padding-bottom: 0;
  scrollbar-width: none;
  /* Свайп по полосе категорий листает её только по горизонтали и не
     тянет страницу по вертикали (иначе — диагональный дрейф на телефоне).
     overscroll-behavior гасит сцепку с прокруткой страницы и свайп «назад». */
  touch-action: pan-x;
  overscroll-behavior-x: contain;
}
.filters-scroll::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  min-height: 48px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .18s ease, border-color .18s ease;
}
.chip:hover { color: var(--ink); }
.chip.active {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}
.chip .n {
  color: var(--faint);
  font-weight: 500;
  font-size: 12px;
  margin-left: 4px;
}
.chip.active .n { color: var(--accent); }

.count-line {
  padding-top: 12px;
  padding-bottom: 0;
  font-size: 12px;
  color: var(--muted);
}

/* ── Сетка каталога ───────────────────────────────────────────────── */

.grid {
  padding-top: clamp(16px, 3vw, 26px);
  padding-bottom: clamp(72px, 10vw, 96px);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(43vw, 236px), 1fr));
  column-gap: clamp(14px, 2.5vw, 30px);
  row-gap: clamp(26px, 4.5vw, 46px);
  align-items: start;
}

/* ── Карточка товара ──────────────────────────────────────────────── */

.card {
  animation: v-up .5s var(--ease) both;
}

.card-photo {
  position: relative;
  aspect-ratio: var(--photo-ar);
  background: var(--photo-bg);
  border-radius: 10px;
  overflow: hidden;
}

.card-photo-zoom {
  position: absolute;
  inset: 0;
  transition: transform .6s var(--ease);
}
@media (hover: hover) {
  .card-photo:hover .card-photo-zoom { transform: scale(1.025); }
}

.card-photo-zoom img,
.modal-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* В открытой карточке фото показываем ЦЕЛИКОМ (без обрезки), чтобы
   покупатель видел весь товар — любой формат снимка вписывается в рамку. */
.modal-photo img { object-fit: contain; }

/* Заглушка без фото: призрачный инвентарный номер, как в каталоге */
.photo-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-empty .num {
  font-family: var(--font-display);
  font-size: clamp(44px, 9vw, 76px);
  font-weight: 500;
  color: var(--ghost);
  user-select: none;
}
.photo-empty .cat {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ghost);
  user-select: none;
}

.card-body {
  padding: 11px 2px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(158, 84, 48, .08);
}

.card-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
}

.card-title {
  font-family: var(--font-display);
  font-size: 17.5px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (hover: hover) {
  .card:hover .card-title { color: var(--accent-dark); }
}

.card-dims {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.card-price {
  margin-top: 3px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.card-noprice {
  margin-top: 3px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

/* ── Футер ────────────────────────────────────────────────────────── */

.site-footer {
  margin-top: auto;
  background: #221A12;
  color: rgba(250, 247, 242, .9);
  padding-top: clamp(24px, 4vw, 36px);
  padding-bottom: calc(clamp(24px, 4vw, 36px) + env(safe-area-inset-bottom));
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.footer-note { opacity: .72; }

.footer-links {
  display: flex;
  gap: 12px 26px;
  align-items: center;
  flex-wrap: wrap;
}

.footer-phones {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.footer-links a {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: #FAF7F2;
  text-decoration: none;
  border-bottom: 1px solid rgba(250, 247, 242, .35);
}
.footer-links a:hover { border-bottom-color: #FAF7F2; }
.footer-phone { font-weight: 600; }

/* На телефоне под футером — место для плавающей кнопки */
@media (max-width: 700px) {
  .site-footer {
    padding-bottom: calc(clamp(24px, 4vw, 36px) + 76px + env(safe-area-inset-bottom));
  }
}

/* ── Кнопка «Позвонить» (только на телефоне) ──────────────────────── */

.call-fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 50;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 26px;
  background: var(--accent);
  color: #FDF9F4;
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: .02em;
  text-decoration: none;
  border-radius: 12px;
  box-shadow: 0 10px 26px rgba(126, 64, 31, .35);
  animation: v-up .5s .7s var(--ease) both;
  transition: transform .15s ease, background .15s ease;
}
.call-fab:hover { color: #FDF9F4; background: var(--accent-dark); }
.call-fab:active { transform: scale(.97); }

@media (max-width: 700px) {
  .call-fab { display: flex; }
}

/* ── Модалка товара ───────────────────────────────────────────────── */

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(28, 20, 12, .44);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 24px;
  box-sizing: border-box;
  animation: v-fade .18s ease;
  /* Собственный слой композитинга: без этого некоторые WebView
     рисуют фон fixed-оверлея со смещением на величину скролла. */
  transform: translateZ(0);
}
.modal-wrap.open { display: flex; }

.modal-box {
  background: var(--paper);
  width: 100%;
  max-width: 880px;
  max-height: 90vh;
  border-radius: 14px;
  overflow: auto;
  position: relative;
  animation: v-sheet .3s var(--ease);
  box-shadow: 0 30px 80px rgba(30, 18, 8, .4);
}

@media (max-width: 700px) {
  .modal-wrap {
    align-items: flex-end;
    padding: 40px 0 0;
  }
  .modal-box {
    max-width: 100%;
    max-height: 94dvh;
    border-radius: 16px 16px 0 0;
  }
}

.modal-top {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 0;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--paper);
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
  line-height: 1;
  font-family: inherit;
  transition: color .15s ease;
}
.modal-close:hover { color: var(--accent); }

.modal-cols {
  display: flex;
  flex-wrap: wrap;
  padding: clamp(16px, 3vw, 28px) clamp(16px, 3vw, 28px) 0;
  gap: 0 clamp(20px, 3vw, 36px);
}

.modal-left {
  flex: 1.1 1 300px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;
  min-width: 0;
  animation: v-up .4s .04s var(--ease) both;
}

.modal-photo {
  position: relative;
  aspect-ratio: 3/4;
  overflow: hidden;
  background: var(--photo-bg);
  border-radius: 10px;
}

.modal-photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-photo-small {
  position: relative;
  aspect-ratio: 3/4;
  overflow: hidden;
  background: var(--photo-bg);
  border-radius: 8px;
}
.modal-photo-small img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-right {
  flex: 1 1 280px;
  padding: clamp(14px, 2vw, 4px) 0 14px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-width: 0;
  animation: v-up .45s .1s var(--ease) both;
}

.modal-cat {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
}

.modal-right h2 {
  margin: 8px 0 4px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(25px, 5.5vw, 33px);
  line-height: 1.12;
  letter-spacing: -.005em;
}

.modal-ids {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 14px;
}

.modal-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 13.5px;
}
.modal-row:first-child { border-top: 1px solid var(--hairline); }
.modal-row .label { color: var(--muted); flex: none; }
.modal-row .value { font-weight: 500; text-align: right; }

.modal-desc {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-soft);
}

.modal-price {
  font-family: var(--font-display);
  font-size: clamp(23px, 5.5vw, 29px);
  margin-top: 16px;
}

.modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: linear-gradient(rgba(250, 247, 242, 0), var(--paper) 34%);
  padding: 16px clamp(16px, 3vw, 28px) calc(16px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  text-align: center;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: .02em;
  text-decoration: none;
}

.btn-avito {
  background: var(--accent);
  color: #FDF9F4;
  transition: transform .15s ease, background .15s ease;
}
.btn-avito:hover { color: #FDF9F4; background: var(--accent-dark); }
.btn-avito:active { transform: scale(.98); }

.btn-call {
  border: 1.5px solid var(--hairline-strong);
  color: var(--ink);
  background: var(--paper);
  transition: transform .15s ease, color .15s ease, border-color .15s ease;
}
.btn-call:hover { border-color: var(--accent); color: var(--accent); }
.btn-call:active { transform: scale(.98); }

/* ── Фото кликабельны ─────────────────────────────────────────────── */

.card-photo { cursor: pointer; }
.modal-photo img.zoomable,
.modal-photo-small img.zoomable { cursor: zoom-in; }

/* ── Полноэкранный просмотр фото (лайтбокс) ───────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 11, 7, .94);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: v-fade .18s ease;
}
.lightbox[hidden] { display: none; }

.lb-img {
  max-width: 94vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
  user-select: none;
  -webkit-user-select: none;
}

.lb-close,
.lb-nav {
  position: fixed;
  border: 0;
  background: rgba(250, 247, 242, .12);
  color: #FAF7F2;
  cursor: pointer;
  border-radius: 10px;
  font-family: inherit;
  line-height: 1;
  transition: background .15s ease;
}
.lb-close:hover,
.lb-nav:hover { background: rgba(250, 247, 242, .24); }

.lb-close {
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  width: 46px;
  height: 46px;
  font-size: 20px;
}
.lb-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 70px;
  font-size: 36px;
}
.lb-prev { left: 10px; }
.lb-next { right: 10px; }

.lb-count {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(250, 247, 242, .85);
  font-size: 13px;
  letter-spacing: .05em;
}

/* ── Лист «кому позвонить» ─────────────────────────────────────────── */

.call-sheet {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(28, 20, 12, .44);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: v-fade .18s ease;
}
.call-sheet[hidden] { display: none; }

.call-sheet-box {
  background: var(--paper);
  width: 100%;
  max-width: 420px;
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  box-sizing: border-box;
  animation: v-sheet .3s var(--ease);
  box-shadow: 0 -12px 40px rgba(30, 18, 8, .3);
}
@media (min-width: 560px) {
  .call-sheet { align-items: center; }
  .call-sheet-box { border-radius: 16px; }
}

.call-sheet-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
  text-align: center;
}

.call-sheet-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color .15s ease;
}
.call-sheet-item:hover { border-color: var(--accent); }
.cs-name { font-weight: 600; font-size: 15px; }
.cs-phone {
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.call-sheet-cancel {
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}
.call-sheet-cancel:hover { color: var(--ink); }
