/**
 * Add-ons (snippets/product-add-ons.liquid).
 *
 * A short list of tickable companion products under the buy buttons.
 */

/* Hidden without JavaScript. The selection is only sent by assets/add-ons.js,
   so with no script these checkboxes would do nothing at all when the form
   posts - and a control that silently ignores you is worse than one that was
   never offered. The main form still adds the product either way. */
html:not(.js) .add-ons {
  display: none;
}

.add-ons {
  border: 1px solid var(--color-line);
  border-radius: var(--radius-m);
  overflow: hidden;
}

.add-ons__heading {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-line);
  background-color: color-mix(in srgb, var(--color-line) 26%, var(--color-bg));
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.add-ons__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.add-ons__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}

.add-ons__item + .add-ons__item {
  border-top: 1px solid var(--color-line);
}

/* The label wraps the checkbox, image and title, so the whole left-hand side
   of the row is a hit target rather than a 16px box. It takes the free space
   so the price can sit hard against the right edge. */
.add-ons__label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
}

.add-ons__check {
  flex: none;
  width: 18px;
  height: 18px;
  accent-color: var(--color-brand);
  cursor: pointer;
}

.add-ons__image {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-s);
  object-fit: cover;
}

.add-ons__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

/* Two lines then ellipsis. Accessory names on this store run long - "WL
   UHMW-PE (UPE) Dot Skate (40PCS)" - and an unbounded title pushes the price
   off the row. */
.add-ons__title {
  font-size: 14px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.add-ons__status {
  color: var(--color-muted);
}

.add-ons__variant {
  flex: none;
  max-width: 40%;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-s);
  background-color: var(--color-bg);
  font-size: 13px;
}

.add-ons__price {
  flex: none;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Sold out rows stay listed rather than being removed: a visitor who came for
   the grip tape should learn it is out of stock, not silently fail to find
   it. The checkbox is disabled, so it cannot be added. */
.add-ons__item--sold-out {
  opacity: 0.55;
}

.add-ons__item--sold-out .add-ons__label {
  cursor: default;
}

@media (prefers-reduced-motion: no-preference) {
  .add-ons__item {
    transition: background-color 200ms ease;
  }
}

.add-ons__item:not(.add-ons__item--sold-out):hover {
  background-color: color-mix(in srgb, var(--color-line) 20%, var(--color-bg));
}

/* A ticked row is marked so the selection is readable at a glance, rather than
   the visitor having to scan a column of small boxes before pressing Add to
   cart. :has is what lets the ROW respond to its own checkbox. */
.add-ons__item:has(.add-ons__check:checked) {
  background-color: color-mix(in srgb, var(--color-brand) 8%, var(--color-bg));
  box-shadow: inset 2px 0 0 var(--color-brand);
}

.add-ons__check:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

@media screen and (max-width: 479px) {
  /* The variant select and the price cannot share a row with a two-line title
     on a narrow phone without one of them wrapping mid-word. */
  .add-ons__item {
    flex-wrap: wrap;
  }

  .add-ons__variant {
    max-width: none;
    order: 3;
    flex: 1 1 100%;
  }
}
