/* ==========================================================================
   Adaptive layer
   Loaded after every page sheet. The sheets above already reflow their grids;
   this layer adjusts the feel of the shared pieces at each size: spacing,
   type, touch targets, form comfort, card density and the odd clipped row.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Page rhythm
   Phones were still paying the desktop gutter and section gaps, which is why
   content felt pinched while also feeling padded.
   -------------------------------------------------------------------------- */
@media (max-width: 1023px) {
  :root {
    --gutter: 20px;
    --section: 40px;
    --radius: 16px;
  }
}

@media (max-width: 699px) {
  :root {
    --gutter: 16px;
    --section: 30px;
  }

  body {
    line-height: 1.58;
  }

  /* Long seller names, listing IDs and prices must never push the page wide. */
  h1,
  h2,
  h3,
  .product-card__title,
  .seller-listing h3,
  .messages-list__item strong,
  .order-card h3 {
    overflow-wrap: anywhere;
  }

  h1 {
    font-size: clamp(1.8rem, 7.4vw, 2.35rem);
    line-height: 1.12;
  }

  .section-title {
    font-size: clamp(1.45rem, 6vw, 1.9rem);
  }

  .section-lead {
    margin-top: 10px;
    font-size: 15px;
    line-height: 1.6;
  }

  .eyebrow {
    margin-bottom: 10px;
    font-size: 11px;
  }

  /* The running promo line was set at 10.4px and clipped on both edges. */
  .announcement {
    font-size: 11.5px;
  }

  .announcement__inner {
    min-height: 30px;
    padding: 5px 0;
  }

  .page-head {
    padding-block: 26px 22px;
  }
}

/* --------------------------------------------------------------------------
   2. Touch ergonomics
   Anything pressable is at least 44px on touch widths; button labels stop
   dropping to 10px to fit a column.
   -------------------------------------------------------------------------- */
@media (max-width: 1023px), (hover: none) {
  .btn {
    min-height: 48px;
    height: auto;
    padding: 13px 18px;
    font-size: 15px;
    line-height: 1.2;
  }

  .btn--small {
    min-height: 44px;
    padding: 11px 16px;
    font-size: 13.5px;
  }

  .btn svg {
    width: 18px;
    height: 18px;
  }

  .text-link {
    min-height: 44px;
    font-size: 14.5px;
  }

  .icon-btn,
  .menu-toggle,
  .header-action,
  .header-action--cart,
  .header-action--note {
    min-width: 44px;
    min-height: 44px;
  }

  /* The mute control in the footer sat at 30px. */
  body[class] .sound-toggle {
    min-height: 40px;
    padding: 0 12px;
    font-size: 12.5px;
  }

  /* Hover-only affordances never appear on a touch screen. */
  .product-card__quick {
    display: none;
  }

  .product-card__media:hover img {
    transform: none;
  }

  /* Inline review links and small helpers get a real target. */
  .product-card__reviews,
  .product-card__meta a,
  .card-wish,
  .card-wish--title {
    min-height: 40px;
  }

  .card-wish--title {
    min-width: 40px;
  }
}

@media (max-width: 699px) {
  /* Category rails and chips: comfortable thumbs, no clipped labels. */
  .category-bar {
    flex-wrap: nowrap;
    gap: 8px;
    padding-bottom: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .category-bar::-webkit-scrollbar {
    display: none;
  }

  .category-bar > * {
    flex: none;
    min-height: 44px;
    white-space: nowrap;
  }

  .footer-col a {
    min-height: 42px;
    font-size: 14px;
  }

  .footer-col h3 {
    font-size: 12px;
  }

  .footer-bottom {
    font-size: 12px;
  }

  .footer-bottom a {
    min-height: 38px;
  }

  .footer-brand p {
    font-size: 14px;
  }
}

/* --------------------------------------------------------------------------
   3. Forms
   Desktop kept two columns and 13px labels well past the phone breakpoint.
   -------------------------------------------------------------------------- */
@media (max-width: 699px) {
  .form-grid,
  .dashboard-form .form-grid,
  .checkout-fields {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .field {
    gap: 6px;
  }

  .field label,
  .fieldset legend {
    font-size: 13.5px;
  }

  .field input,
  .field select,
  .field textarea {
    min-height: 52px;
    height: 52px;
    padding: 0 16px;
    font-size: 16px;
    border-radius: 12px;
  }

  .field textarea {
    min-height: 132px;
    height: auto;
    padding: 14px 16px;
  }

  .field-hint,
  .field-error {
    font-size: 12.5px;
  }

  .form-card,
  .auth-gate {
    padding: 20px 18px;
    border-radius: 16px;
  }

  .form-note {
    font-size: 12.5px;
  }

  /* One primary action per row instead of two squeezed half-width buttons. */
  .section__actions {
    gap: 10px;
    margin-top: 24px;
  }

  .section__actions .btn,
  .dashboard-head__actions .btn,
  .form-actions .btn {
    width: 100%;
  }

  .store-search {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .store-search label {
    font-size: 13.5px;
  }

  body.page-stores .store-search__bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  body.page-stores .store-search__bar input {
    width: 100%;
    min-height: 50px;
    height: 50px;
    padding: 0 18px;
    font-size: 16px;
  }

  body.page-stores .store-search__bar .btn {
    width: 100%;
  }

  .sort-select {
    width: 100%;
    min-height: 46px;
  }
}

/* --------------------------------------------------------------------------
   4. Cards
   -------------------------------------------------------------------------- */
@media (max-width: 699px) {
  .market-grid {
    gap: 12px;
  }

  .market-grid .product-card__body,
  .product-card__body {
    padding: 10px 10px 12px;
  }

  .market-grid .product-card__meta,
  .product-card__meta {
    gap: 4px;
    font-size: 11px;
    letter-spacing: 0;
  }

  .market-grid .product-card__title,
  body[class] .product-card__title {
    margin-top: 4px;
    font-size: 14px;
    line-height: 1.3;
  }

  /* Marketplace clamps its card title to 13px at 390px; keep two lines and
     lift the floor so the title stays readable beside a two-up photo. */
  body[class] .m-grid .product-card__title {
    font-size: clamp(14px, 3.6vw, 15px);
    line-height: 1.3;
  }

  /* Banner dots are the only control under 40px once the arrows are gone. */
  body[class] .m-banners__dots button {
    min-width: 34px;
    min-height: 34px;
  }

  /* The hero badge hung 3px past the right edge at 390px. */
  body[class] .home-stage__badge {
    right: 0;
    transform: translate(0, -25%);
  }

  .market-grid .product-card__price {
    font-size: 15px;
  }

  .market-grid .product-card__actions {
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
  }

  .market-grid .product-card__actions .btn,
  .product-card__actions .btn {
    width: 100%;
    min-height: 44px;
    padding: 0 10px;
    font-size: 13px;
    letter-spacing: 0;
  }

  .market-grid .product-card__badge,
  .product-card__badge {
    top: 8px;
    left: 8px;
    font-size: 10px;
  }

  .seller-listing {
    padding: 12px;
    gap: 10px;
  }

  .seller-listing > img {
    width: 64px;
    height: 64px;
  }

  .seller-listing h3 {
    font-size: 14.5px;
  }

  /* Store directory cards keep their banner readable at one card per view. */
  .store-directory .store-card__banner {
    height: 96px;
  }

  .store-card__body,
  .store-person {
    padding: 14px;
  }

  .store-card h3,
  .store-person strong {
    font-size: 15px;
  }
}

/* --------------------------------------------------------------------------
   5. Information containers
   Notices, empty states and dashboards read better with a tighter radius and
   left-aligned copy than a shrunken desktop block.
   -------------------------------------------------------------------------- */
@media (max-width: 699px) {
  .notice {
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    text-align: left;
  }

  .notice svg {
    width: 18px;
    height: 18px;
    margin-top: 1px;
  }

  .empty-state {
    padding: 26px 18px;
    text-align: left;
  }

  .empty-state h2,
  .empty-state h3 {
    font-size: 1.2rem;
  }

  .empty-state p {
    font-size: 14px;
  }

  .dashboard-page,
  .account-page,
  .messages-page,
  .page-stores .page-head {
    padding-top: 20px;
  }

  .dashboard-head,
  .messages-head {
    gap: 12px;
  }

  .dashboard-stats {
    gap: 10px;
  }

  .dashboard-stats > div {
    padding: 13px;
    border-radius: 12px;
  }

  .dashboard-stats strong {
    font-size: 1.3rem;
  }

  .dashboard-section {
    padding: 16px;
    border-radius: 14px;
  }

  .dashboard-section__head {
    gap: 6px;
  }

  .messages-list__item {
    min-width: 78vw;
    padding: 12px 13px;
  }

  .deal-panel {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .deal-panel > div:first-child {
    grid-column: auto;
  }

  .faq-list summary {
    min-height: 56px;
    padding: 15px 0;
    gap: 14px;
    font-size: 15px;
    line-height: 1.35;
  }

  .faq-list details p {
    padding-bottom: 16px;
    font-size: 14px;
    line-height: 1.6;
  }

  .seller-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* --------------------------------------------------------------------------
   6. Product detail
   -------------------------------------------------------------------------- */
@media (max-width: 699px) {
  body.page-product .piece {
    padding: 14px;
    border-radius: 18px;
  }

  body.page-product .piece h1 {
    font-size: clamp(1.4rem, 6vw, 1.85rem);
    line-height: 1.2;
  }

  body.page-product .piece__price strong {
    font-size: 1.5rem;
  }

  /* Label above value instead of a 180px column squeezing the value. */
  body.page-product .product-facts div {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    padding: 11px 0;
  }

  body.page-product .product-facts dt {
    font-size: 12.5px;
  }

  body.page-product .product-facts dd {
    font-size: 14.5px;
  }

  /* Four tabs never fit 358px, so let the row scroll instead of clipping. */
  body.page-product .piece-tabs__nav {
    gap: 4px;
    padding: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  body.page-product .piece-tabs__nav::-webkit-scrollbar {
    display: none;
  }

  body.page-product .piece-tabs__nav label {
    flex: none;
    padding: 12px 12px;
    font-size: 12.5px;
    letter-spacing: 0;
    white-space: nowrap;
  }

  body.page-product .product-detail__notice {
    align-items: flex-start;
    gap: 8px;
    font-size: 13.5px;
    text-align: left;
  }

  body.page-product .piece__delivery p,
  body.page-product .piece__variations p {
    font-size: 13.5px;
  }
}

/* --------------------------------------------------------------------------
   6b. Shared header and marketplace banners
   Tablet buttons were being held at 38px by the page sheet, and the banner
   arrows sat on top of the baked-in banner copy.
   -------------------------------------------------------------------------- */
@media (max-width: 1023px) {
  body[class] .site-header .header-action,
  body[class] .site-header .header-action--cart,
  body[class] .site-header .header-action--note,
  body[class] .site-header .menu-toggle {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }

  /* The page sheets set the search element itself, so match at their depth. */
  body[class] .site-header .header-search {
    height: 46px;
    min-height: 46px;
  }

  body[class] .site-header .header-search input {
    height: 100%;
    font-size: 16px;
  }

  /* Carousel arrows sat on top of the baked-in banner copy on tablets. */
  body[class] .m-banners__arrow {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   7. Tablet refinement (700-1023)
   Three columns stay, but the type and gaps follow the smaller canvas.
   -------------------------------------------------------------------------- */
@media (min-width: 700px) and (max-width: 1023px) {
  .market-grid {
    gap: 18px;
  }

  .market-grid .product-card__meta {
    font-size: 11px;
    letter-spacing: 0.02em;
  }

  .market-grid .product-card__title {
    font-size: 15.5px;
  }

  .market-grid .product-card__actions .btn {
    min-height: 44px;
    font-size: 12.5px;
  }

  .section-head {
    margin-bottom: 28px;
  }

  .footer-grid {
    gap: 28px 24px;
  }

  .split__media img {
    min-height: 300px;
  }

  .boost-row {
    gap: 14px;
  }
}

/* --------------------------------------------------------------------------
   8. Small laptops (1024-1279)
   The four-column market keeps desktop density, but cards get their readable
   action labels back and the section rhythm tightens slightly.
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) and (max-width: 1279px) {
  .market-grid .product-card__actions .btn {
    min-height: 40px;
    font-size: 12px;
    letter-spacing: 0.02em;
  }

  .market-grid .product-card__meta {
    font-size: 11.5px;
  }

  .market-grid .product-card__title {
    font-size: 1.2rem;
  }
}

/* --------------------------------------------------------------------------
   8a. Overlays and dock clearance
   Quick views, checkout and the bid form open inside dialogs; on a phone they
   need the full width and a scrollable body. Inner-page footers also need to
   clear the fixed dock.
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  dialog {
    max-width: calc(100vw - 16px);
    max-height: 90dvh;
    margin: auto;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body:not(.page-seller):not(.page-admin):not(.page-moderator) .site-footer {
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  /* Phone shopper footer: short brand strip. Shop/Help/Company move into
     the dock + menu — no accordion wall under the page. */
  body .site-footer {
    padding-top: 18px;
  }

  body .footer-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-bottom: 4px;
  }

  body .footer-brand {
    grid-column: 1 / -1;
    padding-bottom: 8px;
  }

  body .footer-brand p {
    max-width: none;
    margin-top: 0;
    font-size: 13px;
    line-height: 1.4;
  }

  body .footer-contact {
    margin-top: 6px;
  }

  body .footer-col {
    display: none;
  }

  body .footer-bottom {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px 12px;
    padding: 12px 0 4px;
  }

  body .footer-bottom__links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
  }

  body .footer-bottom__links a,
  body .footer-bottom .sound-toggle {
    min-height: 36px;
  }

  body .footer-payments {
    order: 0;
  }
}

@media (max-width: 699px) {
  .quickview__grid,
  .checkout-grid,
  .bid-form .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --------------------------------------------------------------------------
   8b. Stores directory on desktop
   The right-to-left rail suits thumbs, but on a wide screen a lone card was
   stranded at the right edge under a left-aligned heading. Desktop rows read
   left to right; tablet and phone keep the right-to-left scroll.
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) {
  .store-directory .store-grid,
  .store-directory .store-people {
    direction: ltr;
  }

  .store-directory .store-grid > .store-card,
  .store-directory .store-people > .store-person {
    direction: ltr;
  }
}

/* --------------------------------------------------------------------------
   9. Phones in landscape
   A tall hero plus a fixed dock left almost no content in view.
   -------------------------------------------------------------------------- */
@media (max-width: 900px) and (max-height: 500px) {
  body.page-home .home-stage__visual {
    aspect-ratio: 21 / 9;
    max-height: 220px;
  }

  body.page-home .home-stage h1 {
    font-size: 1.75rem;
  }

  .mobile-dock {
    display: none !important;
  }

  .site-footer {
    padding-bottom: 40px;
  }
}

/* --------------------------------------------------------------------------
   10. Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .category-bar {
    scroll-behavior: auto;
  }
}

/* --------------------------------------------------------------------------
   10b. Web quality / smoothness (LCP, INP, CLS oriented)
   -------------------------------------------------------------------------- */
.site-footer,
.store-products,
.seller-panel,
.account-section,
.admin-panel,
.ops-card {
  content-visibility: auto;
  contain-intrinsic-size: 1px 480px;
}

img {
  max-width: 100%;
  height: auto;
}

.product-card img,
.buyer-order__media img {
  content-visibility: auto;
}

.store-gallery__track,
.mobile-dock__indicator {
  backface-visibility: hidden;
}

/* New feature surfaces: never spill past the viewport edge. */
.ol-machine,
.ol-receipt,
.ol-codes,
.ship-btn-wrap,
.store-gallery,
.store-gallery__controls,
.payment-card {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   11. Cross-breakpoint polish (facet / UIAnalyzer / UX pass)
   Keep rails inside the viewport, lift unreadable type floors, and give
   product-card links a real thumb target without inventing a new look.
   -------------------------------------------------------------------------- */
html {
  overflow-x: clip;
}

body {
  overflow-x: clip;
}

.m-cats,
.m-cats__row,
.m-grid,
.m-banners,
.category-bar,
.market-cats__row {
  max-width: 100%;
  min-width: 0;
}

@media (max-width: 1023px), (hover: none) {
  .header-search input,
  #header-search,
  .search-overlay input,
  input[type="search"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="text"] {
    font-size: 16px;
  }

  .product-card__title a,
  .product-card__title button {
    min-height: 44px;
    padding-block: 8px;
    box-sizing: border-box;
  }

  .product-card__reviews,
  .product-card__social-reviews,
  a.product-card__social-reviews {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 2px;
    box-sizing: border-box;
  }

  .agent__toggle {
    min-height: 48px;
    font-size: 13px;
  }

  .agent__toggle-label {
    font-size: 13px;
  }

  .footer-col h3,
  .footer-col > button,
  .site-footer [aria-expanded] {
    min-height: 44px;
  }

  .m-stores__all {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 2px;
    box-sizing: border-box;
  }

  /* Icon-only header labels are intentionally clipped for a11y; keep them
     out of layout measurement noise without changing the visible chrome. */
  .header-actions .header-action > span:not(.cart-count):not(.note-count),
  .account-btn > span:not(.cart-count) {
    clip-path: inset(50%);
  }
}

@media (max-width: 699px) {
  .announcement__marquee > span {
    font-size: max(12px, 1em);
  }

  .market-cat__name,
  .category-tile__name {
    font-size: 12px;
    line-height: 1.25;
  }

  .product-card__meta {
    font-size: 12px;
  }

  /* Stacked marketplace / home shelves: keep card text from forcing page width. */
  .product-card,
  .product-card__body,
  .product-card__title,
  .listing-row,
  .listing-row__body {
    min-width: 0;
    max-width: 100%;
  }
}

@media (min-width: 700px) and (max-width: 1023px) {
  .header-search input {
    font-size: 16px;
  }

  body.page-marketplace .market-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --------------------------------------------------------------------------
   12. Desktop and large screens (every page)
   UI/UX Pro Max: cap readable width, kill page overflow, restore desktop
   chrome (nav visible, hamburger hidden), and give each surface room at
   1024 / 1280 / 1440. adaptive.css loads last on every built page.
   -------------------------------------------------------------------------- */
@media (min-width: 981px) {
  :root {
    --gutter: 28px;
    --section: 52px;
  }

  /* .header-actions .menu-toggle { display:inline-flex } was winning over
     the base display:none and left the hamburger on desktop. */
  body .site-header .header-actions .menu-toggle,
  body.page-home .header-actions .menu-toggle,
  body.page-marketplace .header-actions .menu-toggle,
  body.page-marketplace .menu-toggle {
    display: none !important;
  }

  body .site-header .primary-nav,
  body .site-header .header-nav {
    display: flex;
  }

  .mobile-dock {
    display: none !important;
  }

  .container,
  .container--narrow,
  main,
  .section,
  .market-layout,
  .store-shell,
  .store-shell__inner,
  .dashboard-page,
  .messages-page,
  .product-shell,
  .auth-gate,
  .page-head {
    min-width: 0;
    max-width: 100%;
  }

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

  .product-card,
  .product-card__body,
  .product-card__title,
  .listing-row,
  .listing-row__body,
  .store-card,
  .order-card {
    min-width: 0;
  }

  /* Desktop footer: real columns, not the phone accordion. */
  body .footer-grid {
    grid-template-columns: minmax(0, 1.7fr) repeat(3, minmax(0, 1fr));
    gap: 44px 36px;
  }

  body .footer-col {
    display: block;
    border-top: 0;
    padding-top: 0;
  }

  body .footer-brand__blurb--full {
    display: block;
  }

  body .footer-brand__blurb--short {
    display: none;
  }

  body .footer-col h3 {
    display: block;
    min-height: 0;
    padding: 0;
    margin-bottom: 14px;
    cursor: default;
  }

  body .footer-col h3::after {
    content: none;
  }

  body .footer-col ul {
    display: grid;
    gap: 10px;
    margin: 0;
  }

  body .footer-bottom {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  body.page-marketplace .market-layout {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 28px;
  }

  body.page-marketplace .market-filters {
    position: sticky;
    top: 16px;
  }
}

@media (min-width: 1024px) {
  :root {
    --container: 1200px;
    --gutter: 28px;
    --section: 56px;
  }

  .section {
    padding-block: clamp(36px, 4vw, 56px);
  }

  .page-head {
    padding-block: clamp(32px, 4vw, 48px);
  }

  body.page-marketplace .market-layout {
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 32px;
  }

  .store-shell__inner,
  .store-page > .container,
  .dashboard-page > .container,
  .messages-page > .container {
    width: min(100% - (var(--gutter) * 2), var(--container));
  }

  .auth-gate,
  .auth-card,
  .container--narrow {
    width: min(100% - (var(--gutter) * 2), 880px);
  }

  /* Product / auction two-up surfaces stay balanced on laptop. */
  .auction-stage {
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.85fr);
    gap: 28px;
  }

  .site-footer {
    padding-bottom: 56px;
  }
}

@media (min-width: 1280px) {
  :root {
    --container: 1280px;
    --gutter: 32px;
  }

  body.page-marketplace .market-layout {
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 36px;
  }

  body.page-marketplace .market-grid {
    gap: 22px;
  }

  .header-search {
    max-width: 560px;
  }
}

@media (min-width: 1440px) {
  :root {
    --container: 1360px;
    --gutter: 36px;
    --section: 64px;
  }

  body.page-home .container {
    width: min(100% - clamp(32px, 5vw, 72px), 1360px);
  }

  body.page-marketplace .market-layout {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .footer-grid {
    gap: 48px 40px;
  }
}

/* Small laptop band: keep market cards readable without collapsing the rail. */
@media (min-width: 1024px) and (max-width: 1279px) {
  body.page-marketplace .market-grid {
    gap: 18px;
  }

  .header-actions .header-action > span:not(.cart-count):not(.note-count),
  .header-actions .account-btn > span:not(.cart-count) {
    display: none;
  }
}
