/* ══════════════════════════════════════════════════════════════
   ALGOVERSE HERO EXPLAINER
   A ~14s looping motion piece that replaces the static hero image.
   Scenes are driven by algoverse-hero.js, which adds state classes
   to .avx in sequence (s-lines, s-w1 … s-logo). Everything here is
   transitions keyed off those classes.
   ══════════════════════════════════════════════════════════════ */

.avx {
  --v1: #DDD6FE;
  --v2: #A78BFA;
  --v3: #7C3AED;
  --ink: #0B0B0C;
  --panel: #141416;
  --line: #26262B;
  --green: #34D399;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.55, 0, 0.75, 0.2);

  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(55% 60% at 50% 55%, rgba(124, 58, 237, 0.16), transparent 70%),
    var(--ink);
  font-family: var(--f-sans);
  color: #F4F4F5;
  letter-spacing: -0.03em;
  /* keep the content clear of the floating nav */
  padding-top: var(--nav-h);
  box-sizing: border-box;
}

/* everything is centred in the space under the nav */
.avx-stage {
  position: absolute;
  inset: var(--nav-h) 0 0 0;
  display: grid;
  place-items: center;
}
.avx-stage > * { grid-area: 1 / 1; }

/* ── Thin geometric lines ── */
.avx-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.avx-lines path {
  fill: none;
  stroke: var(--v3);
  stroke-width: 1.5;
  stroke-opacity: 0.55;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.6s var(--ease);
}
.avx.s-lines .avx-lines path { stroke-dashoffset: 0; }
.avx.s-end .avx-lines path { stroke-dashoffset: -1; transition-duration: 0.9s; }

/* ── Glowing trail ── */
.avx-trail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.avx-trail path {
  fill: none;
  stroke: url(#avx-trail-grad);
  stroke-width: 26;
  stroke-linecap: round;
  filter: blur(14px);
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0;
  transition: stroke-dashoffset 1.8s var(--ease), opacity 0.6s ease;
}
.avx.s-w3 .avx-trail path { stroke-dashoffset: 0; opacity: 0.9; }
.avx.s-wout .avx-trail path { opacity: 0; transition-duration: 0.8s; }

/* ── Scene 1: kinetic words ── */
.avx-words {
  display: flex;
  gap: 0.28em;
  font-size: clamp(30px, 8.4vw, 116px);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 1.05;
  position: relative;
  transition: transform 0.7s var(--ease-in), opacity 0.5s ease, filter 0.6s ease;
}
.avx-word {
  display: inline-block;
  overflow: hidden;
  padding: 0.04em 0.02em 0.1em;
}
.avx-word span {
  display: inline-block;
  background: linear-gradient(100deg, var(--v1) 0%, var(--v2) 45%, var(--v3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transform: translateY(105%);
  transition: transform 0.75s var(--ease);
}
.avx.s-w1 .avx-word:nth-child(1) span,
.avx.s-w2 .avx-word:nth-child(2) span,
.avx.s-w3 .avx-word:nth-child(3) span { transform: translateY(0); }
.avx.s-wout .avx-words { transform: translateY(-40px) scale(0.92); opacity: 0; filter: blur(6px); }

.avx-spark {
  position: absolute;
  top: -0.28em;
  right: -0.32em;
  width: 0.36em;
  height: 0.36em;
  color: var(--v1);
  filter: drop-shadow(0 0 10px rgba(167, 139, 250, 0.9));
  transform: scale(0) rotate(-90deg);
  transition: transform 0.7s var(--ease);
}
.avx.s-w3 .avx-spark { transform: scale(1) rotate(0); transition-delay: 0.35s; }

/* ── Scene 2: Trending Algos card ── */
.avx-card {
  position: relative;
  width: min(720px, calc(100vw - 48px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 20px 10px;
  box-shadow: 0 40px 120px rgba(124, 58, 237, 0.22), 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(60px) scale(0.94);
  transition: transform 0.8s var(--ease), opacity 0.6s ease, filter 0.6s ease;
}
.avx.s-card .avx-card { opacity: 1; transform: none; }
.avx.s-cardout .avx-card {
  opacity: 0;
  transform: translateY(-30px) scale(0.9);
  filter: blur(6px);
  transition: transform 0.6s var(--ease-in), opacity 0.5s ease, filter 0.5s ease;
}

.avx-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.avx-card-title { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.avx-chips { display: flex; gap: 6px; }
.avx-chip {
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  color: #C9C9CF;
  letter-spacing: -0.01em;
}
.avx-chip.is-on { border-color: var(--v3); color: var(--v1); background: rgba(124, 58, 237, 0.16); }

.avx-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 24px;
  padding: 14px 12px;
  border-top: 1px solid var(--line);
  border-radius: 10px;
  transition: background 0.3s ease;
}
.avx-row-name { font-size: 14.5px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avx-row-meta { font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; color: #8A8A93; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avx-traders {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.avx-margin {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 82px;
  text-align: right;
}
/* hover actions replace the margin column on the hovered row */
.avx-actions {
  position: absolute;
  right: 12px;
  top: 50%;
  display: flex;
  gap: 8px;
  opacity: 0;
  transform: translate(10px, -50%);
  transition: opacity 0.3s ease, transform 0.4s var(--ease);
}
.avx-btn {
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  letter-spacing: -0.01em;
  transition: transform 0.15s ease, background 0.2s ease;
}
.avx-btn--ghost { border: 1px solid #4A4A55; color: #D4D4D8; }
.avx-btn--solid { background: var(--v3); color: #fff; }

.avx.s-hover .avx-row--target { background: #1F1F24; }
.avx-row .avx-traders,
.avx-row .avx-margin { transition: opacity 0.2s ease; }
.avx.s-hover .avx-row--target .avx-margin,
.avx.s-hover .avx-row--target .avx-traders { opacity: 0; }
.avx.s-hover .avx-row--target .avx-actions { opacity: 1; transform: translate(0, -50%); }
.avx.s-click .avx-btn--solid { transform: scale(0.94); background: #6D28D9; }

/* ── Cursor ── */
.avx-cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  z-index: 5;
  opacity: 0;
  transform: translate(var(--cx, 760px), var(--cy, 420px));
  transition: transform 0.9s var(--ease), opacity 0.3s ease;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}
.avx.s-cursor1 .avx-cursor { opacity: 1; }
/* the card grows when P&L appears, so the cursor leaves right after the click */
.avx.s-toast .avx-cursor,
.avx.s-cardout .avx-cursor { opacity: 0; transition: opacity 0.25s ease; }
.avx-ripple {
  position: absolute;
  left: -14px;
  top: -14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--v1);
  opacity: 0;
  transform: scale(0.3);
}
.avx.s-click .avx-ripple { animation: avx-ripple 0.6s var(--ease) forwards; }
@keyframes avx-ripple {
  0% { opacity: 0.9; transform: scale(0.3); }
  100% { opacity: 0; transform: scale(1.6); }
}

/* ── Scene 3: deployed toast + live P&L ── */
.avx-toast {
  position: absolute;
  right: -24px;
  top: -52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 12px 12px;
  background: #1B1B20;
  border: 1px solid #34343C;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(-12px) scale(0.95);
  transition: opacity 0.4s ease, transform 0.6s var(--ease);
}
.avx.s-toast .avx-toast { opacity: 1; transform: none; }
.avx-toast-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(52, 211, 153, 0.16);
  color: var(--green);
  flex-shrink: 0;
}
.avx-toast-title { font-size: 13.5px; font-weight: 700; letter-spacing: -0.02em; }
.avx-toast-sub { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: 11.5px; color: #9B9BA4; }
.avx-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--v1);
  background: rgba(124, 58, 237, 0.22);
  padding: 3px 7px;
  border-radius: 5px;
}
.avx-live::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--v2);
  animation: avx-pulse 1.2s ease-in-out infinite;
}
@keyframes avx-pulse { 50% { opacity: 0.25; } }

.avx-pnl {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 6px 0 8px;
  padding: 14px 12px 6px;
  border-top: 1px solid var(--line);
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.6s var(--ease), opacity 0.4s ease;
}
.avx.s-toast .avx-pnl { max-height: 90px; opacity: 1; }
.avx-pnl-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #8A8A93; }
.avx-pnl-value {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--green);
  margin-top: 2px;
}
.avx-spark-line { width: min(280px, 46%); height: 48px; }
.avx-spark-line path {
  fill: none;
  stroke: var(--green);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 2s var(--ease);
}
.avx-spark-line .avx-area { fill: url(#avx-area-grad); stroke: none; opacity: 0; transition: opacity 1s ease 0.8s; }
.avx.s-toast .avx-spark-line path { stroke-dashoffset: 0; }
.avx.s-toast .avx-spark-line .avx-area { opacity: 1; }

/* ── Scene 4: tagline ── */
.avx-tag {
  text-align: center;
  font-size: clamp(30px, 5.2vw, 68px);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1.08;
  opacity: 0;
  transform: translateY(30px);
  filter: blur(8px);
  transition: opacity 0.6s ease, transform 0.8s var(--ease), filter 0.6s ease;
}
.avx-tag em {
  font-style: normal;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.06em;
  background: linear-gradient(100deg, var(--v1), var(--v2) 60%, var(--v3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.avx-tag small {
  display: block;
  margin-top: 14px;
  font-size: clamp(14px, 1.5vw, 18px);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: #9B9BA4;
}
.avx.s-tag .avx-tag { opacity: 1; transform: none; filter: none; }
.avx.s-tagout .avx-tag { opacity: 0; transform: translateY(-24px) scale(0.96); filter: blur(6px); transition-timing-function: ease, var(--ease-in), ease; }

/* ── Scene 5: wordmark ── */
.avx-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.7s ease, transform 1s var(--ease);
}
/* the real Algoverse logo, inlined */
.avx-logo-mark {
  display: block;
  width: clamp(200px, 26vw, 360px);
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 0 28px rgba(206, 157, 255, 0.45));
}
/* the orbit "o" turns half a revolution as the logo lands, then settles */
.avx-orb {
  transform-box: view-box;
  transform-origin: 33.49px 17.9px;
  transform: rotate(-180deg);
  transition: transform 1.6s var(--ease);
}
.avx.s-logo .avx-orb { transform: rotate(0); }
.avx-logo-sub {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #8A8A93;
}
.avx.s-logo .avx-logo { opacity: 1; transform: none; }
.avx.s-end .avx-logo { opacity: 0; transition-duration: 0.8s; }

/* ── Narrow screens: drop the secondary columns ── */
@media (max-width: 640px) {
  .avx-chips .avx-chip:not(.is-on) { display: none; }
  .avx-traders { display: none; }
  .avx-row { gap: 12px; }
  .avx-toast { right: 8px; top: -50px; padding: 9px 12px 9px 9px; }
  .avx-toast-check { width: 24px; height: 24px; }
  .avx-toast-title { font-size: 12.5px; }
  .avx-card { padding: 14px 12px 4px; width: calc(100vw - 40px); }
  .avx-card-title { font-size: 15px; }
  .avx-card-head { margin-bottom: 8px; }
  /* two rows are enough to tell the story on a phone */
  .avx-row:nth-of-type(4) { display: none; }
  .avx-row { padding: 11px 10px; }
  .avx-row-name { font-size: 13.5px; }
  .avx-btn--ghost { display: none; }
  .avx-row--target > div:first-child { padding-right: 84px; }
  .avx-pnl { padding: 10px 10px 4px; margin-bottom: 6px; }
  .avx-pnl-value { font-size: 21px; }
  .avx-spark-line { height: 36px; }
  .avx.s-toast .avx-pnl { max-height: 70px; }
}

/* ── Reduced motion: hold the final frame, no loop ── */
@media (prefers-reduced-motion: reduce) {
  .avx *, .avx *::before { transition: none !important; animation: none !important; }
}
