/*
 * Commerce components.
 *
 * The parts that render data coming out of WooCommerce rather than out of the content
 * fields: the quantity selector, the price line, the returns line and the reassurance rows.
 * They are used twice on the page, in the hero and in the offer section, from one partial.
 *
 * Kept apart from sections.css because these are the rules that will have to move when the
 * shop grows a second product or a variation, and nothing else should move with them.
 *
 * Enqueue after sections.css. The section files override a few of these by specificity
 * (.offer .qty), which does not depend on load order, but keeping the order stable avoids
 * having to think about it again.
 */

/* ---------- Quantity selector, PRD 7.1 ---------- */

.qty {
  background: var(--bg-light);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 18px;
}

.qty__label {
  font-size: var(--step--1);
  font-weight: 600;
  margin-bottom: 12px;
}

/*
 * minmax(0, 1fr), not 1fr.
 *
 * A bare 1fr is minmax(auto, 1fr), and auto as a minimum means "never smaller than the
 * content". At 320 px in the offer section the shipping strip of the first card carries
 * "3,99 EUR shipping" with white-space: nowrap, whose min-content is 85 px, so that column
 * refused to shrink: the cards came out 87, 80 and 80 px and the grid overflowed its box by
 * 11 px. The right hand inset fell from 15 px to 4 px and the three options stopped reading
 * as three equal options, which is the only job this component has.
 *
 * The hero copy was unaffected only because its column happens to be wider. The bug was in
 * the grid, not in the section.
 */
.qty__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

/* Two or four tiers stay on one row instead of inheriting a three column grid. */
.qty__grid[data-count="1"] {
  grid-template-columns: minmax(0, 1fr);
}

.qty__grid[data-count="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.qty__grid[data-count="4"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.pack {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 0;
  cursor: pointer;
  overflow: visible;
  text-align: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pack:hover {
  border-color: var(--wood-mid);
}

/*
 * The selected ring is drawn on top of the card, by a pseudo element.
 *
 * Two earlier attempts were both wrong, in opposite directions. An outer box-shadow drew a
 * square cornered ring around a rounded card and cut across the shipping strip. An inset
 * box-shadow fixed the corners but paints underneath the backgrounds of child elements, so
 * the shipping strip covered the ring along the bottom and the sides and the selected card
 * looked like it had a gap in its border.
 *
 * A pseudo element with its own border sits above every child, follows the same radius, and
 * cannot be painted over. pointer-events: none keeps it out of the way of the click.
 */
.pack[aria-checked="true"] {
  border-color: var(--ink);
  background: #fffdfa;
}

.pack::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-radius: inherit;
  pointer-events: none;
  z-index: 2;
  transition: border-color 0.15s ease;
}

.pack[aria-checked="true"]::after {
  border-color: var(--ink);
}

.pack__body {
  display: block;
  padding: 16px 6px 12px;
}

.pack__count {
  display: block;
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1.1;
}

.pack__unit {
  display: block;
  font-size: 0.8125rem;
  color: var(--ink-muted);
  margin-top: 4px;
  white-space: nowrap;
}

.pack__ship {
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  padding: 7px 4px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 9px 9px;
  background: var(--bg-warm);
  color: var(--ink-soft);
}

.pack__ship--free {
  background: var(--wood-light);
  color: #43331f;
  font-weight: 600;
}

/*
 * The badge sits on the top edge of its own card, never past its right edge.
 *
 * It used to hang at right: -6px, which put it outside the card. On a phone the cards are
 * about 95 px wide, so the badge covered the top corner of the neighbour, and on the last
 * card it reached for the edge of the container. Tucking it to right: 6px keeps it inside
 * the card's own width at every screen size, and the negative top still lets it straddle
 * the border, which is what makes it read as a badge and not as a label.
 */
.pack__badge {
  position: absolute;
  /*
   * Above the selection ring.
   *
   * The ring is a pseudo element with z-index 2 drawn over the card so no child can paint on
   * top of it. The badge sits on the card's top edge, exactly where the ring runs, so without
   * its own layer the ring cut straight through the discount. On the one card that matters
   * most, the selected one, the number the customer is deciding on was the thing being
   * covered.
   */
  z-index: 3;
  top: -9px;
  right: 6px;
  background: var(--wood-dark);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ---------- Price ---------- */

.price {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 22px 0 16px;
}

.price__now {
  font-size: var(--step-3);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.price__save {
  font-size: var(--step--1);
  color: var(--wood-dark);
  font-weight: 600;
}

.price__note {
  font-size: var(--step--1);
  color: var(--ink-muted);
}

/* WooCommerce price_html, printed only while a sale runs. It carries the struck through
   regular price and the Omnibus sentence about the lowest price of the last 30 days.
   Nothing here composes a price, it only styles what Woo returned. */
.price__legal {
  margin-top: 6px;
  font-size: var(--step--1);
  color: var(--ink-muted);
}

.price__legal del {
  opacity: 0.8;
}

.price__legal ins {
  text-decoration: none;
  font-weight: 600;
  color: var(--ink);
}

.leis-omnibus {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

/* ---------- Returns line under the button ---------- */

.guarantee {
  text-align: center;
  font-size: var(--step--1);
  color: var(--ink-soft);
  margin-top: 12px;
}

/* ---------- Reassurance rows ---------- */

.reassure {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
}

.reassure__row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: center;
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.reassure__row svg {
  color: var(--wood-dark);
}

.reassure__row strong {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- Busy state on the add to cart button ---------- */

.btn-primary[aria-busy="true"] {
  opacity: 0.7;
  pointer-events: none;
}

/*
 * Narrow phones, 380 px and below.
 *
 * At 360 px each card is about 93 px wide and "€3.99 shipping" at 12 px does not fit, so the
 * strip wrapped to two lines. That made the first card 19 px taller than the other two and
 * the row stopped reading as three equal options, which is the one thing this component has
 * to do. Dropping a point of type and the horizontal padding buys the room back.
 *
 * Scoped to the strip and the per unit price. The quantity itself stays large, because that
 * is what the eye lands on.
 */
@media (max-width: 380px) {
  .qty {
    padding: 14px;
  }

  .qty__grid {
    gap: 7px;
  }

  .pack__body {
    padding: 14px 3px 10px;
  }

  .pack__unit {
    font-size: 0.75rem;
  }

  .pack__ship {
    font-size: 0.6875rem;
    padding: 7px 2px;
    letter-spacing: 0;
    white-space: nowrap;
  }

  .pack__badge {
    font-size: 0.6875rem;
    padding: 2px 6px;
    right: 4px;
  }
}
