/* Этап 16 — узкая ширина и планшет. Десктоп не трогаем. */
html {
  overflow-x: clip;
  max-width: 100%;
}

body,
.page {
  overflow-x: hidden;
  max-width: 100%;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

.footer-legal,
.legal-doc,
.shop-crumb,
.cart-row,
.shop-aside {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* —— Планшет —— */
@media (max-width: 1024px) {
  /* герой: не схлопывать высоту первого экрана */
  .hero,
  .hero-grid {
    min-height: 94vh;
  }

  .hero-stage {
    min-height: min(52vh, 560px);
  }
}

@media (max-width: 900px) {
  .mobile-nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .section-inner {
    width: min(1120px, calc(100% - 28px));
  }

  .shop-wrap {
    width: min(1080px, calc(100% - 28px));
  }

  .product-actions .cta,
  .product-actions .cta-ghost {
    flex: 1 1 auto;
    min-width: min(100%, 160px);
  }
}

/* —— Телефон ~390 —— */
@media (max-width: 640px) {
  .hero,
  .hero-grid {
    min-height: 94vh;
  }

  .hero-grid {
    padding-inline: 16px;
    padding-top: max(64px, calc(52px + env(safe-area-inset-top, 0px)));
  }

  .hero-stage {
    min-height: min(44vh, 420px);
  }

  .hoodie-main-wrap {
    width: min(100%, 340px);
  }

  .hoodie-next {
    width: 76px;
    min-width: 76px;
  }

  .cta {
    min-height: 48px;
    width: 100%;
    max-width: 100%;
  }

  .col-left .cta {
    width: auto;
    min-width: min(100%, 220px);
  }

  .size-btn {
    width: 44px;
    height: 44px;
  }

  .slogan {
    white-space: normal;
    text-align: center;
    line-height: 1.35;
    padding-inline: 8px;
  }

  /* popular: горизонтальный лист вместо длинной стопки */
  .popular .section-inner {
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .popular .section-head {
    padding-inline: 16px;
    margin-bottom: 18px;
  }

  .popular-grid {
    display: flex;
    grid-template-columns: none;
    gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 2px 16px 12px;
    scrollbar-width: none;
  }

  .popular-grid::-webkit-scrollbar {
    display: none;
  }

  .popular-grid .product-card {
    flex: 0 0 min(78vw, 300px);
    scroll-snap-align: start;
    max-width: min(78vw, 300px);
  }

  .fabric-copy {
    padding: 28px 16px 36px;
  }

  .fabric-facts {
    gap: 14px;
  }

  .fabric-fact {
    gap: 12px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .site-footer {
    padding: 44px 0 max(48px, calc(28px + env(safe-area-inset-bottom, 0px)));
  }

  .footer-legal {
    font-size: 0.78rem;
  }

  /* магазин */
  .shop-main {
    padding: 88px 0 56px;
  }

  .shop-wrap {
    width: min(1080px, calc(100% - 24px));
  }

  .shop-grid-2 {
    display: flex;
    grid-template-columns: none;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    scrollbar-width: none;
  }

  .shop-grid-2::-webkit-scrollbar {
    display: none;
  }

  .shop-grid-2 .shop-card {
    flex: 0 0 min(78vw, 300px);
    scroll-snap-align: start;
    max-width: min(78vw, 300px);
  }

  .shop-form {
    padding: 18px 16px;
  }

  .shop-form input,
  .shop-form select,
  .shop-form textarea {
    font-size: 16px; /* без автозума iOS */
    min-height: 48px;
  }

  .shop-form textarea {
    min-height: 96px;
  }

  .shop-form .agree input {
    width: 22px;
    height: 22px;
    min-width: 22px;
    flex-shrink: 0;
  }

  .shop-form .cta,
  .order-done .cta,
  .cart-list + .cta,
  .product-actions .cta {
    width: 100%;
  }

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

  .product-actions .cta-ghost {
    width: 100%;
  }

  .cart-row {
    grid-template-columns: 72px 1fr;
    gap: 12px;
  }

  .cart-row .shop-price {
    grid-column: 2;
    justify-self: start;
  }

  .pay-ship {
    width: 100%;
  }

  .badge-chip {
    min-height: 40px;
  }

  /* документы */
  .legal-doc {
    max-width: 100%;
  }

  .legal-doc table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
  }

  .legal-doc th,
  .legal-doc td {
    white-space: nowrap;
  }

  .cookie-bar {
    left: 10px;
    right: 10px;
  }

  .cookie-bar button {
    min-height: 44px;
  }

  .to-top {
    right: 12px;
    bottom: max(96px, calc(80px + env(safe-area-inset-bottom, 0px)));
  }
}
