/* ============================================================
   Компоненты каталога (интернет-магазин / недвижимость / объекты).
   Подключать после base.css и до theme-N.css. Без JS и внешних ресурсов.
   ============================================================ */

/* ---------- Шапка каталога: счётчик сравнения, мессенджеры ---------- */
.head-tools { display: flex; align-items: center; gap: 14px; }
.cmp-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; color: var(--text); white-space: nowrap; }
.cmp-link .cnt { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--primary); color: #fff; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
.msgr { display: inline-flex; gap: 6px; }
.msgr a { width: 30px; height: 30px; border-radius: 50%; background: var(--bg-alt); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; text-decoration: none; }
.tagline { font-size: 12.5px; color: var(--muted); }

/* Логотип в тёмном подвале: акцентная часть названия цветом --primary на тёмном фоне не читается */
.footer .logo-name span { color: rgba(255, 255, 255, .72); }

/* Переключатели валюты и языка в верхней полосе; недоступный пока язык — приглушён */
.tb-switch { white-space: nowrap; }
.tb-switch .soon { opacity: .5; }
.topbar .tb-group { align-items: center; }
.phones .callback { color: var(--muted); text-decoration: underline; font-weight: 400; font-family: var(--font-body); font-size: 13px; }

/* Ярлык внутри карточки-колонки не растягивается на всю ширину */
.card > .badge, .summary .badge { align-self: flex-start; justify-self: start; } /* .card — flex, .summary — grid */

/* Цифры-плитки внутри первого экрана — мельче, иначе «≈ $1 420» переносится в узкой колонке */
.hero .stats { grid-template-columns: repeat(2, 1fr); }
.hero .stat { padding: 12px; }
.hero .stat .n { font-size: 22px; }

/* ---------- Тип сделки: Купить / Снять (первый уровень каталога) ---------- */
.deal-switch { display: inline-flex; background: var(--bg-alt); border-radius: 24px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.deal-switch a { padding: 8px 22px; border-radius: 20px; font-weight: 700; font-size: 15px; color: var(--text); }
.deal-switch a.on { background: var(--primary); color: #fff; }
.deal-switch a:hover { text-decoration: none; }

.deal-q { font-family: var(--font-head); font-weight: 700; font-size: 18px; margin-bottom: 8px; }

/* ---------- Квиз поверх страницы без JS: ссылка href="#quiz" открывает .modal:target ---------- */
.modal { display: none; position: fixed; inset: 0; z-index: 100; align-items: center; justify-content: center; padding: 16px; }
.modal:target { display: flex; }
.modal-bg { position: absolute; inset: 0; background: rgba(10, 20, 30, .55); }
.modal-box { position: relative; width: 100%; max-width: 560px; padding-top: 38px; }
.modal-close { position: absolute; right: 0; top: 0; font-size: 30px; line-height: 1; color: #fff; text-decoration: none; }
.modal-close:hover { text-decoration: none; opacity: .8; }
/* aspect-ratio + min-height задают и минимальную ширину (280 × 4/3 = 373px) — на телефоне это горизонтальный скролл */
.hero-visual { border-color: rgba(255,255,255,.35); color: #5e6a78; aspect-ratio: auto; min-height: 280px; }
.hero .container > * { min-width: 0; }

/* ---------- Поиск по каталогу в первом экране ---------- */
.search-box { background: #fff; color: var(--text); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.search-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.search-tabs span { padding: 6px 14px; border-radius: 20px; font-size: 13.5px; font-weight: 700; background: var(--bg-alt); color: var(--muted); }
.search-tabs span.on { background: var(--primary); color: #fff; }
.search-grid { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 10px; align-items: end; }
.search-grid .form-row { margin: 0; }
.hero .search-grid { grid-template-columns: 1fr 1fr; } /* в колонке первого экрана 4 поля в ряд не помещаются */
.hero .search-grid .btn { grid-column: 1 / -1; }

/* ---------- Плитки-счётчики категорий ---------- */
.counters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.counter { display: block; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; color: var(--text); }
.counter:hover { text-decoration: none; border-color: var(--primary); }
.counter .n { font-family: var(--font-head); font-size: 28px; font-weight: 800; color: var(--primary); display: block; }
.counter .l { font-size: 14px; color: var(--muted); }

/* ---------- Чипсы-подборки ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.chips a { padding: 7px 14px; border: 1px solid var(--border); border-radius: 20px; font-size: 14px; color: var(--text); background: #fff; white-space: nowrap; }
.chips a:hover, .chips a.on { border-color: var(--primary); color: var(--primary); text-decoration: none; }

/* ---------- Листинг с фильтром ---------- */
.catalog { display: grid; grid-template-columns: 270px 1fr; gap: 28px; align-items: start; }
.catalog > * { min-width: 0; } /* иначе широкая таблица листинга распирает колонку и даёт горизонтальный скролл */
.filters { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; }
.filters h3 { font-size: 16px; }
.filters fieldset { border: none; display: grid; gap: 6px; }
.filters legend { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.filters label.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.range input, .filters select { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; font-family: var(--font-body); }
.flt-tgl { display: none; }
.flt-btn { display: none; }
.view-switch { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.view-switch span { padding: 7px 12px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.view-switch span.on { background: var(--primary); color: #fff; }

/* ---------- Карточка объекта ---------- */
.obj-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.obj-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.obj { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.obj .ph { border-radius: 0; border: none; border-bottom: 1px dashed #b9c4cf; }
.obj-media { position: relative; }
.obj-media .tags { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.obj-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.obj h3 { font-size: 17px; }
.obj h3 a { color: var(--text); }
.obj .loc { font-size: 13.5px; color: var(--muted); }
.obj .o-price { font-family: var(--font-head); font-weight: 800; font-size: 20px; color: var(--text); }
.obj .o-price small { font-weight: 600; font-size: 13px; color: var(--muted); }
.obj .o-params { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13.5px; color: var(--muted); list-style: none; padding: 0; margin: 0; }
.obj .o-pay { font-size: 13.5px; }
.obj .o-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.obj .o-actions .btn { flex: 1; }
.fresh { font-size: 12.5px; color: var(--muted); }
.b-ver { background: var(--ok); }
.b-stage { background: #495867; }
.b-warn { background: #b35c00; }
.add-cmp { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; font-weight: 600; color: var(--text); background: #fff; white-space: nowrap; }
.add-cmp:hover { border-color: var(--primary); text-decoration: none; }

/* Листинг таблицей (аналитический вид) */
.obj-table td .t-title { font-weight: 700; color: var(--text); }
.obj-table td .t-sub { display: block; font-size: 12.5px; color: var(--muted); }

/* Пагинация */
.pager { display: flex; gap: 6px; justify-content: center; align-items: center; margin-top: 26px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 38px; height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; color: var(--text); }
.pager .on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Страница объекта ---------- */
.obj-head { display: grid; grid-template-columns: 1.5fr 1fr; gap: 28px; align-items: start; }
.gallery { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.gallery .g-side { display: grid; gap: 8px; }
.gallery .ph { height: 100%; }
.g-main { position: relative; }
.g-main .play { position: absolute; left: 14px; bottom: 14px; }
.summary { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: grid; gap: 10px; }
.summary .s-price { font-family: var(--font-head); font-size: 28px; font-weight: 800; }
.summary .s-price small { font-size: 14px; font-weight: 600; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 600; margin: 0; }
.anchors { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--border); }
.anchors .container { display: flex; gap: 4px; overflow-x: auto; }
.anchors a { padding: 13px 12px; font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; }
.anchors a:hover { color: var(--primary); text-decoration: none; }

/* Консультант */
.consult { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.consult .ph { aspect-ratio: 1/1; border-radius: 50%; padding: 0; font-size: 11px; }
.consult b { display: block; }
.consult .role { font-size: 13px; color: var(--muted); }
.consult .c-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Проверка и риски */
.check { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: grid; gap: 14px; }
.check-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.check-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 22px; font-size: 14.5px; }
.check-list li { padding-left: 26px; position: relative; }
.check-list li::before { position: absolute; left: 0; top: 0; font-weight: 800; }
.check-list .ok::before { content: "✓"; color: var(--ok); }
.check-list .risk::before { content: "!"; color: #b35c00; }
.check-list .open::before { content: "?"; color: var(--muted); }
.check-meta { font-size: 13px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }

/* Ход строительства */
.timeline { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.timeline li { border-top: 3px solid var(--border); padding-top: 10px; font-size: 14px; }
.timeline li.done { border-top-color: var(--ok); }
.timeline li.now { border-top-color: var(--accent); }
.timeline b { display: block; }

/* Динамика цены — столбики без JS */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding: 10px 0 0; border-bottom: 1px solid var(--border); }
.bars .bar { flex: 1; background: var(--primary); opacity: .82; border-radius: 4px 4px 0 0; position: relative; min-width: 18px; }
.bars .bar span { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 11.5px; font-weight: 700; color: var(--text); white-space: nowrap; }
.bars-x { display: flex; gap: 10px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.bars-x span { flex: 1; text-align: center; min-width: 18px; }

/* Районы */
.districts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.district { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.district .d-body { padding: 14px 16px 16px; display: grid; gap: 6px; }
.district .d-tags { font-size: 13px; color: var(--muted); }

/* Сравнение */
.cmp-wrap { overflow-x: auto; }
table.cmp { border-collapse: collapse; min-width: 760px; width: 100%; background: #fff; font-size: 14.5px; table-layout: fixed; } /* колонки объектов равной ширины */
.cmp thead th:first-child { width: 190px; }
.cmp th, .cmp td { border: 1px solid var(--border); padding: 11px 13px; text-align: left; vertical-align: top; }
.cmp thead th { background: var(--bg-alt); }
.cmp tbody th { background: #fff; font-weight: 600; color: var(--muted); position: sticky; left: 0; min-width: 170px; }
.cmp .best { background: #ecf7ef; }
.cmp .warn { background: #fff4e6; }
.cmp-obj { display: grid; gap: 6px; }
.cmp-obj .ph { aspect-ratio: 16/10; }

/* Квиз (статичный макет) */
.quiz-card { background: #fff; color: var(--text); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.quiz-progress { height: 6px; border-radius: 3px; background: var(--bg-alt); overflow: hidden; }
.quiz-progress span { display: block; height: 100%; background: var(--accent); }
.q-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.q-options label { border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 12px; font-size: 14.5px; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.q-options label.on { border-color: var(--primary); background: var(--bg-alt); }
.q-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }

/* ---------- Ветвящийся квиз без JS (как Marquiz) ----------
   <div class="mq"> radio×N (input.mq-r) → div.quiz-card с label[for] → article.mq-branch×N.
   Выбранный ответ первого вопроса показывает ветку с тем же порядковым номером. */
.mq { display: grid; gap: 14px; }
.mq-r { position: absolute; opacity: 0; pointer-events: none; }
.mq-branch { display: none; }
.mq > .mq-r:nth-of-type(1):checked ~ article:nth-of-type(1),
.mq > .mq-r:nth-of-type(2):checked ~ article:nth-of-type(2),
.mq > .mq-r:nth-of-type(3):checked ~ article:nth-of-type(3),
.mq > .mq-r:nth-of-type(4):checked ~ article:nth-of-type(4),
.mq > .mq-r:nth-of-type(5):checked ~ article:nth-of-type(5),
.mq > .mq-r:nth-of-type(6):checked ~ article:nth-of-type(6) { display: block; }
.mq > .mq-r:nth-of-type(1):checked ~ .quiz-card .q-options label:nth-of-type(1),
.mq > .mq-r:nth-of-type(2):checked ~ .quiz-card .q-options label:nth-of-type(2),
.mq > .mq-r:nth-of-type(3):checked ~ .quiz-card .q-options label:nth-of-type(3),
.mq > .mq-r:nth-of-type(4):checked ~ .quiz-card .q-options label:nth-of-type(4),
.mq > .mq-r:nth-of-type(5):checked ~ .quiz-card .q-options label:nth-of-type(5),
.mq > .mq-r:nth-of-type(6):checked ~ .quiz-card .q-options label:nth-of-type(6) { border-color: var(--primary); background: var(--bg-alt); font-weight: 600; }
.mq .q-options label::before { content: ""; width: 14px; height: 14px; border: 2px solid var(--border); border-radius: 50%; flex: none; }
.mq-path { font-size: 13px; color: var(--muted); margin-top: 8px; }
.mq-path b { color: var(--text); }

/* Статья: содержание, автор, источники */
.with-toc { display: grid; grid-template-columns: 1fr 280px; gap: 36px; align-items: start; }
.toc { position: sticky; top: 16px; background: var(--bg-alt); border-radius: var(--radius); padding: 16px 18px; font-size: 14px; }
.toc ol { padding-left: 18px; display: grid; gap: 6px; margin: 8px 0 0; }
.author-box { display: grid; grid-template-columns: 84px 1fr; gap: 16px; align-items: center; background: var(--bg-alt); border-radius: var(--radius); padding: 18px; }
.author-box .ph { aspect-ratio: 1/1; border-radius: 50%; padding: 0; font-size: 11px; }
.sources { font-size: 14px; color: var(--muted); }
.sources ol { padding-left: 20px; display: grid; gap: 4px; }
.note-box { border-left: 4px solid var(--primary); background: var(--bg-alt); padding: 14px 18px; border-radius: 0 var(--radius) var(--radius) 0; margin: 16px 0; font-size: 15px; }

/* Карта-заглушка */
.map-ph { aspect-ratio: 16/7; }
.infra { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 22px; font-size: 14.5px; }
.infra li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--border); padding: 5px 0; }

/* ---------- Адаптив ---------- */
@media (max-width: 980px) {
  .catalog { grid-template-columns: 1fr; }
  .filters { display: none; }
  .flt-btn { display: inline-flex; }
  .flt-tgl:checked ~ .filters { display: grid; }
  .obj-grid, .districts { grid-template-columns: repeat(2, 1fr); }
  .obj-head, .with-toc { grid-template-columns: minmax(0, 1fr); }
  /* ZE-007: long tables inside article must scroll inside their container,
     not enlarge the mobile viewport via the grid min-content width. */
  .with-toc > * { min-width: 0; }
  .toc { position: static; }
  .search-grid { grid-template-columns: 1fr 1fr; }
  .counters { grid-template-columns: repeat(2, 1fr); }
  .timeline { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .obj-grid, .obj-grid.cols-2, .districts, .q-options, .check-list, .infra { grid-template-columns: 1fr; }
  .search-grid { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: 1fr; }
  .gallery .g-side { grid-template-columns: 1fr 1fr; }
  /* Mobile First: шапка не длиннее ~150px — телефон, мессенджеры, сравнение и CTA в две строки */
  .topbar .tb-group + .tb-group, .logo-desc, .phones .small { display: none; }
  .header-main .container { gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .head-contacts { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
  .head-tools { width: 100%; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
  .consult .c-actions { grid-template-columns: 1fr; }
}

/* ---------- Баннер cookie без JS: чекбокс #ck прячет плашку (в прототипе — после каждой загрузки снова) ---------- */
.cookie { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 90; max-width: 760px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 14px 16px; background: #fff; border: 1px solid #c8c8c8; box-shadow: 0 4px 16px rgba(0, 0, 0, .12); font-size: 14px; }
.cookie p { margin: 0; flex: 1 1 260px; }
.cookie .c-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ck-tgl:checked + .cookie { display: none; }
