/* Product listing page: store, category and search results. */

.plp {
  --plp-green: #2e7d32;
  --plp-green-soft: rgba(46, 125, 50, 0.1);
  --plp-green-text: #2e7d32;
  --plp-media-bg: #ffffff;
  --plp-star-off: rgba(22, 24, 29, 0.14);
  padding-block: 20px 56px;
}

html.dark .plp {
  --plp-green-soft: rgba(74, 222, 128, 0.12);
  --plp-green-text: #4ade80;
  --plp-media-bg: #ececef;
  --plp-star-off: rgba(255, 255, 255, 0.18);
}

/* ---------- Heading block ---------- */

.plp__breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  line-height: 20px;
  color: var(--color-fg-subtle);
}

.plp__breadcrumb a:hover {
  color: var(--color-fg-base);
  text-decoration: underline;
}

.plp__breadcrumb [aria-current] {
  color: var(--color-fg-base);
}

.plp__header {
  margin: 10px 0 20px;
}

.plp__title {
  margin: 0;
  font-size: 30px;
  line-height: 38px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-fg-base);
}

.plp__subheading {
  margin: 6px 0 0;
  max-width: 72ch;
  font-size: 15px;
  line-height: 22px;
  color: var(--color-fg-subtle);
}

.plp__subcats {
  display: none;
}

/* ---------- Two-column layout ---------- */

.plp__layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.plp__filters {
  position: sticky;
  top: calc(var(--nav-height) + 16px);
  max-height: calc(100vh - var(--nav-height) - 32px);
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

.plp__filters-head,
.plp__filters-foot,
.plp__backdrop,
.plp__filter-btn {
  display: none;
}

/* ---------- Facets ---------- */

.facet {
  border-bottom: 1px solid var(--color-border-base);
}

.facet__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 14px 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 650;
  color: var(--color-fg-base);
  cursor: pointer;
  list-style: none;
}

.facet__title::-webkit-details-marker {
  display: none;
}

summary.facet__title::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 150ms ease;
  opacity: 0.6;
}

.facet[open] > summary.facet__title::after {
  transform: rotate(-135deg) translateY(-2px);
}

.facet__body {
  padding-bottom: 14px;
}

.facet__option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  font-size: 14px;
  color: var(--color-fg-base);
  cursor: pointer;
}

.facet__option input {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

.facet__option.is-disabled {
  opacity: 0.45;
  cursor: default;
}

.facet__option.is-overflow {
  display: none;
}

.facet__label {
  min-width: 0;
  line-height: 18px;
}

.facet__count {
  margin-left: auto;
  padding-left: 8px;
  font-size: 12px;
  color: var(--color-fg-subtle);
  font-variant-numeric: tabular-nums;
}

.facet__more {
  margin-top: 4px;
  padding: 6px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--plp-green-text);
}

.facet__more:hover {
  text-decoration: underline;
}

.facet--links {
  padding-bottom: 12px;
}

.facet--links ul {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.facet__back {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--color-fg-subtle);
}

.facet__back:hover {
  color: var(--color-fg-base);
}

.facet__link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 18px;
  color: var(--color-fg-base);
}

.facet__link:hover {
  background-color: var(--color-bg-subtle);
}

.facet__link.is-current {
  font-weight: 650;
  color: var(--plp-green-text);
  background-color: var(--plp-green-soft);
}

.facet__link--level-1 {
  padding-left: 20px;
}

/* ---------- Toolbar ---------- */

.plp__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--color-border-base);
}

.plp__count {
  margin: 0;
  font-size: 14px;
  color: var(--color-fg-subtle);
}

.plp__sort {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.plp__sort span {
  font-size: 13px;
  color: var(--color-fg-subtle);
}

.plp__sort select {
  height: 38px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--color-border-base);
  border-radius: 8px;
  background-color: var(--color-bg-base);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23888' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  color: var(--color-fg-base);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.plp__sort select:focus-visible {
  outline: 2px solid var(--plp-green);
  outline-offset: 1px;
}

.plp__active {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.plp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px 0 12px;
  border-radius: var(--radius-full);
  background-color: var(--plp-green-soft);
  color: var(--plp-green-text);
  font-size: 13px;
  font-weight: 500;
}

.plp-chip span {
  font-size: 16px;
  line-height: 1;
}

.plp-chip--clear {
  background: none;
  color: var(--color-fg-subtle);
  text-decoration: underline;
}

/* ---------- Product grid + card ---------- */

.plp-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

@media (min-width: 1280px) {
  .plp-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.plp-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--color-border-base);
  border-radius: 12px;
  background-color: var(--color-bg-base);
  transition: box-shadow 200ms ease, border-color 200ms ease;
}

@media (hover: hover) {
  .plp-card:hover {
    border-color: rgba(46, 125, 50, 0.35);
    box-shadow: 0 8px 24px rgba(22, 24, 29, 0.08);
  }
}

/* Image takes ~60% of the tile: a 3:4 frame over a body kept to title,
   rating, price, pack size and the buy row. */
.plp-card__media {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background-color: var(--plp-media-bg);
}

/* contain, not cover -- packaging shots lose the product's shape when
   cropped, and the buyer needs to see exactly what they're ordering. */
.plp-card__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 6%;
  object-fit: contain;
  transition: opacity 300ms ease, transform 400ms ease;
}

.plp-card__img--alt {
  opacity: 0;
}

@media (hover: hover) {
  .plp-card:hover .plp-card__media.has-alt .plp-card__img {
    opacity: 0;
  }

  .plp-card:hover .plp-card__media.has-alt .plp-card__img--alt {
    opacity: 1;
  }

  .plp-card:hover .plp-card__media:not(.has-alt) .plp-card__img {
    transform: scale(1.05);
  }
}

.plp-card__badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background-color: #dcfce7;
  color: #15803d;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.plp-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 14px;
  min-width: 0;
}

/* Fixed two-line height keeps prices and buttons aligned across a row. */
.plp-card__title {
  display: -webkit-box;
  min-height: 40px;
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  line-height: 20px;
  font-weight: 550;
  color: var(--color-fg-base);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.plp-card__title a:hover {
  color: var(--plp-green-text);
  text-decoration: underline;
}

.plp-card__rating {
  display: flex;
  align-items: center;
  gap: 1px;
}

.plp-star {
  width: 14px;
  height: 14px;
  fill: var(--plp-star-off);
}

.plp-star.is-on {
  fill: #f59e0b;
}

.plp-card__rating span {
  margin-left: 5px;
  font-size: 12px;
  color: var(--color-fg-subtle);
}

.plp-card__price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  margin-top: 2px;
}

.plp-card__amount {
  font-size: 20px;
  line-height: 26px;
  font-weight: 750;
  color: var(--color-fg-base);
  font-variant-numeric: tabular-nums;
}

.plp-card__per {
  font-size: 12px;
  color: var(--color-fg-subtle);
}

.plp-card__unit {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--plp-green-text);
}

.plp-card__pack {
  width: 100%;
  height: 34px;
  margin-top: 2px;
  padding: 0 30px 0 10px;
  overflow: hidden;
  border: 1px solid var(--color-border-base);
  border-radius: 8px;
  background-color: var(--color-bg-base);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23888' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: var(--color-fg-base);
  font: inherit;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.plp-card__pack:hover {
  border-color: var(--plp-green);
}

.plp-card__pack:focus-visible {
  outline: 2px solid var(--plp-green);
  outline-offset: 1px;
}

.plp-card__buy {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.plp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  grid-column: 1 / -1;
  padding: 56px 16px;
  text-align: center;
  color: var(--color-fg-subtle);
}

.plp-empty p {
  margin: 0;
}

/* ---------- Pagination ---------- */

.plp__pagination {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 36px;
}

.plp__pagination:empty {
  display: none;
}

.pg-row,
.pg-numbers {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--color-border-base);
  border-radius: 10px;
  background-color: var(--color-bg-base);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-fg-base);
  font-variant-numeric: tabular-nums;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}

.pg:hover:not(:disabled):not(.is-current):not(.pg--gap) {
  border-color: var(--plp-green);
  color: var(--plp-green-text);
}

.pg.is-current {
  border-color: var(--plp-green);
  background-color: var(--plp-green);
  color: #ffffff;
  cursor: default;
}

.pg--nav {
  padding-inline: 14px;
}

.pg:disabled {
  opacity: 0.4;
  cursor: default;
}

.pg--gap {
  min-width: 20px;
  padding: 0;
  border: none;
  background: none;
  color: var(--color-fg-subtle);
}

.pg-meta {
  margin: 0;
  font-size: 12px;
  color: var(--color-fg-subtle);
}

/* ---------- Tablet + phone: filters become a sheet ---------- */

@media (max-width: 1023px) {
  .plp {
    padding-block: 12px 40px;
  }

  .plp__header {
    margin: 6px 0 14px;
  }

  .plp__title {
    font-size: 24px;
    line-height: 32px;
  }

  .plp__subheading {
    font-size: 14px;
    line-height: 20px;
  }

  .plp__subcats {
    display: flex;
    gap: 8px;
    margin: 0 calc(-1 * var(--content-container-padding-inline)) 14px;
    padding: 0 var(--content-container-padding-inline) 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .plp__subcats::-webkit-scrollbar {
    display: none;
  }

  .plp__subcat {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--color-border-base);
    border-radius: var(--radius-full);
    background-color: var(--color-bg-base);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
  }

  .plp__subcat span {
    font-size: 12px;
    color: var(--color-fg-subtle);
  }

  .plp__layout {
    display: block;
  }

  .plp__filters {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 71;
    display: flex;
    flex-direction: column;
    width: min(420px, 100%);
    max-height: none;
    padding: 0;
    overflow: hidden;
    background-color: var(--color-bg-base);
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.18);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 250ms ease, visibility 0s linear 250ms;
  }

  .plp__filters.is-open {
    transform: none;
    visibility: visible;
    transition: transform 250ms ease;
  }

  .plp__filters-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    padding: 8px 8px 8px 16px;
    border-bottom: 1px solid var(--color-border-base);
  }

  .plp__filters-title {
    font-size: 17px;
    font-weight: 700;
  }

  .plp__filters-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
  }

  .plp__filters-body {
    flex: 1;
    padding: 0 16px 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .plp__filters-foot {
    display: flex;
    flex-shrink: 0;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--color-border-base);
  }

  .plp__clear {
    height: 46px;
    padding: 0 18px;
    border: 1px solid var(--color-border-base);
    border-radius: 8px;
    font-weight: 600;
  }

  .plp__apply {
    flex: 1;
    height: 46px;
    border-radius: 8px;
    background-color: var(--plp-green);
    color: #ffffff;
    font-weight: 700;
  }

  .plp__backdrop:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    background-color: rgba(0, 0, 0, 0.45);
  }

  .facet__option {
    min-height: 44px;
  }

  .facet__option input {
    width: 20px;
    height: 20px;
  }

  .facet__link {
    min-height: 44px;
  }

  .plp__toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    padding-bottom: 0;
    border-bottom: none;
    margin-bottom: 12px;
  }

  .plp__filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 14px;
    border: 1px solid var(--color-border-base);
    border-radius: 8px;
    background-color: var(--color-bg-base);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-fg-base);
  }

  .plp__filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--radius-full);
    background-color: var(--plp-green);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
  }

  .plp__sort span {
    display: none;
  }

  .plp__sort select {
    width: 100%;
    height: 42px;
  }

  .plp__count {
    grid-column: 1 / -1;
    order: 3;
    font-size: 13px;
  }

  .plp-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .plp__breadcrumb a {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .plp-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

html.plp-lock {
  overflow: hidden;
}

/* ---------- Phone: Amazon-style list rows ---------- */

@media (max-width: 639px) {
  .plp__filters {
    width: 100%;
    box-shadow: none;
  }

  .plp-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .plp-card {
    display: grid;
    grid-template-columns: 38% minmax(0, 1fr);
    border-radius: 10px;
  }

  .plp-card__media {
    align-self: stretch;
    aspect-ratio: auto;
    min-height: 100%;
  }

  .plp-card__img {
    padding: 8%;
  }

  .plp-card__badge {
    top: 6px;
    left: 6px;
    font-size: 10px;
  }

  .plp-card__body {
    gap: 4px;
    padding: 10px 12px 12px;
  }

  .plp-card__title {
    min-height: 0;
    font-size: 14px;
    -webkit-line-clamp: 3;
  }

  .plp-card__amount {
    font-size: 18px;
    line-height: 24px;
  }

  .plp-card__pack {
    height: 38px;
  }

  .plp-card__buy {
    padding-top: 6px;
  }
}

@media (max-width: 359px) {
  .plp-card {
    grid-template-columns: 34% minmax(0, 1fr);
  }

  .pg-numbers {
    gap: 4px;
  }

  .pg {
    min-width: 36px;
    padding: 0 6px;
  }
}
