/* mobile-ui.css — мобильная раскладка каталога гайдов (структура по референсу, цвета — из темы сайта)
   Подключать ПОСЛЕ paper-theme.css. Только @media(max-width:640px): десктоп не затронут. */

@media (max-width: 640px) {

  /* ---------- 1. Шапка: логотип строкой, ниже капсульная лента разделов ---------- */

  .header-inner {
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 10px 12px 8px !important;
    align-items: center !important;
  }

  .header-inner .mega-nav {
    flex: 1 0 100% !important;
    order: 3;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    margin: 0 -12px !important;
    padding: 2px 12px 4px !important;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .header-inner .mega-nav::-webkit-scrollbar { display: none; }

  .header-inner .mega-nav > a {
    flex: 0 0 auto !important;
    display: inline-flex !important;
    align-items: center;
    height: 36px;
    padding: 0 13px !important;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 13px;
    white-space: nowrap;
    scroll-snap-align: start;
  }

  .header-inner .mega-nav > a.active {
    border-color: transparent;
  }


  /* ---------- 1b. Hero: убрать 120px боковые поля, иначе текст в 150px ---------- */

  body .hero {
    padding: 26px 16px 22px !important;
  }

  body .hero h1 {
    font-size: 27px !important;
    line-height: 1.14 !important;
    letter-spacing: -.01em !important;
  }

  body .hero p {
    font-size: 14.5px !important;
    line-height: 1.5 !important;
    max-width: none !important;
  }

  /* ---------- 2. Hero-метрики: 2×2 вместо тесного ряда из четырёх ---------- */

  body .hero .hero-metrics {
    width: 100% !important;
    max-width: none !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  body .hero .hero-metric {
    width: auto !important;
    min-width: 0;
    padding: 10px 12px !important;
    box-sizing: border-box;
  }

  body .hero .hero-metric .lbl {
    font-size: 9.5px !important;
    line-height: 1.2 !important;
    letter-spacing: .04em;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }

  /* ---------- 2b. Контейнер каталога: боковые поля, иначе карточки в край экрана ---------- */

  body .container.detail,
  body .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
    box-sizing: border-box;
  }

  /* ---------- 3. Поиск и фильтры: поле 46px + чипы одной лентой ---------- */

  .qc-filterbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 14px;
  }

  .qc-search-wrap { width: 100%; display: flex; align-items: center; }

  .qc-search {
    width: 100%;
    height: 46px;
    box-sizing: border-box;
    font-size: 16px;               /* иначе iOS зумит страницу при фокусе */
    padding: 0 40px 0 14px;
    border-radius: 12px;
  }

  .qc-search-clear {
    width: 40px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .qc-filterbar .qc-chips {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    margin: 0 !important;
    padding: 2px 0 6px !important;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .qc-filterbar .qc-chips::-webkit-scrollbar { display: none; }

  /* подсказка, что лента листается: мягкое затухание у правого края */
  .qc-filterbar .qc-chips,
  .header-inner .mega-nav {
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 20px), transparent 100%);
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 20px), transparent 100%);
  }

  /* место под фиксированный баннер cookie, чтобы он не закрывал карточки */
  body { padding-bottom: 104px !important; }

  /* cookie-баннер: компактная нижняя плашка, чтобы меньше закрывала контент */
  #qc-cookie-bar {
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    border-radius: 12px 12px 0 0 !important;
    padding: 9px 12px 10px !important;
    gap: 7px !important;
    font-size: 11.5px !important;
    line-height: 1.35 !important;
  }

  #qc-cookie-bar .qc-ck-txt {
    max-height: 2.8em;
    overflow: hidden;
  }

  #qc-cookie-bar .qc-ck-btns button {
    height: 36px;
    padding: 0 10px !important;
    font-size: 12.5px !important;
  }

  .qc-filterbar .qc-chips .qc-chip {
    flex: 0 0 auto !important;
    height: 38px;
    padding: 0 14px !important;
    border-radius: 999px;
    font-size: 13px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    scroll-snap-align: start;
  }

  .qc-filterbar .qc-chips .qc-chip .qc-n {
    font-size: 11px;
    opacity: .75;
  }

  /* ---------- 4. Карточки: две колонки, компактные, ровные ---------- */

  body .guide-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    margin-bottom: 28px;
    align-items: stretch;
  }

  body .guide-grid .guide-card {
    display: block !important;
    border-radius: 12px;
    min-height: 0 !important;
    height: auto;
  }

  body .guide-grid .guide-card > a {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    padding: 11px 11px 10px !important;
    height: 100%;
    box-sizing: border-box;
  }

  body .guide-grid .guide-card > a > div:first-of-type {
    flex: 1 1 auto !important;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  body .guide-grid .gc-logos {
    gap: 4px !important;
    margin: 0 0 8px !important;
  }

  body .guide-grid .gc-logos img {
    width: 16px !important;
    height: 16px !important;
    max-width: 16px !important;
  }

  /* заголовок — не больше трёх строк */
  body .guide-grid .guide-card h3 {
    font-size: 13px !important;
    line-height: 1.25 !important;
    margin: 0 0 5px !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 0 !important;
  }

  /* вторая строка (сумма) — до двух строк */
  body .guide-grid .guide-card > a > div:first-of-type > p:nth-of-type(1) {
    font-size: 11.5px !important;
    line-height: 1.3 !important;
    margin: 0 0 7px !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* длинное описание на телефоне не нужно — остаётся на странице гайда */
  body .guide-grid .guide-card > a > div:first-of-type > p:nth-of-type(2) {
    display: none !important;
  }

  /* «Открыть гайд» — мелкой подписью, прижатой к низу */
  body .guide-grid .guide-card > a > div:first-of-type > span {
    font-size: 10.5px !important;
    margin-top: auto !important;
    padding-top: 4px;
    opacity: .9;
  }

  /* стрелка справа не нужна: вся карточка — зона тапа */
  body .guide-grid .guide-card > a > div:last-child {
    display: none !important;
  }

  body .guide-grid .guide-card a:active { opacity: .85; }
}

/* очень узкие экраны — чуть плотнее */
@media (max-width: 360px) {
  body body .guide-grid { gap: 8px !important; }
  body .guide-grid .guide-card > a { padding: 9px !important; }
  body .guide-grid .guide-card h3 { font-size: 12.5px !important; }
  body .guide-grid .guide-card > a > div:first-of-type > p:nth-of-type(1) { font-size: 11px !important; }
}
