/* =============================================================================
   LocalSwarm.ai — 4 · AI hub (#ai) · prefix: ai-
   Circuit-schematic backdrop, neon title, and the hub-and-spoke diagram with the
   mosquito porthole at the core. Builds on css/base.css; never redefines it.

   Hub geometry (desktop, > 760px): a fixed 700 × 560 stage. The wire SVG uses the
   same 700 × 560 viewBox, and every card is centred on the % of that box where
   its wire ends, so wires always disappear under the card edges.
     core      (350, 198)  → 50%      / 35.3571%
     leads     ( 79,  96)  → 11.2857% / 17.1429%
     voice     (621,  96)  → 88.7143% / 17.1429%
     seo       ( 79, 300)  → 11.2857% / 53.5714%
     tracking  (621, 300)  → 88.7143% / 53.5714%
     data      (350, 464)  → 50%      / 82.8571%
   ============================================================================= */

/* ---------- Section shell + backdrop ---------- */
.ai-section { padding-bottom: calc(var(--section-pad) + 28px); }

.ai-bg {
  position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(ellipse 48% 42% at 20% 30%, rgba(247, 198, 0, .075), transparent 72%),
    radial-gradient(ellipse 48% 42% at 80% 70%, rgba(74, 159, 213, .11), transparent 72%);
}
.ai-circuit {
  position: absolute; inset: 0;
  width: 100%; height: 100%; max-width: none;
  opacity: .08;
}

/* ---------- Heading ---------- */
.ai-head { max-width: 920px; margin: 0 auto; }
.ai-section .ai-title { font-weight: 400; margin-bottom: 22px; }
.ai-title__line { display: block; white-space: nowrap; }
.ai-title__line--neon { margin-top: .04em; }
.ai-section .ai-body { max-width: 660px; }

/* ---------- Hub ---------- */
.ai-hub { position: relative; width: 700px; max-width: 100%; margin: 84px auto 0; }
.ai-hub__figure { position: relative; }
.ai-hub__stage { position: relative; width: 700px; height: 560px; }

/* drafting-sheet crop marks just outside the stage corners */
.ai-hub__stage::before {
  --ai-mark: rgba(255, 255, 255, .16);
  content: ''; position: absolute; inset: -22px; z-index: 0; pointer-events: none;
  background:
    linear-gradient(var(--ai-mark), var(--ai-mark)) left top / 16px 1px no-repeat,
    linear-gradient(var(--ai-mark), var(--ai-mark)) left top / 1px 16px no-repeat,
    linear-gradient(var(--ai-mark), var(--ai-mark)) right top / 16px 1px no-repeat,
    linear-gradient(var(--ai-mark), var(--ai-mark)) right top / 1px 16px no-repeat,
    linear-gradient(var(--ai-mark), var(--ai-mark)) left bottom / 16px 1px no-repeat,
    linear-gradient(var(--ai-mark), var(--ai-mark)) left bottom / 1px 16px no-repeat,
    linear-gradient(var(--ai-mark), var(--ai-mark)) right bottom / 16px 1px no-repeat,
    linear-gradient(var(--ai-mark), var(--ai-mark)) right bottom / 1px 16px no-repeat;
}

/* ---------- Wires (centre-to-centre; the core and cards are opaque and hide the ends) ---------- */
.ai-wires {
  position: absolute; inset: 0; z-index: 0;
  width: 100%; height: 100%; max-width: none; overflow: visible;
}
.ai-wires__tracks path { fill: none; stroke: rgba(247, 198, 0, .1); stroke-width: 1; }
.ai-wire {
  fill: none;
  stroke: var(--yellow); stroke-opacity: .35; stroke-width: 1.5;
  stroke-dasharray: 6 5; stroke-linecap: butt;
  animation: ai-flow 1.4s linear infinite;          /* dashes travel outward, core → card */
  transition: stroke-opacity .3s var(--ease-out);
}
@keyframes ai-flow { to { stroke-dashoffset: -11; } }

/* ---------- The core ---------- */
.ai-core {
  --ai-pos: translate(-50%, -50%);
  position: absolute; left: 50%; top: 35.3571%; z-index: 2;
  width: 220px;
  transform: var(--ai-pos);
}
.ai-core::before {   /* big yellow underglow, static (cheap) */
  content: ''; position: absolute; z-index: -1; left: 50%; top: 58%;
  width: 440px; height: 320px; transform: translate(-50%, -50%); pointer-events: none;
  background: radial-gradient(closest-side, rgba(247, 198, 0, .26), rgba(247, 198, 0, .08) 55%, transparent);
}
.ai-core__body {
  position: relative;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 18px 16px 20px;
  border-radius: 20px;
  color: var(--ink);
  background: linear-gradient(160deg, #FFDF63 0%, #F7C600 58%, #EEBA00 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .7),
    inset 0 -2px 0 rgba(160, 110, 0, .2),
    0 0 0 10px rgba(247, 198, 0, .13),
    0 26px 60px -18px rgba(247, 198, 0, .6);
  animation: ai-breathe 4.5s ease-in-out infinite;
}
.ai-core__body::after {   /* inset white hairline */
  content: ''; position: absolute; inset: 6px; pointer-events: none;
  border: 1px solid rgba(255, 255, 255, .55); border-radius: 14px;
}
@keyframes ai-breathe {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, .7),
      inset 0 -2px 0 rgba(160, 110, 0, .2),
      0 0 0 10px rgba(247, 198, 0, .13),
      0 26px 60px -18px rgba(247, 198, 0, .6);
  }
  50% {
    transform: scale(1.035);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, .7),
      inset 0 -2px 0 rgba(160, 110, 0, .2),
      0 0 0 17px rgba(247, 198, 0, .08),
      0 30px 72px -16px rgba(247, 198, 0, .72);
  }
}

.ai-core__pill {
  position: relative; z-index: 1;
  background: var(--ink); color: var(--yellow);
  padding: 4px 9px 3px 11.2px;              /* right side minus the trailing .22em of tracking */
  font-size: 10px; letter-spacing: .22em;
}

/* porthole: the mascot at the heart of the system */
.ai-porthole {
  position: relative; z-index: 1;
  width: 96px; height: 96px; margin: 14px 0;
  border-radius: 50%;
  background: #03080B;
  color: rgba(150, 205, 240, .5);
  box-shadow:
    0 0 0 3px rgba(11, 14, 26, .92),
    0 0 0 4.5px rgba(255, 255, 255, .5),
    0 12px 22px -8px rgba(110, 72, 0, .6);
}
.ai-porthole__lens {
  position: absolute; inset: 0; overflow: hidden;
  border-radius: 50%; clip-path: circle(50% at 50% 50%);   /* clip-path also clips <video> in Safari */
}
.ai-porthole__still,
.ai-porthole__video {
  position: absolute; left: -20%; top: -20%;
  width: 140%; height: 140%; max-width: none;
  object-fit: cover; object-position: 48% 46%;              /* zoomed onto the head and body */
  filter: brightness(1.1) contrast(1.03) saturate(1.06);    /* matches the original render's illumination */
}
.ai-porthole__video { transition: opacity .32s linear; }
.ai-porthole__video--dip { opacity: 0; }                     /* motion off: fade to the identical still */
.ai-porthole__reticle { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ai-porthole::after {   /* glass: highlight + vignette + cool inner rim */
  content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, .2), transparent 34%),
    radial-gradient(circle, transparent 56%, rgba(3, 8, 11, .62) 100%);
  box-shadow: inset 0 0 0 1px rgba(120, 190, 240, .25), inset 0 0 14px rgba(0, 0, 0, .55);
}

.ai-core__name {
  position: relative; z-index: 1;
  font-family: var(--f-display); font-weight: 400;
  font-size: 34px; line-height: 1; letter-spacing: .01em; text-transform: uppercase;
  color: var(--ink);
}
.ai-core__desc {
  position: relative; z-index: 1; margin-top: 7px; padding-left: .14em;   /* re-centres the tracked lines */
  font: 700 11px/1.35 var(--f-label); letter-spacing: .14em; text-transform: uppercase;
  color: rgba(11, 14, 26, .74);
}
.ai-core__desc-line { display: block; }

/* ---------- Spokes ---------- */
.ai-spokes { position: absolute; inset: 0; pointer-events: none; }
.ai-spoke {
  --ai-pos: translate(-50%, -50%);
  position: absolute; left: var(--ai-x); top: var(--ai-y); z-index: 3;
  width: 158px;
  transform: var(--ai-pos);
  pointer-events: auto;
}
.ai-spoke--leads    { --ai-x: 11.2857%; --ai-y: 17.1429%; --ai-dx:  3px; --ai-dy: 5px; --ai-dur: 7.4s; --ai-delay: -1.2s; --ai-i: 0; }
.ai-spoke--voice    { --ai-x: 88.7143%; --ai-y: 17.1429%; --ai-dx: -3px; --ai-dy: 6px; --ai-dur: 8.6s; --ai-delay: -4.1s; --ai-i: 1; }
.ai-spoke--seo      { --ai-x: 11.2857%; --ai-y: 53.5714%; --ai-dx:  4px; --ai-dy: 4px; --ai-dur: 8s;   --ai-delay: -2.6s; --ai-i: 2; }
.ai-spoke--tracking { --ai-x: 88.7143%; --ai-y: 53.5714%; --ai-dx: -4px; --ai-dy: 5px; --ai-dur: 7.1s; --ai-delay: -5.3s; --ai-i: 3; }
.ai-spoke--data     { --ai-x: 50%;      --ai-y: 82.8571%; --ai-dx:  2px; --ai-dy: 5px; --ai-dur: 9s;   --ai-delay: -3.4s; --ai-i: 4; }

.ai-spoke__float { animation: ai-drift var(--ai-dur, 8s) ease-in-out var(--ai-delay, 0s) infinite; }
@keyframes ai-drift {
  0%, 100% { transform: translate3d(0, 0, 0); }
  30% { transform: translate3d(var(--ai-dx), calc(var(--ai-dy) * -1), 0); }
  65% { transform: translate3d(calc(var(--ai-dx) * -.6), calc(var(--ai-dy) * .7), 0); }
}

.ai-spoke__card {
  --ai-d: calc(.4s + var(--ai-i, 0) * .09s);
  position: relative;
  min-height: 132px;
  padding: 14px 14px 16px;
  background: var(--navy);
  border: 1.5px solid rgba(247, 198, 0, .55);
  border-radius: 16px;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 20px 40px -24px rgba(0, 0, 0, .85);
  transition: border-color .3s var(--ease-out), box-shadow .3s var(--ease-out);
}
.ai-spoke__icon {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin-bottom: 12px;
  border-radius: 9px;
  background: rgba(247, 198, 0, .15);
  color: var(--yellow);
}
.ai-spoke__icon svg { width: 18px; height: 18px; }
.ai-spoke__num {
  position: absolute; top: 27px; right: 14px;
  font: 800 9px/1 var(--f-code); letter-spacing: .18em;
  color: rgba(200, 206, 223, .45);
}
.ai-spoke__title {
  font: 800 13px/1.25 var(--f-body); letter-spacing: .03em; text-transform: uppercase;
  color: var(--on-dark);
}
.ai-spoke__sub {
  margin-top: 5px; min-height: 2.9em;     /* two lines, so every card is the same height */
  font-size: 11.5px; line-height: 1.45;
  color: var(--on-dark-2);
}

/* hover: the card lights up and so does its wire (no link implied — nothing moves) */
@media (hover: hover) and (min-width: 761px) {
  .ai-spoke__card:hover {
    border-color: var(--yellow);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 0 0 4px rgba(247, 198, 0, .08), 0 20px 44px -22px rgba(247, 198, 0, .35);
  }
  .ai-hub__stage:has(.ai-spoke--leads:hover) .ai-wire--leads,
  .ai-hub__stage:has(.ai-spoke--voice:hover) .ai-wire--voice,
  .ai-hub__stage:has(.ai-spoke--seo:hover) .ai-wire--seo,
  .ai-hub__stage:has(.ai-spoke--tracking:hover) .ai-wire--tracking,
  .ai-hub__stage:has(.ai-spoke--data:hover) .ai-wire--data { stroke-opacity: .9; }
}

/* ---------- Title block (bottom-left of the stage) + motion switch (bottom-right) ---------- */
.ai-hub__caption {
  position: absolute; left: 0; bottom: 0; z-index: 1;
  min-width: 196px; padding: 11px 0 0 14px;
  border-top: 1px solid rgba(255, 255, 255, .12);
  text-align: left;
}
.ai-hub__caption::before {
  content: ''; position: absolute; left: 0; top: -1px; bottom: 0; width: 2px;
  background: var(--yellow);
}
.ai-hub__code { display: block; margin-bottom: 7px; font-size: 10px; color: var(--yellow); }
.ai-hub__caption-text {
  display: block;
  font: 600 12px/1.5 var(--f-label); letter-spacing: .14em; text-transform: uppercase;
  color: var(--on-dark-3);
}

.ai-motion {
  position: absolute; right: 0; bottom: 0; z-index: 1;
  display: none; align-items: center; gap: 8px;
  padding: 9px 13px 8px;
  font: 700 11px/1 var(--f-label); letter-spacing: .18em; text-transform: uppercase;
  color: var(--on-dark-3);
  background: rgba(11, 14, 26, .6);
  border: 1px solid rgba(255, 255, 255, .14);
  transition: color .2s, border-color .2s;
}
.js .ai-motion { display: inline-flex; }
.ai-motion:hover { color: var(--on-dark); border-color: rgba(255, 255, 255, .32); }
.ai-motion__led {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--yellow); box-shadow: 0 0 8px rgba(247, 198, 0, .7);
}
.ai-motion__state { min-width: 2.3em; text-align: left; color: var(--on-dark); }
.ai-motion[aria-checked="false"] .ai-motion__led { background: transparent; box-shadow: inset 0 0 0 1px var(--on-dark-3); }
.ai-motion[aria-checked="false"] .ai-motion__state { color: var(--on-dark-3); }

/* ---------- Staged entrance (main.js adds .is-in to the [data-reveal] hub) ---------- */
.js .ai-hub .ai-core {
  opacity: 0; transform: var(--ai-pos) scale(.9);
  transition: opacity .7s var(--ease-out) .05s, transform .9s var(--ease-out) .05s;
}
.js .ai-hub.is-in .ai-core { opacity: 1; transform: var(--ai-pos); }

/* wires power up after the core and cards are opaque, so no wire ever shows through a fading card */
.js .ai-hub .ai-wires { opacity: 0; transition: opacity .8s var(--ease-out) 1.25s; }
.js .ai-hub.is-in .ai-wires { opacity: 1; }

.js .ai-hub .ai-spoke__card {
  opacity: 0; transform: translateY(10px) scale(.94);
  transition:
    opacity .6s var(--ease-out) var(--ai-d),
    transform .7s var(--ease-out) var(--ai-d),
    border-color .3s var(--ease-out),
    box-shadow .3s var(--ease-out);
}
.js .ai-hub.is-in .ai-spoke__card { opacity: 1; transform: none; }

.js .ai-hub .ai-hub__caption,
.js .ai-hub .ai-motion { opacity: 0; transition: opacity .8s var(--ease-out) 1.35s, color .2s, border-color .2s; }
.js .ai-hub.is-in .ai-hub__caption,
.js .ai-hub.is-in .ai-motion { opacity: 1; }

/* ---------- ≤ 900px: hub keeps its desktop form; just tighten the gap above it ---------- */
@media (max-width: 900px) {
  .ai-hub { margin-top: 72px; }
}

/* ---------- ≤ 760px: core on top, spokes in a 2-column grid on a dashed bus ---------- */
@media (max-width: 760px) {
  .ai-hub {
    width: 100%; margin-top: 52px;
    display: flex; flex-direction: column; align-items: center;
  }
  .ai-hub__figure { width: 100%; }
  .ai-hub__stage {
    width: 100%; height: auto;
    display: flex; flex-direction: column; align-items: center;
  }
  .ai-hub__stage::before,
  .ai-wires { display: none; }

  .ai-core { --ai-pos: translate(0, 0); position: relative; left: auto; top: auto; width: 236px; }
  .ai-core::before { width: 360px; height: 260px; }

  .ai-spokes {
    position: relative; inset: auto;
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px 28px;
    width: 100%; max-width: 440px; margin-top: 48px;
    pointer-events: auto;
  }
  /* the bus: from the core's bottom edge down the column gap, tucked under the Data card */
  .ai-spokes::before {
    content: ''; position: absolute; z-index: 1;
    left: calc(50% - 1px); top: -48px; bottom: 40px; width: 2px;
    background: repeating-linear-gradient(180deg, rgba(247, 198, 0, .5) 0 6px, transparent 6px 11px);
    animation: ai-bus 1.4s linear infinite;
  }
  .ai-spoke { --ai-pos: translate(0, 0); position: relative; left: auto; top: auto; width: auto; }
  .ai-spoke--data { grid-column: 1 / -1; justify-self: center; width: calc(50% - 14px); }
  .ai-spoke__float { height: 100%; animation: none; }
  .ai-spoke__card { height: 100%; min-height: 0; padding: 13px 12px 15px; }
  .ai-spoke__num { top: 25px; right: 12px; }

  /* stubs from each side card to the bus (gap / 2 = 14px, plus the 1.5px border) */
  .ai-spoke--left .ai-spoke__card::after,
  .ai-spoke--right .ai-spoke__card::after {
    content: ''; position: absolute; top: calc(50% - 1px); width: 14px; height: 2px;
    background: repeating-linear-gradient(90deg, rgba(247, 198, 0, .5) 0 6px, transparent 6px 11px);
  }
  .ai-spoke--left .ai-spoke__card::after { right: -15.5px; }
  .ai-spoke--right .ai-spoke__card::after { left: -15.5px; transform: scaleX(-1); }

  .ai-hub__caption {
    position: relative; left: auto; bottom: auto;
    width: min(100%, 280px); min-width: 0; margin: 40px auto 0; padding: 12px 0 0;
    text-align: center;
  }
  .ai-hub__caption::before { left: 50%; bottom: auto; width: 28px; height: 2px; transform: translateX(-50%); }
  .ai-motion { position: relative; right: auto; bottom: auto; margin-top: 16px; }
}
@keyframes ai-bus { to { background-position: 0 11px; } }

/* ---------- ≤ 600px: the neon line stays on one line, bolts included ---------- */
@media (max-width: 600px) {
  /* "NOW POWERED BY AI." ≈ 8.3em in Anton (8.2em in its Impact fallback); the base bolts need 26px each side */
  .ai-section .ai-title {
    font-size: clamp(22px, calc((100vw - 2 * var(--gutter) - 56px) / 8.6), 36px);
    line-height: 1.08;
  }
}
@media (max-width: 380px) {
  .ai-spoke__title { font-size: 12px; letter-spacing: .02em; }
  .ai-spoke__card { padding: 12px 10px 14px; }
  .ai-spoke__num { top: 24.5px; right: 10px; }
}

/* ---------- Motion states set by js/sections/ai.js ---------- */
/* off-screen or hidden tab: freeze every loop in the section */
.ai-section--idle *,
.ai-section--idle *::before,
.ai-section--idle *::after { animation-play-state: paused !important; }

/* visitor turned motion off: everything settles to its resting frame */
.ai-section--still *,
.ai-section--still *::before,
.ai-section--still *::after { animation: none !important; }
.ai-section--still .electric-text { text-shadow: 0 0 12px rgba(247, 198, 0, .45), 0 0 26px rgba(247, 198, 0, .2); }
.ai-section--still .electric-text::before,
.ai-section--still .electric-text::after { opacity: .8; }

/* ---------- Reduced motion: base.css stops the CSS loops; settle the rest ---------- */
@media (prefers-reduced-motion: reduce) {
  .ai-section *,
  .ai-section *::before,
  .ai-section *::after { transition-delay: 0s !important; }
  .js .ai-motion { display: none; }
}
