/* ============================================================
   HOME HERO — the home page's first-screen headline (site/src/components/HomeHero.astro), on word-pills.css.
   Source: the live embed embed/intro-pills-embed.html (Figma 18223:294 desktop, 18238:2 phones).
   Everything is in em of the pill size (--ps): the live Figma px ÷ 52 (the frame's kegl).
   The page's own pieces: the slanted «performance», the outline hex «agents» (both the live wrap SVGs as artwork,
   coloured from tokens) and the cursor. Colours: «Ad automation» is live #FFAA00, which has no token — Primary
   (the nearest system yellow; a question in the report); «performance» is live #FC4830 → Accent/Red (#FF4747, a step).
   ============================================================ */

.home-hero__connector {
  --connector-mark-size: var(--space);
  --connector-mark-gap: var(--space-xs);
  anchor-name: --home-hero-connector;
}
.home-hero__connector .home-hero__connector-toggle {
  --motion-scale: 1.25;
  position: relative;
  inline-size: 100%;
}
.home-hero__connector-label {
  display: inline-flex;
  align-items: center;
  gap: var(--connector-mark-gap);
}
@media (min-width: 48rem) {
  .home-hero__connector .home-hero__connector-toggle {
    justify-content: flex-start;
  }
}
.home-hero__connector-toggle .nav2__chev {
  position: absolute;
  inset-inline-end: calc(var(--space) - var(--btn-border));
  inset-block: 0;
  margin-block: auto;
  transition:
    rotate var(--duration-toggle) var(--ease-toggle),
    scale var(--duration-hover) var(--ease-hover);
}
.home-hero__connector:has(:popover-open) .home-hero__connector-toggle .nav2__chev {
  rotate: 180deg;
  scale: var(--motion-scale);
}
@media (hover: hover) {
  .home-hero__connector-toggle:hover .nav2__chev { scale: var(--motion-scale); }
}
@media (prefers-reduced-motion: reduce) {
  .home-hero__connector-toggle .nav2__chev { transition: none; }
}

.home-hero__connector-menu {
  border: 0;
  color: var(--color-text);
  text-align: start;
  inset: auto;
  margin: var(--space-xs) 0;
  inline-size: max-content;
  max-inline-size: calc(100vw - 2 * var(--pad-horizontal));
  max-block-size: calc(100dvh - 2 * var(--space-xs));
  overflow: auto;
}
.home-hero__connector-menu > a {
  display: flex;
  align-items: center;
  gap: var(--connector-mark-gap);
  padding-block: var(--space-xs);
  padding-inline: calc(var(--space) - var(--space-xs));
  border-radius: calc(var(--radius-lg) - var(--space-xs));
  color: inherit;
}
.home-hero__connector-label img,
.home-hero__connector-menu img {
  flex: none;
  inline-size: var(--connector-mark-size);
  block-size: var(--connector-mark-size);
  object-fit: contain;
}
.home-hero__connector-type { margin-inline-start: auto; }
@media (max-width: 47.9375rem) {
  .home-hero__connector {
    --connector-mark-size: var(--space-sm);
    --connector-mark-gap: var(--space-xxs);
  }
}
.home-hero__connector-menu > a:focus-visible { background: var(--color-bg-cta-grey); }
@media (hover: hover) {
  .home-hero__connector-menu > a:hover { background: var(--color-bg-cta-grey); }
}
@supports (position-area: bottom center) and (width: anchor-size(width)) {
  .home-hero__connector-menu {
    position-anchor: --home-hero-connector;
    position-area: bottom center;
    position-try-fallbacks: flip-block;
    inline-size: anchor-size(width);
  }
}

/* ── Shapes: the layout box keeps the Figma width, the artwork sits behind the text at its own Figma size and is
   never stretched to the text (its slanted / pointed ends would skew) ── */
.home-hero__perf,
.home-hero__agents {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 1.365em;            /* 71 — the pill box */
  color: var(--color-text);
}
.home-hero__perf   { width: 6.865em; }  /* 357 */
.home-hero__agents { width: 4.058em; }  /* 211 */
.home-hero__shape-art {
  position: absolute;
  top: 50%;
  left: 50%;
  height: 1.365em;
  overflow: visible;
  max-width: none;           /* the artwork overhangs its box on purpose */
}
.home-hero__perf .home-hero__shape-art {
  width: 7.327em;                         /* 381 */
  translate: calc(-50% - 0.038em) -50%;   /* the live −2 nudge */
  color: var(--color-accent-red);
}
.home-hero__agents .home-hero__shape-art {
  width: 4.115em;                         /* 214 */
  translate: calc(-50% - 0.019em) -50%;   /* the live −1 nudge */
}
/* the same 6 under the text as a pill, so the words sit at one height along the row */
.home-hero__shape-text {
  position: relative;
  padding-bottom: 0.115em;
  line-height: 1.25;
  white-space: nowrap;
}

/* ── Cursor: a 66-wide slot; the artwork overhangs it to the left (part of the Figma composition, not a nudge) ── */
.home-hero__cursor {
  position: relative;
  z-index: 1;                 /* it crosses «agents» in flight: a cursor paints on top */
  flex: none;
  width: 1.269em;             /* 66 */
  height: 1.365em;
  color: var(--color-text);
}
.home-hero__cursor--after { margin-left: 0.064em; } /* phones: a hair more air after «agents», as live */
.home-hero__cursor-art {
  position: absolute;
  left: -0.153em;             /* −7.95 */
  top: -0.029em;              /* −1.5 */
  width: 1.404em;             /* 73 */
  height: 1.462em;            /* 76 */
  overflow: visible;
  max-width: none;
  /* a thin white line on a dark ground: its own layer, or the edges shimmer at every subpixel step in flight */
  backface-visibility: hidden;
}
.home-hero__cursor-art path { fill: var(--color-text-inverted); }

/* ============================================================
   ENTRANCE — once, on scroll-in (home-hero.js sets [data-anim], then .is-in). Without JS or with «reduce motion»
   [data-anim] is never set: the final layout shows as is.
   Row 2 («and» «their» «agents») pops in tight, the cursor slot closed by `translate` (never an animated width);
   the cursor pops in parked one gap past «agents», holds, flies an arc under the row into its slot, and late in the
   flight the pills are shoved apart.
   Pop-ins are the scene's plain parts → Reveal (duration, curve, step). The flight and the shove are the scene itself:
   no character matches (Glide is 1.8 s and brakes long; Spring is never for words), so they keep the live CFG
   timings, as --motion-* variables the Motion panel can tune.
   ============================================================ */
.home-hero-pills {
  --motion-start: 0.32s;                               /* live: the beat before row 2 starts — no token */
  --motion-pop-dur: var(--duration-reveal);            /* live 0.52 (pills) / 0.4 (cursor) */
  --motion-pop-ease: var(--ease-reveal);               /* live: a small overshoot on the scale — Reveal has none */
  --motion-step: var(--reveal-step);                   /* live 0.14 between and → their → agents */
  --motion-pop-scale: 0.86;
  --motion-cursor-scale: 0.7;
  --motion-cursor-gap: 0.28s;                          /* live: pause before the cursor shows — no token */
  --motion-hold: 0.36s;                                /* live: how long it sits parked — no token */
  --motion-fly-dur: 0.56s;                             /* live flight — no token */
  --motion-fly-ease: cubic-bezier(0.43, 0.01, 0.24, 1); /* live — no token */
  --motion-dip: 1.154em;                               /* 60: how far under the row the arc swings */
  --motion-push-at: 0.37s;                             /* live: into the flight when the pills part — no token */
  --motion-push-dur: 0.44s;                            /* live shove — no token */
  --motion-push-ease: cubic-bezier(0.34, 1.45, 0.45, 1); /* live overshoot: reads as a push — no token */

  --hh-cursor-at: calc(var(--motion-start) + 3 * var(--motion-step) + var(--motion-cursor-gap));
  --hh-fly-at: calc(var(--hh-cursor-at) + var(--motion-pop-dur) + var(--motion-hold));
  /* half the cursor's footprint (slot 66 + gap 8): «and» «their» lean right by it, «agents» left — the closed line
     stays centred */
  --hh-shift: calc((1.269em + 0.154em) / 2);
  /* parked one gap past the closed «agents»: slot + gap + agents − its lean + gap + the artwork's overhang */
  --hh-park: calc(1.269em + 0.154em + 4.058em - var(--hh-shift) + 0.154em + 0.153em);
}
.home-hero__pop--1 { --hh-i: 0; }
.home-hero__pop--2 { --hh-i: 1; }
.home-hero__pop--3 { --hh-i: 2; }
.home-hero-pills[data-anim] .home-hero__pop--l { --hh-sx: var(--hh-shift); }
.home-hero-pills[data-anim] .home-hero__pop--r { --hh-sx: calc(-1 * var(--hh-shift)); }

/* The «from» state: no transition on it, so arming is instant (a transition here would fade the words out first) */
.home-hero-pills[data-anim] .home-hero__pop { opacity: 0; scale: var(--motion-pop-scale); translate: var(--hh-sx, 0) 0; }
.home-hero-pills[data-anim] .home-hero__cursor { opacity: 0; scale: var(--motion-cursor-scale); }
.home-hero-pills[data-anim] .home-hero__cursor--fly { translate: var(--hh-park) 0; will-change: translate; }

/* The final state carries the transitions (the transition sits on the state it goes to, docs/layout-rules.md Motion) */
.home-hero-pills[data-anim].is-in :is(.home-hero__pop, .home-hero__cursor) { opacity: 1; scale: 1; translate: 0 0; }
.home-hero-pills[data-anim].is-in .home-hero__pop {
  transition:
    opacity var(--motion-pop-dur) var(--motion-pop-ease) calc(var(--motion-start) + var(--hh-i) * var(--motion-step)),
    scale var(--motion-pop-dur) var(--motion-pop-ease) calc(var(--motion-start) + var(--hh-i) * var(--motion-step)),
    translate var(--motion-push-dur) var(--motion-push-ease) calc(var(--hh-fly-at) + var(--motion-push-at));
}
.home-hero-pills[data-anim].is-in .home-hero__cursor {
  transition:
    opacity var(--motion-pop-dur) var(--motion-pop-ease) var(--hh-cursor-at),
    scale var(--motion-pop-dur) var(--motion-pop-ease) var(--hh-cursor-at);
}
/* The arc is split in two: X on the slot as one transition (compositor, one real curve), the dip on the artwork as a
   3-stop keyframe (non-monotonic, which a transition cannot do) — a single calc() keyframe track stutters. */
.home-hero-pills[data-anim].is-in .home-hero__cursor--fly {
  transition:
    opacity var(--motion-pop-dur) var(--motion-pop-ease) var(--hh-cursor-at),
    scale var(--motion-pop-dur) var(--motion-pop-ease) var(--hh-cursor-at),
    translate var(--motion-fly-dur) var(--motion-fly-ease) var(--hh-fly-at);
}
.home-hero-pills[data-anim].is-in .home-hero__cursor--fly .home-hero__cursor-art {
  animation: home-hero-dip var(--motion-fly-dur) ease-in-out var(--hh-fly-at) both;
}
@keyframes home-hero-dip {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 var(--motion-dip); }
}

@media (prefers-reduced-motion: reduce) {
  .home-hero-pills[data-anim] :is(.home-hero__pop, .home-hero__cursor),
  .home-hero-pills[data-anim].is-in :is(.home-hero__pop, .home-hero__cursor) {
    opacity: 1; scale: 1; translate: 0 0; transition: none;
  }
  .home-hero-pills[data-anim] .home-hero__cursor-art { animation: none; }
}
