/* ═══════════════════════════════════════════════════════════
   AI 3D — Neural visuals, video showcase, AI lab
   ═══════════════════════════════════════════════════════════ */

/* Hero video + 3D */
.hero-ai-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

.hero-ai-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.hero-ai-fallback {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 55% at 65% 45%, rgba(61, 184, 191, 0.18), transparent 55%),
    radial-gradient(ellipse 50% 45% at 20% 80%, rgba(139, 92, 246, 0.12), transparent 50%),
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(201, 169, 98, 0.08), transparent 55%),
    #050a12;
  transition: opacity 0.8s ease;
}

.hero-ai-grid {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(61, 184, 191, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(61, 184, 191, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 90% 80% at 60% 50%, black 20%, transparent 75%);
  opacity: 0.7;
}

.hero-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-media img { display: none; }

.hero-3d-wrap {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: min(52vw, 680px);
  height: min(52vw, 680px);
  z-index: 3;
  pointer-events: none;
}

#hero-3d-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.hero-content {
  position: relative;
  z-index: 4;
  max-width: 100%;
}

@media (min-width: 1024px) {
  .hero-content {
    max-width: 38rem;
  }
}

.hero-orbit-ring {
  position: absolute;
  top: 50%;
  right: 12%;
  width: min(42vw, 520px);
  height: min(42vw, 520px);
  margin-top: calc(min(42vw, 520px) / -2);
  border: 1px dashed rgba(61, 184, 191, 0.18);
  border-radius: 50%;
  animation: orbit-spin 30s linear infinite;
  z-index: 2;
  pointer-events: none;
}

.hero-orbit-ring--2 {
  width: min(52vw, 640px);
  height: min(52vw, 640px);
  margin-top: calc(min(52vw, 640px) / -2);
  right: 8%;
  border-color: rgba(139, 92, 246, 0.12);
  animation-direction: reverse;
  animation-duration: 22s;
}

@keyframes orbit-spin {
  to { transform: rotate(360deg); }
}

/* ─── AI Lab Section ─── */
.ai-lab {
  padding: var(--section-pad) 0;
  position: relative;
  overflow: hidden;
}

.ai-lab::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 30% 50%, rgba(0, 240, 255, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 30%, rgba(255, 45, 154, 0.05) 0%, transparent 55%);
  pointer-events: none;
}

#ai-matrix-canvas {
  position: absolute;
  inset: 0;
  opacity: 0.12;
  pointer-events: none;
}

.ai-lab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 4vw, 3rem);
  align-items: stretch;
  margin-bottom: clamp(3rem, 6vw, 5rem);
}

.ai-core-wrap {
  position: relative;
  min-height: 420px;
  background: rgba(4, 12, 26, 0.6);
  border: 1px solid rgba(0, 240, 255, 0.2);
  clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 20px 100%, 0 calc(100% - 20px));
  overflow: hidden;
}

#ai-core-3d {
  width: 100%;
  height: 100%;
  min-height: 420px;
  display: block;
}

.ai-core-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ai-core-stat {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: rgba(0, 240, 255, 0.7);
  text-transform: uppercase;
}

.ai-core-stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 20px rgba(0, 240, 255, 0.5);
  margin-top: 0.2rem;
  letter-spacing: 0.05em;
}

.ai-core-stat--pink strong { color: var(--neon-magenta); text-shadow: 0 0 20px rgba(255, 45, 154, 0.5); }

.ai-core-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120px;
  height: 120px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 50%;
  animation: core-pulse 2s ease-out infinite;
  pointer-events: none;
}

@keyframes core-pulse {
  0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

/* AI Demo terminal */
.ai-demo {
  display: flex;
  flex-direction: column;
  background: rgba(4, 12, 26, 0.8) !important;
  border: 1px solid rgba(0, 240, 255, 0.2) !important;
  border-radius: 0 !important;
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
  backdrop-filter: blur(12px);
  min-height: 420px;
}

.ai-demo-header {
  font-family: var(--font-mono) !important;
  font-size: 0.75rem !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase !important;
  background: rgba(0, 240, 255, 0.05) !important;
  border-bottom-color: rgba(0, 240, 255, 0.15) !important;
  color: var(--neon-cyan) !important;
}

.ai-demo-dot {
  background: var(--neon-green) !important;
  box-shadow: 0 0 8px var(--neon-green) !important;
}

.ai-demo-body {
  flex: 1;
  min-height: 280px !important;
  max-height: none !important;
}

.ai-demo-input {
  border-top-color: rgba(0, 240, 255, 0.15) !important;
}

.ai-demo-input input {
  border-radius: 0 !important;
  font-family: var(--font-mono) !important;
  font-size: 0.82rem !important;
}

.ai-demo-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 1rem 1rem;
}

.ai-demo-chip {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  padding: 0.35rem 0.75rem;
  border: 1px solid rgba(0, 240, 255, 0.25);
  color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.06);
  cursor: pointer;
  transition: all 0.25s;
  clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
}

.ai-demo-chip:hover {
  background: rgba(0, 240, 255, 0.15);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}

/* Video showcase */
.video-showcase {
  margin-bottom: clamp(3rem, 6vw, 4rem);
}

.video-showcase h3 {
  font-family: var(--font-display) !important;
  font-size: clamp(1.2rem, 2.5vw, 1.6rem) !important;
  margin-bottom: 1.5rem;
  text-align: center;
  letter-spacing: 0.08em;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.video-card {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
  border: 1px solid rgba(0, 240, 255, 0.2) !important;
  border-radius: 0 !important;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  background: #000 !important;
  transition: transform 0.4s, box-shadow 0.4s;
}

.video-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 20px 50px rgba(0, 240, 255, 0.15);
  border-color: rgba(0, 240, 255, 0.5) !important;
}

.video-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.85;
  transition: opacity 0.3s;
}

.video-card:hover video { opacity: 1; }

.video-card-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2rem 1rem 1rem;
  background: linear-gradient(transparent, rgba(0, 2, 8, 0.9));
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--neon-cyan);
}

.video-card-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border: 1px solid rgba(0, 240, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--neon-cyan);
  opacity: 0;
  transition: opacity 0.3s;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  background: rgba(0, 2, 8, 0.6);
}

.video-card:hover .video-card-play { opacity: 1; }

/* AI capability pills */
.ai-capabilities {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.ai-cap {
  padding: 1.5rem 1.25rem;
  text-align: center;
  background: rgba(4, 12, 26, 0.7);
  border: 1px solid rgba(0, 240, 255, 0.12);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  transition: transform 0.35s, border-color 0.35s, box-shadow 0.35s;
}

.ai-cap:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 240, 255, 0.4);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.1);
}

.ai-cap-icon {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
  display: block;
  animation: cap-float 3s ease-in-out infinite;
}

.ai-cap:nth-child(2) .ai-cap-icon { animation-delay: -0.5s; }
.ai-cap:nth-child(3) .ai-cap-icon { animation-delay: -1s; }
.ai-cap:nth-child(4) .ai-cap-icon { animation-delay: -1.5s; }

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

.ai-cap h4 {
  font-family: var(--font-mono) !important;
  font-size: 0.75rem !important;
  letter-spacing: 0.1em !important;
  text-transform: uppercase !important;
  margin-bottom: 0.4rem;
  color: var(--neon-cyan) !important;
}

.ai-cap p {
  font-size: 0.85rem !important;
  color: #b8c9d8 !important;
  line-height: 1.5;
}

.ai-demo-body .chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 92%;
}

.ai-demo-body .chat-msg--bot { align-self: flex-start; }
.ai-demo-body .chat-msg--user { align-self: flex-end; }

.ai-demo-body .chat-bubble {
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  line-height: 1.55;
  border-radius: 0;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

.ai-demo-body .chat-msg--bot .chat-bubble {
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.2);
  color: #d0e8f5;
}

.ai-demo-body .chat-msg--user .chat-bubble {
  background: rgba(255, 45, 154, 0.15);
  border: 1px solid rgba(255, 45, 154, 0.3);
  color: #fff;
}

.typing-cursor::after {
  content: '▋';
  animation: blink 1s step-end infinite;
  color: var(--neon-cyan);
  margin-left: 2px;
}

@keyframes blink {
  50% { opacity: 0; }
}

@media (max-width: 1024px) {
  .hero-orbit-ring {
    right: -15%;
    opacity: 0.35;
  }

  .hero-orbit-ring--2 {
    right: -20%;
    opacity: 0.25;
  }

  .hero-3d-wrap {
    width: 70vw;
    height: 50vw;
    top: 55%;
    right: -10%;
    opacity: 0.5;
  }

  .hero-content { max-width: 100%; }

  .ai-lab-grid { grid-template-columns: 1fr; }

  .video-grid { grid-template-columns: 1fr; }
  .ai-capabilities { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .hero-content {
    max-width: 46rem;
  }

  .ai-lab-grid {
    grid-template-columns: 1fr 1fr;
  }

  .ai-capabilities {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 600px) {
  body:not(.page-home) .hero-3d-wrap { display: none; }
  .ai-capabilities { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-orbit-ring,
  .hero-ai-grid,
  .ai-cap-icon,
  .ai-core-pulse,
  .video-card { animation: none !important; }

  .page-home .hero-ai-fallback {
    opacity: 1 !important;
  }
}
