/* =====================================================
   IoT Pipeline – Animated Process Flow
   5 stages: Sensors → Collect → Cloud → Monitor → Optimize
   Green accent theme (#10B981)
   ===================================================== */

/* --- Container --- */
.iot {
  position: relative;
  overflow: hidden;
  background: var(--color-primary);
  padding: var(--space-12) 0 var(--space-10);
}

.iot__header {
  text-align: center;
  margin-bottom: var(--space-10);
  position: relative;
  z-index: 2;
}

/* --- Stage Wrapper --- */
.iot__stages {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-5);
  position: relative;
  z-index: 2;
}

/* --- Timeline bar --- */
.iot__timeline {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-5);
  margin-top: var(--space-8);
  z-index: 2;
}

.iot__timeline::before {
  content: '';
  position: absolute;
  top: 20px;
  left: 5%;
  width: 90%;
  height: 2px;
  background: rgba(255,255,255,0.08);
  z-index: 0;
}

.iot__timeline-progress {
  position: absolute;
  top: 20px;
  left: 5%;
  width: 0%;
  max-width: 90%;
  height: 2px;
  background: linear-gradient(90deg, #10B981, #34d399);
  z-index: 1;
  transition: width 1.8s cubic-bezier(.4, 0, .2, 1);
}

/* --- Stage Card --- */
.iot__card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(40px) scale(0.95);
  transition: opacity 0.7s cubic-bezier(.4,0,.2,1),
              transform 0.7s cubic-bezier(.4,0,.2,1),
              border-color 0.4s ease,
              box-shadow 0.4s ease;
}

.iot__card.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  border-color: rgba(16,185,129,0.25);
  box-shadow: 0 0 40px rgba(16,185,129,0.08), inset 0 1px 0 rgba(255,255,255,0.05);
}

.iot__card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 100%, rgba(16,185,129,0.06), transparent 70%);
  opacity: 0;
  transition: opacity 0.6s ease;
}

.iot__card.active::before { opacity: 1; }

/* --- Label --- */
.iot__label {
  font-size: 10px;
  color: #10B981;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: var(--space-4);
  opacity: 0;
  transition: opacity 0.4s ease 0.3s;
}

.iot__card.active .iot__label { opacity: 1; }

/* === Stage 1: Deploy Sensors === */
.iot__sensors {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 130px;
}

.iot__sensor-node {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.iot__sensor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(16,185,129,0.4);
  transition: all 0.5s ease;
}

.iot__card.active .iot__sensor-dot {
  background: #10B981;
  box-shadow: 0 0 8px rgba(16,185,129,0.5);
  animation: iotPulse 2s ease-in-out infinite;
}

.iot__card.active .iot__sensor-node:nth-child(2) .iot__sensor-dot { animation-delay: 0.2s; }
.iot__card.active .iot__sensor-node:nth-child(3) .iot__sensor-dot { animation-delay: 0.4s; }
.iot__card.active .iot__sensor-node:nth-child(4) .iot__sensor-dot { animation-delay: 0.6s; }
.iot__card.active .iot__sensor-node:nth-child(5) .iot__sensor-dot { animation-delay: 0.3s; }
.iot__card.active .iot__sensor-node:nth-child(6) .iot__sensor-dot { animation-delay: 0.5s; }

@keyframes iotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* === Stage 2: Collect Data === */
.iot__data-streams {
  width: 100%;
  max-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.iot__stream {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(16,185,129,0.05);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.04);
  font-size: 10px;
  color: var(--color-text-light);
  font-family: 'Courier New', monospace;
  position: relative;
  overflow: hidden;
}

.iot__stream-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.iot__stream-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 0%;
  background: #10B981;
  transition: width 1s ease;
}

.iot__card.active .iot__stream-bar { width: 100%; }
.iot__card.active .iot__stream:nth-child(2) .iot__stream-bar { transition-delay: 0.3s; }
.iot__card.active .iot__stream:nth-child(3) .iot__stream-bar { transition-delay: 0.5s; }
.iot__card.active .iot__stream:nth-child(4) .iot__stream-bar { transition-delay: 0.7s; }

/* === Stage 3: Cloud Processing === */
.iot__cloud {
  text-align: center;
  position: relative;
}

.iot__cloud-icon {
  width: 64px;
  height: 44px;
  margin: 0 auto 8px;
  position: relative;
}

.iot__cloud-icon svg { color: rgba(16,185,129,0.4); }
.iot__card.active .iot__cloud-icon svg { color: #10B981; }

.iot__cloud-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.iot__cloud-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(16,185,129,0.3);
}

.iot__card.active .iot__cloud-dot {
  animation: iotCloudProcess 1.2s ease-in-out infinite;
}
.iot__card.active .iot__cloud-dot:nth-child(2) { animation-delay: 0.2s; }
.iot__card.active .iot__cloud-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes iotCloudProcess {
  0%, 100% { background: rgba(16,185,129,0.3); transform: scale(1); }
  50% { background: #10B981; transform: scale(1.5); }
}

.iot__cloud-text {
  font-size: 10px;
  color: var(--color-text-light);
  font-family: 'Courier New', monospace;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.4s ease 0.4s;
}

.iot__card.active .iot__cloud-text { opacity: 1; }

/* === Stage 4: Monitor & Alert === */
.iot__monitor {
  width: 100%;
  max-width: 160px;
}

.iot__monitor-header {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #10B981;
  font-family: 'Courier New', monospace;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.iot__monitor-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.iot__monitor-stat {
  text-align: center;
  padding: 6px 4px;
  background: rgba(16,185,129,0.05);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.04);
}

.iot__monitor-stat-num {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-white);
  font-family: 'Courier New', monospace;
}

.iot__monitor-stat-label {
  font-size: 9px;
  color: var(--color-text-light);
  margin-top: 2px;
}

.iot__alert {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  opacity: 0;
  transform: translateX(-10px);
  transition: all 0.4s ease 0.5s;
}

.iot__card.active .iot__alert {
  opacity: 1;
  transform: translateX(0);
}

.iot__alert--warn {
  background: rgba(247,148,29,0.1);
  border: 1px solid rgba(247,148,29,0.2);
  color: var(--color-accent-orange);
}

.iot__alert--ok {
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.2);
  color: #10B981;
}

.iot__alert-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.iot__alert--warn .iot__alert-dot { background: var(--color-accent-orange); }
.iot__alert--ok .iot__alert-dot { background: #10B981; }

/* === Stage 5: Optimize === */
.iot__optimize {
  width: 100%;
  max-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.iot__opt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(16,185,129,0.04);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.04);
}

.iot__opt-icon {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.iot__opt-text {
  flex: 1;
  font-size: 11px;
}

.iot__opt-text strong {
  display: block;
  color: var(--color-white);
  font-size: 10px;
  font-weight: 600;
}

.iot__opt-text span {
  color: var(--color-text-light);
  font-size: 9px;
}

.iot__opt-row {
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.4s ease;
}

.iot__card.active .iot__opt-row:nth-child(1) { opacity: 1; transform: translateY(0); transition-delay: 0.1s; }
.iot__card.active .iot__opt-row:nth-child(2) { opacity: 1; transform: translateY(0); transition-delay: 0.3s; }
.iot__card.active .iot__opt-row:nth-child(3) { opacity: 1; transform: translateY(0); transition-delay: 0.5s; }

/* --- Step (timeline dot + label) --- */
.iot__step {
  text-align: center;
  position: relative;
  z-index: 2;
}

.iot__step-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary, #0A1628);
  border: 2px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-3);
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-bold);
  color: var(--color-text-light);
  transition: all 0.5s cubic-bezier(.4,0,.2,1);
}

.iot__step.active .iot__step-dot {
  background: #0f2318;
  border-color: #10B981;
  color: #10B981;
  box-shadow: 0 0 16px rgba(16,185,129,0.3);
}

.iot__step-title {
  font-size: var(--fs-caption);
  color: var(--color-text-light);
  transition: color 0.4s ease;
}

.iot__step.active .iot__step-title {
  color: #10B981;
}

/* --- Ambient --- */
.iot__ambient {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.iot__ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.08;
}

.iot__ambient-orb--1 {
  width: 400px; height: 400px;
  background: #10B981;
  top: -100px; right: -100px;
}

.iot__ambient-orb--2 {
  width: 300px; height: 300px;
  background: var(--color-accent);
  bottom: -80px; left: -60px;
  opacity: 0.05;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .iot__stages,
  .iot__timeline {
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-3);
  }
  .iot__card {
    min-height: 180px;
    padding: var(--space-3);
  }
}

@media (max-width: 768px) {
  .iot__stages {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }
  .iot__timeline {
    display: none;
  }
  .iot__card {
    min-height: 160px;
    flex-direction: row;
    gap: var(--space-4);
    padding: var(--space-5);
  }
  .iot__card::after {
    position: absolute;
    top: var(--space-2);
    left: var(--space-3);
    font-size: 10px;
    color: #10B981;
    font-weight: 700;
    letter-spacing: 0.1em;
  }
  .iot__card:nth-child(1)::after { content: 'STEP 01'; }
  .iot__card:nth-child(2)::after { content: 'STEP 02'; }
  .iot__card:nth-child(3)::after { content: 'STEP 03'; }
  .iot__card:nth-child(4)::after { content: 'STEP 04'; }
  .iot__card:nth-child(5)::after { content: 'STEP 05'; }

  .iot__card {
    opacity: 0;
    transform: translateY(30px) scale(0.98);
  }
  .iot__card.active {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
