/* Shop and category archives: header, subcategory chips, toolbar, loop cells,
   pagination and the empty state.

   Two things to know before editing:

   1. Every colour, radius, shadow, type size and spacing step comes from
      assets/css/tokens.css. Raw pixels appear only for component dimensions
      that have no token (hit areas, icon plates), which is how layout.css and
      components.css already do it.

   2. WooCommerce prints its own stylesheets before the theme sheets, so ties
      go to the theme — but a handful of core selectors are simply more
      specific than ours (.woocommerce ul.products li.product a img, and the
      legacy h3 rule). The "loop cell" block below carries extra selector
      weight on purpose, to keep the shared .ip-card look inside the loop.
      Those are the only places where weight is added deliberately. */

/* ---------------------------------------------------------------------------
   Archive header
   ------------------------------------------------------------------------ */

.ip-shop .ip-shop__head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--ip-s4);
}

.ip-shop .ip-shop__title {
  font-family: var(--ip-font-display);
  font-size: var(--ip-fs-2xl);
  margin: 0;
}

/* WooCommerce prints the term/shop copy into .term-description; the trailing
   paragraph margin would double up on the flex gap. */
.ip-shop .ip-shop__head .term-description { margin: 0; }
.ip-shop .ip-shop__head .term-description > :last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------------------
   Subcategory chips — children of this category, else its siblings, else the
   top level. With 85 categories this is the main way sideways navigation
   happens, so it sits directly under the title.
   ------------------------------------------------------------------------ */

.ip-chips {
  display: flex;
  align-items: baseline;
  gap: var(--ip-s3);
  width: 100%;
  min-width: 0;
}

.ip-chips__label {
  flex: none;
  font-size: var(--ip-fs-xs);
  font-weight: 700;
  color: var(--ip-ink-3);
}

.ip-chips__list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--ip-s2);
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

/* Built on .ip-pill (components.css): inherits the pill radius, inline-flex
   and gap, and only changes what a link-with-a-count needs. */
.ip-chip {
  background: var(--ip-surface);
  color: var(--ip-ink);
  border: 1.5px solid var(--ip-line);
  padding: 5px 7px 5px 14px;
  font-size: var(--ip-fs-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.ip-chip:hover {
  border-color: var(--ip-red);
  color: var(--ip-red);
}

.ip-chip__count {
  background: var(--ip-tint-yellow);
  color: var(--ip-yellow-ink);
  border-radius: var(--ip-r-pill);
  padding: 1px 8px;
  font-size: var(--ip-fs-xs);
  font-weight: 700;
}

.ip-chip.is-current {
  background: var(--ip-red);
  border-color: var(--ip-red);
  color: var(--ip-ink-invert);
}
.ip-chip.is-current:hover { color: var(--ip-ink-invert); }
.ip-chip.is-current .ip-chip__count {
  background: var(--ip-red-dark);
  color: var(--ip-ink-invert);
}

/* ---------------------------------------------------------------------------
   Toolbar: result count + sort. WooCommerce floats both of these, and its
   notices wrapper lands in here too (same hook), so it gets its own row.
   ------------------------------------------------------------------------ */

.ip-shop .ip-shop__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--ip-s3);
  margin: 0 0 var(--ip-s5);
  padding: var(--ip-s3) var(--ip-s4);
  background: var(--ip-surface);
  border-radius: var(--ip-r-lg);
  box-shadow: var(--ip-shadow-sm);
}
.ip-shop .ip-shop__toolbar > .woocommerce-notices-wrapper { flex: 1 1 100%; }
.ip-shop .ip-shop__toolbar > .woocommerce-notices-wrapper:empty { display: none; }

.ip-shop .ip-shop__toolbar .ip-result-count {
  float: none;
  margin: 0;
  font-size: var(--ip-fs-sm);
  font-weight: 600;
  color: var(--ip-ink-2);
}

.ip-shop .ip-shop__toolbar .ip-sort {
  float: none;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--ip-s2);
  min-width: 0;
}

.ip-sort__label {
  flex: none;
  font-size: var(--ip-fs-sm);
  font-weight: 600;
  color: var(--ip-ink-2);
}

.ip-shop .ip-shop__toolbar .ip-sort__select {
  font-family: var(--ip-font-body);
  font-size: var(--ip-fs-sm);
  font-weight: 600;
  color: var(--ip-ink);
  background: var(--ip-surface);
  border: 1.5px solid var(--ip-line-input);
  border-radius: var(--ip-r-pill);
  padding: 8px 14px;
  max-width: 100%;
  cursor: pointer;
  transition: border-color .15s ease;
}
.ip-shop .ip-shop__toolbar .ip-sort__select:hover { border-color: var(--ip-line-strong); }

/* ---------------------------------------------------------------------------
   Loop cell. The <ul class="products"> grid stays with woocommerce.css
   (4 / 3 / 2 columns). The <li> is only a transparent cell here, because
   woocommerce/content-product.php puts a full .ip-card inside it and the card
   already draws the surface, the shadow and the hover lift.
   ------------------------------------------------------------------------ */

.woocommerce ul.products li.product.ip-cell {
  background: none;
  box-shadow: none;
  padding: 0;
  gap: 0;
}
.woocommerce ul.products li.product.ip-cell:hover {
  transform: none;
  box-shadow: none;
}
/* Fill the grid row so prices and buttons line up across a row. */
.woocommerce ul.products li.product.ip-cell > .ip-card { flex: 1 1 auto; }

/* WooCommerce core adds a bottom margin to loop images; the card spaces its
   own media with a flex gap. */
.woocommerce ul.products li.product.ip-cell .ip-card__media img { margin: 0; }

/* WooCommerce core still carries a legacy "li.product h3" rule that pads the
   title and resets its size. Restate the card's own scale from tokens. */
.woocommerce ul.products li.product.ip-cell .ip-card__title {
  font-family: var(--ip-font-body);
  font-size: var(--ip-fs-card-title);
  font-weight: 600;
  line-height: 1.4;
  padding: 0;
  margin: 0;
}

/* ---------------------------------------------------------------------------
   Pagination
   ------------------------------------------------------------------------ */

.ip-shop .ip-pagination {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ip-s3);
  margin: 0 0 var(--ip-s6);
}

.ip-shop .ip-pagination ul.page-numbers {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--ip-s2);
  list-style: none;
  margin: 0;
  padding: 0;
  border: 0;
  white-space: normal;
}

.ip-shop .ip-pagination ul.page-numbers li {
  display: block;
  float: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: visible;
}

.ip-shop .ip-pagination ul.page-numbers li .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 42px;
  padding: 0 var(--ip-s3);
  background: var(--ip-surface);
  color: var(--ip-ink);
  border: 1.5px solid var(--ip-line);
  border-radius: var(--ip-r-pill);
  font-size: var(--ip-fs-sm);
  font-weight: 700;
  line-height: 1;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}

.ip-shop .ip-pagination ul.page-numbers li a.page-numbers:hover {
  border-color: var(--ip-red);
  color: var(--ip-red);
  background: var(--ip-surface);
}

.ip-shop .ip-pagination ul.page-numbers li .page-numbers.current {
  background: var(--ip-red);
  border-color: var(--ip-red);
  color: var(--ip-ink-invert);
}

.ip-shop .ip-pagination ul.page-numbers li .page-numbers.dots {
  background: none;
  border-color: transparent;
  color: var(--ip-ink-3);
  min-width: 0;
  padding: 0 var(--ip-s1);
}

.ip-pagination__arrow { display: inline-flex; }
.ip-pagination__arrow--prev { transform: rotate(180deg); }

.ip-pagination__info {
  margin: 0;
  font-size: var(--ip-fs-sm);
  color: var(--ip-ink-3);
}

/* ---------------------------------------------------------------------------
   Empty state
   ------------------------------------------------------------------------ */

.ip-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--ip-s4);
  background: var(--ip-surface);
  border-radius: var(--ip-r-lg);
  box-shadow: var(--ip-shadow-sm);
  padding: var(--ip-s7) var(--ip-s5);
  margin-bottom: var(--ip-s6);
}

.ip-empty__icon {
  display: grid;
  place-items: center;
  width: var(--ip-s8);
  height: var(--ip-s8);
  flex: none;
  border-radius: var(--ip-r-pill);
  background: var(--ip-tint-warm);
  color: var(--ip-red);
}

.ip-empty__title {
  font-family: var(--ip-font-display);
  font-size: var(--ip-fs-xl);
  margin: 0;
}

.ip-empty__text {
  margin: 0;
  max-width: 56ch;
  color: var(--ip-ink-2);
  font-size: var(--ip-fs-md);
}

.ip-empty__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--ip-s3);
}

/* .ip-search (layout.css) is a flex-grow field in the header; here it is a
   fixed-measure block in a centred column. */
.ip-empty__search {
  flex: none;
  width: 100%;
  max-width: 38ch;
}

.ip-empty__note {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ip-s2);
  margin: 0;
  font-size: var(--ip-fs-sm);
  color: var(--ip-ink-3);
}
.ip-empty__note svg { flex: none; color: var(--ip-ok); }

/* ---------------------------------------------------------------------------
   Responsive. The product grid itself steps 4 / 3 / 2 in woocommerce.css.
   ------------------------------------------------------------------------ */

@media (max-width: 780px) {
  /* Chips become a single swipeable row rather than a wall of wrapped pills. */
  .ip-chips {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--ip-s2);
  }
  .ip-chips__list {
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    padding-bottom: var(--ip-s1);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .ip-chips__list::-webkit-scrollbar { display: none; }

  .ip-shop .ip-shop__toolbar {
    flex-direction: column;
    align-items: stretch;
    border-radius: var(--ip-r);
  }
  .ip-shop .ip-shop__toolbar .ip-sort { justify-content: space-between; }
  .ip-shop .ip-shop__toolbar .ip-sort__select { flex: 1 1 auto; min-width: 0; }

  .woocommerce ul.products li.product.ip-cell .ip-card__title {
    font-size: var(--ip-fs-card-title-sm);
  }

  .ip-empty { padding: var(--ip-s6) var(--ip-s4); }
}

@media (max-width: 460px) {
  /* Two cards across a 375px screen leaves ~140px of card: price and button
     cannot share a row, so the button takes its own full-width line. */
  .woocommerce ul.products li.product.ip-cell .ip-card__foot { flex-wrap: wrap; }
  .woocommerce ul.products li.product.ip-cell .ip-card__foot .ip-btn { flex: 1 1 100%; }

  .ip-empty__actions .ip-btn { flex: 1 1 100%; }

  .ip-shop .ip-pagination ul.page-numbers { gap: var(--ip-s1); }
  .ip-shop .ip-pagination ul.page-numbers li .page-numbers {
    min-width: 38px;
    min-height: 38px;
    padding: 0 var(--ip-s2);
  }
}
