/**
 * Visual Enhancements - Phase 1: Page-Level Animations
 *
 * Features:
 * - Parallax hero with layered backgrounds
 * - Floating coffee elements
 * - Enhanced view transitions
 */

/* =========================================
   1. PARALLAX HERO SECTION
   ========================================= */

.hero {
  position: relative;
  overflow: hidden;
}

/* Background layers for parallax effect */
.hero__bg-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  will-change: transform;
}

.hero__bg-layer--pattern {
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 5c-2.5 0-4.5 2-4.5 4.5S27.5 14 30 14s4.5-2 4.5-4.5S32.5 5 30 5zm0 2c1.4 0 2.5 1.1 2.5 2.5S31.4 12 30 12s-2.5-1.1-2.5-2.5S28.6 7 30 7z' fill='%23f4a261' fill-opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.5;
  transform: translateY(calc(var(--scroll-y, 0) * 0.1));
}

.hero__bg-layer--gradient {
  background: radial-gradient(ellipse at 50% 0%, rgba(244, 162, 97, 0.08) 0%, transparent 60%);
  transform: translateY(calc(var(--scroll-y, 0) * 0.15));
}

.hero__bg-layer--glow {
  background: radial-gradient(circle at 30% 70%, rgba(244, 162, 97, 0.05) 0%, transparent 40%),
              radial-gradient(circle at 70% 30%, rgba(102, 126, 234, 0.04) 0%, transparent 40%);
  transform: translateY(calc(var(--scroll-y, 0) * 0.2));
}

/* Hero content stays above layers */
.hero__content {
  position: relative;
  z-index: 1;
}

/* =========================================
   2. FLOATING COFFEE ELEMENTS
   ========================================= */

.floating-elements {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.floating-element {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  animation: float 6s ease-in-out infinite, fadeInFloat 1s ease-out forwards;
}

/* Coffee bean SVG elements */
.floating-element--bean {
  width: 24px;
  height: 24px;
  color: #f4a261;
  opacity: 0.4;
}

.floating-element--bean svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* Steam wisp elements */
.floating-element--steam {
  width: 20px;
  height: 40px;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.1), transparent);
  border-radius: 50%;
  filter: blur(6px);
}

/* Cup silhouette */
.floating-element--cup {
  width: 32px;
  height: 32px;
  color: rgba(244, 162, 97, 0.25);
}

.floating-element--cup svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* Leaf element */
.floating-element--leaf {
  width: 20px;
  height: 20px;
  color: rgba(134, 239, 172, 0.3);
}

.floating-element--leaf svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* Float animation keyframes */
@keyframes float {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-20px) rotate(5deg);
  }
  50% {
    transform: translateY(-10px) rotate(-3deg);
  }
  75% {
    transform: translateY(-25px) rotate(2deg);
  }
}

@keyframes float-delayed {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  33% {
    transform: translateY(-15px) rotate(-5deg);
  }
  66% {
    transform: translateY(-25px) rotate(3deg);
  }
}

@keyframes float-slow {
  0%, 100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }
  50% {
    transform: translateY(-30px) rotate(8deg) scale(1.05);
  }
}

@keyframes fadeInFloat {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Variation timing for different elements */
.floating-element:nth-child(1) {
  animation: float 6s ease-in-out infinite, fadeInFloat 1s 0.2s ease-out forwards;
  animation-delay: 0s, 0.2s;
}

.floating-element:nth-child(2) {
  animation: float-delayed 8s ease-in-out infinite, fadeInFloat 1s 0.4s ease-out forwards;
  animation-delay: -2s, 0.4s;
}

.floating-element:nth-child(3) {
  animation: float-slow 10s ease-in-out infinite, fadeInFloat 1s 0.6s ease-out forwards;
  animation-delay: -4s, 0.6s;
}

.floating-element:nth-child(4) {
  animation: float 7s ease-in-out infinite, fadeInFloat 1s 0.8s ease-out forwards;
  animation-delay: -1s, 0.8s;
}

.floating-element:nth-child(5) {
  animation: float-delayed 9s ease-in-out infinite, fadeInFloat 1s 1s ease-out forwards;
  animation-delay: -3s, 1s;
}

.floating-element:nth-child(6) {
  animation: float-slow 11s ease-in-out infinite, fadeInFloat 1s 1.2s ease-out forwards;
  animation-delay: -5s, 1.2s;
}

/* Positioning for floating elements */
.floating-element:nth-child(1) { top: 15%; left: 8%; }
.floating-element:nth-child(2) { top: 25%; right: 12%; }
.floating-element:nth-child(3) { top: 60%; left: 5%; }
.floating-element:nth-child(4) { top: 45%; right: 8%; }
.floating-element:nth-child(5) { top: 75%; left: 15%; }
.floating-element:nth-child(6) { top: 35%; right: 20%; }

/* =========================================
   3. ENHANCED VIEW TRANSITIONS
   ========================================= */

/* Morphing page transitions with blur */
::view-transition-old(root) {
  animation: 0.35s ease-out both vt-morph-out;
}

::view-transition-new(root) {
  animation: 0.4s ease-out both vt-morph-in;
}

@keyframes vt-morph-out {
  to {
    opacity: 0;
    transform: scale(0.96);
    filter: blur(4px);
  }
}

@keyframes vt-morph-in {
  from {
    opacity: 0;
    transform: scale(1.04);
    filter: blur(4px);
  }
}

/* =========================================
   4. STEAM RISING ANIMATION
   ========================================= */

.steam-container {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 80px;
  pointer-events: none;
  z-index: 2;
}

.steam {
  position: absolute;
  width: 8px;
  height: 20px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  filter: blur(4px);
  animation: steam 3s ease-out infinite;
}

.steam:nth-child(1) { left: 5px; }
.steam:nth-child(2) { left: 16px; animation-delay: 0.5s; }
.steam:nth-child(3) { left: 27px; animation-delay: 1s; }

@keyframes steam {
  0% {
    transform: translateY(0) scaleX(1);
    opacity: 0;
  }
  15% {
    opacity: 0.6;
  }
  50% {
    transform: translateY(-40px) scaleX(1.3);
  }
  100% {
    transform: translateY(-80px) scaleX(0.6);
    opacity: 0;
  }
}

/* =========================================
   5. SCROLL PROGRESS ENHANCEMENT
   ========================================= */

.scroll-progress-bar {
  background: linear-gradient(90deg, #f4a261 0%, #e76f51 50%, #f4a261 100%);
  background-size: 200% 100%;
  animation: gradient-shift 3s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* =========================================
   6. HERO STAT COUNTERS
   ========================================= */

.hero__stat-number[data-count] {
  font-variant-numeric: tabular-nums;
}

.hero__stat-number.counting {
  animation: pulse-count 0.1s ease-out;
}

@keyframes pulse-count {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* =========================================
   7. MOBILE OPTIMIZATIONS
   ========================================= */

@media (max-width: 768px) {
  /* Reduce floating elements on mobile */
  .floating-element:nth-child(n+4) {
    display: none;
  }

  /* Simpler parallax on mobile */
  .hero__bg-layer--pattern,
  .hero__bg-layer--gradient,
  .hero__bg-layer--glow {
    transform: none !important;
  }

  /* Smaller floating elements */
  .floating-element--bean {
    width: 18px;
    height: 18px;
  }

  .floating-element--cup {
    width: 24px;
    height: 24px;
  }
}

/* =========================================
   8. REDUCED MOTION SUPPORT
   ========================================= */

@media (prefers-reduced-motion: reduce) {
  .floating-element {
    animation: none !important;
    opacity: 0.3 !important;
  }

  .hero__bg-layer {
    transform: none !important;
  }

  .steam {
    animation: none !important;
    opacity: 0.3 !important;
  }

  .scroll-progress-bar {
    animation: none !important;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.01ms !important;
  }
}

/* =========================================
   9. DARK THEME GLOW EFFECTS
   ========================================= */

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    ellipse at center,
    rgba(244, 162, 97, 0.03) 0%,
    transparent 50%
  );
  pointer-events: none;
  animation: glow-pulse 8s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% {
    opacity: 0.5;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero::before {
    animation: none !important;
    opacity: 0.5 !important;
  }
}
