/* ========================================
   3D Animations & Keyframes
   ======================================== */

/* ── Washing Machine 3D Animation ── */
.washing-machine-3d {
  position: relative;
  width: 280px;
  height: 340px;
  perspective: 1000px;
  margin: 0 auto;
}

.machine-body {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #2a3a5c, #1a2540);
  border-radius: 24px;
  border: 2px solid rgba(168, 218, 220, 0.2);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform-style: preserve-3d;
  animation: machineFloat 4s ease-in-out infinite;
}

.machine-panel {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  height: 50px;
  background: linear-gradient(90deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
}

.machine-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
}

.machine-btn.red { background: #EF4444; box-shadow: 0 0 6px rgba(239,68,68,0.5); }
.machine-btn.yellow { background: #F59E0B; box-shadow: 0 0 6px rgba(245,158,11,0.5); }
.machine-btn.green { background: #10B981; box-shadow: 0 0 6px rgba(16,185,129,0.5); }

.machine-display {
  margin-left: auto;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.65rem;
  color: var(--secondary, #A8DADC);
  background: rgba(0,0,0,0.3);
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 2px;
}

.machine-door {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -40%);
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a1628, #162035);
  border: 4px solid rgba(168, 218, 220, 0.3);
  overflow: hidden;
  box-shadow:
    inset 0 0 30px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(168, 218, 220, 0.1);
}

.machine-glass {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%,
    rgba(168, 218, 220, 0.15),
    rgba(69, 123, 157, 0.05));
  overflow: hidden;
}

.machine-drum {
  position: absolute;
  inset: 0;
  animation: drumSpin 3s linear infinite;
}

.drum-clothes {
  position: absolute;
  border-radius: 50%;
  opacity: 0.7;
}

.drum-clothes:nth-child(1) {
  width: 30px; height: 25px;
  background: #FF6F61;
  top: 20%; left: 30%;
  border-radius: 40% 60% 50% 50%;
  animation: tumbleCloth1 3s ease-in-out infinite;
}

.drum-clothes:nth-child(2) {
  width: 25px; height: 30px;
  background: #A8DADC;
  top: 50%; left: 55%;
  border-radius: 60% 40% 50% 50%;
  animation: tumbleCloth2 3s ease-in-out infinite;
}

.drum-clothes:nth-child(3) {
  width: 28px; height: 22px;
  background: #F59E0B;
  top: 65%; left: 25%;
  border-radius: 50% 50% 40% 60%;
  animation: tumbleCloth3 3s ease-in-out infinite;
}

.drum-clothes:nth-child(4) {
  width: 22px; height: 26px;
  background: #10B981;
  top: 30%; left: 60%;
  border-radius: 45% 55% 55% 45%;
  animation: tumbleCloth4 3s ease-in-out infinite;
}

.machine-water {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(0deg,
    rgba(168, 218, 220, 0.25),
    rgba(168, 218, 220, 0.05));
  animation: waterWave 2s ease-in-out infinite;
}

.machine-reflection {
  position: absolute;
  top: 10%;
  left: 15%;
  width: 30%;
  height: 30%;
  background: linear-gradient(135deg,
    rgba(255,255,255,0.2),
    transparent);
  border-radius: 50%;
  filter: blur(2px);
}

.machine-feet {
  position: absolute;
  bottom: -4px;
  display: flex;
  justify-content: space-between;
  width: 80%;
  left: 10%;
}

.foot {
  width: 24px;
  height: 8px;
  background: #1a2540;
  border-radius: 0 0 8px 8px;
  border: 1px solid rgba(168, 218, 220, 0.1);
}

/* ── Keyframes ── */
@keyframes machineFloat {
  0%, 100% { transform: translateY(0) rotateX(2deg) rotateY(-2deg); }
  50% { transform: translateY(-12px) rotateX(-1deg) rotateY(2deg); }
}

@keyframes drumSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes tumbleCloth1 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(15px, -20px) rotate(90deg); }
  50% { transform: translate(30px, 0) rotate(180deg); }
  75% { transform: translate(15px, 20px) rotate(270deg); }
}

@keyframes tumbleCloth2 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-20px, -15px) rotate(-90deg); }
  50% { transform: translate(-30px, 5px) rotate(-180deg); }
  75% { transform: translate(-15px, 15px) rotate(-270deg); }
}

@keyframes tumbleCloth3 {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
  33% { transform: translate(20px, -25px) rotate(120deg) scale(0.9); }
  66% { transform: translate(-10px, -30px) rotate(240deg) scale(1.1); }
}

@keyframes tumbleCloth4 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-20px, -20px) rotate(180deg); }
}

@keyframes waterWave {
  0%, 100% { 
    height: 40%;
    border-radius: 40% 60% 0 0;
  }
  50% { 
    height: 45%;
    border-radius: 60% 40% 0 0;
  }
}

/* ── Floating Bubbles ── */
.bubbles-container {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.bubble {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%,
    rgba(168, 218, 220, 0.4),
    rgba(168, 218, 220, 0.1));
  border: 1px solid rgba(168, 218, 220, 0.2);
  animation: bubbleFloat var(--duration, 4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

.bubble:nth-child(1) { width: 20px; height: 20px; left: 10%; bottom: -20px; --duration: 5s; --delay: 0s; }
.bubble:nth-child(2) { width: 14px; height: 14px; left: 25%; bottom: -14px; --duration: 4s; --delay: 1s; }
.bubble:nth-child(3) { width: 24px; height: 24px; left: 45%; bottom: -24px; --duration: 6s; --delay: 0.5s; }
.bubble:nth-child(4) { width: 10px; height: 10px; left: 60%; bottom: -10px; --duration: 3.5s; --delay: 2s; }
.bubble:nth-child(5) { width: 18px; height: 18px; left: 75%; bottom: -18px; --duration: 5.5s; --delay: 1.5s; }
.bubble:nth-child(6) { width: 12px; height: 12px; left: 85%; bottom: -12px; --duration: 4.5s; --delay: 0.8s; }
.bubble:nth-child(7) { width: 16px; height: 16px; left: 35%; bottom: -16px; --duration: 5s; --delay: 2.5s; }
.bubble:nth-child(8) { width: 22px; height: 22px; left: 55%; bottom: -22px; --duration: 6.5s; --delay: 0.3s; }

@keyframes bubbleFloat {
  0% {
    transform: translateY(0) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
    transform: translateY(-20px) scale(1);
  }
  90% {
    opacity: 0.6;
  }
  100% {
    transform: translateY(-400px) scale(0.5) translateX(30px);
    opacity: 0;
  }
}

/* ── 3D Card Flip ── */
.flip-card {
  perspective: 1000px;
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg, 16px);
}

.flip-card-back {
  transform: rotateY(180deg);
}

/* ── 3D Tilt Effect ── */
.tilt-card {
  transform-style: preserve-3d;
  transition: transform var(--transition-normal, 300ms ease);
}

.tilt-card:hover {
  transform: perspective(1000px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
}

.tilt-card .tilt-content {
  transform: translateZ(30px);
  transition: transform var(--transition-normal, 300ms ease);
}

/* ── Entrance Animations ── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes ripple {
  0% { transform: scale(0); opacity: 0.6; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* ── Animated Gradient Background ── */
.animated-gradient {
  background: linear-gradient(-45deg,
    #0B1120, #1D3557, #0F172A, #264573);
  background-size: 400% 400%;
  animation: gradientShift 12s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ── Status Pipeline Animation ── */
.status-pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 0;
}

.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}

.pipeline-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-glass, rgba(255,255,255,0.06));
  border: 2px solid var(--border-glass, rgba(255,255,255,0.1));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  z-index: 2;
  transition: all var(--transition-normal, 300ms ease);
}

.pipeline-step.completed .pipeline-dot {
  background: var(--success, #10B981);
  border-color: var(--success, #10B981);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
  animation: pulse 2s ease infinite;
}

.pipeline-step.active .pipeline-dot {
  background: var(--info, #3B82F6);
  border-color: var(--info, #3B82F6);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
  animation: pulse 1.5s ease infinite;
}

.pipeline-line {
  position: absolute;
  top: 13px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border-glass, rgba(255,255,255,0.1));
  z-index: 1;
}

.pipeline-step.completed .pipeline-line {
  background: var(--success, #10B981);
}

.pipeline-step:last-child .pipeline-line { display: none; }

.pipeline-label {
  font-size: 0.65rem;
  color: var(--text-muted, #64748B);
  margin-top: 6px;
  text-align: center;
}

.pipeline-step.completed .pipeline-label,
.pipeline-step.active .pipeline-label {
  color: var(--text-primary, #F8FAFC);
}

/* ── Loading Spinner ── */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-glass, rgba(255,255,255,0.1));
  border-top-color: var(--secondary, #A8DADC);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

/* ── Count Up Animation ── */
.count-up {
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
}

/* ── Staggered Children ── */
.stagger-children > * {
  opacity: 0;
  animation: fadeInUp 0.5s ease forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.4s; }

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
