/* ═══════════════════════════════════════════
   S&S SELECTOR — in-cart Subscribe & Save control
   ═══════════════════════════════════════════
   Shared by the cart drawer (parts/cart-drawer.php) and the /cart page
   (woocommerce/cart/cart.php). Two states per line:
     A (one-time)     — a single "Subscribe & Save X%" toggle.
     B (subscription) — "Subscription" pill + delivery-frequency listbox +
                        "Change to a $X one-time purchase" toggle.
   Switching is a blocking AJAX (price + cart-key change), so on interaction
   the live controls are replaced by a green "Updating subscription options…"
   pending line until the host re-renders.

   Mobile-first. No @media (max-width). Tokens only. BEM.
   A11y: Listbox/Variation-Picker pattern (A11Y-PATTERNS.md §LISTBOX). The
   listbox EXPANDS INLINE (not absolute) because the drawer content is an
   overflow:auto scroll container that would clip an overlay.
   ═══════════════════════════════════════════ */

.wv-ss-selector {
  margin-top: 6px;
}

/* ── Pending state (the green "Updating…" line) ── */
.wv-ss-selector__pending {
  display: block;
  color: var(--wv-color-green);
  margin: 4px 0;
}
.wv-ss-selector__pending[hidden] {
  display: none;
}
@media (prefers-reduced-motion: no-preference) {
  .wv-ss-selector__pending:not([hidden]) {
    animation: wv-ss-pulse 1.1s ease-in-out infinite;
  }
}
@keyframes wv-ss-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* When a switch is in flight, the live controls are hidden by JS. */
.wv-ss-selector__live[hidden] {
  display: none;
}

/* ── State B: "Subscription" pill ──
   Dark text on olive accent (4.63:1, passes AA). The legacy cream-on-accent
   pill (--wv-color-text-inverse on --wv-color-accent) is a KNOWN AA blocker
   (2.86:1, A11Y-PATTERNS.md PENDING table) — not reused here. */
.wv-ss-selector__pill {
  display: inline-flex;
  align-items: center;
  background: var(--wv-color-accent);
  color: var(--wv-color-text-primary);
  padding: 4px 10px;
  border-radius: var(--wv-radius-pill);
  width: max-content;
  max-width: 100%;
  margin-top: 2px;
}

/* ── Delivery-frequency listbox (custom dropdown) ── */
.wv-ss-selector__freq {
  margin-top: 6px;
}

.wv-ss-selector__freq-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 44px;            /* WCAG 2.5.5 touch target */
  padding: 8px 12px;
  background: var(--wv-color-card-bg);
  color: var(--wv-color-text-primary);
  border: 1px solid var(--wv-color-border);
  border-radius: var(--wv-radius-sm, 6px);
  cursor: pointer;
  text-align: left;
}
.wv-ss-selector__freq-trigger:focus-visible {
  outline: 2px solid var(--wv-color-text-primary);
  outline-offset: 2px;
}

.wv-ss-selector__caret {
  flex-shrink: 0;
  transition: transform 180ms ease;
}
@media (prefers-reduced-motion: reduce) {
  .wv-ss-selector__caret { transition: none; }
}
.wv-ss-selector__freq-trigger[aria-expanded="true"] .wv-ss-selector__caret {
  transform: rotate(180deg);
}

/* Inline-expanding option list (clip-safe in the scroll container). */
.wv-ss-selector__listbox {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px;
  border: 1px solid var(--wv-color-border);
  border-radius: var(--wv-radius-sm, 6px);
  background: var(--wv-color-card-bg);
}
.wv-ss-selector__listbox[hidden] {
  display: none;
}

.wv-ss-selector__option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;            /* touch target */
  padding: 8px 10px;
  border-radius: var(--wv-radius-sm, 6px);
  color: var(--wv-color-text-primary);
  cursor: pointer;
}
.wv-ss-selector__option:hover,
.wv-ss-selector__option:focus-visible {
  background: var(--wv-color-background);
  outline: none;
}
/* Selected indicator — a checkmark, NOT color alone (WCAG 1.4.1). The mark is
   a mask tinted by a token (the mask's own stroke color is irrelevant — only
   its alpha is used — so no hardcoded color leaks in). */
.wv-ss-selector__option::before {
  content: "";
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  background-color: var(--wv-color-olive-dark);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M2.5 7.5l3 3 6-7' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M2.5 7.5l3 3 6-7' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0;
}
.wv-ss-selector__option[aria-selected="true"] {
  font-weight: 600;
}
.wv-ss-selector__option[aria-selected="true"]::before {
  opacity: 1;
}

/* ── Toggle link (both states) ──
   inline-block (NOT inline-flex): the revert copy drops a wc_price <span> in
   mid-sentence, and a flex container discards the whitespace between text and
   the span — gluing the price to the surrounding words. inline-block keeps
   the price inline so the spaces render. */
.wv-ss-selector__toggle {
  display: inline-block;
  min-height: 44px;            /* touch target */
  margin-top: 6px;
  padding: 11px 0;
  background: none;
  border: none;
  color: var(--wv-color-text-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  text-align: left;
}
.wv-ss-selector__toggle:focus-visible {
  outline: 2px solid var(--wv-color-text-primary);
  outline-offset: 2px;
}
/* --subscribe uses the base toggle color (--wv-color-text-primary, AA on the
   row bg). Olive-dark as 12px text would fail AA (4.23:1). */
