/* Mobile-first shell — safe areas, bottom nav, touch targets. Edit independently. */

:root {
  --mobile-nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Bottom tab bar (primary mobile navigation) */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

.mobile-nav__inner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: var(--container);
  margin: 0 auto;
}

.mobile-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: var(--mobile-nav-h);
  padding: 0.5rem 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav__item svg {
  width: 22px;
  height: 22px;
}

.mobile-nav__item--active {
  color: var(--accent);
}

.mobile-nav__badge {
  position: absolute;
  top: 6px;
  margin-left: 18px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--accent);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  border-radius: 999px;
  display: grid;
  place-items: center;
}

.mobile-nav__item-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Mobile search trigger in header */
.mobile-search-btn {
  display: none;
  border: 0;
  background: var(--bg);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  place-items: center;
  cursor: pointer;
  color: var(--primary);
}

/* ── Mobile breakpoint (default-first overrides) ── */
@media (max-width: 960px) {
  /* Belt-and-suspenders: no page should ever scroll sideways on a phone. */
  html, body { overflow-x: clip; max-width: 100%; }

  .container {
    width: min(var(--container), calc(100% - 1rem));
  }

  /* Catalog: horizontal category strip instead of overflowing grid */
  .catalog {
    padding-bottom: 2rem;
  }

  .catalog__sidebar {
    padding: 0.75rem;
    margin-bottom: 0.25rem;
    overflow: hidden;
  }

  .catalog__sidebar-title {
    margin-bottom: 0.5rem;
  }

  .cat-nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.35rem;
    margin: 0 -0.25rem;
    padding-inline: 0.25rem;
  }

  .cat-nav::-webkit-scrollbar { display: none; }

  .cat-nav li { flex-shrink: 0; }

  .cat-nav__link {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.35rem;
    width: 5.5rem;
    padding: 0.5rem 0.35rem;
    font-size: 0.6875rem;
    line-height: 1.2;
    min-height: 44px;
  }

  .cat-nav__thumb {
    width: 44px;
    height: 44px;
  }

  .cat-nav__label {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
  }

  .catalog__hero {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 1rem;
  }

  .catalog__hero img {
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: 16 / 10;
    max-height: 140px;
  }

  .catalog__hero h1 {
    font-size: 1.25rem;
  }

  .breadcrumb {
    font-size: 0.75rem;
    padding-top: 1rem;
  }

  .catalog__toolbar #catalogFilters {
    min-width: 0;
  }

  .vehicle-cats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  body {
    padding-bottom: calc(var(--mobile-nav-h) + var(--safe-bottom));
  }

  .mobile-nav { display: block; }

  .topbar { display: none; }

  .mobile-search-btn { display: grid; }

  .header__inner {
    padding: 0.75rem 0;
  }

  .logo__mark {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .logo { font-size: 1.125rem; }

  .hero {
    padding: 1.75rem 0 2.5rem;
  }

  .hero h1 {
    font-size: 1.625rem;
  }

  .hero__lead {
    font-size: 0.9375rem;
  }

  .hero__points {
    flex-direction: column;
    gap: 0.375rem;
  }

  .article-search__row {
    flex-direction: column;
  }

  .article-search__row input,
  .article-search__row .btn {
    min-height: 44px;
    width: 100%;
  }

  section { padding: 2rem 0; }

  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .category-tile__body h3 {
    font-size: 0.875rem;
  }

  .category-tile__body p {
    font-size: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .product-card__name {
    font-size: 0.8125rem;
  }

  .price-current {
    font-size: 1rem;
  }

  .btn {
    min-height: 44px;
  }

  .vehicle-picker__fields select {
    min-height: 44px;
    font-size: 1rem;
  }

  .vin-search__row input {
    min-height: 44px;
  }

  .chip {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }

  .cart-drawer__panel {
    width: 100%;
    max-height: 92vh;
    top: auto;
    bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    transform: translateY(100%);
  }

  .cart-drawer.open .cart-drawer__panel {
    transform: translateY(0);
  }

  .toast {
    bottom: calc(var(--mobile-nav-h) + var(--safe-bottom) + 0.75rem);
  }

  .vehicle-bar__inner {
    flex-wrap: wrap;
    font-size: 0.8125rem;
    gap: 0.5rem;
  }

  .vehicle-bar__text {
    flex: 1 1 100%;
    min-width: 0;
    line-height: 1.35;
  }

  .vehicle-bar__text strong {
    word-break: break-word;
  }

  .vehicle-bar__change {
    margin-left: 0;
    min-height: 36px;
  }

  .vehicle-bar__clear {
    min-width: 44px;
    min-height: 44px;
  }

  .subnav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
  }

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

  .subnav .chip {
    flex-shrink: 0;
  }

  .catalog__toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .catalog__toolbar #catalogFilters {
    min-width: 0;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar__field select {
    width: 100%;
    min-height: 44px;
  }

  .catalog__sort {
    width: 100%;
    justify-content: space-between;
  }

  .catalog__sort select {
    min-height: 44px;
    flex: 1;
    width: auto;
    min-width: 0;
  }
}

/* Standalone / installed PWA */
@media (display-mode: standalone) {
  .topbar { display: none; }
}
