/* Optitrade Tech AI — Shared Animation Layer
   Loaded by all 4 pages. Never edit page content — animation only. */

/* ---- Hero: canvas + orbs need a positioned parent ---- */
header.hero {
  position: relative;
  overflow: hidden;
}
header.hero > .container {
  position: relative;
  z-index: 2;
}

/* ---- Neural network canvas ---- */
.ai-neural-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 1;
}

/* ---- Floating gradient orbs ---- */
.ai-orbs {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.ai-orb {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, var(--orb-c, rgba(99,102,241,0.42)) 0%, transparent 65%);
  filter: blur(52px);
  animation: aiOrbFloat var(--od, 22s) ease-in-out infinite alternate;
}
.ai-orb-1 { width: 820px; height: 820px; top: -320px; left: -160px; --od: 24s; }
.ai-orb-2 { width: 560px; height: 560px; top: 30px;  right: -140px; --od: 19s; animation-delay: -9s; }
.ai-orb-3 { width: 400px; height: 400px; bottom: -130px; left: 38%; --od: 28s; animation-delay: -15s; }

@keyframes aiOrbFloat {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  33%  { transform: translate(28px, -20px) scale(1.06); opacity: 0.85; }
  66%  { transform: translate(-14px, 28px) scale(0.95); opacity: 0.95; }
  100% { transform: translate(20px, 12px) scale(1.08); opacity: 0.9; }
}

/* ---- Glassmorphism hero stat tiles (overrides page CSS) ---- */
.hero-stat-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 36px;
  border-top: 1px solid var(--line-2);
}
.hero-stat {
  flex: 1;
  min-width: 130px;
  padding: 18px 20px;
  background: color-mix(in srgb, var(--bg-2) 72%, transparent);
  border: 1px solid color-mix(in srgb, var(--neural-color, var(--accent)) 22%, transparent);
  border-radius: 8px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  transform: translateY(12px);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hero-stat.ai-stat-vis {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease, transform 0.5s ease, box-shadow 0.2s ease;
}
.hero-stat:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 28px color-mix(in srgb, var(--neural-color, var(--accent)) 15%, transparent);
}
.hero-stat .num {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--neural-color, var(--accent));
}
.hero-stat .lbl {
  font-size: 12.5px;
  color: var(--fg-2);
  margin-top: 4px;
  line-height: 1.5;
}

/* ---- Spotlight on cards ---- */
.problem-card,
.agent-card {
  position: relative;
  overflow: hidden;
}
.problem-card::before,
.agent-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    480px circle at var(--sx, 50%) var(--sy, 50%),
    color-mix(in srgb, var(--neural-color, var(--accent)) 9%, transparent),
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 1;
}
.problem-card:hover::before,
.agent-card:hover::before { opacity: 1; }
.problem-card > *,
.agent-card > * {
  position: relative;
  z-index: 2;
}

/* ---- Featured agent card glow pulse ---- */
@keyframes aiFeatPulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--neural-color, var(--accent)) 0%, transparent); }
  50%       { box-shadow: 0 0 24px 2px color-mix(in srgb, var(--neural-color, var(--accent)) 16%, transparent); }
}
.agent-card.featured {
  animation: aiFeatPulse 3.5s ease-in-out infinite;
}

/* ---- Scroll fade-in ---- */
.ai-fade {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.ai-fade.ai-vis {
  opacity: 1;
  transform: translateY(0);
}

/* ---- Button shimmer ---- */
.btn-primary,
.btn-warn,
.btn-vaccent {
  position: relative;
  overflow: hidden;
}
.btn-primary::after,
.btn-warn::after,
.btn-vaccent::after {
  content: "";
  position: absolute;
  top: 0; left: -100%;
  width: 55%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.14), transparent);
  transform: skewX(-20deg);
  animation: aiShimmer 3.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes aiShimmer {
  0%   { left: -100%; }
  40%  { left: 160%; }
  100% { left: 160%; }
}

/* ---- Flow item data pulse (index.html) ---- */
.flow-item {
  position: relative;
  overflow: hidden;
}
.flow-item::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: -20%;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(99,102,241,0.06), transparent);
  transform: skewX(-15deg);
  animation: aiDataPulse calc(2.5s + var(--fd, 0s)) linear infinite;
  pointer-events: none;
}
.flow-item:nth-child(1) { --fd: 0s; }
.flow-item:nth-child(2) { --fd: 0.5s; }
.flow-item:nth-child(3) { --fd: 1s; }
.flow-item:nth-child(4) { --fd: 1.5s; }
.flow-item:nth-child(5) { --fd: 2s; }
@keyframes aiDataPulse {
  0%   { left: -40%; }
  100% { left: 120%; }
}

/* ---- Typewriter cursor ---- */
.ai-typing::after {
  content: "|";
  animation: aiCursor 0.8s step-end infinite;
  color: var(--neural-color, var(--accent));
  margin-left: 1px;
}
.ai-typing.ai-typed::after { display: none; }
@keyframes aiCursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ---- Mobile hamburger nav ---- */
.nav-burger {
  display: none;
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 7px 9px;
  cursor: pointer;
  flex-direction: column;
  gap: 4.5px;
  align-items: center;
  flex-shrink: 0;
  transition: border-color .15s;
}
.nav-burger:hover { border-color: rgba(255,255,255,0.28); }
.nav-burger span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--fg, #EEEEF6);
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.18s ease;
  pointer-events: none;
}
nav.top.nav-open .nav-burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
nav.top.nav-open .nav-burger span:nth-child(2) { opacity: 0; transform: scaleX(0); }
nav.top.nav-open .nav-burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 820px) {
  .nav-burger { display: flex; }

  .brand-logo { height: auto; max-height: 30px; max-width: calc(100vw - 96px); } /* scales to viewport: 375px→279px wide, 320px→224px wide */

  nav.top { position: relative; }

  nav.top .btn { display: none; }

  nav.top.nav-open { overflow: visible; }

  nav.top.nav-open .nav-links {
    display: flex !important;
    flex-direction: column;
    position: absolute;
    top: 68px;
    left: 0; right: 0;
    background: color-mix(in srgb, var(--bg, #0E0E13) 94%, transparent);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid rgba(255,255,255,0.07);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    padding: 8px 20px 16px;
    gap: 0;
    z-index: 200;
  }
  nav.top.nav-open .nav-links a {
    padding: 13px 0;
    font-size: 15px !important;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: var(--fg, #EEEEF6) !important;
  }
  nav.top.nav-open .nav-links a:last-child { border-bottom: none; }
}

/* ---- Brand logo image ---- */
.brand { flex-shrink: 0; }
.brand-logo-wrap {
  display: inline-flex;
  align-items: center;
}
.brand-logo {
  height: 48px; /* 986x98 ratio → ~483px wide at this height */
  width: auto;
  display: block;
}

/* ---- Reduced motion: disable everything ---- */
@media (prefers-reduced-motion: reduce) {
  .ai-neural-canvas,
  .ai-orb { display: none; }
  .hero-stat,
  .hero-stat.ai-stat-vis { opacity: 1 !important; transform: none !important; transition: none !important; }
  .agent-card.featured { animation: none !important; }
  .btn-primary::after,
  .btn-warn::after,
  .btn-vaccent::after { display: none; }
  .flow-item::after { display: none; }
  .ai-typing::after { animation: none !important; }
  .ai-fade,
  .ai-fade.ai-vis { opacity: 1 !important; transform: none !important; transition: none !important; }
}
