/* ==========================================================================
   Build-a-Box Custom Bundle Builder (Template B)
   All classes prefixed with `bab-`
   Mobile-first with breakpoints at 480px, 768px, 1024px
   ========================================================================== */

/* --- Reset & Container --- */
.bab-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 16px;
}

.bab-section *,
.bab-section *::before,
.bab-section *::after {
  box-sizing: border-box;
}

/* --- Section Titles --- */
.bab-step {
  margin-bottom: 48px;
}

.bab-step__header {
  margin-bottom: 24px;
}

.bab-step__number {
  display: inline-block;
  font-family: var(--FONT-HEADING-FAMILY), sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-a50);
  margin-bottom: 8px;
}

.bab-step__title {
  font-family: var(--FONT-HEADING-FAMILY), sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: var(--FONT-HEADING-UPPERCASE);
  letter-spacing: var(--FONT-HEADING-LETTERSPACING);
  color: var(--text);
  margin: 0;
}

.bab-step__subtitle {
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.9375rem;
  color: var(--text-a50);
  margin-top: 4px;
}

/* ==========================================================================
   Step 1: Box Size / Tier Selection
   ========================================================================== */
.bab-tiers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.bab-tier {
  position: relative;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

.bab-tier:hover {
  border-color: var(--accent);
}

.bab-tier.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.bab-tier__badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 12px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.bab-tier__count {
  font-family: var(--FONT-HEADING-FAMILY), sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.bab-tier__label {
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.8125rem;
  color: var(--text-a50);
  margin-top: 2px;
}

.bab-tier__price {
  font-family: var(--FONT-HEADING-FAMILY), sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 12px;
}

.bab-tier__per-meal {
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.8125rem;
  color: var(--text-a50);
  margin-top: 2px;
}

/* Checkmark indicator */
.bab-tier__check {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  align-items: center;
  justify-content: center;
}

.bab-tier.is-selected .bab-tier__check {
  display: flex;
}

/* ==========================================================================
   Step 2: Purchase Type
   ========================================================================== */
.bab-purchase-types {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.bab-purchase-type {
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.bab-purchase-type:hover {
  border-color: var(--accent);
}

.bab-purchase-type.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.bab-purchase-type__header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bab-purchase-type__radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.15s ease;
}

.bab-purchase-type.is-selected .bab-purchase-type__radio {
  border-color: var(--accent);
}

.bab-purchase-type.is-selected .bab-purchase-type__radio::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.bab-purchase-type__name {
  flex: 1;
  font-family: var(--FONT-HEADING-FAMILY), sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.bab-purchase-type__prices {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bab-purchase-type__price {
  font-family: var(--FONT-HEADING-FAMILY), sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

.bab-purchase-type__compare-price {
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.875rem;
  color: var(--text-a50);
  text-decoration: line-through;
}

.bab-purchase-type__savings-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(22, 163, 74, 0.1);
  color: #16a34a;
  border-radius: var(--radius-pill);
}

.bab-purchase-type__recurring {
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.8125rem;
  color: var(--text-a50);
  margin: 8px 0 0 32px;
}

.bab-purchase-type__perks {
  margin-top: 12px;
  padding-left: 32px;
  list-style: none;
}

.bab-purchase-type__perk {
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.875rem;
  color: var(--text-a50);
  padding: 3px 0;
  position: relative;
  padding-left: 20px;
}

.bab-purchase-type__perk::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 12px;
  height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 6l3 3 5-5' stroke='%2316a34a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* ==========================================================================
   Step 3: Choose Flavors
   ========================================================================== */
.bab-flavors-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.bab-flavors-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

/* --- Flavor Card --- */
.bab-flavor-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: var(--bg);
}

.bab-flavor-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.bab-flavor-card.has-selections {
  border-color: var(--accent);
}

.bab-flavor-card__image-wrap {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-accent, #f5f5f5);
}

.bab-flavor-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bab-flavor-card__image--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20%;
}

.bab-flavor-card__placeholder-svg {
  width: 100%;
  height: 100%;
  opacity: 0.3;
}

.bab-flavor-card__info {
  padding: 16px 16px 8px;
}

.bab-flavor-card__title {
  font-family: var(--FONT-HEADING-FAMILY), sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.bab-flavor-card__description {
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.8125rem;
  color: var(--text-a50);
  margin: 4px 0 0;
  line-height: 1.4;
}

.bab-flavor-card__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 16px 20px;
}

.bab-flavor-card__btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

.bab-flavor-card__btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.bab-flavor-card__btn:disabled {
  opacity: 0.3;
}

.bab-flavor-card__qty {
  font-family: var(--FONT-HEADING-FAMILY), sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
  color: var(--text);
}

/* --- Progress Bar --- */
.bab-progress {
  margin-bottom: 24px;
}

.bab-progress__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.bab-progress__label {
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.bab-progress__count {
  font-family: var(--FONT-HEADING-FAMILY), sans-serif;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
}

.bab-progress__track {
  height: 10px;
  background: #e5e7eb;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.bab-progress__fill {
  height: 100%;
  background: #f59e0b;
  border-radius: var(--radius-md);
  transition: width 0.3s ease, background-color 0.3s ease;
  width: 0%;
}

.bab-progress__fill.is-complete {
  background: #16a34a;
}

/* --- Order Summary Sidebar --- */
.bab-summary {
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--bg);
}

.bab-summary__title {
  font-family: var(--FONT-HEADING-FAMILY), sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
}

.bab-summary__items {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.bab-summary__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.875rem;
  color: var(--text);
}

.bab-summary__item:last-child {
  border-bottom: none;
}

.bab-summary__item-name {
  flex: 1;
}

.bab-summary__item-qty {
  font-weight: 600;
  margin-left: 12px;
}

.bab-summary__empty {
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.875rem;
  color: var(--text-a50);
  text-align: center;
  padding: 16px 0;
}

.bab-summary__divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.bab-summary__total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--FONT-HEADING-FAMILY), sans-serif;
  font-weight: 700;
}

.bab-summary__total-label {
  font-size: 0.75rem;
  color: var(--text);
}

.bab-summary__total-price {
  font-size: 1.25rem;
  color: var(--text);
}

.bab-summary__per-meal {
  text-align: right;
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.8125rem;
  color: var(--text-a50);
  margin-top: 4px;
}

/* --- Add to Cart Button --- */
.bab-add-to-cart {
  width: 100%;
  padding: 18px 32px;
  font-family: var(--FONT-BUTTON-FAMILY, var(--FONT-HEADING-FAMILY)), sans-serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent);
  color: #fff;
  transition: opacity 0.2s ease;
  margin-top: 16px;
  -webkit-tap-highlight-color: transparent;
}

.bab-add-to-cart:hover:not(:disabled) {
  opacity: 0.85;
}

.bab-add-to-cart:disabled {
  opacity: 0.4;
}

.bab-add-to-cart.is-loading {
  position: relative;
  color: transparent;
}

.bab-add-to-cart.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: bab-spin 0.6s linear infinite;
}

@keyframes bab-spin {
  to { transform: rotate(360deg); }
}

/* --- Error Message --- */
.bab-error {
  display: none;
  margin-top: 12px;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.875rem;
  color: #dc2626;
}

.bab-error.is-visible {
  display: block;
}

/* --- Disabled / Inactive State --- */
.bab-step.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ==========================================================================
   Mobile Bottom Bar (Sticky CTA)
   ========================================================================== */
.bab-mobile-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
}

.bab-mobile-bar__inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bab-mobile-bar__info {
  flex: 1;
}

.bab-mobile-bar__price {
  font-family: var(--FONT-HEADING-FAMILY), sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

.bab-mobile-bar__progress {
  font-family: var(--FONT-STACK-BODY);
  font-size: 0.75rem;
  color: var(--text-a50);
}

.bab-mobile-bar__btn {
  padding: 14px 24px;
  font-family: var(--FONT-BUTTON-FAMILY, var(--FONT-HEADING-FAMILY)), sans-serif;
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent);
  color: #fff;
  transition: opacity 0.2s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.bab-mobile-bar__btn:disabled {
  opacity: 0.4;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

/* 480px+ */
@media (min-width: 480px) {
  .bab-flavors-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* 768px+ */
@media (min-width: 768px) {
  .bab-section {
    padding: 60px 24px;
  }

  .bab-step__title {
    font-size: 1.75rem;
  }

  .bab-tiers {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  .bab-purchase-types {
    grid-template-columns: 1fr 1fr;
  }

  .bab-flavors-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .bab-flavors-layout {
    flex-direction: row;
    gap: 32px;
  }

  .bab-flavors-grid-wrap {
    flex: 1;
  }

  .bab-summary-wrap {
    width: 360px;
    flex-shrink: 0;
  }

  .bab-summary {
    position: sticky;
    top: 120px;
  }

  .bab-mobile-bar {
    display: none !important;
  }
}

/* 1024px+ */
@media (min-width: 1024px) {
  .bab-section {
    padding: 80px 40px 0;
  }

  .bab-tier {
    padding: 24px 20px;
  }

  .bab-tier__count {
    font-size: 2.5rem;
  }

  .bab-summary-wrap {
    width: 400px;
  }
}

/* Mobile only: show bottom bar */
@media (max-width: 767px) {
  .bab-mobile-bar {
    display: block;
  }

  .bab-summary-wrap {
    display: none;
  }

  /* Extra padding at bottom for the sticky bar */
  .bab-section {
    padding-bottom: 100px;
  }
}
