/* ============================================================
   How AI Works — Page-Specific Styles
   ============================================================ */

/* Hero neural network canvas */
.ai-hero-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ---- Interactive Stepper ---- */
.ai-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  position: relative;
  padding: 2rem 0;
}

.ai-stepper-track {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 56rem;
  position: relative;
}

.ai-stepper-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
  cursor: pointer;
  flex: 1;
  transition: transform 0.3s ease;
}

.ai-stepper-step:hover {
  transform: translateY(-2px);
}

.ai-stepper-circle {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: linear-gradient(135deg, rgba(17, 17, 17, 0.8), rgba(26, 26, 26, 0.9));
  border: 2px solid rgba(255, 255, 255, 0.12);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.ai-stepper-step.active .ai-stepper-circle,
.ai-stepper-step:hover .ai-stepper-circle {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-color: transparent;
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.5), 0 0 60px rgba(168, 85, 247, 0.2);
}

.ai-stepper-label {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #71717a;
  text-align: center;
  transition: color 0.3s ease;
  white-space: nowrap;
}

.ai-stepper-step.active .ai-stepper-label {
  color: #a855f7;
}

.ai-stepper-line {
  flex: 1;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 1;
  margin: 0 -0.5rem;
}

.ai-stepper-line-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #6366f1, #a855f7);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 1px;
}

.ai-stepper-line.active .ai-stepper-line-fill {
  width: 100%;
}

/* ---- Step Sections ---- */
.ai-step-section {
  scroll-margin-top: 6rem;
}

.ai-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.15));
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

/* ---- Before/After Slider ---- */
.ba-slider {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  user-select: none;
  touch-action: none;
}

.ba-slider-inner {
  position: relative;
  width: 100%;
  min-height: 320px;
  overflow: hidden;
}

.ba-slider-before,
.ba-slider-after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ba-slider-before {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(17, 17, 17, 0.9));
  z-index: 1;
  clip-path: inset(0 50% 0 0);
}

.ba-slider-after {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), rgba(17, 17, 17, 0.9));
  z-index: 0;
}

.ba-slider-handle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 3px;
  height: 100%;
  background: linear-gradient(to bottom, #6366f1, #a855f7);
  z-index: 3;
  cursor: ew-resize;
  transform: translateX(-50%);
}

.ba-slider-handle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
  z-index: 4;
}

.ba-slider-handle::after {
  content: '⟨ ⟩';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  z-index: 5;
  white-space: nowrap;
  letter-spacing: 4px;
}

.ba-label {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.ba-label-messy {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.ba-label-clean {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #4ade80;
}

.ba-data-line {
  font-family: 'Plus Jakarta Sans', monospace;
  font-size: 0.8rem;
  line-height: 1.8;
  color: #a1a1aa;
}

.ba-data-line.highlight-bad {
  color: #f87171;
  text-decoration: line-through;
  text-decoration-color: rgba(248, 113, 113, 0.4);
}

.ba-data-line.highlight-good {
  color: #4ade80;
}

/* ---- Neural Network Visualization ---- */
.nn-container {
  position: relative;
  width: 100%;
  border-radius: 1rem;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(17, 17, 17, 0.5), rgba(26, 26, 26, 0.6));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.nn-svg {
  width: 100%;
  height: 400px;
  display: block;
}

.nn-node {
  transition: all 0.3s ease;
}

.nn-node circle {
  fill: rgba(99, 102, 241, 0.2);
  stroke: rgba(99, 102, 241, 0.5);
  stroke-width: 2;
  transition: all 0.4s ease;
}

.nn-node.active circle {
  fill: rgba(99, 102, 241, 0.8);
  stroke: #6366f1;
  filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.6));
}

.nn-node text {
  fill: #a1a1aa;
  font-size: 10px;
  text-anchor: middle;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.nn-connection {
  stroke: rgba(99, 102, 241, 0.1);
  stroke-width: 1;
  transition: stroke 0.3s ease, stroke-width 0.3s ease;
}

.nn-connection.active {
  stroke: rgba(99, 102, 241, 0.6);
  stroke-width: 2;
}

.nn-particle {
  fill: #a855f7;
  opacity: 0;
}

.nn-layer-label {
  fill: #71717a;
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
  font-family: 'Plus Jakarta Sans', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Training Controls */
.train-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: rgba(17, 17, 17, 0.6);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.train-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.5rem;
  border-radius: 9999px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.train-btn:hover {
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.train-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.training-progress {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.training-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #6366f1, #a855f7);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.training-status {
  font-size: 0.75rem;
  color: #71717a;
  white-space: nowrap;
  min-width: 3rem;
  text-align: right;
}

/* Loss Curve */
.loss-curve-container {
  padding: 1rem 1.25rem;
  background: rgba(17, 17, 17, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.loss-curve-label {
  font-size: 0.7rem;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.loss-curve-svg {
  width: 100%;
  height: 80px;
}

/* ---- Data Flow Animation ---- */
.data-flow-container {
  position: relative;
  width: 100%;
  height: 350px;
  border-radius: 1rem;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(17, 17, 17, 0.5), rgba(26, 26, 26, 0.6));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.data-flow-svg {
  width: 100%;
  height: 100%;
}

.data-source-icon {
  font-size: 2rem;
}

.data-source-label {
  fill: #a1a1aa;
  font-size: 11px;
  text-anchor: middle;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* ---- Scatter Plot / Pattern Chart ---- */
.pattern-chart-container {
  position: relative;
  width: 100%;
  border-radius: 1rem;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(17, 17, 17, 0.5), rgba(26, 26, 26, 0.6));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pattern-chart-svg {
  width: 100%;
  height: 400px;
  display: block;
}

.pattern-lens-btns {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  background: rgba(17, 17, 17, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  flex-wrap: wrap;
}

.pattern-lens-btn {
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #a1a1aa;
  cursor: pointer;
  transition: all 0.3s ease;
}

.pattern-lens-btn:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
}

.pattern-lens-btn.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.2));
  border-color: rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}

/* ---- Application Cards ---- */
.ai-app-card {
  background: linear-gradient(135deg, rgba(17, 17, 17, 0.35) 0%, rgba(26, 26, 26, 0.4) 100%);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1.5rem;
  padding: 2rem;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-app-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06) 50%, transparent);
  transform: skewX(-20deg);
  transition: left 0.6s ease;
  pointer-events: none;
}

.ai-app-card:hover::before {
  left: 100%;
}

.ai-app-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
  border-color: rgba(99, 102, 241, 0.3);
}

.ai-app-icon {
  width: 3.5rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.15));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 1rem;
  margin-bottom: 1.25rem;
}

/* ---- Animations ---- */
@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
  }
  50% {
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.6), 0 0 60px rgba(168, 85, 247, 0.2);
  }
}

@keyframes data-flow {
  0% {
    offset-distance: 0%;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    offset-distance: 100%;
    opacity: 0;
  }
}

@keyframes node-activate {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.3);
    filter: brightness(1.5) drop-shadow(0 0 10px rgba(99, 102, 241, 0.8));
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

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

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .ai-stepper {
    flex-direction: column;
    gap: 0;
  }

  .ai-stepper-track {
    flex-direction: column;
    align-items: center;
  }

  .ai-stepper-line {
    width: 2px;
    height: 2rem;
    margin: 0;
  }

  .ai-stepper-line-fill {
    width: 100% !important;
    height: 0%;
    transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .ai-stepper-line.active .ai-stepper-line-fill {
    height: 100%;
  }

  .nn-svg {
    height: 300px;
  }

  .pattern-chart-svg {
    height: 300px;
  }

  .data-flow-container {
    height: 280px;
  }

  .ba-slider-inner {
    min-height: 280px;
  }
}

@media (max-width: 640px) {
  .ai-stepper-circle {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1rem;
  }

  .ai-stepper-label {
    font-size: 0.65rem;
  }

  .train-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .training-status {
    text-align: center;
  }
}
