/* LOOPLY-1383 D-01/D-03. A separate band preserves both existing endpoints.
   Important declarations bridge legacy route typography without changing weights.
   style-boundary-allow-important -- shared portrait-iPad typography contract. */
@media (min-width: 750px) and (max-width: 1023px) {
  :root:root {
    --page-margin: 2rem;
    --content-rail-width: 100%;
    --text-xs: .75rem;
    --text-sm: .75rem;
    --text-base: .875rem;
    --text-lg: .875rem;
    --text-xl: 1rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.75rem;
    --text-4xl: 1.75rem;
    --text-5xl: 1.75rem;
    --text-6xl: 1.75rem;
  }

  body { font-size: .875rem; }
  :is(.fs-10, .fs-12, .text-xs, [class~="text-[.625rem]"], [class~="text-[0.625rem]"], [class~="text-[.75rem]"], [class~="text-[0.75rem]"]) { font-size: .75rem !important; }
  :is(.fs-14, .text-sm, [class~="text-[.875rem]"], [class~="text-[0.875rem]"]) { font-size: .75rem !important; }
  :is(.fs-16, .text-base, .text-lg, [class~="text-[1rem]"], [class~="text-[1.125rem]"]) { font-size: .875rem !important; }
  :is(.fs-20, .text-xl) { font-size: 1rem !important; }
  .text-2xl { font-size: 1.5rem !important; }
  :is(.text-3xl, .text-4xl, .text-5xl, .text-6xl) { font-size: 1.75rem !important; }
  /* Legacy arbitrary utilities participate in the same role scale. */
  :is([class~="text-[.5625rem]"], [class~="text-[0.5rem]"], [class~="text-[0.5625rem]"], [class~="text-[0.6rem]"], [class~="text-[.6875rem]"], [class~="text-[0.6875rem]"]) { font-size: .75rem !important; }
  :is([class~="text-[.8125rem]"], [class~="text-[0.8125rem]"]) { font-size: .75rem !important; }
  :is([class~="text-[0.93rem]"], [class~="text-[0.9375rem]"]) { font-size: .875rem !important; }
  :is([class~="text-[1.25rem]"], [class~="text-[1.375rem]"]) { font-size: 1rem !important; }
  :is([class~="text-[1.5rem]"]) { font-size: 1.5rem !important; }
  :is([class~="text-[1.75rem]"], [class~="text-[1.875rem]"], [class~="text-[2rem]"], [class~="text-[2.25rem]"], [class~="text-[2.5rem]"], [class~="text-[3rem]"]) { font-size: 1.75rem !important; }
  :is(h1, h1 span) { font-size: 1.5rem !important; }
  :is(h2, h2 span) { font-size: 1.5rem !important; }
  :is(h3, h3 span) { font-size: 1rem !important; }
  :is(p, input, textarea, select) { font-size: .875rem; }
  :is(small, figcaption) { font-size: .75rem !important; }
  :is(button, [role="button"], input[type="submit"]) { font-size: 1rem !important; }

  /* These two controls contain the visible H1 text. */
  h1 > span[data-collection-mobile-page-title],
  h1 > button[data-ui-part="pdp-copy-title"] { font-size: 1.5rem !important; }

  /* Legal pages retain their content layout; only shell chrome follows H5. */
  [data-legal-shell] > [data-testid="desktop-header"],
  [data-legal-shell] .legal-shell-footer { display: none !important; }

}

/* F7: show only the PC home hero on portrait iPad, keeping H5 content below. */
@media (min-width: 750px) and (max-width: 1023px) {
  [data-ui-part="home-page"][data-surface="pc"][data-state="default"] { display: block; }
  [data-ui-part="home-page"][data-surface="pc"][data-state="default"] > :not([data-ui-part="home-hero"]) { display: none; }
  [data-ui-part="home-page"][data-surface="h5"][data-state="default"] > [data-ui-part="home-hero"] { display: none; }
}

/* F10: align independently identified content rails on portrait iPad. */
@media (min-width: 750px) and (max-width: 1023px) {
  main[class~="min-h-[50vh]"][class~="max-w-[var(--content-max-width)]"]:has(> h1:only-child),
  [data-ui-part="condition-guide-rail"],
  [data-ui-part="seller-request"] > div,
  [data-ui-part="sell-policies"] > section {
    padding-inline: 2rem;
  }
  .legal-root .legal-page { padding-inline: 0 !important; }
  .legal-root .legal-column { width: calc(100% - 4rem) !important; max-width: none !important; }
}

/* F10: shared rails for the public content, collection and product templates. */
@media (min-width: 750px) and (max-width: 1023px) {
  [data-ui-part="authenticity-root"] .auth-overview-rail,
  [data-ui-part="authenticity-faq"] {
    max-width: none;
    padding-inline: 2rem;
  }
  [data-ui-part="about-page"] [class*="__container"] {
    width: calc(100% - 4rem);
    max-width: none;
  }
  [data-ui-part="contact-page"] :is([data-ui-part="contact-hero"], [data-ui-part="contact-body"]),
  [data-ui-part="collection-mobile-title-content"],
  [data-collection-product-grid],
  [data-ui-part="collection-product-skeleton-grid"],
  [data-ui-part="pdp-primary-content"] {
    padding-inline: 2rem;
  }
  .shop-responsive-page.shop-responsive-page [data-ui-part="shop-section"][data-card-style="horizontal"] {
    padding-inline: 2rem !important;
  }
}

@layer route-components {
  @media (min-width: 750px) and (max-width: 1023px) {
    .shop-responsive-page.shop-responsive-page [data-ui-part="shop-section"][data-card-style="horizontal"] {
      padding-inline: 2rem !important;
    }
  }
}

/* F10: public templates and identifiable authenticated content rails. */
@media (min-width: 750px) and (max-width: 1023px) {
  main:has(> div > :is([data-ui-part="auth-login-page"], [data-ui-part="auth-register-page"])) { padding-inline: 2rem; }
  main > div:has(> :is([data-ui-part="auth-login-page"], [data-ui-part="auth-register-page"])),
  [data-ui-part="login-form"] { max-width: none; }
  [data-ui-part="UI-CART-APP-PAGE"], [data-ui-part="UI-CART-APP-CHECKOUT-BAR"] { max-width: none; }
  [data-ui-part="UI-CART-APP-PAGE"] :is([data-ui-part="UI-CART-APP-EMPTY"], [data-ui-part="UI-CART-APP-ITEM-CARD"], [data-ui-part="cart-unavailable-header"], [data-ui-part="cart-unavailable-item-content"]),
  [data-ui-part="UI-CART-APP-CHECKOUT-BAR"] > div,
  :is([data-ui-part="mobile-search-results-header"], [data-ui-part="mobile-search-filter-track"], [data-ui-part="mobile-search-product-grid"], [data-ui-part="search-mobile-products-skeleton"]),
  main[class~="max-w-6xl"],
  [data-ui-part="account-skeleton-mobile"],
  :is([data-ui-part="checkout-mobile-contact"], [data-ui-part="checkout-mobile-delivery"], [data-ui-part="checkout-mobile-shipping"], [data-ui-part="checkout-mobile-review"], [data-ui-part="checkout-mobile-billing"], [data-ui-part="checkout-promotion-summary"], [data-ui-part="checkout-mobile-policy"]) { padding-inline: 2rem; }
  [data-ui-part="orders-view-mobile"] > div:first-child,
  [data-ui-part="orders-results"] > :is(ul, div, h2)[class~="px-4"] { padding-inline: 2rem; }
  .color-archive-page { --page-margin: 2rem; }
  .color-archive-page .color-archive-container { max-width: none; }
  .bf-page .bf-container { width: calc(100% - 4rem); }
  .bf-page .bf-sale-content { padding-inline: 2rem; }
}

/* F10 follow-up: align collection controls, shop category labels and empty-cart CTA. */
@media (min-width: 750px) and (max-width: 1023px) {
  [data-collection-quick-filter-navigation] { padding-inline: 2rem; }
  [data-ui-part="shop-category-rail"] > button { padding-left: 1.875rem !important; }
  [data-ui-part="UI-CART-APP-EMPTY"] + div { max-width: none; }
  [data-ui-part="UI-CART-APP-EMPTY"] + div > div:last-child { padding-inline: 2rem; }
}

@media (min-width: 750px) and (max-width: 1023px) {
  :is([data-ui-part="home-hero"], [data-ui-part="sell-hero"]) h1,
  :is([data-ui-part="home-hero"], [data-ui-part="sell-hero"]) h1 span { font-size: 1.75rem !important; }
}

@layer route-components {
  @media (min-width: 750px) and (max-width: 1023px) {
    h1 > span[data-collection-mobile-page-title],
    h1 > button[data-ui-part="pdp-copy-title"] { font-size: 1.5rem !important; }
  }
}

/* F12 follow-up: homepage section headings and content rails. */
@layer route-components {
  @media (min-width: 750px) and (max-width: 1023px) {
    [data-ui-part="home-page-root"] [data-ui-part="home-collections"][data-surface="h5"] h2,
    [data-ui-part="home-page-root"] [data-ui-part="home-feed"][data-surface="h5"][data-feed-context="home"] h2 { font-size: 1.5rem !important; }
  }
}
@media (min-width: 750px) and (max-width: 1023px) {
  [data-ui-part="home-page-root"] [data-ui-part="home-collections"][data-surface="h5"] :is(h2, [data-ui-part="home-collections-track"]),
  [data-ui-part="home-page-root"] [data-ui-part="home-feed"][data-surface="h5"][data-feed-context="home"] :is(h2, [data-ui-part="home-feed-sticky-filter"], [data-ui-part="home-feed-grid"], [data-ui-part="home-feed-skeleton-grid"]) { padding-inline: 2rem; }
  [data-ui-part="home-page-root"] [data-ui-part="home-collections"][data-surface="h5"] [data-ui-part="home-collections-track"] { scroll-padding-inline: 2rem; }
}

/* F12-D: cart page title and empty-cart CTA retain their semantic sizes. */
@layer route-components {
  @media (min-width: 750px) and (max-width: 1023px) {
    [data-ui-part="UI-CART-APP-PAGE"]:has([data-ui-part="UI-CART-APP-EMPTY"]) [data-ui-part="cart-page-nav"] h1 { font-size: 1.5rem !important; }
    [data-ui-part="UI-CART-APP-EMPTY"] + div a { font-size: 1rem !important; }
  }
}

/* F16: shared storefront search surfaces in the iPad header and search flow. */
@media (min-width: 750px) and (max-width: 1023px) {
  :is(
    [data-ui-part$="-mobile-search"]:has(> [data-ui-part$="-mobile-search-action"]),
    [data-ui-part="mobile-search-discovery-field"],
    [data-ui-part="mobile-search-results-field"]
  ) {
    background-color: #f9f9f9;
    border-radius: .25rem;
    color: #848484;
  }

  :is([data-ui-part="mobile-search-discovery-field"], [data-ui-part="mobile-search-results-field"]) input::placeholder {
    color: #848484;
  }

  :is(
    [data-ui-part$="-mobile-search-action"],
    [data-ui-part="mobile-search-discovery-field"] > button[type="submit"],
    [data-ui-part="mobile-search-results-field"] > button[type="submit"]
  ) {
    border-left-color: #ebebeb;
  }
}

/* F16 / S2: the keyword results header shows the camera entry on iPad only (≤749 keeps Clear + Search). */
@media (min-width: 750px) and (max-width: 1023px) {
  [data-ui-part="mobile-search-results-field"] > [data-ui-part="mobile-header-image-search-entry"] {
    display: inline-flex;
  }
}

/* F26: subpage controls and non-full-bleed content share the tablet page gutter. */
@media (min-width: 750px) and (max-width: 1023px) {
  /* In-flow controls use the rail padding; absolutely positioned back buttons
     use the same inset without moving the centered title. */
  :is(header, div).px-4:has(> :is(a, button):not(.absolute) > [data-testid="h5-back-icon"]),
  [data-ui-part="collection-mobile-title-header"],
  [data-ui-part="pdp-mobile-header"] > div.px-4,
  [data-ui-part="campaign-mobile-header"] {
    padding-inline: var(--page-margin);
  }

  :is(header, div) > :is(button, a).absolute:has(> [data-testid="h5-back-icon"]),
  [data-ui-part="policy-mobile-header"] > button.absolute,
  [data-ui-part="about-mobile-back"],
  .auth-detail-mobile-header > button {
    inset-inline-start: var(--page-margin);
  }

  header[data-ui-part="policy-mobile-header"].sticky { display: flex; }

  .legal-root {
    --legal-mobile-gutter: var(--page-margin);
  }

  .legal-root .legal-mobile-return-bar > .legal-back {
    inset-inline-start: var(--legal-mobile-gutter);
    justify-items: start;
  }

  .auth-detail-root .auth-detail-h5 { max-width: none; }
  .auth-detail-h5 > :is(.auth-detail-tabs-h5, .auth-detail-section),
  [data-testid="policy-list-content"].w-full,
  [data-ui-part="profile-mobile"] > div.p-4,
  [data-ui-part="privacy-choices-page-h5"] > [data-ui-part="privacy-choices-card"],
  [data-ui-part="account-address-mobile-panel"],
  [data-ui-part="account-address-mobile-add-bar"] > div,
  [data-ui-part="marketplace-mobile-product-grid"] {
    padding-inline: var(--page-margin);
  }

  .auth-detail-h5 > .auth-detail-section {
    --auth-detail-content-width: calc(100vw - 2 * var(--page-margin));
  }

  .auth-detail-h5 .auth-detail-mobile-height-320 { height: calc(var(--auth-detail-content-width) * 320 / 343); }
  .auth-detail-h5 .auth-detail-mobile-height-169 { height: calc(var(--auth-detail-content-width) * 169 / 343); }
  .auth-detail-h5 .auth-detail-mobile-height-180 { height: calc(var(--auth-detail-content-width) * 180 / 343); }
  .auth-detail-h5 .auth-detail-mobile-height-153 { height: calc(var(--auth-detail-content-width) * 153 / 343); }

  /* Preserve the product gallery's full bleed with the wider detail rail. */
  [data-ui-part="pdp-primary-content"] {
    --pdp-gutter-h5: var(--page-margin);
  }
}

/* F26 search follow-up: align the scrollable cards and summary with the grid. */
@media (min-width: 750px) and (max-width: 1023px) {
  [data-ui-part="search-series-track"],
  :is([data-testid="search-pending-summary"], [data-testid="mobile-search-result-summary"]) {
    padding-inline: var(--page-margin);
  }
}
