/* ============================================================
   scrolly.css — "the machine is awake" layer
   Data spine, AI ops terminal, decode labels, word-mask reveals,
   marquees, 3D tilt + beam borders, process rail, CTA radar.
   Pairs with /assets/js/scrolly.js. Reduced-motion safe: every
   animated state only applies under html.fx (added by JS, which
   bails when prefers-reduced-motion is set or GSAP is missing).
   ============================================================ */

/* ── JOURNEY LINE — serpentine path that leads you down the page ──
   Built by JS from real section positions; drawn on scroll with a
   glowing comet head that stays just ahead of the reader. Sits
   behind content (painted first in DOM order) so it weaves under
   panels and re-emerges in open space. */
/* Document-space layer: static SVG content scrolls with the page, so
   the browser's tile cache does the work — zero repaint while the
   line is settled, and only one segment's box repaints mid-draw. */
.journey-layer {
  position: absolute; top: 0; left: 0; right: 0; z-index: 0;
  pointer-events: none; overflow: visible;
  padding: 0; margin: 0; border: 0;
}
.journey-layer svg {
  position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible;
}
/* clickable section markers stay in document space (near-zero paint) */
.journey-markers {
  position: absolute; top: 0; left: 0; right: 0; height: 0;
  z-index: 1; pointer-events: none; overflow: visible;
}
.jp-base {
  fill: none; stroke: rgba(255,255,255,0.07);
  stroke-width: 1.6; stroke-dasharray: 4 9;
}
/* single animated stroke — a second halo stroke doubled the repaint
   cost of a document-tall SVG layer every frame, so the glow lives on
   the comet instead */
.jp-glow {
  fill: none; stroke: url(#journeyGrad); stroke-width: 2;
  stroke-linecap: round; opacity: 0.85;
}
/* comet lives in a separate above-content layer so it's never occluded */
.journey-comet-layer {
  position: absolute; top: 0; left: 0; right: 0; height: 0;
  z-index: 5; pointer-events: none; overflow: visible;
}
.jp-comet {
  position: absolute; left: 0; top: 0; width: 11px; height: 11px;
  margin: -5.5px 0 0 -5.5px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 14px 4px var(--glow-gold), 0 0 36px 10px rgba(255,184,28,0.16);
}
html.fx .jp-comet::after {
  content: ''; position: absolute; inset: -8px; border-radius: 50%;
  border: 1px solid var(--line-gold);
  animation: jp-ping 1.9s var(--ease-out) infinite;
}
@keyframes jp-ping {
  0% { transform: scale(.4); opacity: .9; }
  100% { transform: scale(1.7); opacity: 0; }
}
.jp-marker {
  position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px;
  border-radius: 50%; background: var(--bg-3);
  border: 1px solid var(--line-strong);
  pointer-events: auto; cursor: pointer; padding: 0;
  transition: background var(--dur), border-color var(--dur),
              box-shadow var(--dur), transform var(--dur) var(--ease-spring);
}
.jp-marker:hover, .jp-marker:focus-visible { transform: scale(1.3); border-color: var(--gold); }
.jp-marker.is-lit {
  background: var(--gold); border-color: var(--gold);
  box-shadow: 0 0 14px 3px var(--glow-gold);
}
/* one-shot reactions when the comet lands on a stop */
html.fx .jp-marker.is-pop { animation: jp-pop .7s var(--ease-spring); }
@keyframes jp-pop {
  0% { transform: scale(1); }
  35% { transform: scale(2); }
  100% { transform: scale(1); }
}
html.fx .section-label.is-struck { animation: label-strike 1.1s var(--ease-out); }
@keyframes label-strike {
  0% { color: var(--gold); text-shadow: 0 0 20px var(--glow-gold); }
  100% { color: inherit; text-shadow: none; }
}
/* Markers sit beside the real section headings now, so their own
   label is a hover-only chip below the dot (no text-on-text overlap) */
.jp-label {
  position: absolute; left: 50%; top: calc(100% + 10px);
  transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-soft); white-space: nowrap;
  padding: 4px 9px; border-radius: 6px;
  background: var(--glass-strong); border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  opacity: 0; transition: opacity var(--dur), color var(--dur);
  pointer-events: none;
}
.jp-marker:hover .jp-label, .jp-marker:focus-visible .jp-label { opacity: 1; }
.jp-marker.is-current .jp-label { color: var(--gold); }
@media (max-width: 1099px) { .journey-layer, .journey-comet-layer, .journey-markers { display: none; } }

/* ── WORD-MASK SPLIT REVEALS (wrappers built by JS) ── */
.sw { display: inline-block; overflow: hidden; vertical-align: bottom; }
.swi { display: inline-block; will-change: transform; }
/* background-clip:text doesn't reach into inline-block children —
   re-apply the gold gradient on split words inside the hero accent */
.hero h1 .accent .swi {
  background: linear-gradient(120deg, var(--gold-soft), var(--gold), var(--gold-deep));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── SECTION LABEL DECODE ── */
html.fx .section-label.is-decoding { color: var(--gold); }

/* ── TOOLS TICKER (after stats bar) ── */
.tools-ticker {
  overflow: hidden; border-block: 1px solid var(--line);
  background: var(--bg-1); padding: 16px 0;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.tt-track {
  display: inline-flex; align-items: center; gap: 34px;
  white-space: nowrap; will-change: transform;
}
html.fx .tools-ticker.anim-on .tt-track { animation: tt-scroll 36s linear infinite; }
.tools-ticker:hover .tt-track { animation-play-state: paused; }
@keyframes tt-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tt-item {
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.06em;
  color: var(--ink-mute); transition: color var(--dur);
}
.tt-item:hover { color: var(--gold); }
.tt-sep { color: var(--gold-deep); font-size: 9px; opacity: .8; }

/* ── STATS BAR scan sweep ── */
.stats-bar { position: relative; overflow: hidden; }
html.fx .stats-bar.anim-on::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -30%;
  width: 18%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255,184,28,0.05) 45%, rgba(255,184,28,0.12) 50%, rgba(255,184,28,0.05) 55%, transparent);
  animation: stats-scan 5.5s var(--ease-in-out) infinite;
}
@keyframes stats-scan {
  0% { transform: translateX(0); }
  60%, 100% { transform: translateX(720%); }
}

/* ── LIVE OPS — AI terminal section ── */
.liveops-section { position: relative; max-width: var(--maxw); margin-inline: auto; }
.liveops-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: clamp(32px, 5vw, 72px); align-items: center;
}
.liveops-points { list-style: none; display: flex; flex-direction: column; gap: 14px; margin-top: -22px; }
.liveops-points li {
  position: relative; padding-left: 30px; color: var(--ink-soft);
  font-size: 15px; line-height: 1.6;
}
.liveops-points li::before {
  content: '▸'; position: absolute; left: 0; top: 0;
  font-family: var(--font-mono); color: var(--gold);
}
.liveops-points li b { color: var(--ink); font-weight: 600; }

.ai-terminal {
  position: relative; border-radius: var(--r-lg); overflow: hidden;
  background: #0A0C10; border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg), 0 0 80px -30px var(--glow-gold);
  font-family: var(--font-mono);
}
.ai-terminal::after {
  /* faint CRT scanlines */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.015) 0 1px, transparent 1px 3px);
}
.ait-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; background: var(--bg-3);
  border-bottom: 1px solid var(--line);
}
.ait-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--bg-4); }
.ait-dot:nth-child(1) { background: #E5564B; }
.ait-dot:nth-child(2) { background: #E5A93D; }
.ait-dot:nth-child(3) { background: #4BB95E; }
.ait-title { margin-left: 10px; font-size: 11.5px; color: var(--ink-mute); letter-spacing: 0.04em; }
.ait-status {
  margin-left: auto; font-size: 10px; letter-spacing: 0.12em;
  color: var(--green-soft);
}
html.fx .ai-terminal.anim-on .ait-status { animation: ait-blink 2.2s var(--ease-in-out) infinite; }
@keyframes ait-blink { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.ait-body {
  height: clamp(320px, 40vw, 420px); overflow: hidden;
  padding: 20px 22px; font-size: 12.8px; line-height: 1.95;
  display: flex; flex-direction: column; justify-content: flex-start;
}
.ait-line { display: flex; gap: 10px; align-items: baseline; white-space: pre-wrap; }
.ait-time { color: var(--ink-faint); flex-shrink: 0; font-size: 11px; }
.ait-ic { flex-shrink: 0; width: 14px; text-align: center; }
.ait-line.ok .ait-ic { color: var(--green-soft); }
.ait-line.in .ait-ic { color: var(--gold); }
.ait-line.ok .ait-txt em { color: var(--green-soft); font-style: normal; }
.ait-txt { color: var(--ink-soft); }
.ait-txt .q { color: var(--ink); }
.ait-txt .hl { color: var(--gold); }
.ait-line.cmd { color: var(--gold); }
.ait-line.cmd::before { content: '$ '; color: var(--ink-faint); }
.ait-line.spin .ait-ic { color: var(--gold); }
.ait-line.sum {
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line-strong);
  color: var(--gold); font-size: 12px; letter-spacing: 0.04em;
}
.ait-caret {
  display: inline-block; width: 7px; height: 14px; margin-left: 2px;
  background: var(--gold); vertical-align: text-bottom;
}
html.fx .ait-caret { animation: caret-blink 0.9s steps(1) infinite; }
@keyframes caret-blink { 50% { opacity: 0; } }
.ait-gap { height: 12px; flex-shrink: 0; }
html.fx .ait-line { animation: line-in .3s var(--ease-out) both; }
@keyframes line-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}
@media (max-width: 920px) {
  .liveops-grid { grid-template-columns: 1fr; }
  .ait-body { height: 340px; font-size: 11.5px; padding: 16px; }
}

/* ── MEGA MARQUEE (between case studies and pricing) ── */
.mega-marquee {
  overflow: hidden; padding: clamp(40px, 6vw, 90px) 0;
  border-block: 1px solid var(--line);
  background: var(--bg-0);
}
.mm-row {
  white-space: nowrap; will-change: transform;
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(3rem, 8vw, 7.5rem); line-height: 1.05;
  letter-spacing: var(--tracking-tight);
}
.mm-row span { display: inline-block; padding-right: 0.6em; }
.mm-a {
  color: transparent;
  -webkit-text-stroke: 1px rgba(255,184,28,0.45);
}
.mm-b { color: rgba(244,241,234,0.07); margin-top: -0.12em; }
.mm-b .mm-fire { color: var(--gold-deep); opacity: .55; }

/* ── PROCESS assembly rail (injected by JS) ── */
.process-rail {
  position: relative; height: 2px; margin: 6px 0 34px;
  background: var(--line); border-radius: 2px;
}
.pr-fill {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
  transform-origin: left; transform: scaleX(0); border-radius: 2px;
}
.pr-packet {
  position: absolute; top: 50%; left: 0; width: 9px; height: 9px;
  margin-top: -4.5px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 16px 4px var(--glow-gold);
}
html.fx .process-step { transition: border-color .5s var(--ease-out), transform .5s var(--ease-out), box-shadow .5s; }
.process-step.is-lit {
  border-color: var(--line-gold);
  box-shadow: 0 18px 50px -24px var(--glow-gold), var(--inner-line);
  transform: translateY(-5px);
}
.process-step.is-lit .step-num { color: var(--gold); text-shadow: 0 0 18px var(--glow-gold); }
@media (max-width: 920px) { .process-rail { display: none; } }

/* ── CARD BEAM BORDER (injected <i class="card-beam"> on service cards) ── */
@property --beam-a {
  syntax: '<angle>'; inherits: false; initial-value: 0deg;
}
.card-beam {
  position: absolute; inset: -1px; border-radius: inherit; padding: 1px;
  background: conic-gradient(from var(--beam-a),
    transparent 0turn, transparent 0.62turn,
    var(--gold) 0.78turn, rgba(255,184,28,0.0) 0.92turn, transparent 1turn);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity .45s var(--ease-out);
  pointer-events: none;
}
.service-card:hover .card-beam, .pricing-card.popular .card-beam { opacity: 1; }
html.fx .service-card:hover .card-beam { animation: beam-spin 2.6s linear infinite; }
/* the popular card's beam repaints a conic gradient per frame — only
   let it spin while the pricing section is actually on screen */
html.fx .pricing-card.popular.anim-on .card-beam { animation: beam-spin 5s linear infinite; }
.pricing-card.popular .card-beam { opacity: .65; }
@keyframes beam-spin { to { --beam-a: 1turn; } }

/* ── 3D TILT (JS drives transform; glare element injected) ── */
.services-grid, .case-grid, .pricing-grid { perspective: 1100px; }
/* GSAP owns transform on tilt cards — keep CSS transitions off it */
html.fx .tilt-card {
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur);
  transform-style: preserve-3d;
}
.tilt-glare {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(420px circle at var(--glx, 50%) var(--gly, 50%),
    rgba(255,255,255,0.07), transparent 65%);
  opacity: 0; transition: opacity .4s var(--ease-out);
}
[data-tilting] .tilt-glare { opacity: 1; }

/* ── FOUNDER photo clip reveal ── */
html.fx .founder-photo { will-change: clip-path; }

/* ── FINAL CTA radar rings (injected by JS) ── */
.cta-section { overflow: hidden; }
.cta-radar {
  position: absolute; left: 50%; top: 42%; width: 0; height: 0;
  pointer-events: none; z-index: -1;
}
.cta-radar i {
  position: absolute; left: 50%; top: 50%; width: 240px; height: 240px;
  margin: -120px 0 0 -120px; border-radius: 50%;
  border: 1px solid var(--line-gold); opacity: 0;
}
html.fx .cta-section.anim-on .cta-radar i { animation: radar 5.2s var(--ease-out) infinite; }
.cta-radar i:nth-child(2) { animation-delay: 2.6s; }
@keyframes radar {
  0% { transform: scale(.3); opacity: 0; }
  12% { opacity: .8; }
  100% { transform: scale(4.2); opacity: 0; }
}

/* ── HERO DIAGRAM TOOLTIPS (.auto-node explainers) ──
   The hero visual container is pointer-events:none; nodes re-enable
   themselves on desktop only. On mobile the diagram is a faint
   backdrop behind the copy — tooltips stay off and untouchable. */
@media (min-width: 981px) {
  .auto-node[data-tip] { pointer-events: auto; cursor: help; }
  .auto-node[data-tip]:hover, .auto-node.tt-open { z-index: 7; }
  .auto-node[data-tip]:hover > span:first-child,
  .auto-node.tt-open > span:first-child {
    transform: scale(1.16); border-color: var(--node-color, var(--gold));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--node-color, var(--gold)) 22%, transparent),
                0 0 28px color-mix(in srgb, var(--node-color, var(--gold)) 50%, transparent);
  }
  .auto-node[data-tip]:hover .auto-node-label,
  .auto-node.tt-open .auto-node-label { color: var(--ink); }
}
.an-tooltip {
  position: absolute; left: 50%; width: 252px; padding: 14px 16px;
  border-radius: var(--r); text-align: left;
  background: var(--glass-strong); backdrop-filter: blur(12px);
  border: 1px solid var(--line-gold); box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; pointer-events: none; z-index: 10;
  transition: opacity .25s var(--ease-out), transform .25s var(--ease-out);
}
.auto-node[data-tip-pos="below"] .an-tooltip {
  top: calc(100% + 12px); transform: translateX(-50%) translateY(-6px);
}
.auto-node[data-tip-pos="above"] .an-tooltip {
  bottom: calc(100% + 12px); transform: translateX(-50%) translateY(6px);
}
.auto-node[data-tip]:hover .an-tooltip, .auto-node.tt-open .an-tooltip {
  opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}
/* connector notch */
.an-tooltip::after {
  content: ''; position: absolute; left: 50%; width: 9px; height: 9px;
  margin-left: -4.5px; transform: rotate(45deg);
  background: var(--glass-strong);
  border: 1px solid var(--line-gold);
}
.auto-node[data-tip-pos="below"] .an-tooltip::after {
  top: -5.5px; border-right: 0; border-bottom: 0;
}
.auto-node[data-tip-pos="above"] .an-tooltip::after {
  bottom: -5.5px; border-left: 0; border-top: 0;
}
.an-tooltip-title {
  font-family: var(--font-display); font-weight: 700; font-size: 13px;
  color: var(--gold); margin-bottom: 6px; letter-spacing: 0;
}
.an-tooltip-body {
  font-family: var(--font-body); font-size: 12px; font-weight: 400;
  color: var(--ink-soft); line-height: 1.55; text-transform: none; letter-spacing: 0;
}
@media (max-width: 980px) { .an-tooltip { display: none; } }

/* ── Screen-reader-only helper ── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Reduced motion: kill every looping effect from this layer ── */
@media (prefers-reduced-motion: reduce) {
  .journey-layer, .journey-comet-layer, .journey-markers, .cta-radar { display: none !important; }
  .tt-track, .ait-status, .ait-caret, .stats-bar::after,
  .card-beam, .jp-comet::after { animation: none !important; }
}
