/* Build Your Own Bundle — styles.css
 *
 * ONLY what Tailwind cannot express:
 *   - @keyframes animations
 *   - Pseudo-elements (::before, ::after)
 *   - JS-toggled class states (.active, .selected, .filled, .disabled, .complete)
 *   - Complex child selectors triggered by parent hover
 *   - Mobile responsive visibility switches (display: none overrides)
 *   - The CSS toggle-switch component (input:checked sibling selector)
 */

/* ── Keyframes ─────────────────────────────────────────── */

@keyframes slotPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60%  { transform: translateX(-5px); }
  40%, 80%  { transform: translateX(5px); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(15, 23, 42, 0.4), 0 8px 30px rgba(15, 23, 42, 0.2); }
  50%       { box-shadow: 0 0 0 10px rgba(15, 23, 42, 0), 0 8px 30px rgba(15, 23, 42, 0.2); }
}

/* ── Tier Tab — JS-toggled .active state ───────────────── */

.byob-tier-tab:hover {
  background: rgba(255, 255, 255, 0.8);
  color: var(--color-foreground);
}

.byob-tier-tab.active {
  background: var(--color-primary);
  color: var(--color-primary-foreground);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

/* Badge positioned absolutely on the tab — must be CSS */
.byob-tier-tab .tier-tab-badge {
  position: absolute;
  top: -8px;
  right: -4px;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

@media (max-width: 1023px) {
  .byob-tier-tab .tier-tab-badge {
    font-size: 0.5rem;
    padding: 3px 6px;
    top: -6px;
    right: -2px;
  }
}

/* ── CSS Toggle Switch (subscription checkbox) ─────────── */
/* Uses input:checked + sibling selector — cannot be Tailwind */

.toggle-switch {
  width: 44px;
  height: 24px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  position: relative;
  transition: background 0.3s ease;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: left 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Works because checkbox.sr-only is immediately before .toggle-switch */
input:checked + .toggle-switch {
  background: var(--color-primary);
}

input:checked + .toggle-switch::after {
  left: 22px;
}

/* ── Selection Slots — JS-generated elements ───────────── */
/* JS creates these DOM nodes; they can't use Tailwind classes */

.selection-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.selection-slot {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  position: relative;
  overflow: visible;
  transition: all 0.25s ease;
}

.selection-slot .slot-image {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.selection-slot .slot-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.selection-slot.empty {
  background: var(--color-secondary);
}

/* Dashed inner border — pseudo-element */
.selection-slot.empty::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1.5px dashed var(--color-ring);
  border-radius: calc(var(--radius-md) - 4px);
  pointer-events: none;
}

.selection-slot.filled {
  background: white;
  box-shadow: 0 0 0 2px var(--color-primary);
}

.selection-slot.filled.just-added {
  animation: slotPop 0.3s ease-out;
}

/* Free slots */
.selection-slot.free-slot.empty {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
}

.selection-slot.free-slot.empty::before {
  border-color: rgba(34, 197, 94, 0.4);
}

.selection-slot.free-slot.filled {
  box-shadow: 0 0 0 2px #22c55e;
}

.slot-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-number {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-ring);
}

.slot-free-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #16a34a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.slot-free-badge {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.625rem;
  font-weight: 700;
  color: white;
  background: #22c55e;
  padding: 3px 8px;
  border-radius: var(--radius-md);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.slot-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  padding: 0;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--color-muted-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  z-index: 10;
  transition: all 0.2s ease;
}

.slot-remove:hover {
  background: var(--color-secondary);
  color: var(--color-foreground);
}

.slot-remove svg {
  width: 10px;
  height: 10px;
}

/* Shake on overflow attempt */
.selection-slots.shake {
  animation: shake 0.5s ease;
}

/* ── Product Card — JS-toggled .selected + hover child transforms ── */

.product-option-card.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary), 0 4px 12px rgba(15, 23, 42, 0.1);
  transform: translateY(-2px);
}

/* Image zoom on card hover — child selector, cannot be Tailwind */
.product-option-card:hover .product-option-image img {
  transform: scale(1.08);
}

/* Gradient overlay fade on hover — pseudo-element */
.product-option-image::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to top, rgba(255,255,255,0.9), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.product-option-card:hover .product-option-image::after {
  opacity: 1;
}

/* ── Product Add Button — JS toggles display:none/flex ─────────── */
/* Base appearance is Tailwind; only the display state lives here */

.product-add-btn {
  display: flex; /* JS sets style.display = 'none' or 'flex' */
}

/* ── Quantity Controls — JS toggles display:none/flex ──────────── */

.product-qty-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
  background: var(--color-secondary);
  border-radius: var(--radius-md);
  padding: 3px;
}

.product-qty-controls .qty-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-base);
  border: none;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.product-qty-controls .qty-btn:hover {
  background: var(--color-primary);
  color: var(--color-primary-foreground);
}

.product-qty-controls .qty-value {
  font-size: 0.9375rem;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
  color: var(--color-foreground);
}

/* ── Selected Badge — JS toggles display ───────────────── */

.product-selected-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: var(--color-primary-foreground);
  width: 24px;
  height: 24px;
  border-radius: var(--radius-base);
  font-size: 0.8125rem;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.3);
  z-index: 2;
}

/* ── Add to Cart CTA — .complete state + :disabled override ─────── */

.byob-add-btn {
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.byob-add-btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.25);
}

.byob-add-btn:disabled {
  opacity: 0.4 !important;
  cursor: not-allowed !important;
  background: var(--color-border) !important;
  border-color: var(--color-border) !important;
  color: var(--color-ring) !important;
  transform: none !important;
}

.byob-add-btn.complete {
  animation: pulse 2s infinite;
}

/* ── Mobile Responsive Layout ───────────────────────────── */
/* Visibility switches that can't be done with responsive Tailwind
   because they respond to JS-rendered section position on the page */

.byob-mobile-header,
.byob-mobile-footer {
  display: none;
}

@media (max-width: 1023px) {
  /* Show mobile sticky header */
  .byob-mobile-header {
    display: block;
    position: sticky;
    top: var(--navbar-height-mobile, 64px);
    z-index: 100;
    background: white;
    padding: 8px 0;
    margin: 0 -24px;
    padding-left: 24px;
    padding-right: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  }

  /* Show mobile sticky footer */
  .byob-mobile-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: white;
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    border-top: 1px solid var(--color-border);
  }

  /* Hide desktop config column on mobile */
  .byob-config-column {
    display: none !important;
  }

  /* Add padding so content doesn't hide under fixed footer */
  .byob-products-column {
    padding-bottom: 160px;
  }

  /* Mobile slots: horizontal scroll row */
  .mobile-footer-slots .mobile-slots {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px;
  }

  .mobile-footer-slots .mobile-slots::-webkit-scrollbar {
    display: none;
  }

  .mobile-footer-slots .selection-slot {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
  }

  .mobile-footer-slots .slot-remove {
    width: 18px;
    height: 18px;
    top: -4px;
    right: -4px;
  }

  /* Mobile purchase toggle pill */
  .mobile-purchase-toggle {
    display: flex;
    width: 100%;
    background: var(--color-secondary);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 3px;
  }

  .mobile-purchase-toggle .toggle-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 10px;
    border: none;
    border-radius: calc(var(--radius-md) - 3px);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .mobile-purchase-toggle .toggle-option.active {
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }

  .mobile-purchase-toggle .toggle-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-muted-foreground);
    transition: color 0.2s ease;
  }

  .mobile-purchase-toggle .toggle-option.active .toggle-label {
    color: var(--color-foreground);
  }

  .mobile-purchase-toggle .toggle-desc {
    font-size: 0.6875rem;
    color: var(--color-ring);
  }
}
