/* ===== ReactBits-style effects — generated, themed to MeritX tokens ===== */

/* ---------- pill-nav ---------- */
/* =========================================================================
   pill-nav — sliding pill indicator for the MeritX top navbar.
   Self-contained, namespaced .pillnav-*. Enhances the existing .nav__links
   rail in place: a single pill slides (translateX) and resizes (width) behind
   the hovered / focused / active link. Position animates via transform
   (GPU-friendly); width animates directly — the pill is a single absolutely
   positioned element, so animating its width reflows nothing else.
   Active state is driven by the existing scrollspy (the .active class on a link).
   ========================================================================= */

/* The rail becomes the positioning context + the pill's track. We DON'T change
   layout of .nav__links — only add position + a pill child. Applied via the
   .pillnav-on flag so the component is opt-in and collision-free. */
.nav__links.pillnav-on { position: relative; }

/* Lift links above the pill and give them a stable, transparent resting bg so
   the component's own hover/active background (the moving pill) reads cleanly. */
.nav__links.pillnav-on > a { position: relative; z-index: 1; }

/* While the pill is the active indicator, suppress the legacy per-link
   ::after underline + per-link hover background so we don't double up.
   (Targets the real selectors in interactions.css L50-55 / styles.css L350.) */
.nav__links.pillnav-on > a::after { display: none; }
.nav__links.pillnav-on > a:hover { background: transparent; }

/* The sliding pill.
   - Position animates via transform: translateX (no layout/paint of siblings).
   - Width animates DIRECTLY (it's an absolutely-positioned single element, so
     width changes don't reflow the rail). We deliberately do NOT use scaleX:
     scaling a thin base would smear the 1px border and stretch the box-shadow
     horizontally. Animating width keeps the border + shadow crisp. */
.pillnav-pill {
  position: absolute;
  top: 50%;
  left: 0;
  height: var(--pillnav-h, 34px);
  width: var(--pillnav-w, 0px);
  margin-top: calc(var(--pillnav-h, 34px) / -2);
  border-radius: 9px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  box-shadow: 0 2px 10px -4px color-mix(in srgb, var(--accent) 60%, transparent);
  transform: translateX(var(--pillnav-x, 0px));
  /* enter ease-out; ~260ms feels morph-y without being sluggish */
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),
              width 0.26s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  will-change: transform, width;
}

/* Visible once positioned (JS adds .pillnav-ready after first measure) */
.nav__links.pillnav-on.pillnav-ready .pillnav-pill { opacity: 1; }

/* Hover/focus state = brighter pill; resting (no hover, follows .active) = soft. */
.nav__links.pillnav-on.pillnav-hot .pillnav-pill {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
  border-color: color-mix(in srgb, var(--accent) 48%, transparent);
}

/* Text color lift for the link the pill is currently parked on. */
.nav__links.pillnav-on > a.pillnav-current,
.nav__links.pillnav-on > a:hover,
.nav__links.pillnav-on > a:focus-visible { color: var(--text); }

/* Keyboard focus ring stays on the link itself (pill is decorative). */
.nav__links.pillnav-on > a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}

/* Light theme: keep contrast — accent-soft already adapts, nudge the shadow down. */
[data-theme="light"] .pillnav-pill {
  box-shadow: 0 2px 10px -5px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* Reduced motion: no slide/resize travel — the pill snaps to position.
   It still moves (so the indicator is correct) but without animated travel. */
@media (prefers-reduced-motion: reduce) {
  .pillnav-pill {
    transition: opacity 0.15s ease;
    will-change: auto;
  }
}

/* color-mix() fallback: very old engines that lack color-mix would render the
   pill with no background/border. Give a token-based fallback that still themes. */
@supports not (color: color-mix(in srgb, red, blue)) {
  .pillnav-pill { background: var(--accent-soft); border-color: var(--border-strong); box-shadow: var(--shadow-soft); }
  .nav__links.pillnav-on.pillnav-hot .pillnav-pill { background: var(--surface-3); border-color: var(--accent); }
}

/* The pill is only meaningful on the desktop rail; on mobile .nav__links is
   hidden (existing @media max-width:1024px in styles.css) so nothing renders. */

/* ---------- card-nav ---------- */
/* =========================================================================
   CARD NAV — mobile card-based navigation panel for MeritX
   Each top-level destination is a tappable card (icon + label + desc) that
   animates in staggered (scale + fade from top). Replaces .nav__drawer on
   touch / narrow viewports. Self-contained; namespaced .cardnav-*.
   ========================================================================= */

/* Panel container — anchored under the fixed navbar, full-bleed scrim below.
   z-index 998 keeps it UNDER the navbar (.nav is z-index 1000) so the
   hamburger / theme toggle / logo stay clickable while the sheet is open. */
.cardnav {
  position: fixed;
  inset: var(--nav-h) 0 0 0;
  z-index: 998;
  display: flex;
  flex-direction: column;
  /* hidden state */
  visibility: hidden;
  pointer-events: none;
}
.cardnav.is-open {
  visibility: visible;
  pointer-events: auto;
}

/* Dimming scrim — sits behind the card sheet, click to dismiss */
.cardnav__scrim {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 10, 0.55);
  opacity: 0;
  transition: opacity 0.24s ease;
}
[data-theme="light"] .cardnav__scrim { background: rgba(20, 30, 60, 0.32); }
.cardnav.is-open .cardnav__scrim { opacity: 1; }

/* The sheet that holds the cards */
.cardnav__sheet {
  position: relative;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* enter from top */
  transform: translateY(-10px);
  opacity: 0;
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}
.cardnav.is-open .cardnav__sheet {
  transform: translateY(0);
  opacity: 1;
}

/* Optional small section label inside the sheet */
.cardnav__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 6px 10px;
}

/* Card grid — two-up on phones, single column when very narrow */
.cardnav__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 639px) {
  .cardnav__grid { grid-template-columns: 1fr; }
}

/* A single destination card */
.cardnav__card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 88px;            /* comfortably > 44px touch target */
  padding: 14px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  /* staggered entrance: start scaled-down + faded, shifted up */
  opacity: 0;
  transform: translateY(-8px) scale(0.94);
  transform-origin: top center;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}
/* When the panel is open, run the staggered reveal */
.cardnav.is-open .cardnav__card {
  animation: cardnav-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--cardnav-delay, 0ms);
}
@keyframes cardnav-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Hover / focus / active affordances (animation uses `both`, so its final
   keyframe holds until the next open; these only matter once settled). */
.cardnav__card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.cardnav__card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.cardnav__card:active { transform: scale(0.975); }

/* Icon chip */
.cardnav__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}
.cardnav__icon svg { width: 18px; height: 18px; }

/* Featured / live card accent (e.g. Terminal) — uses the site's established
   .badge--live token pairing (green-bg + green-text) so the glyph keeps a
   readable ~4.5:1 contrast instead of green-on-green. */
.cardnav__card--live .cardnav__icon {
  background: var(--green-bg);
  color: var(--green-text);
}

.cardnav__name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.cardnav__desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

/* Live dot beside the name */
.cardnav__name .cardnav__dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 999px;
  background: var(--green);
  vertical-align: middle;
}

/* Primary CTA spanning the full width below the grid */
.cardnav__cta {
  grid-column: 1 / -1;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px;
  border-radius: var(--r);
  background: var(--grad);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  border: none;
  /* The CTA participates in the same staggered reveal as the cards. */
  opacity: 0;
  transform: translateY(-8px) scale(0.94);
  transform-origin: top center;
}
.cardnav.is-open .cardnav__cta {
  animation: cardnav-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--cardnav-delay, 0ms);
}
.cardnav__cta:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Show the card-nav only where the mobile toggle is active; hide the legacy
   flat drawer so the two never collide. */
.cardnav { display: none; }
@media (max-width: 639px) {
  .cardnav { display: flex; }
  .nav__drawer { display: none !important; }   /* superseded by cardnav */
}

/* Reduced-motion: no scale/translate/stagger — instant, opacity-only */
@media (prefers-reduced-motion: reduce) {
  .cardnav__scrim,
  .cardnav__sheet { transition: opacity 0.001ms linear; }
  .cardnav__sheet { transform: none; }
  .cardnav__card,
  .cardnav__cta {
    transform: none;
    opacity: 1;
  }
  .cardnav__card {
    transition: border-color 0.18s ease, background 0.18s ease;
  }
  .cardnav.is-open .cardnav__card,
  .cardnav.is-open .cardnav__cta {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .cardnav__card:active { transform: none; }
}

/* ---------- magic-bento-border-glow ---------- */
/* ============================================================
   MAGIC BENTO · BORDER GLOW  (.mbento-*)
   Edge/border glow only — NO cursor radial spotlight fill.
   Lives on a CHILD layer (.mbento-glow) so it never touches the
   card's own `transform` (the 3D tilt sets that inline).
   VERIFIED: the host card does NOT itself set position:relative
   or transform-style:preserve-3d, so .mbento establishes BOTH
   here. preserve-3d is what actually makes the glow tilt with
   the card (without it the child renders flat — the original
   spec claim "tilts with the card for free" was not met).
   ============================================================ */

@property --mbento-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

/* FIXED: establish position + 3D context here — the real .card /
   .s-wwd-card rules set NEITHER. preserve-3d makes the .mbento-glow
   child share the card's tilted 3D plane so the glow tracks the tilt. */
.mbento {
  position: relative;
  transform-style: preserve-3d;
}

.mbento-glow {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s ease-out;
  transform: translateZ(0.01px);
}

.mbento-glow::before,
.mbento-glow::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
          mask-composite: exclude;
}

.mbento-glow::before {
  padding: 2px;
  background: var(--grad);
  filter: blur(2px);
  opacity: 0.55;
}

/* FIXED: replaced bare `transparent` stops with transparent-of-hue
   (color-mix … 0%, transparent) to kill the dark/grey comet fringe. */
.mbento-glow::after {
  background:
    conic-gradient(
      from var(--mbento-angle),
      color-mix(in srgb, var(--accent) 0%, transparent) 0deg,
      color-mix(in srgb, var(--accent) 0%, transparent) 60deg,
      var(--accent) 130deg,
      var(--accent-2) 200deg,
      color-mix(in srgb, var(--accent-2) 0%, transparent) 270deg,
      color-mix(in srgb, var(--accent) 0%, transparent) 360deg
    );
}

/* NOTE: :focus-within only fires if a card has a focusable descendant.
   Current .s-wwd-card has none — see a11yNotes for the keyboard fix. */
.mbento:hover .mbento-glow,
.mbento:focus-within .mbento-glow,
.mbento.is-mbento-active .mbento-glow {
  opacity: 1;
}

@supports (background: conic-gradient(from var(--mbento-angle), red, blue)) {
  .mbento:hover .mbento-glow::after,
  .mbento:focus-within .mbento-glow::after,
  .mbento.is-mbento-active .mbento-glow::after {
    animation: mbento-trace 2.6s linear infinite;
  }
}

@keyframes mbento-trace {
  to { --mbento-angle: 360deg; }
}

.mbento {
  transition: box-shadow 0.22s ease-out, border-color 0.22s ease-out;
}
.mbento:hover,
.mbento:focus-within,
.mbento.is-mbento-active {
  box-shadow:
    0 10px 30px -12px color-mix(in srgb, var(--accent) 45%, transparent),
    0 4px 14px -8px color-mix(in srgb, var(--accent-2) 40%, transparent),
    var(--shadow-soft);
  border-color: var(--border-strong);
}

/* No-tilt fallback (coarse pointer / no fine hover): transform is free. */
@media (hover: hover) and (pointer: coarse), (hover: none) {
  .mbento { transition: transform 0.2s ease-out, box-shadow 0.22s ease-out, border-color 0.22s ease-out; }
  .mbento.is-mbento-active { transform: translateY(-4px) scale(1.02); }
}

.mbento-ripple {
  position: absolute;
  z-index: 0;
  border-radius: 50%;
  pointer-events: none;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 55%, transparent) 0%, transparent 70%);
  opacity: 0.55;
  transform: scale(0);
  animation: mbento-ripple 0.55s ease-out forwards;
}
@keyframes mbento-ripple {
  to { transform: scale(16); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .mbento-glow,
  .mbento { transition: none !important; }
  .mbento-glow::after { animation: none !important; }
  .mbento:hover .mbento-glow,
  .mbento:focus-within .mbento-glow,
  .mbento.is-mbento-active .mbento-glow { opacity: 1; }
  .mbento:hover .mbento-glow::after,
  .mbento:focus-within .mbento-glow::after,
  .mbento.is-mbento-active .mbento-glow::after {
    background: var(--grad);
    opacity: 0.5;
  }
  .mbento-ripple { display: none; }
}

[data-theme="light"] .mbento:hover,
[data-theme="light"] .mbento:focus-within,
[data-theme="light"] .mbento.is-mbento-active {
  box-shadow:
    0 10px 26px -14px color-mix(in srgb, var(--accent) 38%, transparent),
    0 4px 12px -8px color-mix(in srgb, var(--accent-2) 32%, transparent),
    var(--shadow-soft);
}
[data-theme="light"] .mbento-glow::before { opacity: 0.45; }

/* ---------- scroll-float + scroll-reveal ---------- */
/* =========================================================================
   MeritX — scroll-float (titles) + scroll-reveal (lead paragraphs)
   Clean-room vanilla. transform/opacity/filter only. reduced-motion safe.
   Namespaced .scrollfloat-* / .scrollreveal-* so it drops in collision-free.
   Lives INSIDE .section-head, which already gets a whole-block
   [data-reveal="up"]; the per-word effects compose with that (block animates
   the container, these animate the inner runs). will-change is lifecycle-gated
   via .is-anim classes so we never pin compositor layers permanently.
   ========================================================================= */

/* ---------- SCROLL-FLOAT — section titles float up word-by-word ----------
   JS adds .scrollfloat-split to the <h2> and wraps each word/em in a unit.
   Units start lower + smaller + transparent (+ tiny blur) and settle when the
   title scrolls into view. One-time; staggered via per-unit --sf-i. */
.scrollfloat-split { /* keep gradient/serif descenders from being clipped while units transform */
  overflow: visible;
}
.scrollfloat-unit {
  display: inline-block;
  white-space: pre;              /* preserve any whitespace captured with a run */
  opacity: 0;
  transform: translate3d(0, 0.42em, 0) scale(0.92);
}
/* will-change only WHILE the title is animating in — added with .is-floated,
   removed on transitionend by JS (so idle titles hold no compositor layer). */
.scrollfloat-split.is-anim .scrollfloat-unit {
  will-change: transform, opacity, filter;
}
/* the serif gradient accent is moved (not re-created) into a unit; it keeps its
   own -webkit-text-fill-color:transparent clip — we must NOT set color here.
   translateZ via translate3d keeps the clip on its own layer so the gradient
   fill survives the blur/scale on Blink/WebKit. */
.scrollfloat-unit.scrollfloat-em {
  display: inline-block;         /* <em> already styled by .section-title em */
}
.scrollfloat-split.is-floated .scrollfloat-unit {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  transition:
    opacity 0.5s cubic-bezier(.22, 1, .36, 1),
    transform 0.6s cubic-bezier(.22, 1, .36, 1);
  /* cap the stagger so very long headings don't lag for seconds */
  transition-delay: min(calc(var(--sf-i, 0) * 42ms), 520ms);
}

/* ---------- SCROLL-REVEAL — lead paragraph words clear up as it scrolls ----------
   JS wraps each word in a unit; a per-word --sr-p (0..1) is driven from the
   block's scroll position (0 = just entered bottom, 1 = cleared upper band).
   We interpolate opacity + blur from that progress with a per-word offset so
   words resolve left-to-right as the paragraph travels the viewport. */
.scrollreveal-split { /* don't clip the blurred glyph halos */
  overflow: visible;
}
.scrollreveal-unit {
  display: inline-block;
  white-space: pre;
  /* --sr-p is the per-word resolved progress (0..1), set inline by JS (rAF). */
  opacity: calc(0.3 + 0.7 * var(--sr-p, 0));
}
/* will-change only WHILE the paragraph is in the active (near-viewport) band;
   JS adds/removes .is-active so off-screen paragraphs hold no layer. */
.scrollreveal-split.is-active .scrollreveal-unit {
  will-change: opacity, filter;
}

/* ---------- Reduced motion: show everything fully, no transforms/blur ---------- */
@media (prefers-reduced-motion: reduce) {
  .scrollfloat-unit,
  .scrollfloat-split.is-floated .scrollfloat-unit {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
    will-change: auto !important;
  }
  .scrollreveal-unit {
    opacity: 1 !important;
    filter: none !important;
    will-change: auto !important;
  }
}

/* ---------- mx-fx (rotating-text + count-up + odometer) ---------- */
/* ============================================================
   mx-fx — three view-triggered number/text effects
   Namespaced .mx-fx-*  ·  transform/opacity only  ·  dark + light
   CSP-safe (no inline script/innerHTML)  ·  reduced-motion safe
   ============================================================ */

/* visually-hidden SR helper (namespaced; no collision with .sr-only) */
.mx-fx-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- 1. ROTATING TEXT --------------------------------------
   Inline word that up-slides + fades between words.
   The host word sits in a fixed-height clip; only one word is
   visible at a time. Purple serif display treatment. */
.mx-fx-rot {
  display: inline-flex;
  vertical-align: -0.2em;   /* align the rolling word's baseline with the static title text */
  position: relative;
  overflow: hidden;
  height: 1.08em;
  line-height: 1.08em;
  border-radius: .28em !important;   /* rounded pill — overflow:hidden clips the rolling word to this shape (beats the global sharp-corner reset) */
  transition: width 420ms cubic-bezier(.22,.61,.36,1);
  /* will-change is toggled in JS only while animating — not left on idle */
}
.mx-fx-rot__list {
  display: block;
  position: relative;
}
.mx-fx-rot__word {
  display: block;
  white-space: nowrap;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  /* solid mono-purple highlight block + white text; the word keeps square corners
     but the .mx-fx-rot container is rounded and clips it, so the visible pill is rounded */
  color: #fff;
  -webkit-text-fill-color: #fff;
  background: var(--purple);   /* deep brand indigo #33058d (was #7c3aed) */
  -webkit-background-clip: border-box;
  background-clip: border-box;
  padding: 0 0.32em;
  border-radius: 0;
  position: absolute;
  left: 0;
  top: 0;
  opacity: 1;
  transform: translateY(100%);   /* parked below; rolls up into view (no fade) */
  transition: transform 480ms cubic-bezier(.22,.61,.36,1);
  pointer-events: none;
}
.mx-fx-rot__word.is-in {            /* current — rolled into place */
  transform: translateY(0);
}
.mx-fx-rot__word.is-out {           /* leaving — rolls up and out (clipped) */
  transform: translateY(-100%);
}

/* Contrast-safe variant for small/body sizes:
   solid darker-purple fill (no gradient clip), passes AA on both themes.
   var(--purple) #a855f7 fails AA on white at body sizes, so the light
   override below uses a darkened purple. */
.mx-fx-rot--solid .mx-fx-rot__word {
  color: #fff;
  -webkit-text-fill-color: #fff;
}

/* light theme: keep white text on the purple pill (the pill supplies its own
   high-contrast background, so no per-theme darkening is needed). */
[data-theme="light"] .mx-fx-rot__word,
[data-theme="light"] .mx-fx-rot--solid .mx-fx-rot__word {
  color: #fff;
  -webkit-text-fill-color: #fff;
}

/* hero headline accent: block pill on its own centred line (keeps the line break) */
.hero h1 em.mx-fx-rot {
  display: block;
  width: fit-content;
  margin-inline: auto;
}

/* ---- 2. COUNT-UP -------------------------------------------
   Purely JS-driven on a text node; no structural CSS needed.
   tabular-nums keeps width steady so neighbours don't jitter. */
.mx-fx-count {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ---- 3. ODOMETER -------------------------------------------
   Each digit is a vertical 0-9 strip that translateY-rolls.
   Separators (, .) render as static glyphs between reels. */
.mx-fx-odo {
  display: inline-flex;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  line-height: 1;
}
.mx-fx-odo__prefix,
.mx-fx-odo__suffix,
.mx-fx-odo__sep {
  display: inline-block;
  white-space: pre;
}
.mx-fx-odo__reel {
  display: inline-block;
  position: relative;
  overflow: hidden;            /* clips the 10-cell strip to one digit row */
  height: 1em;
  width: 1ch;                  /* full tabular digit advance — avoids clipping
                                  centred glyphs on non-mono faces */
  min-width: 0.6em;            /* floor for narrow tabular fonts */
  vertical-align: baseline;
  text-align: center;
}
.mx-fx-odo__strip {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  transform: translateY(0);
  /* duration/easing + will-change are set inline per-digit while rolling;
     will-change is cleared on transitionend so reels aren't promoted idle */
}
.mx-fx-odo__cell {
  display: block;
  height: 1em;
  line-height: 1em;
  text-align: center;
}

/* ---- reduced-motion: everything resolves to final state ---- */
@media (prefers-reduced-motion: reduce) {
  .mx-fx-rot { transition: none !important; }
  .mx-fx-rot__word { transition: none !important; }
  .mx-fx-odo__strip {
    transition: none !important;
  }
}

/* ---------- animated-list ---------- */
/* ============================================================
   animated-list  —  staggered vertical feed (transform/opacity)
   Namespaced .alist-* ; composes with existing MeritX feed CSS.
   Honors prefers-reduced-motion. Edge-fade is OPT-IN (.alist--fade).
   ============================================================ */

.alist {
  --alist-fade: 22px;          /* height of the top/bottom soft fade   */
  --alist-stagger: 50ms;       /* delay between consecutive items      */
  --alist-dur: 320ms;          /* per-item enter duration              */
  --alist-rise: 14px;          /* translateY distance on enter         */
  --alist-hover-rise: -2px;    /* extra lift on hover (composes w/ host)*/
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Edge-fade mask is OPT-IN: it only makes sense on a SCROLLING list.
   The default MeritX .s-intelligence__feed / .s-news feeds do NOT scroll,
   so applying the mask unconditionally would permanently clip the first
   and last card by --alist-fade px (FIXED). Add .alist--fade only on a
   container you have given overflow-y:auto + a max-height. */
.alist--fade {
  overflow-y: auto;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 var(--alist-fade),
    #000 calc(100% - var(--alist-fade)),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 var(--alist-fade),
    #000 calc(100% - var(--alist-fade)),
    transparent 100%
  );
}

/* Item: starts hidden+offset, animates to resting state when .is-in is
   set by the observer. Transition is attached only via .is-in so resting
   items keep hover snappy. */
.alist__item {
  opacity: 0;
  transform: translate3d(0, var(--alist-rise), 0);
  transition:
    opacity var(--alist-dur) cubic-bezier(.22, 1, .36, 1),
    transform var(--alist-dur) cubic-bezier(.22, 1, .36, 1);
  transition-delay: var(--alist-delay, 0ms);
  border-radius: var(--r, 14px);
  will-change: opacity, transform;
}

.alist__item.is-in {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* Once enter settles, drop stagger delay + long enter durations so any
   host hover transition feels immediate. We do NOT redefine transform
   transition here so the host element's own hover (e.g. .s-intelligence__
   alert translateX) keeps its timing. */
.alist__item.is-settled {
  transition: transform 180ms ease-out;
  transition-delay: 0ms;
  will-change: auto;
}

/* Hover / focus highlight.
   IMPORTANT: we deliberately do NOT set `transform` here. The host card
   (.s-intelligence__alert:hover) already applies translateX(2px); a
   transform on a higher-specificity .alist selector would silently kill
   that lift (FIXED). Instead we only layer box-shadow + a custom-prop
   nudge the host can opt into, leaving the host transform authoritative. */
.alist__item.is-settled:hover,
.alist__item.is-settled:focus-visible,
.alist__item.is-settled:focus-within {
  box-shadow: var(--shadow-soft, 0 8px 30px -12px rgba(0, 0, 0, .5));
}

/* Keyboard focus ring for interactive items (those given tabindex/role) */
.alist__item:focus-visible {
  outline: 2px solid var(--accent, #3f7dfb);
  outline-offset: 2px;
}

/* Interactive items get a pointer + min 44px target for touch a11y */
.alist__item[role="button"],
.alist__item[tabindex] {
  cursor: pointer;
  min-height: 44px;
}

/* Prepended "new" item flash — brief accent ring that fades out.
   Driven by .alist__new which the JS adds then removes. Uses
   --accent-soft so it reads in both themes. */
.alist__item.alist__new {
  animation: alist-new var(--alist-dur) cubic-bezier(.22, 1, .36, 1);
}
@keyframes alist-new {
  0% {
    opacity: 0;
    transform: translate3d(0, calc(var(--alist-rise) * -1), 0) scale(.985);
    box-shadow: 0 0 0 1px var(--accent-soft, rgba(63, 125, 251, .14));
  }
  60% {
    box-shadow: 0 0 0 1px var(--accent-soft, rgba(63, 125, 251, .14));
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
    box-shadow: 0 0 0 1px transparent;
  }
}

/* ---------- Reduced motion: show everything, no transforms ---------- */
@media (prefers-reduced-motion: reduce) {
  .alist__item,
  .alist__item.is-in,
  .alist__item.is-settled {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    animation: none !important;
    transition-delay: 0ms !important;
  }
}

/* ---------- Touch / no-hover: don't depend on hover ---------- */
@media (hover: none) {
  .alist__item.is-settled:hover { box-shadow: none; }
}

/* ---------- fluid-glass ---------- */
/* =========================================================================
   FLUID GLASS — refined glassmorphism surface (CSS, no WebGL)
   Drop-in elevation for the fixed navbar + optional feature cards.
   Layers: themed translucent base · backdrop blur+saturate ·
           inset top highlight · brand-tinted edge · pointer-tracked sheen.
   Append AFTER the NAVBAR block in styles.css so .fluid-glass.nav wins
   the cascade over the original .nav background/backdrop-filter.
   ========================================================================= */
.fluid-glass {
  position: relative;
  isolation: isolate;                 /* keep pseudo-element layers local   */
  /* tweakables (override per instance) */
  --fg-blur: 16px;
  --fg-sat: 168%;
  --fg-tint: 70%;                     /* how much --bg shows through        */
  --fg-edge: var(--accent);          /* brand colour of the lit edge       */
  /* pointer position for the sheen (defaults = centred, idle)            */
  --fg-x: 50%;
  --fg-y: 0%;
  --fg-sheen: 0;                      /* 0 = idle, 1 = active (set by JS)   */

  background: color-mix(in srgb, var(--bg) var(--fg-tint), transparent);
  -webkit-backdrop-filter: saturate(var(--fg-sat)) blur(var(--fg-blur));
  backdrop-filter: saturate(var(--fg-sat)) blur(var(--fg-blur));
  border: 1px solid var(--border-strong);
}

/* graceful fallback: if backdrop-filter is unsupported, lean opaque so
   text contrast (>=4.5:1) is never at risk */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .fluid-glass { background: color-mix(in srgb, var(--bg) 94%, transparent); }
}

/* ---- Layer 1: inset top highlight (the "lit glass" edge) -------------- */
.fluid-glass::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
  /* a hairline of light along the top + a brand-tinted glow in the corner */
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.14) 0%,
      rgba(255, 255, 255, 0.04) 1px,
      transparent 38%
    ),
    radial-gradient(
      120% 90% at 0% 0%,
      color-mix(in srgb, var(--fg-edge) 22%, transparent) 0%,
      transparent 46%
    );
  /* render only on the border ring so the fill stays clean.
     FIXED: standard (unprefixed) mask + mask-composite added so the ring
     mask works in Firefox; previously only -webkit- was set, so FF filled
     the whole box. */
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  padding: 1px;
  opacity: 0.9;
}

/* ---- Layer 2: moving sheen (pointer-tracked, event-driven) ------------ */
.fluid-glass::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(
    180px 180px at var(--fg-x) var(--fg-y),
    rgba(255, 255, 255, 0.10) 0%,
    rgba(255, 255, 255, 0.04) 30%,
    transparent 65%
  );
  opacity: var(--fg-sheen);
  transition: opacity 0.32s ease-out;
}

/* default (idle) sheen stays off so the surface reads as clean glass
   when the pointer leaves (sheen is re-enabled on hover/focus-within) */
.fluid-glass:not(:hover):not(:focus-within) { --fg-sheen: 0; }

/* ---- Light theme: dial back the white film, lift the edge ------------- */
[data-theme="light"] .fluid-glass {
  --fg-tint: 64%;
  --fg-sat: 150%;
}
[data-theme="light"] .fluid-glass::before {
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.7) 0%,
      rgba(255, 255, 255, 0.25) 1px,
      transparent 40%
    ),
    radial-gradient(
      120% 90% at 0% 0%,
      color-mix(in srgb, var(--fg-edge) 16%, transparent) 0%,
      transparent 46%
    );
}
[data-theme="light"] .fluid-glass::after {
  background: radial-gradient(
    180px 180px at var(--fg-x) var(--fg-y),
    color-mix(in srgb, var(--fg-edge) 9%, transparent) 0%,
    transparent 62%
  );
}

/* ---- Navbar specialisation -------------------------------------------- */
/* Use alongside the existing .nav class. Replaces its flat backdrop with
   the fluid-glass treatment; the edge only fully appears once scrolled.
   FIXED: explicitly override the original .nav background + backdrop-filter
   here so the glass base wins regardless of source order, and re-add the
   .nav background/border transition so the edge fades (not snaps). */
.fluid-glass.nav {
  background: color-mix(in srgb, var(--bg) var(--fg-tint), transparent);
  border: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease, background 0.3s ease;
}
.fluid-glass.nav::before { opacity: 0; transition: opacity 0.3s ease; }
.fluid-glass.nav.scrolled { border-bottom-color: var(--border-strong); }
.fluid-glass.nav.scrolled::before { opacity: 0.9; }

/* ---- Feature-card specialisation (optional) --------------------------- */
.fluid-glass.fluid-glass--card {
  --fg-blur: 14px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-soft);
}

/* ---- Motion preference guard ------------------------------------------ */
/* Freeze the sheen to a static, gentle corner glint; no pointer tracking.
   The :not(:hover):not(:focus-within) reset above would zero the sheen, so
   FIXED: force it on with !important inside the reduced-motion block, and
   kill the opacity transition. */
@media (prefers-reduced-motion: reduce) {
  .fluid-glass {
    --fg-x: 18%;
    --fg-y: 0%;
  }
  .fluid-glass::after {
    opacity: 0.6 !important;
    transition: none;
  }
}

/* ---------- flowing-menu ---------- */
/* =========================================================================
   FLOWING MENU — restrained fintech "Explore" list
   On hover/focus a brand-gradient panel wipes in from the pointer's vertical
   direction; the label duplicates into a slow horizontal marquee strip.
   transform/opacity only · event-driven · reduced-motion safe.
   Namespaced .flowmenu-*  ·  drop-in, no collisions.
   ========================================================================= */

.flowmenu {
  position: relative;
  border-block: 1px solid var(--border);
  /* exposed knobs */
  --flowmenu-dur: 0.42s;
  --flowmenu-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --flowmenu-marquee-dur: 22s;
}

.flowmenu__list {
  display: block;
  list-style: none;     /* it is a <ul>; kill default markers/padding */
  margin: 0;
  padding: 0;
}

.flowmenu__item { position: relative; border-top: 1px solid var(--border); }
.flowmenu__item:first-child { border-top: 0; }

/* The real link — large, keyboard operable, >=44px touch target */
.flowmenu__link {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: clamp(16px, 2.6vw, 26px) clamp(16px, 2.4vw, 28px);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1.6rem, 4.4vw, 2.9rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--text-2);
  text-decoration: none;
  isolation: isolate;
  transition: color var(--flowmenu-dur) var(--flowmenu-ease);
}
.flowmenu__link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
  border-radius: var(--r-sm);
}

/* Trailing meta (count) sits in sans, muted. The arrow glyph is decorative
   and carried by a separate aria-hidden span in the markup. */
.flowmenu__meta {
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
  transition: color var(--flowmenu-dur) var(--flowmenu-ease),
              transform var(--flowmenu-dur) var(--flowmenu-ease);
}

/* ---- The gradient wipe panel ---- */
.flowmenu__panel {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--grad);
  /* default origin = from bottom; JS flips to top per pointer direction */
  transform: translateY(102%);
  opacity: 0;
  transition: transform var(--flowmenu-dur) var(--flowmenu-ease),
              opacity var(--flowmenu-dur) var(--flowmenu-ease);
}
.flowmenu__item[data-enter="top"] .flowmenu__panel { transform: translateY(-102%); }

/* Active (hover / focus) -> panel covers the row.
   will-change is applied ONLY while active so idle rows hold no compositor
   layers (no perpetual memory cost). */
.flowmenu__item.is-active .flowmenu__panel {
  transform: translateY(0);
  opacity: 1;
  will-change: transform;
}

/* When the panel is up, the static label fades so the marquee reads cleanly */
.flowmenu__item.is-active .flowmenu__label { opacity: 0; transform: translateY(-4px); }
.flowmenu__item.is-active .flowmenu__link  { color: #ffffff; }
.flowmenu__item.is-active .flowmenu__meta  { color: rgba(255, 255, 255, 0.82); transform: translateX(4px); }

.flowmenu__label {
  display: inline-block;
  transition: opacity calc(var(--flowmenu-dur) * 0.6) var(--flowmenu-ease),
              transform calc(var(--flowmenu-dur) * 0.6) var(--flowmenu-ease);
}

/* ---- Marquee strip (sits inside the panel) ---- */
.flowmenu__marquee {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--flowmenu-dur) var(--flowmenu-ease);
}
.flowmenu__item.is-active .flowmenu__marquee { opacity: 1; }

/* Track holds two identical groups -> seamless -50% loop */
.flowmenu__track {
  display: flex;
  flex: none;
  align-items: center;
  white-space: nowrap;
  animation: flowmenu-scroll var(--flowmenu-marquee-dur) linear infinite;
  animation-play-state: paused;            /* only runs while active */
}
.flowmenu__item.is-active .flowmenu__track {
  animation-play-state: running;
  will-change: transform;                  /* scoped to active only */
}

.flowmenu__group { display: flex; align-items: center; flex: none; }

.flowmenu__word {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1.6rem, 4.4vw, 2.9rem);
  line-height: 1;
  color: #ffffff;
  padding-inline: clamp(16px, 2.4vw, 28px);
}
/* small diamond separator between repeats */
.flowmenu__dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.6);
  transform: rotate(45deg);
}

@keyframes flowmenu-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ---- Light theme: keep white text on the gradient (gradient stays vivid) ---- */
[data-theme="light"] .flowmenu__item.is-active .flowmenu__link { color: #ffffff; }
[data-theme="light"] .flowmenu__item.is-active .flowmenu__meta { color: rgba(255, 255, 255, 0.86); }

/* ---- Reduced motion: no wipe travel, no marquee scroll, no label/meta shift.
   Panel still appears as a clean fade so the affordance survives. ---- */
@media (prefers-reduced-motion: reduce) {
  .flowmenu__panel {
    transform: none !important;
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  .flowmenu__item.is-active .flowmenu__panel { opacity: 1; }
  .flowmenu__track { animation: none !important; transform: none !important; }
  .flowmenu__label,
  .flowmenu__item.is-active .flowmenu__label { transition: opacity 0.2s ease; transform: none !important; }
  .flowmenu__item.is-active .flowmenu__meta  { transform: none !important; }
}

/* ---- Coarse pointer / no-hover: marquee is decorative; the link still works.
   The panel still wipes on tap-focus, so the affordance is preserved. ---- */
@media (hover: none) {
  .flowmenu__marquee { display: none; }
}

/* ---------- elastic-slider ---------- */
/* ============================================================================
   ELASTIC SLIDER — "Market cap filter" for the Stock Screener section
   Draggable range slider with spring/elastic overshoot: drag past either end
   and the TRACK stretches in the drag direction, then springs back.
   transform/opacity only · 150-420ms · reduced-motion-safe · keyboard + pointer
   Namespaced .elasticslider-*  ·  uses MeritX tokens (works dark + light)
   ============================================================================ */

.elasticslider {
  --es-track-h: 6px;
  --es-thumb: 22px;          /* visual thumb size */
  --es-spring: cubic-bezier(.34, 1.56, .64, 1);  /* slight overshoot */
  display: block;
  padding: 4px 2px 2px;
  font-family: var(--font-sans);
}

/* ---- Header: label + live value readout ------------------------------------ */
.elasticslider__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.elasticslider__label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.elasticslider__value {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  display: inline-block;     /* so scale transform applies cleanly */
  transform-origin: right center;
  /* a hair of motion when the value lands; transform only */
  transition: transform 0.18s var(--es-spring);
}
.elasticslider__value.is-bump { transform: scale(1.12); }

/* ---- Control row: end icons hug the rail ----------------------------------- */
.elasticslider__row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* end icons (min = small, max = big rupee). decorative; rail carries semantics */
.elasticslider__cap {
  flex: none;
  display: grid;
  place-items: center;
  color: var(--faint);
  transition: color 0.18s ease, transform 0.18s var(--es-spring);
  user-select: none;
  -webkit-user-select: none;
}
.elasticslider__cap svg { display: block; }
.elasticslider__cap--min svg { width: 13px; height: 13px; }
.elasticslider__cap--max svg { width: 19px; height: 19px; }
/* the cap on the side you're pushing past lights up + nudges */
.elasticslider__cap.is-active { color: var(--accent); }
.elasticslider__cap--min.is-active { transform: translateX(-2px); }
.elasticslider__cap--max.is-active { transform: translateX(2px); }

/* ---- The rail: focusable control + positioning context -------------------- */
.elasticslider__rail {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: var(--es-thumb);            /* tall hit zone */
  display: flex;
  align-items: center;
  cursor: grab;
  touch-action: none;                 /* we own the gesture; no scroll hijack */
}
.elasticslider__rail.is-grabbing { cursor: grabbing; }

/* visible track — THIS is the block that stretches ('elastic' feel).
   Kept separate from the thumb so the thumb never gets squished by scaleX. */
.elasticslider__track {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--es-track-h);
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  /* origin is set inline by JS to whichever end you're overshooting */
  transform-origin: center;
  transition: transform 0.42s var(--es-spring);
  will-change: transform;
}
.elasticslider__rail.is-dragging .elasticslider__track { transition: none; }

/* gradient fill from min -> thumb */
.elasticslider__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--grad);
  transform-origin: left center;
  transform: scaleX(0);               /* JS drives scaleX 0->1 */
  will-change: transform;
  transition: transform 0.42s var(--es-spring);
}
.elasticslider__rail.is-dragging .elasticslider__fill { transition: none; }

/* the thumb — sits on the rail (NOT inside the stretching track), so it stays
   a perfect circle. >=44px hit target via ::before, smaller visual dot */
.elasticslider__thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: var(--es-thumb);
  height: var(--es-thumb);
  border-radius: 50%;
  background: var(--bg-elev);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-soft);
  transform: translate(-50%, -50%);   /* JS sets left:%; this centres it */
  will-change: left;
  z-index: 2;
  transition: left 0.42s var(--es-spring), box-shadow 0.18s ease, transform 0.18s var(--es-spring);
}
.elasticslider__rail.is-dragging .elasticslider__thumb {
  transition: box-shadow 0.18s ease, transform 0.18s var(--es-spring);
}
/* invisible >=44px touch/click target centred on the thumb */
.elasticslider__thumb::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}
/* focus + active affordance (transform/opacity/shadow only) */
.elasticslider__rail:focus-visible {
  outline: none;                      /* replaced by the ring below */
}
.elasticslider__rail:focus-visible .elasticslider__thumb {
  box-shadow: var(--shadow-soft), 0 0 0 4px var(--accent-soft);
}
.elasticslider__rail.is-grabbing .elasticslider__thumb {
  transform: translate(-50%, -50%) scale(1.14);
}

/* ---- Footer scale ticks ---------------------------------------------------- */
.elasticslider__scale {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.66rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* ---- Reduced motion: plain slider, no overshoot / bump / stretch ----------- */
@media (prefers-reduced-motion: reduce) {
  .elasticslider__track,
  .elasticslider__fill,
  .elasticslider__thumb,
  .elasticslider__value,
  .elasticslider__cap {
    transition: none !important;
  }
  .elasticslider__track { transform: none !important; }      /* no stretch */
  .elasticslider__value.is-bump { transform: none !important; }
  .elasticslider__rail.is-grabbing .elasticslider__thumb {
    transform: translate(-50%, -50%) !important;             /* no scale pop */
  }
}
