/* ==========================================================================
   AUREL — Additive responsive overrides
   Breakpoints:
     Mobile  ≤767px
     Tablet  768–1023px
   Desktop / laptop ≥1024px is intentionally UNCHANGED.
   ========================================================================== */

/* ── Shared: prevent horizontal scroll (phone + tablet only) ── */
@media (max-width: 1023px) {
  html {
    overflow-x: clip;
    overscroll-behavior-x: none;
    max-width: 100%;
  }

  body {
    overflow-x: clip;
    overscroll-behavior-x: none;
    max-width: 100%;
    width: 100%;
    position: relative;
  }

  body.site-storefront .site-header,
  body.site-storefront .site-header__float,
  body.site-storefront #main-content,
  body.site-storefront .site-footer,
  body.site-storefront .container,
  body.site-storefront .section,
  body.site-storefront .pdp,
  body.site-storefront .page-shop,
  body.site-storefront .shop-layout,
  body.site-storefront .cart-layout,
  body.site-storefront .page-banner {
    max-width: 100%;
    min-width: 0;
  }

  body.site-storefront .container {
    box-sizing: border-box;
    padding-inline: clamp(1rem, 4vw, 1.25rem);
  }

  body.site-storefront img,
  body.site-storefront video,
  body.site-storefront iframe,
  body.site-storefront svg {
    max-width: 100%;
  }

  /* Absolute framed product photography keeps explicit height */
  body.site-storefront .product-card__image,
  body.site-storefront .category-card__image,
  body.site-storefront .pdp__image,
  body.site-storefront .pdp-slider__slide img {
    max-width: none;
  }

  /* Off-canvas panels + marquee must not expand document scrollWidth
     (common iOS Safari horizontal-scroll cause on PDP / storefront). */
  body.site-storefront .announcement-bar,
  body.site-storefront .announcement-ticker,
  body.site-storefront .announcement-ticker__viewport {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  /* Closed drawers: hide from hit-testing + focus scrollIntoView
     (width/height collapse lives in layout.css / pages.css) */
  body.site-storefront .mobile-nav-drawer,
  body.site-storefront .cart-drawer,
  body.site-storefront .pdp-lightbox {
    overflow: hidden;
    overscroll-behavior: contain;
  }

  body.site-storefront .site-header__inner,
  body.site-storefront .site-header__actions {
    min-width: 0;
    max-width: 100%;
  }
}

/* ── Tablet: 768–1023 ── */
@media (min-width: 768px) and (max-width: 1023px) {
  /* Story hero title (About / Contact / Cart / Checkout / Auth / Legal pages) —
     base clamp(2rem, 5vw, 3.35rem) runs too large + too wide-tracked for
     tablet width, causing wrap/overflow that disturbs the layout below it. */
  .story-hero__title {
    font-size: clamp(1.85rem, 4vw, 2.6rem);
    letter-spacing: 0.17em;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .page-product .pdp__layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }

  .page-product .pdp__gallery,
  .page-product .pdp__info {
    max-width: 100%;
    width: 100%;
    margin-inline: 0;
    justify-self: stretch;
  }

  .page-shop .shop-grid,
  .home-products-grid.grid--4,
  .grid.grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ── Mobile: ≤767 ── */
@media (max-width: 767px) {
  body.site-storefront .container {
    padding-inline: 1rem;
  }

  /* Story hero title — guard against clipping/overflow on narrow phones
     when a longer title (e.g. "Shipping & Exchanges") wraps */
  .story-hero__title {
    line-height: 1.2;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
  }

  .story-hero__inner {
    max-width: 100%;
    padding-inline: 0.25rem;
  }

  /* PDP */
  .page-product,
  .page-product #main-content,
  .page-product .pdp,
  .page-product .pdp-details,
  .page-product .pdp-reviews,
  .page-product .pdp-related {
    overflow-x: clip;
    max-width: 100%;
    min-width: 0;
  }

  .page-product .pdp__layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .page-product .pdp__gallery,
  .page-product .pdp__info {
    max-width: 100%;
    width: 100%;
    margin-inline: 0;
    justify-self: stretch;
    min-width: 0;
  }

  .page-product .pdp-slider,
  .page-product .pdp-slider__viewport,
  .page-product .pdp-option,
  .page-product .pdp-option__values,
  .page-product .pdp-actions,
  .page-product .pdp-buy,
  .page-product .pdp-reviews__layout,
  .page-product .pdp-reviews__toolbar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .page-product .pdp-slider__viewport {
    overflow: hidden;
  }

  .page-product .pdp-acc__table.sg-table-scroll,
  .page-product .sg-table-scroll {
    max-width: 100%;
    margin-inline: 0;
  }

  .page-product .site-header__actions {
    gap: 0.55rem;
  }

  .page-product .pdp-actions .btn,
  .page-product .pdp-actions .btn--block,
  .page-product .pdp-buy .btn {
    width: 100%;
  }

  .page-product .pdp-trust__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Product cards / grids */
  .shop-grid,
  .home-products-grid,
  .grid.grid--3,
  .grid.grid--4 {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-shop .shop-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
  }

  /* Forms — single column where grids are used */
  .form-grid,
  .auth-form__grid,
  .checkout-form__grid,
  .contact-form__grid,
  .account-form .form-row {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Tables — scroll inside wrapper, not the page */
  table {
    max-width: 100%;
  }

  .sg-table-scroll,
  .size-table-wrap,
  .table-responsive,
  .cart-table-wrap,
  .orders-table-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sg-table {
    min-width: 360px;
  }

  /* Modals — top sheet, fit viewport (no 100vw) */
  .pdp-modal {
    place-items: start center;
    align-items: start;
    padding: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  .pdp-modal__dialog,
  .pdp-modal__dialog--wide {
    width: 100%;
    max-width: 100%;
    height: min(100dvh, 100%);
    max-height: min(100dvh, 100%);
    border-radius: 0 0 20px 20px;
    transform: translateY(-100%);
    margin: 0;
    box-sizing: border-box;
  }

  .pdp-modal.is-open .pdp-modal__dialog {
    transform: translateY(0);
  }

  .pdp-modal__header {
    padding: max(1rem, env(safe-area-inset-top)) 1.1rem 1rem;
    flex-shrink: 0;
  }

  .pdp-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    padding-inline: 1.1rem;
    padding-bottom: calc(1.15rem + env(safe-area-inset-bottom));
  }

  .pdp-modal__tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
  }

  .pdp-modal__tabs::-webkit-scrollbar {
    display: none;
  }

  .pdp-modal__tab {
    flex: 1 0 auto;
    white-space: nowrap;
  }

  .cart-item,
  .thankyou-item {
    grid-template-columns: 72px minmax(0, 1fr);
  }
}

/* Narrow phones */
@media (max-width: 480px) {
  .page-shop .shop-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-product .pdp-trust__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .story-hero__title {
    font-size: clamp(1.5rem, 8vw, 1.9rem);
    letter-spacing: 0.12em;
  }
}

/* Extra-narrow — keep 5 header actions inside the viewport */
@media (max-width: 360px) {
  body.site-storefront .site-header__actions {
    gap: 0.35rem;
  }

  body.site-storefront .site-header__account,
  body.site-storefront .site-header__cart,
  body.site-storefront .site-header__wishlist,
  body.site-storefront .site-header__search-toggle,
  body.site-storefront .site-header__menu-toggle {
    width: 28px;
    height: 28px;
  }

  body.site-storefront .site-header__icon {
    width: 20px;
    height: 20px;
  }
}
