/**
 * Vespera mobile product-search and COA catalog repair.
 *
 * This file deliberately contains narrowly scoped overrides. It does not
 * replace the production design system or product imagery.
 */

/* The production mobile card rule sets every table row to display:block.
 * Give the catalog's existing hidden state enough specificity to win. */
[data-vp-coa-catalog] .vp-coa-table tbody tr[hidden],
[data-vp-coa-catalog] .vp-coa-empty[hidden] {
  display: none !important;
}

[data-vp-coa-catalog] .vp-coa-copy {
  color: rgba(218, 232, 244, 0.78) !important;
}

[data-vp-coa-catalog] .vp-coa-count {
  color: rgba(224, 237, 248, 0.74) !important;
}

[data-vp-coa-catalog] .vp-coa-table-wrap {
  scroll-margin-top: 96px;
}

@media (max-width: 782px) {
  /* WordPress' mobile toolbar is 46px tall. Logged-in mobile users were
   * losing the top of the search dialog underneath it. */
  body.admin-bar .vp-site-search {
    top: 46px !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    height: auto !important;
  }

  .vp-site-search__panel {
    max-height: calc(100svh - 70px) !important;
    overflow: hidden !important;
  }

  .vp-site-search__results {
    max-height: calc(100svh - 220px) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 760px) {
  [data-vp-coa-catalog] .vp-coa-hero {
    padding: 16px !important;
  }

  [data-vp-coa-catalog] .vp-coa-copy {
    margin-top: 8px !important;
    font-size: 0.9rem !important;
    line-height: 1.55 !important;
  }

  [data-vp-coa-catalog] .vp-coa-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    margin-top: 14px !important;
  }

  [data-vp-coa-catalog] .vp-coa-stat:last-child {
    display: none !important;
  }

  [data-vp-coa-catalog] .vp-coa-stat {
    min-width: 0 !important;
    padding: 10px 5px !important;
  }

  [data-vp-coa-catalog] .vp-coa-stat strong {
    font-size: 1.2rem !important;
    line-height: 1 !important;
  }

  [data-vp-coa-catalog] .vp-coa-stat span {
    margin-top: 5px !important;
    font-size: 0.55rem !important;
    line-height: 1.25 !important;
  }

  [data-vp-coa-catalog] .vp-coa-tools {
    gap: 8px !important;
    margin-top: 14px !important;
  }

  [data-vp-coa-catalog] .vp-coa-tools label {
    gap: 6px !important;
  }

  [data-vp-coa-catalog] .vp-coa-tools input,
  [data-vp-coa-catalog] .vp-coa-tools select {
    min-height: 48px !important;
  }

  [data-vp-coa-catalog] .vp-coa-count {
    margin-top: 10px !important;
  }

  [data-vp-coa-catalog] .vp-coa-table-wrap {
    margin-top: 10px !important;
  }

  /* A product search is a results task, not a second visit to the catalog
   * landing hero. Keep the same visual language while bringing the products
   * into the first mobile viewport. */
  body.search.post-type-archive-product .vp-catalog-hero__visual,
  body.search.post-type-archive-product .vp-catalog-hero__trail-art,
  body.search.post-type-archive-product .vp-catalog-hero__particles,
  body.search.post-type-archive-product .vp-catalog-hero__fulfillment {
    display: none !important;
  }

  body.search.post-type-archive-product .vp-catalog-hero,
  body.search.post-type-archive-product .vp-catalog-hero__inner {
    min-height: 0 !important;
    height: auto !important;
  }

  body.search.post-type-archive-product .vp-catalog-hero__inner {
    display: block !important;
  }

  body.search.post-type-archive-product .vp-catalog-hero__content {
    min-height: 0 !important;
    padding: 28px 20px 26px !important;
  }

  body.search.post-type-archive-product .vp-catalog-hero__eyebrow {
    margin-bottom: 10px !important;
  }

  body.search.post-type-archive-product .vp-catalog-hero__title {
    max-width: 100% !important;
    margin-bottom: 12px !important;
    font-size: clamp(2rem, 9vw, 2.65rem) !important;
    line-height: 1.02 !important;
    white-space: normal !important;
  }

  body.search.post-type-archive-product .vp-catalog-hero__sub {
    max-width: 34rem !important;
    margin-bottom: 0 !important;
    font-size: 0.95rem !important;
    line-height: 1.55 !important;
  }

  body.search.post-type-archive-product .vp-catalog {
    padding-top: 10px !important;
  }
}

@media (max-width: 480px) {
  .vp-site-search {
    padding: 12px !important;
  }

  .vp-site-search__panel {
    border-radius: 14px !important;
  }

  .vp-site-search__top {
    gap: 12px !important;
    margin-bottom: 16px !important;
  }

  .vp-site-search__top h2 {
    font-size: 1.25rem !important;
    line-height: 1.2 !important;
  }
}
