/* ==========================================================================
   EGR Car Shop — Shop and product-category archives
   Source of truth: doc/egr-html-prototype/assets/css/collection.css and
   assets/css/home/product-card.css. Values are measured from those files,
   not approximated from screenshots.

   Scope: .egr-collection-page (body class added by inc/woocommerce/archive.php)
   for archive layout, and .egr-product-cards for the shared card component.
   The card rules also apply to the homepage product grids
   (inc/woocommerce/home-products.php), which render the same `.egr-hprod`
   markup through WooCommerce's loop.
   ========================================================================== */

/* The prototype paints the whole page #ffffff. GP defaults the body to
   #f7f8f9, which shows as grey bands around the white .inside-article. */
.egr-collection-page {
  background-color: #ffffff;
}

.egr-collection-page .site-content,
.egr-collection-page #primary,
.egr-collection-page #main {
  margin: 0;
  padding: 0;
}

/* GP prints its own archive header; the collection hero replaces it. */
.egr-collection-page .page-header,
.egr-collection-page .woocommerce-breadcrumb {
  display: none;
}

/* --------------------------------------------------------------------------
   Container: prototype is 1160px with 55px side padding (mobile 540 / 15).

   GP's own chain is .grid-container > #primary > main#main >
   .woocommerce-content > .inside-article (40px padding) > .entry-content.
   The outer padding is zeroed here so the 55px below is the only one that
   applies; everything the archive needs sits inside .entry-content.
   -------------------------------------------------------------------------- */
.egr-collection-page .grid-container {
  box-sizing: border-box;
  max-width: 1160px;
  padding-left: 0;
  padding-right: 0;
}

.egr-collection-page .site-main,
.egr-collection-page .woocommerce-content {
  margin: 0;
  padding: 0;
}

.egr-collection-page .inside-article,
.egr-collection-page .entry-content {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.egr-collection-page .entry-content > * {
  box-sizing: border-box;
  width: 100%;
  max-width: 1160px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 55px;
  padding-right: 55px;
}

.egr-collection-page .entry-content > .wc-columns-container {
  padding-top: 30px;
}

.egr-collection-page .entry-content > .woocommerce-notices-wrapper,
.egr-collection-page .entry-content > .woocommerce-products-header {
  padding-left: 55px;
  padding-right: 55px;
}

/* --------------------------------------------------------------------------
   1. Hero: banner / title / description

   Measured on the prototype at 1512: container 1160 with 55px side padding,
   then a -15px row gutter. The banner, title and description all end up 1080
   wide at x=216 — i.e. a 40px inset inside our 1160 content box, not 55px.

   The banner itself is a GeneratePress Element hooked to generate_after_header,
   so it sits outside .entry-content and carries its own container.
   -------------------------------------------------------------------------- */
.egr-collection-page .egr-collection__banner {
  box-sizing: border-box;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 40px;
}

.egr-collection-page .egr-collection__hero {
  box-sizing: border-box;
  padding-left: 40px;
  padding-right: 40px;
  padding-top: 0;
}

.egr-collection-page .egr-collection__cover {
  position: relative;
  width: 100%;
  padding-bottom: 450px;
  overflow: hidden;
}

/* The banner is a GenerateBlocks Hook Element, whose inline CSS is not
   generated for this context — these rules carry the whole layout. The
   cover-img class lands on the <figure>; the <img> inside it fills it. */
.egr-collection-page .egr-collection__cover-img {
  position: absolute;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.egr-collection-page .egr-collection__cover-img img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}

.egr-collection-page .egr-collection__title {
  margin: 20px 0;
  padding: 0;
  color: #000000;
  font-family: var(--egr-font-body, "Work Sans", sans-serif);
  font-size: 34px;
  font-weight: 700;
  line-height: 44.2px;
  text-align: left;
}

.egr-collection-page .egr-collection__desc {
  margin: 20px 0;
  padding: 0 0 16px;
  color: #666666;
  font-size: 18px;
  font-weight: 400;
  line-height: 21.6px;
  text-align: left;
}

.egr-collection-page .egr-collection__desc p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   2. Toolbar: count / filters / sort
   -------------------------------------------------------------------------- */
.egr-collection-page .egr-collection__toolbar {
  position: relative;
  margin: 0;
  padding: 0 0 25px;
}

.egr-collection-page .egr-collection__number {
  margin: 0;
  padding: 0;
  color: #000000;
  font-size: 14px;
  font-weight: 400;
  line-height: 38px;
  text-align: left;
}

.egr-collection-page .egr-collection__form {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
  height: 52px;
  margin: 0;
  padding: 0;
}

.egr-collection-page .egr-collection__filters {
  display: flex;
  align-items: center;
  height: 52px;
}

.egr-collection-page .egr-collection__filter {
  position: relative;
  padding-top: 12px;
}

.egr-collection-page .egr-collection__filter-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  height: 40px;
  margin: 0 12px 0 0;
  padding: 8px 12px;
  border: 1px solid #d4d4d4;
  border-radius: 0;
  background: #ffffff;
  color: #212121;
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}

.egr-collection-page .egr-collection__filter-btn[aria-expanded="true"] {
  border-color: #282828;
}

.egr-collection-page .egr-collection__arrow {
  display: block;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  transform: rotate(90deg);
  pointer-events: none;
}

.egr-collection-page .egr-collection__filter-btn[aria-expanded="true"] .egr-collection__arrow {
  transform: rotate(-90deg);
}

/* Dropdown */
.egr-collection-page .egr-collection__dropdown {
  position: absolute;
  top: 52px;
  left: 0;
  z-index: 20;
  width: 375px;
  margin: 8px 0 0;
  border: 1px solid #d4d4d4;
  background: #ffffff;
}

.egr-collection-page .egr-collection__dropdown[hidden] {
  display: none;
}

.egr-collection-page .egr-collection__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  margin: 0 16px;
  padding: 8px 0;
  border-bottom: 1px solid #e5e5e5;
  color: #212121;
  font-size: 16px;
  line-height: 24px;
  cursor: pointer;
}

.egr-collection-page .egr-collection__option:last-of-type {
  border-bottom: 0;
}

.egr-collection-page .egr-collection__option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.egr-collection-page .egr-collection__option i {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 17px;
  height: 17px;
  border: 1px solid #d4d4d4;
  color: transparent;
  font-style: normal;
}

.egr-collection-page .egr-collection__option i svg {
  width: 15px;
  height: 15px;
}

.egr-collection-page .egr-collection__option input:checked ~ i {
  border-color: #212121;
  background: #212121;
  color: #ffffff;
}

.egr-collection-page .egr-collection__option input:focus-visible ~ i {
  outline: 2px solid #212121;
  outline-offset: 2px;
}

.egr-collection-page .egr-collection__note {
  margin: 0;
  padding: 10px 16px 12px;
  border-top: 1px dashed #e5e5e5;
  color: #777777;
  font-size: 12px;
  line-height: 18px;
}

/* Price panel */
.egr-collection-page .egr-collection__highest {
  margin: 16px 16px 0;
  color: #212121;
  font-size: 16px;
  line-height: 24px;
  text-align: center;
}

.egr-collection-page .egr-collection__price-inputs {
  display: flex;
  gap: 16px;
  padding: 8px 16px 20px;
}

.egr-collection-page .egr-collection__price-input {
  display: flex;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
  height: 50px;
  border: 1px solid #d4d4d4;
  background: #ffffff;
}

.egr-collection-page .egr-collection__price-input > span {
  flex: 0 0 auto;
  padding: 0 0 0 12px;
  color: #212121;
  font-size: 16px;
}

.egr-collection-page .egr-collection__price-input input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 8px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #212121;
  font-family: inherit;
  font-size: 16px;
}

.egr-collection-page .egr-collection__price-input:focus-within {
  border-color: #282828;
}

/* Sort */
.egr-collection-page .egr-collection__sort {
  display: flex;
  align-items: center;
}

.egr-collection-page .egr-collection__sort-label {
  margin: 0 16px 0 0;
  color: #000000;
  font-size: 16px;
  line-height: 20.8px;
}

.egr-collection-page .egr-collection__sort-wrap {
  position: relative;
  width: 214.62px;
  height: 40px;
}

.egr-collection-page .egr-collection__sort-select {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0 46px 0 12px;
  border: 1px solid #d4d4d4;
  border-radius: 0;
  background: #ffffff;
  color: #212121;
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  line-height: 16px;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.egr-collection-page .egr-collection__sort-wrap .egr-collection__arrow {
  position: absolute;
  top: 9px;
  right: 12px;
}

/* Active filter chips */
.egr-collection-page .egr-collection__actives {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0 0 10px;
}

.egr-collection-page .egr-collection__chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid #d4d4d4;
  background: #f7f7f7;
  color: #212121;
  font-size: 12px;
  line-height: 18px;
}

.egr-collection-page .egr-collection__chip .woocommerce-Price-amount {
  font-size: 12px;
}

.egr-collection-page .egr-collection__chip button,
.egr-collection-page .egr-collection__clear-all {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  text-decoration: underline;
  cursor: pointer;
}

.egr-collection-page .egr-collection__clear-all {
  margin-left: 4px;
  color: #212121;
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   3. Grid: 4 columns desktop, 2 on mobile.
   Prototype measures the row at -42px against the container's 1050px content
   box, 12px column padding → 283.5px column → 259.5px card image.
   -------------------------------------------------------------------------- */
.egr-collection-page .wc-columns-container .products {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  width: auto;
  margin: 0 -42px;
  padding: 0;
  list-style: none;
}

.egr-collection-page .wc-columns-container .products::before,
.egr-collection-page .wc-columns-container .products::after {
  display: none;
  content: none;
}

/* GP's grid CSS sets `#wc-column-container .product { margin: 0 }` behind an
   ID selector, which silently zeroes the prototype's 40px column margin and
   leaves the rows (and the last row's footer gap) touching. The ID is repeated
   here so the margin survives the cascade. */
.egr-collection-page #wc-column-container .products > li.product {
  display: block;
  float: none;
  width: auto;
  min-width: 0;
  margin: 0 0 40px;
  padding: 0 12px;
  line-height: 24px;
}

/* --------------------------------------------------------------------------
   4. Card: .egr-hprod (prototype namespace)
   -------------------------------------------------------------------------- */
.egr-product-cards .egr-hprod {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 0;
}

/* Media and add-to-cart occupy the same grid cell so the button overlays the
   square image without absolute positioning against an unknown height. */
.egr-product-cards .egr-hprod__media {
  display: block;
  position: relative;
  grid-row: 1;
  grid-column: 1;
  width: 100%;
  margin: 0;
  padding: 0 0 100%;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}

/* The prototype paints #f1f1f1 on the square image itself, not on the 121%
   media box. On the homepage the top/bottom 10.5% margins must therefore show
   the white section background; the shared image rule below still carries the
   grey behind transparent product images. */
.egr-product-cards .egr-hprod__media-inner {
  display: block;
  position: absolute;
  inset: 0;
  background: transparent;
}

.egr-product-cards .egr-hprod__media img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  object-fit: fill;
  background: #f1f1f1;
}

/* GP's secondary image: keep it stacked, swap on hover like the prototype.
   GP centres it with left:50% + translate(-50%,0); the media inner box is
   already a full-bleed positioned box, so both are reset here. */
.egr-product-cards .egr-hprod__media .secondary-image {
  position: absolute;
  inset: 0;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: transparent;
  transform: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.egr-product-cards .egr-hprod__media:hover .secondary-image {
  opacity: 1;
}

/* Sale triangle: prototype collection page is 84×84, #904246. */
.egr-product-cards .egr-hprod__media .onsale,
.egr-product-cards ul.products li.product .onsale {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  box-sizing: border-box;
  display: block;
  width: 84px;
  height: 84px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #904246;
  color: #ffffff;
  font-size: 0;
  line-height: 0;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
  white-space: nowrap;
  pointer-events: none;
}

/* Percentage label, rotated along the hypotenuse. */
.egr-product-cards .egr-hprod__media .onsale::after {
  content: attr(data-egr-sale);
  position: absolute;
  top: 35%;
  left: 60%;
  display: block;
  width: max-content;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  line-height: 16.8px;
  transform: translate(-50%, -50%) rotate(45deg);
  transform-origin: center;
}

/* Add to cart: overlay on the media, revealed on hover (≥768px). */
.egr-product-cards .egr-hprod > .button,
.egr-product-cards .egr-hprod > .added_to_cart {
  grid-row: 1;
  grid-column: 1;
  align-self: end;
  justify-self: center;
  z-index: 3;
  box-sizing: border-box;
  width: 70%;
  min-height: 36px;
  margin: 0 0 30px;
  padding: 6px 12px;
  border: 1px solid #212121;
  border-radius: 0;
  background: #ffffff;
  color: #212121;
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  line-height: 22px;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.egr-product-cards .egr-hprod > .added_to_cart {
  display: none;
}

.egr-product-cards .egr-hprod:hover > .button,
.egr-product-cards .egr-hprod > .button:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.egr-product-cards .egr-hprod > .button:hover {
  background: #212121;
  color: #ffffff;
}

.egr-product-cards .egr-hprod > .button.loading {
  opacity: 1;
  pointer-events: auto;
}

/* Title: 2-line clamp, 13px/19.5, #999, centred. */
.egr-product-cards .egr-hprod__title {
  display: -webkit-box;
  grid-row: 2;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  margin: 15px 0 0;
  padding: 0;
  color: #999999;
  font-size: 13px;
  font-weight: 400;
  line-height: 19.5px;
  text-align: center;
  text-decoration: none;
}

.egr-product-cards .egr-hprod__title:hover {
  color: #212121;
}

/* Rating row: 14px tall, only rendered when reviews exist. */
.egr-product-cards .egr-hprod__rating {
  display: flex;
  grid-row: 3;
  align-items: center;
  justify-content: center;
  height: 14px;
  margin: 10px 0 0;
  line-height: 13px;
}

.egr-product-cards .egr-hprod__rating[hidden] {
  display: none;
}

.egr-product-cards .egr-hprod__rating .star-rating {
  float: none;
  margin: 0 6px 0 0;
  color: #ffc700;
  font-size: 12px;
  line-height: 13px;
}

.egr-product-cards .egr-hprod__rating .star-rating::before {
  color: #ffc700;
}

.egr-product-cards .egr-hprod__rating .star-rating span::before {
  color: #ffc700;
}

/* Price: 15px, #9b3c44, centred, 10px above. */
.egr-product-cards .egr-hprod .price {
  display: block;
  grid-row: 4;
  margin: 10px 0 0;
  padding: 0;
  color: #9b3c44;
  font-size: 15px;
  line-height: 15px;
  text-align: center;
}

.egr-product-cards .egr-hprod .price .woocommerce-Price-amount {
  color: #9b3c44;
  font-size: 15px;
  font-weight: 400;
  line-height: 15px;
}

.egr-product-cards .egr-hprod .price del {
  color: #999999;
  font-size: 15px;
  text-decoration: line-through;
  opacity: 1;
}

.egr-product-cards .egr-hprod .price ins {
  color: #9b3c44;
  font-weight: 400;
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   5. Pagination and empty state
   -------------------------------------------------------------------------- */
.egr-collection-page .woocommerce-pagination {
  margin: 0 0 40px;
  padding-top: 0;
}

.egr-collection-page .woocommerce-pagination ul.page-numbers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  list-style: none;
}

.egr-collection-page .woocommerce-pagination ul.page-numbers li {
  border: 0;
}

/* paginate_links( 'type' => 'list' ) puts .page-numbers on the <ul> as well as
   on each button, and :hover propagates up the ancestor chain — a descendant
   selector would paint the whole bar. Match the <li> children only. */
.egr-collection-page .woocommerce-pagination li > .page-numbers {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #d4d4d4;
  background: #ffffff;
  color: #212121;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
}

.egr-collection-page .woocommerce-pagination li > .page-numbers.current,
.egr-collection-page .woocommerce-pagination li > .page-numbers:hover {
  border-color: #212121;
  background: #212121;
  color: #ffffff;
}

.egr-collection-page .woocommerce-no-products-found .woocommerce-info {
  margin: 20px 0;
  padding: 14px 16px;
  border: 1px dashed #d4d4d4;
  background: #fafafa;
  color: #555555;
  font-size: 16px;
  line-height: 24px;
}

/* --------------------------------------------------------------------------
   6. Responsive — prototype breakpoint 767.98px
   -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  .egr-collection-page .grid-container {
    max-width: 540px;
  }

  .egr-collection-page .entry-content > * {
    max-width: 540px;
    padding-left: 15px;
    padding-right: 15px;
  }

  .egr-collection-page .entry-content > .wc-columns-container {
    padding-top: 10px;
  }

  /* The prototype banner stays full-bleed on mobile (container max-width 540,
     but the cover is not inset), so the desktop gutter is removed. */
  .egr-collection-page .egr-collection__banner {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  /* Prototype mobile: the banner container caps at 540 and is centred, with
     no side padding — unlike the title and description, which sit inside a
     15px inset. Measured at 615 wide: cover 540 at x=38. */
  .egr-collection-page .egr-collection__banner {
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
    padding: 0;
  }

  .egr-collection-page .egr-collection__hero {
    padding-left: 15px;
    padding-right: 15px;
  }

  .egr-collection-page .egr-collection__cover {
    padding-bottom: 200px;
  }

  .egr-collection-page .egr-collection__title {
    margin: 16px 0;
    padding: 0;
    font-size: 18px;
    line-height: 27px;
  }

  .egr-collection-page .egr-collection__desc {
    margin: 10px 0;
    padding: 0 0 16px;
    font-size: 14px;
    line-height: 21px;
  }

  .egr-collection-page .egr-collection__toolbar {
    padding: 0 0 15px;
  }

  .egr-collection-page .egr-collection__number {
    margin: 0 0 15px;
    line-height: 14px;
  }

  /* The prototype hides the desktop filter row and shows a mobile sheet.
     Here the same form reflows instead of duplicating every control. */
  .egr-collection-page .egr-collection__form {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    gap: 12px;
  }

  .egr-collection-page .egr-collection__filters {
    flex-wrap: wrap;
    height: auto;
    gap: 8px;
  }

  .egr-collection-page .egr-collection__filter {
    flex: 1 1 0;
    min-width: 0;
    padding-top: 0;
  }

  .egr-collection-page .egr-collection__filter-btn {
    width: 100%;
    margin: 0;
  }

  .egr-collection-page .egr-collection__dropdown {
    position: static;
    width: 100%;
    margin: 8px 0 0;
  }

  .egr-collection-page .egr-collection__sort {
    justify-content: space-between;
  }

  .egr-collection-page .egr-collection__sort-wrap {
    width: auto;
    flex: 1 1 auto;
    max-width: 214.62px;
  }

  .egr-collection-page .wc-columns-container .products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 -7.5px;
  }

  .egr-collection-page #wc-column-container .products > li.product {
    margin-bottom: 32.5px;
    padding: 0 7.5px;
  }

  /* Quick view is desktop-only in the prototype, but add-to-cart is not
     optional on touch: it becomes a static button under the price. */
  .egr-product-cards .egr-hprod > .button {
    grid-row: 5;
    grid-column: 1;
    justify-self: stretch;
    width: auto;
    margin: 10px 0 0;
    opacity: 1;
    pointer-events: auto;
  }

  .egr-product-cards .egr-hprod__media .onsale {
    width: 84px;
    height: 84px;
  }

  .egr-product-cards .egr-hprod__media .onsale::after {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .egr-product-cards .egr-hprod__media .onsale {
    width: 58px;
    height: 58px;
  }

  .egr-product-cards .egr-hprod__media .onsale::after {
    font-size: 11px;
    line-height: 13px;
  }
}
