/**
 * UI Enhancements — micro-animations, sticky header,
 * scroll-reveal, add-to-cart feedback, trust strip
 */

/* ============================================
   Sticky Shrinking Header
   ============================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  /* Prevents the browser's scroll-anchoring from adjusting scroll position
     when the header height changes during the shrink animation */
  overflow-anchor: none;
  transition: box-shadow var(--transition-fast);
}

.site-header.header-scrolled {
  box-shadow: var(--shadow-md);
}

/* Desktop-only shrink — transitions are safe here because overflow-anchor:none
   stops the browser from fighting the height change with scroll compensation */
@media (min-width: 992px) {
  .navbar-primary {
    transition: padding-block var(--transition-fast);
  }

  .site-logo {
    transition: max-height var(--transition-fast);
  }

  .site-header.header-scrolled .navbar-primary {
    padding-block: var(--space-1);
  }

  .site-header.header-scrolled .site-logo {
    max-height: 36px;
  }
}

/* ============================================
   Trust Strip
   ============================================ */
.trust-strip {
  background: var(--color-background);
  border-bottom: 1px solid var(--color-border-light);
  padding-block: var(--space-3);
}

.trust-strip-list {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-6);
  list-style: none;
  margin: 0;
  padding: 0;
}

.trust-strip-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

@media (max-width: 575px) {
  .trust-strip-item {
    white-space: normal;
    text-align: center;
    flex-direction: column;
    font-size: var(--text-xs);
  }
}

.trust-strip-item i {
  font-size: var(--text-lg);
  color: var(--color-primary);
  flex-shrink: 0;
}

/* Dividers between trust items (hidden on mobile) */
.trust-strip-item + .trust-strip-item::before {
  content: '·';
  color: var(--color-border);
  margin-inline-end: var(--space-6);
  display: none;
}

@media (min-width: 768px) {
  .trust-strip-item + .trust-strip-item::before {
    display: block;
  }
}

/* ============================================
   Add-to-Cart Micro-Animation
   ============================================ */
.btn-add-to-cart {
  position: relative;
  overflow: hidden;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.btn-add-to-cart.btn-success-anim {
  background: var(--color-success) !important;
  border-color: var(--color-success) !important;
  transform: scale(0.97);
  pointer-events: none;
}

.btn-add-to-cart.btn-success-anim::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-white);
  background: var(--color-success);
  animation: checkPop 0.3s ease;
}

@keyframes checkPop {
  0%   { opacity: 0; transform: scale(0.5); }
  60%  { transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

/* ============================================
   Wishlist Heart Burst Animation
   ============================================ */
.product-wishlist.wishlisted {
  color: var(--color-error) !important;
  background: color-mix(in srgb, var(--color-error) 10%, var(--color-white)) !important;
  animation: heartBurst 0.4s ease;
}

@keyframes heartBurst {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.35); }
  60%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* ============================================
   Staggered Scroll-Reveal for Product Cards
   ============================================ */
.product-card-reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.product-card-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger delays — reset every 4 items (4n+1 = first in each row) */
.product-card-reveal:nth-child(4n+1) { transition-delay: 0ms; }
.product-card-reveal:nth-child(4n+2) { transition-delay: 80ms; }
.product-card-reveal:nth-child(4n+3) { transition-delay: 160ms; }
.product-card-reveal:nth-child(4n+4) { transition-delay: 240ms; }

/* ============================================
   Mobile Search Bar (below primary nav)
   ============================================ */
.mobile-search-bar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
  padding: var(--space-2) var(--space-3);
}

/* ── 4-Style Section Backgrounds ─────────────────────────── */
.homepage-section--default {
  background-color: var(--color-surface);
}

/* Soft: visible light lavender — clearly different from white */
.homepage-section--soft {
  background-color: color-mix(in srgb, var(--color-primary) 7%, #fff);
}

/* Soft: left accent bar on section title */
.homepage-section--soft .section-title,
.homepage-section--soft .category-strip-title {
  padding-inline-start: var(--space-4);
  border-inline-start: 4px solid var(--color-primary);
}

/* Gradient: diagonal lavender-to-white, more visible */
.homepage-section--gradient {
  background: linear-gradient(145deg,
    color-mix(in srgb, var(--color-primary) 10%, #fff) 0%,
    var(--color-surface) 55%
  );
}

/* Gradient: centered title with accent underline */
.homepage-section--gradient .section-header {
  text-align: center;
}

.homepage-section--gradient .section-header .section-cta {
  justify-content: center;
}

.homepage-section--gradient .section-title::after,
.homepage-section--gradient .category-strip-title::after {
  content: '';
  display: block;
  width: 48px;
  height: 3px;
  background: var(--color-primary);
  border-radius: 99px;
  margin: var(--space-2) auto 0;
}

/* Featured: vibrant brand bg — primary with slight depth, not near-black */
.homepage-section--featured {
  background: color-mix(in srgb, var(--color-primary) 85%, #000);
}

/* Featured: all non-card text inherits white */
.homepage-section--featured .section-header,
.homepage-section--featured .category-strip-header,
.homepage-section--featured .flash-sale-header,
.homepage-section--featured .section-header *:not(.btn),
.homepage-section--featured .category-strip-header *:not(.btn) {
  color: #fff;
}

/* Beat fashion demo specificity (0,3,0) — these are 0,4,0 */
[data-demo="fashion"] .homepage-section--featured .products-showcase-section .section-title,
[data-demo="fashion"] .homepage-section--featured .brand-showcase-section .section-title,
[data-demo="fashion"] .homepage-section--featured .category-strip-section .category-strip-title {
  color: #fff;
}

/* Featured: BIG dramatic title */
.homepage-section--featured .section-title,
.homepage-section--featured .category-strip-title,
.homepage-section--featured .flash-sale-title {
  color: #fff;
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.homepage-section--featured .section-description,
.homepage-section--featured .flash-sale-description {
  color: rgba(255, 255, 255, 0.75);
  font-size: var(--text-base);
}

/* Featured: accent line under big title */
.homepage-section--featured .section-title::after,
.homepage-section--featured .category-strip-title::after {
  content: '';
  display: block;
  width: 56px;
  height: 3px;
  background: var(--color-accent);
  border-radius: 99px;
  margin-top: var(--space-3);
}

/* Featured: invert CTA buttons */
.homepage-section--featured .section-cta .btn-outline-primary,
.homepage-section--featured .category-strip-cta {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.55);
}

.homepage-section--featured .section-cta .btn-outline-primary:hover,
.homepage-section--featured .category-strip-cta:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.8);
}

/* Featured: card borders softer on dark bg */
.homepage-section--featured .product-card {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* ── Extended Scroll-Reveal: Category + Banner Cards ─────── */
.category-card-modern,
.banner-card {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.category-card-modern.revealed,
.banner-card.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   Reduced Motion Overrides
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .product-card-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .category-card-modern,
  .banner-card {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .btn-add-to-cart.btn-success-anim::after {
    animation: none;
  }

  .product-wishlist.wishlisted {
    animation: none;
  }

  .announcement-bar-item {
    animation: none;
  }
}
