/* Mobile layout safety layer.
   Loaded last so the desktop redesign cannot accidentally override the
   compact storefront that already existed before it. */

@media (max-width: 680px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  *,
  *::before,
  *::after { box-sizing: border-box; }

  img,
  svg,
  video,
  iframe { max-width: 100%; }

  .wrap {
    width: 100%;
    max-width: 100%;
    padding-inline: 14px;
  }

  /* Header: stable compact rows without the desktop action capsule.
     Верхняя строка (.topbar) удалена с витрины 27.07.2026 вместе с её
     мобильными правилами. */
  /* На мобильном backdrop-filter отключён, поэтому фон шапки должен быть
     НЕПРОЗРАЧНЫМ — иначе тёмный герой «просвечивает» сквозь липкую шапку
     при прокрутке и выглядит как наезжающая полоса. */
  header { backdrop-filter: none; background: var(--card-bg) !important; }
  .head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 40px 44px;
    gap: 6px 10px;
    width: 100%;
    height: auto;
    min-height: 106px;
    padding: 8px 14px;
  }
  /* Здесь только МЕСТО логотипа в сетке шапки. Сам вид значка (размер,
     скругление, тень) — в storefront.v3.css, блок «ЛОГОТИП». */
  .logo {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    margin: 0;
  }
  .head-actions {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    min-width: 0;
    margin: 0;
    padding: 0;
    gap: 2px;
    border: 0;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none;
  }
  .head-actions .hbtn-divider { display: none; }
  .hbtn,
  .head-actions .theme-toggle {
    display: grid;
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
    border-radius: 10px;
    background: transparent;
  }
  .hbtn .ico { font-size: 20px; line-height: 1; }
  /* Здесь только МЕСТО и РАЗМЕР поиска в сетке шапки. Сам вид (рамка,
     скругление, фон, тень, шрифт) — в storefront.v3.css, блок «СТРОКА
     ПОИСКА». */
  .search {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    height: 44px;
    min-width: 0;
    margin: 0;
  }
  .search input { min-width: 0; }
  .search button {
    min-width: 72px;
    height: 40px;
    margin: 1px;
  }
  #voiceBtn { display: none; }

  /* Scrolling must not replace this tested geometry with another header. */
  body.scrolled-header .head {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 40px 44px;
    height: auto;
    min-height: 106px;
    padding: 8px 14px;
  }
  body.scrolled-header .head .logo {
    display: flex;
    grid-column: 1;
    grid-row: 1;
  }
  body.scrolled-header .search {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }
  body.scrolled-header .head-actions {
    grid-column: 2;
    grid-row: 1;
  }
  body.scrolled-header .head-actions .theme-toggle { display: grid; }
  nav.cats .wrap { display: none !important; }
  .cats-burger {
    display: inline-flex !important;
    width: 100%;
    min-width: 0;
    justify-content: center;
  }

  /* Home: the redesign used to reserve 250px for an illustration that the
     original mobile CSS hides. That empty area made every following section
     look shifted. */
  .hero {
    width: calc(100% - 20px);
    margin: 10px auto 0;
  }
  .hero .wrap {
    display: block;
    min-height: 0;
    padding: 30px 20px 28px;
  }
  .hero-side,
  .plus7 { display: none !important; }
  .hero h1 {
    max-width: none;
    font-size: clamp(28px, 8.6vw, 38px);
    line-height: 1.08;
  }
  .hero p { max-width: none; }
  .hero-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 12px;
  }
  .hero-stat:last-child { grid-column: 1 / -1; }

  section { min-width: 0; }
  .section { padding-block: 38px; }
  .section-head {
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
  }
  .section-head > * { min-width: 0; }
  .section-sub { max-width: 100%; }
  .brands { max-width: 100%; overflow: hidden; }

  /* Product grids remain compact and cannot force horizontal scrolling. */
  .grid,
  #saleGrid:has(> :nth-child(3):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .grid > *,
  .card { min-width: 0; }
  .card { padding: 10px; }
  .card .thumb {
    height: 112px;
    min-height: 112px;
    margin-bottom: 8px;
    border: 0;
    border-radius: 0;
    background: transparent !important;
  }
  .card .thumb.has-img { background: transparent !important; }
  .card .thumb img {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
    object-position: center;
    transform: scale(1.06);
  }
  .card:hover .thumb img { transform: scale(1.08); }
  /* storefront.v3.css enlarges touch targets with pointer:coarse, but its
     generic `position:relative` accidentally pulled these controls into the
     card flow. Keep them over the photo instead of reserving two empty rows. */
  .card .fav,
  .card .cmp {
    position: absolute;
    left: auto;
    right: 8px;
    width: 32px;
    height: 32px;
    margin: 0;
  }
  .card .fav { top: 8px; }
  .card .cmp { top: 44px; }
  .card h3 {
    min-height: 34px;
    font-size: 12.5px;
    overflow-wrap: anywhere;
  }
  .card .specs { display: none; }
  .price-row { flex-wrap: wrap; }
  .grid.hscroll { padding-inline: 0; }
  .grid.hscroll .card {
    flex-basis: calc(50vw - 25px);
    min-width: 145px;
    max-width: 190px;
  }

  .perks .row { grid-template-columns: 1fr; }
  .perk {
    min-height: 0;
    width: 100%;
  }

  .promo-grid { grid-template-columns: 1fr; }
  .promo,
  .promo:first-child { min-width: 0; }
  .cta-strip,
  .cta-actions { width: 100%; max-width: 100%; }

  /* Catalog: controls stack; the filter itself remains a deliberate drawer. */
  .catalog-page,
  .catalog-grid-wrap,
  .catalog-page .cgw-flex,
  .catalog-page .dl-catalog-rail { min-width: 0; }
  .catalog-page .cgw-flex { display: block; }
  .catalog-page .dl-catalog-rail { display: contents; }
  .cat-page-head,
  .cat-page-head-left,
  .catalog-toolbar {
    width: 100%;
    min-width: 0;
  }
  .catalog-toolbar { align-items: stretch; }
  .catalog-toolbar > * { max-width: 100%; }
  .sort-select { min-width: 0; }
  .catalog-page .cat-stage,
  .catalog-page .cat-mosaic { max-width: 100%; }
  .catalog-page #catFilters { max-width: 100vw; }

  /* Product detail: one column and a bottom action bar that stays inside the
     safe screen area. */
  .pp-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }
  .pp-gallery,
  .pp-info { width: 100%; min-width: 0; }
  .pp-main-img {
    width: 100%;
    height: 300px;
    min-height: 300px;
  }
  .product-page .pp-info h1 {
    max-width: 100%;
    font-size: clamp(20px, 5.8vw, 25px);
    overflow-wrap: anywhere;
  }
  .pp-key-grid { grid-template-columns: 1fr; }
  .pp-price-block { max-width: 100%; }
  .pp-tabs { max-width: 100%; overflow-x: auto; }
  .spec-table { table-layout: fixed; }
  .spec-table td { overflow-wrap: anywhere; }
  .pp-actions {
    display: grid;
    width: auto;
    max-width: none;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .pp-actions > * { min-width: 0 !important; }

  /* Addresses, information pages, overlays and footer. */
  .map-layout { display: grid; grid-template-columns: minmax(0, 1fr); }
  .salon-list {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }
  .map-frame { width: 100%; height: 300px; }
  .info-text { max-width: 100%; padding-right: 0; overflow-wrap: anywhere; }
  footer .cols { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  footer #footCats { column-count: 1; }
  .drawer,
  .cats-drawer { width: 100%; max-width: 100%; }
  .modal { max-width: calc(100% - 16px); }
  #carousel3d,
  #carousel3d > .wrap { max-width: 100%; }
}

@media (max-width: 360px) {
  .head { padding-inline: 10px; }
  .hbtn,
  .head-actions .theme-toggle { width: 40px; min-width: 40px; height: 40px; }
  .grid.hscroll .card { min-width: 138px; }
  .pp-actions .buy,
  .pp-actions .oneclick { font-size: 12px; }
}


@media (max-width: 680px) {
  /* Поиск поднят в верхнюю строку рядом с логотипом (свободное место). */
  .head, body.scrolled-header .head {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: 52px;
    min-height: 52px;
    gap: 8px;
    padding: 8px 12px;
  }
  .head .logo, body.scrolled-header .head .logo { grid-column: 1; grid-row: 1; }
  .search, body.scrolled-header .search { grid-column: 2; grid-row: 1; height: 44px; }
  .head-actions, body.scrolled-header .head-actions { grid-column: 3; grid-row: 1; justify-self: end; }
  .head-actions .theme-toggle, .hbtn { width: 36px; min-width: 36px; height: 36px; }
  .search button { min-width: 58px; }
}