/* Keep catalog cards readable without making every commercial value equally heavy. */
body:is(.post-type-archive-product, .tax-product_cat) .atlas-product-card__title {
  font-weight: 600;
}

body:is(.post-type-archive-product, .tax-product_cat) .atlas-product-card__price,
body:is(.post-type-archive-product, .tax-product_cat) .atlas-product-card__price ins {
  font-weight: 650;
}

/* One heading and breadcrumb rhythm for every product catalogue archive. */
body:is(.post-type-archive-product, .tax-product_cat) .catalog-breadcrumbs {
  color: #8791a1;
  font-size: 14px;
  line-height: 1.45;
}

body:is(.post-type-archive-product, .tax-product_cat) .catalog-toolbar h1 {
  margin: 2px 0 0;
  font-size: 2.2rem;
  font-weight: 650;
  line-height: 1.08;
}

@media (min-width: 768px) {
  /* Let each grid row follow its content instead of reserving empty card space. */
  body .catalog-results ul.products li.product.atlas-product-card {
    min-height: 0;
  }

  body:is(.post-type-archive-product, .tax-product_cat) .catalog-toolbar {
    min-height: 61px;
  }
}

@media (max-width: 767px) {
  body:is(.post-type-archive-product, .tax-product_cat) .catalog-breadcrumbs {
    font-size: 13px;
  }

  body:is(.post-type-archive-product, .tax-product_cat) .catalog-toolbar h1 {
    font-size: 1.72rem;
  }
}

/* A scrolling gesture must not leave a catalogue card in its hover state. */
@media (hover: none), (pointer: coarse) {
  body:is(.post-type-archive-product, .tax-product_cat, .search-results) .catalog-results ul.products li.product.atlas-product-card:is(:hover, :focus-within),
  body:is(.post-type-archive-product, .tax-product_cat, .search-results) .atlas-product-grid .atlas-product-card:is(:hover, :focus-within) {
    z-index: auto;
    border-color: #dfe3e8;
    box-shadow: var(--atlas-product-shadow) !important;
    transform: none;
  }
}
/* The selected density already has a red border; suppress the second focus ring
 * after clicking it while retaining the focus indicator on unselected options. */
@media (min-width: 1280px) {
  body:is(.post-type-archive-product, .tax-product_cat) .catalog-toolbar__controls {
    width: 412px;
    min-width: 412px;
    justify-content: flex-end;
  }

  body:is(.post-type-archive-product, .tax-product_cat) .catalog-toolbar__controls .atlas-density {
    width: 94px;
    min-width: 94px;
  }

  html[data-atlas-catalog-columns="4"] body .catalog-results ul.products,
  html[data-atlas-catalog-columns="4"] body.woocommerce .atlas-search-page.catalog-results .atlas-search-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  html[data-atlas-catalog-columns="5"] body .catalog-results ul.products,
  html[data-atlas-catalog-columns="5"] body.woocommerce .atlas-search-page.catalog-results .atlas-search-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  html[data-atlas-catalog-columns="5"] body .catalog-results .atlas-product-card {
    zoom: .8;
  }

  html[data-atlas-catalog-columns="5"] body .catalog-results .atlas-product-card__title {
    --atlas-title-lines: 3;
    min-height: 2.7em;
    max-height: 4.05em;
    color: #092341;
    font-size: calc(15px / .8) !important;
    font-weight: 600;
    line-height: 1.35;
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }

  html[data-atlas-catalog-columns="4"] body .catalog-results .atlas-product-card--compact-title-row .atlas-product-card__title {
    min-height: 1.42em;
  }

  html[data-atlas-catalog-columns="5"] body .catalog-results .atlas-product-card--compact-title-row .atlas-product-card__title {
    min-height: 1.35em;
  }

  html[data-atlas-catalog-columns="5"] body .catalog-results :is(.atlas-product-card__catalog-summary, .atlas-product-card__catalog-summary-value, .atlas-product-card__catalog-summary-mobile-value) {
    color: #627086;
    font-size: calc(12px / .8) !important;
  }

  html[data-atlas-catalog-columns="5"] body .catalog-results :is(.atlas-product-card__sku, .atlas-product-card__category) {
    font-size: calc(11px / .8) !important;
  }

  html[data-atlas-catalog-columns="5"] body .catalog-results .atlas-product-card__catalog-price-value {
    font-size: calc(22px / .8) !important;
  }

  html[data-atlas-catalog-columns="5"] body .catalog-results .atlas-product-status {
    font-size: calc(13px / .8) !important;
  }

  html[data-atlas-catalog-columns="5"] body .catalog-results .atlas-product-card__image {
    height: 303px !important;
  }

  .catalog-toolbar__controls .woocommerce-ordering {
    width: 300px;
    max-width: 100%;
    min-width: 300px;
    flex: 0 0 300px;
    min-height: 42px;
  }

  .catalog-toolbar__controls .woocommerce-ordering select {
    width: 100%;
  }

  html[data-atlas-catalog-columns="4"] .atlas-density button[data-columns="4"],
  html[data-atlas-catalog-columns="5"] .atlas-density button[data-columns="5"] {
    border-color: #e30613;
    background: #fff5f5;
    color: #303945;
  }

  html[data-atlas-catalog-columns="4"] .atlas-density button[data-columns="5"],
  html[data-atlas-catalog-columns="5"] .atlas-density button[data-columns="4"] {
    border-color: #d9dde3;
    background: #fff;
    color: #7c8490;
  }

  .atlas-density button[aria-pressed="true"]:focus-visible {
    outline: 0;
  }

  body:is(.post-type-archive-product, .tax-product_cat, .search-results) .catalog-results ul.products li.product.atlas-product-card:hover,
  body:is(.post-type-archive-product, .tax-product_cat, .search-results) .atlas-product-grid .atlas-product-card:hover {
    transform: none;
  }
}

/* With no filter sidebar, five normal-size cards match the width of four
 * cards in a filtered category. These two screens deliberately ignore the
 * saved 4/5 density preference and keep the complete image visible. */
@media (min-width: 1280px) {
  html body .catalog-results.catalog-results--fixed-five ul.products {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  }

  html body .catalog-results.catalog-results--fixed-five .atlas-product-card {
    zoom: 1 !important;
    container-type: inline-size;
  }

  body .catalog-results.catalog-results--fixed-five .atlas-product-card__image {
    height: 330px !important;
  }

  body.woocommerce-shop .catalog-results--fixed-five .catalog-toolbar__controls {
    width: 300px;
    min-width: 300px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .catalog-results .atlas-product-card__title:hover {
    color: var(--atlas-red, #e30613);
  }
}

@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
  .catalog-results .atlas-product-card__main {
    -webkit-user-drag: none;
    -webkit-user-select: text;
    user-select: text;
  }

  .catalog-results .atlas-product-card__main .atlas-product-card__title:hover,
  .catalog-results .atlas-product-card__main:focus-visible .atlas-product-card__title {
    color: var(--atlas-red, #e30613);
  }

  html body .catalog-results ul.products > li.product.atlas-product-card {
    --atlas-catalog-hover-overhang: 13px;
    --atlas-catalog-hover-overhang-block: 5px;
    --atlas-product-shadow-hover: var(--atlas-product-shadow);
    position: relative;
    top: 0 !important;
    isolation: isolate;
    /* Keep the same paint containment before, during and after hover. */
    content-visibility: visible !important;
  }

  html body .catalog-results ul.products > li.product.atlas-product-card::after {
    content: none !important;
  }

  html body.woocommerce .catalog-results ul.products > li.product.atlas-product-card.atlas-product-card:is(:hover, :focus-within) {
    border-color: transparent !important;
    box-shadow: var(--atlas-product-shadow) !important;
  }

  html body.woocommerce .catalog-results ul.products > li.product.atlas-product-card.atlas-product-card:is(:hover, :has(:focus-visible)) {
    box-shadow: var(--atlas-product-shadow) !important;
  }

  html body .catalog-results ul.products > li.product.atlas-product-card::before {
    position: absolute;
    z-index: -1;
    inset: calc(-1 * var(--atlas-catalog-hover-overhang-block)) calc(-1 * var(--atlas-catalog-hover-overhang));
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 7px 16px #20252b40, 0 2px 4px #20252b20;
    opacity: 0;
    transform: scaleX(.94);
    transition: opacity var(--atlas-card-hover-duration) var(--atlas-card-hover-ease),
      transform var(--atlas-card-hover-duration) var(--atlas-card-hover-ease);
    pointer-events: none;
    content: "";
  }

  html body .catalog-results ul.products > li.product.atlas-product-card:is(:hover, :has(:focus-visible))::before {
    opacity: 1;
    transform: scaleX(1);
  }
}

@media (min-width: 1280px) and (hover: hover) and (pointer: fine) {
  html[data-atlas-catalog-columns="5"] body .catalog-results:not(.catalog-results--fixed-five) ul.products > li.product.atlas-product-card {
    --atlas-catalog-hover-overhang: 16.25px;
    --atlas-catalog-hover-overhang-block: 6.25px;
  }
}

@media (min-width: 768px) and (hover: hover) and (pointer: fine) and (prefers-reduced-motion: reduce) {
  html body .catalog-results ul.products > li.product.atlas-product-card::before {
    transition: none;
    transform: none;
  }
}
