/**
 * INTERACTIVE COMPONENTS CSS - Premium Features
 * Tillerstead.com - Phase 2 Styles
 * 
 * Features:
 * - FAQ Accordion
 * - Before/After Slider
 * - Pricing Calculator
 * - Toast Notifications
 * - Image Lightbox
 */

/* ==============================================
   MOBILE: Disable heavy interactive features
   ============================================== */

@media (max-width: 768px) {
  /* Simplify all interactions on mobile for performance */
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ==========================================================================
   FAQ ACCORDION
   ========================================================================== */

[data-accordion] {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

[data-accordion-item] {
  background: rgb(255 255 255 / 5%);
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

[data-accordion-item]:hover {
  background: rgb(255 255 255 / 8%);
  border-color: rgb(255 255 255 / 20%);
}

[data-accordion-item].is-expanded {
  background: rgb(255 255 255 / 10%);
  box-shadow: 0 8px 32px rgb(0 0 0 / 10%);
}

[data-accordion-trigger] {
  width: 100%;
  padding: 1.5rem 2rem;
  background: none;
  border: none;
  text-align: left;
  font-size: 1.125rem;
  font-weight: 700;
  color: inherit;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  transition: color 0.3s ease;
}

[data-accordion-trigger]:hover {
  color: var(--color-primary, #00a35c);
}

[data-accordion-trigger]::after {
  content: '+';
  font-size: 2rem;
  font-weight: 300;
  transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  flex-shrink: 0;
}

[data-accordion-trigger][aria-expanded='true']::after {
  transform: rotate(45deg);
}

[data-accordion-content] {
  padding: 0 2rem;
  font-size: 1rem;
  line-height: 1.7;
  color: rgb(255 255 255 / 90%);
}

[data-accordion-content] > *:last-child {
  margin-bottom: 1.5rem;
}

/* ==========================================================================
   BEFORE/AFTER SLIDER
   ========================================================================== */

[data-before-after] {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 16px;
  cursor: ew-resize;
  user-select: none;
}

[data-ba-before],
[data-ba-after] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

[data-ba-overlay] {
  position: absolute;
  inset: 0;
  clip-path: inset(0 50% 0 0);
  transition: clip-path 0.1s ease-out;
}

[data-ba-handle] {
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  background: rgb(255 255 255 / 90%);
  cursor: ew-resize;
  transform: translateX(-50%);
  z-index: 10;
  transition: background 0.2s ease;
}

[data-ba-handle]::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  background: rgb(255 255 255 / 95%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 12px rgb(0 0 0 / 20%);
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-ba-handle]::after {
  content: '⟷';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  color: #333333;
  z-index: 1;
}

[data-ba-handle].is-dragging {
  background: var(--color-primary, #00a35c);
}

[data-ba-handle].is-dragging::before {
  box-shadow: 0 8px 24px rgb(0 0 0 / 30%);
}

/* Labels */
[data-before-after]::before,
[data-before-after]::after {
  position: absolute;
  top: 1rem;
  padding: 0.5rem 1rem;
  background: rgb(0 0 0 / 70%);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 8px;
  z-index: 5;
  pointer-events: none;
}

[data-before-after]::before {
  content: 'Before';
  left: 1rem;
}

[data-before-after]::after {
  content: 'After';
  right: 1rem;
}

/* ==========================================================================
   PRICING CALCULATOR
   ========================================================================== */

[data-pricing-calculator] {
  background: rgb(255 255 255 / 5%);
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 16px;
  padding: 2rem;
}

.calc-input-group {
  margin-bottom: 1.5rem;
}

.calc-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: rgb(255 255 255 / 90%);
}

[data-calc-input] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgb(255 255 255 / 8%);
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 8px;
  color: inherit;
  font-size: 1rem;
  transition: all 0.3s ease;
}

[data-calc-input]:focus {
  outline: none;
  background: rgb(255 255 255 / 12%);
  border-color: var(--color-primary, #00a35c);
  box-shadow: 0 0 0 3px rgb(0 163 92 / 10%);
}

.calc-output-wrapper {
  margin-top: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, rgb(0 163 92 / 10%), rgb(0 163 92 / 5%));
  border: 2px solid rgb(0 163 92 / 30%);
  border-radius: 12px;
  text-align: center;
}

.calc-output-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgb(255 255 255 / 90%);
}

[data-calc-output] {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--color-primary, #00a35c);
  text-shadow: 0 2px 8px rgb(0 163 92 / 30%);
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: rgb(255 255 255 / 95%);
  backdrop-filter: blur(20px);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgb(0 0 0 / 20%);
  opacity: 0%;
  transform: translateX(100%);
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
  pointer-events: auto;
  color: #333333;
}

.toast--show {
  opacity: 100%;
  transform: translateX(0);
}

.toast--exit {
  opacity: 0%;
  transform: translateX(100%) scale(0.9);
}

.toast__icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.25rem;
  font-weight: 700;
}

.toast--success .toast__icon {
  background: rgb(34 197 94 / 20%);
  color: #22c55e;
}

.toast--error .toast__icon {
  background: rgb(239 68 68 / 20%);
  color: #ef4444;
}

.toast--warning .toast__icon {
  background: rgb(251 191 36 / 20%);
  color: #fbbf24;
}

.toast--info .toast__icon {
  background: rgb(59 130 246 / 20%);
  color: #3b82f6;
}

.toast__message {
  flex: 1;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.toast__close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  background: rgb(0 0 0 / 10%);
  border: none;
  border-radius: 50%;
  font-size: 1.25rem;
  color: #666666;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toast__close:hover {
  background: rgb(0 0 0 / 20%);
  color: #333333;
}

/* ==========================================================================
   IMAGE LIGHTBOX
   ========================================================================== */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0%;
  transition: opacity 0.3s ease;
}

.lightbox--show {
  opacity: 100%;
}

.lightbox--exit {
  opacity: 0%;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 95%);
  cursor: pointer;
}

.lightbox__content {
  position: relative;
  width: 90%;
  max-width: 1200px;
  max-height: 90vh;
  z-index: 1;
}

.lightbox__image {
  width: 100%;
  height: auto;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox__close,
.lightbox__prev,
.lightbox__next {
  position: absolute;
  width: 48px;
  height: 48px;
  padding: 0;
  background: rgb(255 255 255 / 10%);
  backdrop-filter: blur(10px);
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 50%;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__close:hover,
.lightbox__prev:hover,
.lightbox__next:hover {
  background: rgb(255 255 255 / 20%);
  transform: scale(1.1);
}

.lightbox__close {
  top: -60px;
  right: 0;
}

.lightbox__prev {
  left: -60px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__next {
  right: -60px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__counter {
  position: absolute;
  bottom: -50px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  background: rgb(255 255 255 / 10%);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .toast-container {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }

  .lightbox__prev,
  .lightbox__next {
    bottom: 1rem;
    top: auto;
    transform: none;
  }

  .lightbox__prev {
    left: 1rem;
  }

  .lightbox__next {
    right: 1rem;
    left: auto;
  }

  .lightbox__close {
    top: 1rem;
    right: 1rem;
  }

  .lightbox__counter {
    bottom: auto;
    top: 1rem;
  }
}

/* Accessibility - Reduced motion */
@media (prefers-reduced-motion: reduce) {
  [data-accordion-item],
  [data-accordion-trigger],
  [data-accordion-content],
  [data-ba-handle],
  [data-calc-input],
  .toast,
  .lightbox {
    transition-duration: 0.01ms !important;
  }

  [data-accordion-trigger]::after {
    transition: none;
  }
}
