/* Stage 5: mobile adaptation for the core storefront flow.
   Desktop styles stay untouched; this file only refines phone and small-tablet layouts. */

@media (hover: none) and (pointer: coarse) {
  a,
  button,
  input,
  select,
  textarea,
  label { touch-action: manipulation; }

  .button:hover,
  .header-action:hover,
  .product-card:hover,
  .category-card:hover,
  .catalog-category-pill:hover {
    transform: none;
    box-shadow: none;
  }

  .product-card:hover .product-image img { transform: none; }
}

@media (max-width: 760px) {
  :root { --mobile-edge: 12px; }

  body { padding-bottom: env(safe-area-inset-bottom); }

  .topline { display: none; }

  .site-header {
    position: relative;
    border-bottom-color: #eee5df;
    box-shadow: none;
    backdrop-filter: none;
  }

  .header-main,
  .category-nav-inner,
  .page-shell,
  .footer-benefits,
  .footer-grid {
    width: calc(100% - (var(--mobile-edge) * 2));
  }

  .header-main {
    grid-template-columns: minmax(0,1fr) auto;
    gap: 7px 8px;
    padding: 7px 0 8px;
  }

  .logo-wrap { min-height: 46px; }
  .logo-wrap img { width: 138px; max-height: 48px; }
  .header-script { display: none; }

  .header-actions { gap: 4px; }
  .header-action {
    min-width: 46px;
    min-height: 46px;
    padding: 0;
    border-radius: 12px;
  }
  .action-icon-wrap {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }
  .header-action > span:last-child { display: none; }

  .search-form { grid-column: 1/-1; }
  .search-form input {
    height: 46px;
    padding-left: 15px;
    padding-right: 51px;
    border-radius: 13px;
    font-size: 16px;
  }
  .search-form button {
    right: 3px;
    width: 42px;
    height: 42px;
  }

  .category-nav { border-top: 0; border-bottom: 1px solid #f1e9e4; }
  .category-nav-inner {
    min-height: 42px;
    gap: 18px;
    padding: 0 1px;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
  }
  .category-nav a {
    min-height: 42px;
    padding: 12px 0 10px;
    display: flex;
    align-items: center;
    scroll-snap-align: start;
    font-size: .76rem;
  }

  .button,
  .add-button,
  .checkout-button {
    min-height: 48px;
    border-radius: 12px;
  }

  /* Home: preserve the clean visual language while making the first screen shorter. */
  .page-shell { margin-top: 8px; gap: 8px; }
  .mobile-catalog-trigger { min-height: 48px; border-radius: 12px; }
  .catalog-card nav a { min-height: 46px; }

  .hero {
    min-height: 338px;
    padding: 24px 18px 42px;
    border-radius: 14px;
  }
  .hero h1 { max-width: 320px; font-size: clamp(2.05rem,10vw,2.65rem); }
  .hero-content p { margin: 12px 0 17px; max-width: 285px; font-size: .88rem; line-height: 1.48; }
  .hero .button { min-width: 160px; }
  .hero-dots { left: 18px; bottom: 15px; }

  .content-section { padding-top: 16px; scroll-margin-top: 12px; }
  .section-heading { margin-bottom: 9px; gap: 10px; }
  .section-heading h2 { font-size: 1.14rem; }

  .category-grid,
  .product-grid { gap: 8px; }
  .category-card,
  .product-card { border-radius: 12px; box-shadow: none; }
  .category-card span { min-height: 38px; }
  .product-body { padding: 9px; }
  .product-body h3 { margin-bottom: 7px; font-size: .8rem; line-height: 1.3; }
  .add-button.compact {
    min-height: 44px;
    margin-top: 8px;
    font-size: .75rem;
  }

  /* Catalog: filters stay a bottom sheet and all primary controls are thumb-sized. */
  .catalog-main,
  .product-main,
  .commerce-main {
    width: calc(100% - (var(--mobile-edge) * 2));
    margin-top: 10px;
  }

  .catalog-breadcrumbs {
    margin-bottom: 10px;
    gap: 5px;
    font-size: .68rem;
  }

  .catalog-intro {
    padding: 19px 17px;
    margin-bottom: 13px;
    gap: 10px;
    border-radius: 15px;
    box-shadow: none;
  }
  .catalog-intro h1 { font-size: 2rem; }
  .catalog-intro p { margin-top: 9px; font-size: .84rem; line-height: 1.48; }
  .catalog-intro__note { padding: 9px 10px; }

  .catalog-category-section { margin-bottom: 12px; }
  .catalog-category-strip {
    grid-auto-columns: minmax(118px,36vw);
    gap: 8px;
    padding-bottom: 7px;
  }
  .catalog-category-pill { padding: 7px; border-radius: 12px; }
  .catalog-category-pill--all { min-height: 94px; }

  .catalog-filter-toggle {
    min-height: 48px;
    border-radius: 12px;
  }
  .catalog-filter-card {
    max-height: min(88dvh,760px);
    padding-bottom: env(safe-area-inset-bottom);
    border-radius: 18px 18px 0 0;
  }
  .catalog-filter-head { min-height: 56px; padding-inline: 14px; }
  .catalog-filter-close { width: 44px; height: 44px; }
  .catalog-filter-search__control input,
  .catalog-filter-prices input,
  .catalog-sort-wrap select { min-height: 44px; font-size: 16px; }
  .catalog-filter-option { min-height: 44px; }
  .catalog-filter-option input { width: 20px; height: 20px; }
  .catalog-filter-actions .button { min-height: 48px; }

  .catalog-toolbar {
    min-height: 0;
    margin-bottom: 9px;
    padding: 8px;
    border-radius: 12px;
  }
  .catalog-sort-wrap select { height: 44px; }

  .catalog-product-grid,
  .product-related .catalog-product-grid { gap: 8px; }
  .catalog-product-grid .product-body { min-height: 166px; padding: 9px; }
  .catalog-product-grid .product-body h3 { min-height: 40px; font-size: .79rem; }
  .catalog-product-grid .add-button { min-height: 44px; font-size: .74rem; }
  .catalog-product-badge { border-radius: 7px; }
  .favorite-button { width: 36px; height: 36px; }

  /* Product: large, full-width purchasing controls and horizontal gallery thumbnails. */
  .product-detail { gap: 16px; }
  .product-main-image { border-radius: 15px; }
  .product-thumbnails {
    gap: 7px;
    margin-top: 7px;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
  }
  .product-thumbnails button {
    flex-basis: 66px;
    width: 66px;
    height: 66px;
    scroll-snap-align: start;
  }
  .product-detail-copy h1 {
    margin-top: 4px;
    margin-bottom: 8px;
    font-size: 1.9rem;
  }
  .product-detail-price { margin: 11px 0 7px; }
  .product-detail-price strong { font-size: 1.35rem; }
  .product-stock { margin-bottom: 11px; }
  .product-short-description { font-size: .9rem; line-height: 1.55; }
  .product-detail-actions { gap: 8px; margin: 15px 0 17px; }
  .product-detail-actions .add-button,
  .product-favorite-button { min-height: 50px; border-radius: 12px; }
  .product-description { margin-top: 18px; padding-top: 16px; }
  .product-description p { font-size: .9rem; line-height: 1.58; }

  /* Commerce pages: compact heading and dense, touch-friendly cart. */
  .commerce-main { padding-top: 0; padding-bottom: 46px; }
  .commerce-hero { padding: 18px 0 20px; }
  .commerce-hero > span { font-size: 10px; }
  .commerce-hero h1 { margin: 5px 0 8px; font-size: 2.15rem; }
  .commerce-hero p { font-size: .88rem; line-height: 1.48; }

  .cart-page-layout { gap: 10px; }
  .cart-page-card { border-radius: 16px; }
  .cart-page-card__head {
    padding: 14px;
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
  .cart-page-card__head h2 { font-size: 1.2rem; }
  .cart-page-card__head a { min-height: 40px; display: inline-flex; align-items: center; }
  .cart-page-items { padding: 0 13px 6px; }
  .cart-page-items .cart-item {
    grid-template-columns: 64px minmax(0,1fr);
    gap: 10px;
    padding: 13px 0;
  }
  .cart-page-items .cart-item img { width: 64px; height: 64px; }
  .cart-item__info > a {
    font-size: .82rem;
    line-height: 1.35;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .cart-item__unit-price { margin-top: 3px; }
  .cart-page-items .cart-item__side {
    grid-column: 1/-1;
    min-height: 46px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .cart-qty { margin-top: 0; gap: 6px; }
  .cart-qty button,
  .cart-remove {
    width: 44px;
    height: 44px;
    border-radius: 11px;
  }
  .cart-qty span { min-width: 28px; }
  .cart-page-items .cart-item__line-total { font-size: .95rem; }

  .cart-page-summary {
    padding: 16px;
    border-radius: 16px;
  }
  .cart-page-total { margin: 8px 0 12px; padding: 12px 0; }
  .cart-page-total strong { font-size: 1.45rem; }
  .cart-page-checkout { min-height: 52px; }

  /* Checkout: single column, clear radio cards and large form fields. */
  .checkout-layout { gap: 10px; }
  .checkout-form { gap: 10px; }
  .checkout-form > section {
    padding: 15px;
    gap: 12px;
    border-radius: 16px;
  }
  .checkout-form h2 { font-size: 1.18rem; }
  .checkout-form label { gap: 6px; font-size: .78rem; }
  .checkout-form input,
  .checkout-form select,
  .checkout-form textarea {
    min-height: 50px;
    padding: 12px 13px;
    border-radius: 11px;
    font-size: 16px;
  }
  .checkout-form textarea { min-height: 88px; }
  .checkout-choice-grid { gap: 8px; }
  .checkout-choice {
    min-height: 66px;
    padding: 11px 12px;
    align-items: center;
    border-radius: 12px;
  }
  .checkout-choice input {
    width: 21px !important;
    height: 21px;
    min-height: 21px !important;
    flex-basis: 21px;
  }
  .checkout-choice b { font-size: .84rem; }
  .checkout-choice small,
  .checkout-field-hint { font-size: .7rem; }
  .checkout-submit { min-height: 54px; border-radius: 13px; font-size: .92rem; }
  .checkout-summary { border-radius: 16px; }
  .checkout-summary__head { padding: 15px 15px 11px; }
  .checkout-summary__head h2 { font-size: 1.18rem; }
  .checkout-summary__head a { min-height: 40px; display: inline-flex; align-items: center; }
  .checkout-items { padding: 0 15px; }
  .checkout-item { padding: 11px 0; }
  .checkout-summary__total { padding: 14px 15px 15px; }
  .checkout-summary__total strong { font-size: 1.35rem; }
  .commerce-empty,
  .checkout-success { min-height: 230px; padding: 24px 18px; border-radius: 18px; }

  /* Footer remains complete but becomes shorter and easier to scan. */
  .footer-benefits { grid-template-columns: 1fr; }
  .footer-benefits > div,
  .footer-benefits > div:nth-child(3n) {
    min-height: 48px;
    justify-content: flex-start;
    border-right: 0;
    border-bottom: 1px solid #efe5df;
  }
  .footer-benefits > div:last-child { border-bottom: 0; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 20px 16px; }
  .footer-brand,
  .footer-contact { grid-column: 1/-1; }
}

@media (max-width: 430px) {
  :root { --mobile-edge: 8px; }

  .logo-wrap img { width: 128px; }
  .header-actions { gap: 2px; }
  .header-action { min-width: 44px; }

  .hero { min-height: 320px; padding-inline: 16px; }
  .hero h1 { font-size: 2.02rem; }

  .catalog-intro { padding: 17px 15px; }
  .catalog-intro h1 { font-size: 1.82rem; }
  .catalog-toolbar { align-items: stretch; flex-direction: column; gap: 7px; }
  .catalog-sort-wrap,
  .catalog-sort-wrap select { width: 100%; max-width: none; }

  .catalog-product-grid .product-body { min-height: 158px; padding: 8px; }
  .catalog-product-grid .product-body h3 { min-height: 39px; font-size: .76rem; }
  .catalog-product-grid .add-button { min-height: 43px; padding-inline: 6px; }

  .product-detail-copy h1 { font-size: 1.72rem; }
  .product-thumbnails button { flex-basis: 60px; width: 60px; height: 60px; }

  .commerce-hero { padding-top: 14px; }
  .commerce-hero h1 { font-size: 1.95rem; }
  .cart-page-card__head { padding: 12px; }
  .cart-page-card__head a { font-size: .7rem; }
  .cart-page-items { padding-inline: 11px; }
  .cart-page-summary { padding: 14px; }

  .checkout-form > section { padding: 13px; }
  .checkout-summary__head,
  .checkout-items,
  .checkout-summary__total { padding-left: 13px; padding-right: 13px; }
}

@media (max-width: 350px) {
  .header-main { gap: 6px; }
  .logo-wrap img { width: 116px; }
  .header-action { min-width: 42px; }
  .action-icon-wrap { width: 40px; height: 40px; }

  .category-grid,
  .product-grid,
  .catalog-product-grid,
  .product-related .catalog-product-grid { gap: 6px; }
  .product-body,
  .catalog-product-grid .product-body { padding: 7px; }

  .cart-page-card__head { align-items: flex-start; flex-direction: column; gap: 2px; }
  .cart-page-card__head a { min-height: 34px; }
}

/* Mobile accessibility: keep text-entry controls at 16px to avoid iOS focus zoom. */
@media (max-width: 760px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
  select,
  textarea {
    font-size: 16px;
  }
}
