/* Mobile catalogue components inherit many legacy !important declarations.
   An explicit cascade layer gives these scoped repairs predictable precedence. */
@layer cybertel-shopping-responsive {
  @media (max-width: 980px) {
    #catalogueProducts #catalogueFilterPanel:not(.mobile-open) {
      display: none !important;
    }

    /* The existing filter controller moves the open drawer under <body>.
       Its facet layout must work outside the catalogue's page selector. */
    #catalogueFilterPanel.mobile-open {
      display: block !important;
      box-sizing: border-box !important;
      max-height: 100dvh !important;
      overflow-y: auto !important;
      overscroll-behavior: contain;
      padding-bottom: max(1rem, env(safe-area-inset-bottom)) !important;
      z-index: 2147483300 !important;
    }
    #catalogueFilterPanel.mobile-open .cyb-marketplace-facet-head {
      display: flex !important;
      align-items: center !important;
      justify-content: space-between !important;
      gap: .75rem !important;
      min-height: 44px !important;
      font-size: .875rem !important;
      list-style: none !important;
    }
    #catalogueFilterPanel.mobile-open .cyb-marketplace-chevron,
    #catalogueFilterPanel.mobile-open .cyb-marketplace-chevron svg {
      display: block !important;
      flex: 0 0 18px !important;
      width: 18px !important;
      height: 18px !important;
      fill: none !important;
      stroke: currentColor !important;
      stroke-width: 1.8;
    }
    #catalogueFilterPanel.mobile-open .cyb-marketplace-facet[open] .cyb-marketplace-chevron {
      transform: rotate(180deg);
    }
    #catalogueFilterPanel.mobile-open #catalogueSearch {
      font-size: 1rem !important;
    }
    #catalogueProducts #mobileFilterToggle {
      font-size: .875rem !important;
      min-height: 44px !important;
    }
  }

  @media (max-width: 1024px) {
    #catalogueGrid .catalogue-product-card .product-body {
      height: auto !important;
      max-height: none !important;
      grid-template-rows: none !important;
      grid-auto-rows: auto !important;
    }
    #catalogueGrid .catalogue-product-card .retail-card-actions {
      grid-template-rows: minmax(44px, auto) !important;
      height: auto !important;
      max-height: none !important;
    }
    #catalogueGrid .catalogue-product-card .retail-card-actions button,
    #catalogueGrid .catalogue-product-card .cyb-marketplace-compare {
      box-sizing: border-box !important;
      height: auto !important;
      min-height: 44px !important;
      max-height: none !important;
      font-size: .875rem !important;
    }
    #catalogueGrid .catalogue-product-card .cyb-marketplace-compare {
      min-width: 44px !important;
      padding: .35rem .5rem !important;
      color: #215a81 !important;
      white-space: normal !important;
    }
    #catalogueGrid .catalogue-product-card .cyb-marketplace-compare::before {
      content: none !important;
    }
    #cyb1600Detail :is(.cyb1653-close, .cyb1646-round, .cyb1653-enlarge),
    #cyb1600AccountModal .cyb-compare-workspace :is(.cyb-compare-close, .cyb-compare-remove),
    #v214AcHost .midnight-turn {
      min-width: 44px !important;
      min-height: 44px !important;
      max-width: none !important;
      max-height: none !important;
    }
    #cyb1600Detail :is(.cyb1653-actions button, .cyb1646-tabs button, .cyb-pd-ask-photos, .cyb-detail-all-specs),
    #cyb1600AccountModal .cyb-compare-workspace button,
    #v214AcHost :is(.midnight-controls, .midnight-modes) button {
      min-height: 44px !important;
      max-height: none !important;
    }
  }

  @media (min-width: 641px) and (max-width: 1024px) {
    #page-catalogue .cyb26-page-hero,
    #page-catalogue .cyb26-hero-body {
      min-height: clamp(28rem, 48vw, 33rem) !important;
      height: auto !important;
    }
    #page-catalogue .cyb26-hero-body {
      padding-block: clamp(2.5rem, 6vw, 4rem) !important;
    }
  }

  @media (max-width: 640px) {
    #page-catalogue .cyb26-page-hero,
    #page-catalogue .cyb26-hero-body {
      min-height: 0 !important;
      height: auto !important;
    }
    #page-catalogue .cyb26-hero-body {
      padding: clamp(2.75rem, 9vw, 4rem) clamp(1.125rem, 5vw, 2rem) 2.25rem !important;
    }
    #cyb1600AccountModal .cyb-compare-scroll {
      overscroll-behavior-inline: contain;
    }
    /* Show the feature label and a whole product column together on a phone. */
    #cyb1600AccountModal .cyb-compare-matrix {
      width: calc(200% - 6rem) !important;
      min-width: 0 !important;
    }
    #cyb1600AccountModal [data-compare-count="3"] .cyb-compare-matrix {
      width: calc(300% - 12rem) !important;
      min-width: 0 !important;
    }
    #cyb1600AccountModal .cyb-compare-matrix th:first-child {
      width: 6rem !important;
      overflow-wrap: anywhere;
    }
    #cyb1600AccountModal .cyb-compare-product-column {
      padding: .375rem !important;
    }
    #cyb1600AccountModal .cyb-compare-product :is(h3, p, span) {
      overflow-wrap: anywhere;
    }
    #cyb1600AccountModal .cyb-compare-product-actions {
      display: flex !important;
      flex-wrap: wrap !important;
    }
    #cyb1600AccountModal .cyb-compare-product-actions button {
      flex: 1 1 6rem !important;
    }
  }

  @media (max-height: 500px) and (max-width: 1024px) {
    /* Give the table room when phone landscape or a software keyboard
       leaves insufficient height for a pinned comparison header and footer. */
    #cyb1600AccountModal .cyb-compare-workspace {
      display: block !important;
      overflow-y: auto !important;
      overscroll-behavior: contain;
    }
    #cyb1600AccountModal .cyb-compare-content,
    #cyb1600AccountModal .cyb-compare-scroll {
      height: auto !important;
      max-height: none !important;
    }
  }
}
