/**
 * Front-office styles for the wb_productvariants block.
 * Theme-neutral, fully scoped under .wb-pv. No external imports, no @import.
 *
 * The markup is the same for every layout (ul.wb-pv-items > li.wb-pv-item); layout, column
 * count and alignment are driven purely by the modifier classes the block prints, which is
 * what lets a merchant restyle the block from the settings page without editing a .tpl.
 */

.wb-pv {
  margin: 1.5rem 0;
}

.wb-pv-header {
  margin-bottom: 1rem;
}

.wb-pv-title {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.wb-pv-description {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.85;
}

.wb-pv-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ===================== Item shell (shared) ===================== */

.wb-pv-item {
  display: flex;
  padding: 0;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  overflow: hidden;
}

.wb-pv-item__wrap {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: 0.5rem;
  padding: 0.5rem;
  color: inherit;
  text-decoration: none;
}

/* The item template decides which line holds the label, so hover feedback is on the whole
   tile rather than on a line number that may not be the title. */
.wb-pv-item:hover {
  border-color: #b7b7b7;
}

.wb-pv-item__line {
  display: block;
  min-width: 0;
  line-height: 1.3;
}

.wb-pv-item__text {
  overflow-wrap: anywhere;
}

/* Line 0 is the first template line - usually the image or the main label. */
.wb-pv-item__line--0 {
  font-weight: 500;
}

.wb-pv-item__line--1,
.wb-pv-item__line--2,
.wb-pv-item__line--3,
.wb-pv-item__line--4 {
  font-size: 0.85rem;
  opacity: 0.85;
}

.wb-pv-item__image {
  position: relative;
  display: block;
}

.wb-pv-item__img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

/* ===================== Grid layout ===================== */

.wb-pv--grid .wb-pv-items {
  display: grid;
  gap: 1rem;
}

.wb-pv--grid .wb-pv-item__wrap {
  flex-direction: column;
}

.wb-pv--cols-1 .wb-pv-items { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.wb-pv--cols-2 .wb-pv-items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wb-pv--cols-3 .wb-pv-items { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.wb-pv--cols-4 .wb-pv-items { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.wb-pv--cols-5 .wb-pv-items { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.wb-pv--cols-6 .wb-pv-items { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.wb-pv--cols-7 .wb-pv-items { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.wb-pv--cols-8 .wb-pv-items { grid-template-columns: repeat(8, minmax(0, 1fr)); }

.wb-pv--grid .wb-pv-item {
  flex-direction: column;
}

.wb-pv--grid .wb-pv-add-to-cart {
  margin: 0 0.5rem 0.5rem;
}

/* ===================== List layout =====================
 * A compact, scrollable list of rich rows. Capped height so a long list stays usable.
 */

.wb-pv--list .wb-pv-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
}

.wb-pv--list .wb-pv-item__wrap {
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.wb-pv--list .wb-pv-item__image {
  flex: 0 0 auto;
  width: 56px;
}

.wb-pv--list .wb-pv-item__line {
  flex: 1 1 auto;
}

.wb-pv--list .wb-pv-add-to-cart {
  flex: 0 0 auto;
  align-self: center;
  margin: 0 0.5rem;
}

/* ===================== Inline layout =====================
 * Compact chips, for shops whose variants are a short label (a size, a colour, a dimension).
 */

.wb-pv--inline .wb-pv-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.wb-pv--inline .wb-pv-item {
  border-radius: 999px;
}

.wb-pv--inline .wb-pv-item__wrap {
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  white-space: nowrap;
}

.wb-pv--inline .wb-pv-item__line {
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 1;
}

.wb-pv--inline .wb-pv-item__image {
  width: 24px;
}

.wb-pv--inline .wb-pv-item__img {
  border-radius: 50%;
}

.wb-pv--inline .wb-pv-add-to-cart {
  margin: 0 0.4rem 0 0;
  padding: 0.2rem 0.5rem;
  align-self: center;
  border-radius: 999px;
  font-size: 0.75rem;
}

/* ===================== Alignment ===================== */

.wb-pv--align-center .wb-pv-item__wrap {
  text-align: center;
}

.wb-pv--align-center.wb-pv--grid .wb-pv-item__wrap {
  align-items: center;
}

/* ===================== States ===================== */

.wb-pv-item--current {
  border-color: #2d7a33;
  box-shadow: 0 0 0 1px #2d7a33 inset;
  background: #f4fbf5;
}

.wb-pv-item--greyout {
  opacity: 0.5;
}

.wb-pv-item--strike .wb-pv-item__text {
  text-decoration: line-through;
}

.wb-pv-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: #c0392b;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Overlaid on the thumbnail when the image partial renders it. */
.wb-pv-item__image .wb-pv-badge {
  position: absolute;
  top: 4px;
  left: 4px;
}

/* ===================== Add to cart ===================== */

.wb-pv-add-to-cart {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  border: 1px solid #2d7a33;
  border-radius: 4px;
  background: #2d7a33;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.wb-pv-add-to-cart:hover {
  background: #256128;
  border-color: #256128;
  color: #fff;
}

.wb-pv-add-to-cart--busy {
  opacity: 0.6;
  pointer-events: none;
}

/* ===================== Toast ===================== */

.wb-pv-toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10500;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 320px;
}

.wb-pv-toast {
  padding: 0.6rem 0.9rem;
  border-radius: 4px;
  color: #fff;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.wb-pv-toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.wb-pv-toast--success {
  background: #2d7a33;
}

.wb-pv-toast--error {
  background: #c0392b;
}

/* ===================== Responsive =====================
 * Column counts are a desktop intent; narrower viewports collapse them rather than
 * squeezing unreadable tiles, so a merchant can pick 6 columns without breaking mobile.
 */

@media (max-width: 991px) {
  .wb-pv--grid.wb-pv--cols-5 .wb-pv-items,
  .wb-pv--grid.wb-pv--cols-6 .wb-pv-items,
  .wb-pv--grid.wb-pv--cols-7 .wb-pv-items,
  .wb-pv--grid.wb-pv--cols-8 .wb-pv-items {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* No !important here on purpose: this rule already beats .wb-pv--cols-N by source order at
   equal specificity, which leaves a theme free to dictate its own mobile column count. */
@media (max-width: 575px) {
  .wb-pv--grid .wb-pv-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
