/**
 * Free Delivery Progress Bar Module Styles (Compiled)
 *
 * Displays a progress bar on WooCommerce cart pages showing customers
 * how close they are to qualifying for free delivery.
 *
 * @package Bricks_Child
 * @since   1.0.0
 */

/* =============================================================================
   Keyframe Animations
   ============================================================================= */

/* Progress bar fill animation */
@keyframes fdb-progress-fill {
  from {
    width: 0;
  }
  to {
    width: var(--fdb-progress-width, 0%);
  }
}

/* Success pulse animation */
@keyframes fdb-success-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

/* Shimmer effect for progress bar */
@keyframes fdb-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Success bounce animation */
@keyframes fdb-success-bounce {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

/* =============================================================================
   Block
   ============================================================================= */

.free-delivery-bar {
  /* CSS Custom Properties (set via inline styles by PHP) */
  --fdb-bar-color: #4CAF50;
  --fdb-bg-color: #E8E8E8;
  --fdb-text-color: #333333;

  /* Block styles */
  width: 100%;
  padding: 16px 0;
  margin: 0 0 20px 0;
  box-sizing: border-box;
}

/* =============================================================================
   Elements
   ============================================================================= */

.free-delivery-bar__message {
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--fdb-text-color, #333333);
  text-align: center;
  line-height: 1.5;
}

/* Remove margin when no track follows (success state) */
.free-delivery-bar__message:last-child {
  margin-bottom: 0;
}

.free-delivery-bar__track {
  width: 100%;
  height: 12px;
  background-color: var(--fdb-bg-color, #E8E8E8);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.free-delivery-bar__progress {
  height: 100%;
  background-color: var(--fdb-bar-color, #4CAF50);
  border-radius: 6px;
  position: relative;
  min-width: 0;
  max-width: 100%;
}

/* Progress indicator dot */
.free-delivery-bar__progress::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  background-color: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

/* Show dot when progress is visible */
.free-delivery-bar__progress[style*="width:"]:not([style*="width: 0"])::after {
  opacity: 1;
}

/* =============================================================================
   Modifiers
   ============================================================================= */

/* Animated state - enables transitions */
.free-delivery-bar--animated .free-delivery-bar__progress {
  transition: width 0.3s ease-out;
}

/* Success state - threshold reached */
.free-delivery-bar--success .free-delivery-bar__message {
  color: var(--fdb-bar-color, #4CAF50);
  font-weight: 600;
}

/* Optional: Add success animation */
.free-delivery-bar--success.free-delivery-bar--animated {
  animation: fdb-success-bounce 0.5s ease-out;
}

/* With shimmer effect (optional enhancement) */
.free-delivery-bar--shimmer .free-delivery-bar__progress {
  background-image: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: fdb-shimmer 2s infinite;
}

/* Initial fill animation (for page load) */
.free-delivery-bar--fill-animation .free-delivery-bar__progress {
  animation: fdb-progress-fill 0.6s ease-out forwards;
}

/* Pulse animation for near-threshold state */
.free-delivery-bar--pulse .free-delivery-bar__progress {
  animation: fdb-success-pulse 2s ease-in-out infinite;
}

/* =============================================================================
   Responsive Styles (Mobile-first)
   ============================================================================= */

@media (max-width: 768px) {
  .free-delivery-bar {
    padding: 12px 0;
  }

  .free-delivery-bar__track {
    height: 8px;
  }

  .free-delivery-bar__message {
    font-size: 13px;
  }
}

/* =============================================================================
   Accessibility
   ============================================================================= */

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .free-delivery-bar__progress {
    transition: none;
    animation: none;
  }

  .free-delivery-bar--animated .free-delivery-bar__progress,
  .free-delivery-bar--shimmer .free-delivery-bar__progress,
  .free-delivery-bar--fill-animation .free-delivery-bar__progress,
  .free-delivery-bar--pulse .free-delivery-bar__progress {
    animation: none;
    transition: none;
  }

  .free-delivery-bar--success.free-delivery-bar--animated {
    animation: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .free-delivery-bar__track {
    border: 2px solid var(--fdb-text-color, #333333);
  }

  .free-delivery-bar__progress {
    border-right: 2px solid var(--fdb-text-color, #333333);
  }
}

/* Forced colors mode (Windows High Contrast) */
@media (forced-colors: active) {
  .free-delivery-bar__track {
    border: 1px solid CanvasText;
  }

  .free-delivery-bar__progress {
    background-color: Highlight;
  }

  .free-delivery-bar__message {
    color: CanvasText;
  }

  .free-delivery-bar--success .free-delivery-bar__message {
    color: Highlight;
  }
}

/* =============================================================================
   WooCommerce Integration
   ============================================================================= */

/* Ensure proper spacing in WooCommerce contexts */
.woocommerce-cart .free-delivery-bar,
.woocommerce-checkout .free-delivery-bar {
  /* Clear any floats that might interfere */
  clear: both;
  /* Ensure it doesn't overflow containers */
  max-width: 100%;
}

/* Style when placed in cart collaterals */
.woocommerce-cart .cart-collaterals .free-delivery-bar {
  margin-bottom: 15px;
  padding: 12px;
  background-color: rgba(0, 0, 0, 0.02);
  border-radius: 4px;
}

/* Style when placed before checkout button */
.woocommerce-proceed-to-checkout .free-delivery-bar {
  margin-bottom: 15px;
  padding: 12px;
  background-color: rgba(0, 0, 0, 0.02);
  border-radius: 4px;
}
