/* ========================================================================
   apple-polish.css — Tier 1+2+3 layer for the Apple-redesign markup
   Loaded AFTER inline <style> in index.html. Surgical and additive.
   Honors prefers-reduced-motion AND localStorage.nf_anim=0 (via
   html[data-ap-anim="off"], set by apple-polish.js on boot).
   ======================================================================== */

/* ------------------------------------------------------------------
   1. Roaming mesh-blob background
   apple-polish.js injects <div class="ap-bg"> with 5 child .ap-blob
   divs into <body> on boot. They sit fixed behind everything (z-index
   below hero ::before aurora). Refraction comes from blobs drifting
   behind the glass tiles.
   ------------------------------------------------------------------ */
.ap-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}
.ap-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  will-change: transform;
  pointer-events: none;
}
.ap-blob.b1 {
  width: 780px; height: 780px;
  top: -240px; left: -160px;
  background: rgba(255, 106, 31, 0.16);
  animation: ap-drift-a 38s ease-in-out infinite alternate;
}
.ap-blob.b2 {
  width: 640px; height: 640px;
  bottom: -200px; right: -140px;
  background: rgba(255, 138, 61, 0.14);
  animation: ap-drift-b 44s ease-in-out infinite alternate;
}
.ap-blob.b3 {
  width: 560px; height: 560px;
  top: 35%; left: 55%;
  background: rgba(255, 90, 10, 0.10);
  animation: ap-drift-c 52s ease-in-out infinite alternate;
}
.ap-blob.b4 {
  width: 720px; height: 720px;
  top: 60%; left: -10%;
  background: rgba(255, 106, 31, 0.10);
  animation: ap-drift-d 60s ease-in-out infinite alternate;
}
.ap-blob.b5 {
  width: 480px; height: 480px;
  top: 12%; right: 18%;
  background: rgba(255, 138, 61, 0.10);
  animation: ap-drift-e 48s ease-in-out infinite alternate;
}
[data-theme="dark"] .ap-blob.b1 { background: rgba(255, 106, 31, 0.20); }
[data-theme="dark"] .ap-blob.b2 { background: rgba(255, 138, 61, 0.16); }
[data-theme="dark"] .ap-blob.b3 { background: rgba(255, 90, 10, 0.14); }
[data-theme="dark"] .ap-blob.b4 { background: rgba(255, 106, 31, 0.12); }
[data-theme="dark"] .ap-blob.b5 { background: rgba(255, 138, 61, 0.12); }

/* ------------------------------------------------------------------
   1b. Global Apple chrome correction
   Keeps every route on a compact CardsCloud-style rail while retaining
   the full mobile drawer and the payment CTA.
   ------------------------------------------------------------------ */
nav.bar {
  background: color-mix(in oklab, var(--surface, #fff) 82%, transparent) !important;
  border-bottom: 1px solid color-mix(in oklab, var(--hairline, rgba(0,0,0,.08)) 74%, transparent) !important;
}
[data-theme="dark"] nav.bar {
  background: color-mix(in oklab, var(--surface, #1d1d1f) 76%, transparent) !important;
}
.bar-inner {
  display: grid !important;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr) !important;
  align-items: center !important;
  gap: 28px !important;
}
.brand {
  justify-self: start;
  font-size: 15px !important;
  font-weight: 650 !important;
  letter-spacing: -0.02em !important;
}
.nav-links {
  justify-self: center;
  display: grid !important;
  grid-auto-flow: column !important;
  grid-auto-columns: minmax(82px, 1fr) !important;
  align-items: center !important;
  gap: 2px !important;
  width: clamp(430px, 42vw, 560px) !important;
  height: 54px !important;
  padding: 5px !important;
  border-radius: 999px !important;
  border: 1px solid color-mix(in oklab, var(--hairline, rgba(0,0,0,.08)) 72%, transparent) !important;
  background: color-mix(in oklab, var(--bg-elevated, #f5f5f7) 86%, transparent) !important;
  box-shadow: inset 0 1px 0 color-mix(in oklab, #fff 58%, transparent), 0 12px 30px -28px rgba(0,0,0,.30) !important;
  color: var(--ink-2, #6e6e73) !important;
  overflow: hidden !important;
  isolation: isolate !important;
  position: relative !important;
  transform: translateZ(0);
  --nav-eye-x: 5px;
  --nav-eye-y: 5px;
  --nav-eye-w: 86px;
  --nav-eye-h: 44px;
}
[data-theme="dark"] .nav-links {
  background: color-mix(in oklab, var(--surface-alt, #161617) 84%, transparent) !important;
  border-color: rgba(255,255,255,.08) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06) !important;
}
.nav-links li:nth-child(n+4) {
  display: flex !important;
}
.nav-links li {
  position: relative !important;
  z-index: 1 !important;
  min-width: 0 !important;
}
.nav-links a {
  width: 100% !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 14px !important;
  border-radius: 999px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  font-size: 14px !important;
  font-weight: 590 !important;
  line-height: 1 !important;
  letter-spacing: -0.012em !important;
  color: var(--ink-2, var(--text-dim, #424245)) !important;
  position: relative !important;
  z-index: 1 !important;
  background: transparent !important;
  box-shadow: none !important;
  transition:
    color .18s cubic-bezier(.32,.72,0,1),
    transform .18s cubic-bezier(.32,.72,0,1) !important;
}
.nav-links a .nav-link-icon,
.nav-links a .glyph {
  width: 15px !important;
  height: 15px !important;
  flex: 0 0 auto !important;
  opacity: .72 !important;
  stroke-width: 1.8 !important;
}
.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--ink, #1d1d1f) !important;
  background: transparent !important;
  box-shadow: none !important;
}
.nav-links a.active,
.nav-links a[aria-current="page"] {
  color: var(--ink, #1d1d1f) !important;
  background: transparent !important;
  box-shadow: none !important;
}
.nav-glass-eye {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--nav-eye-w);
  height: var(--nav-eye-h);
  border-radius: 999px;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transform: translate3d(var(--nav-eye-x), var(--nav-eye-y), 0);
  background:
    linear-gradient(135deg,
      color-mix(in oklab, var(--surface, #fff) 92%, transparent),
      color-mix(in oklab, var(--bg, #fff) 66%, transparent) 48%,
      color-mix(in oklab, var(--ink, #1d1d1f) 5%, transparent)),
    color-mix(in oklab, var(--surface, #fff) 82%, transparent);
  border: 1px solid color-mix(in oklab, var(--hairline, rgba(0,0,0,.08)) 48%, #fff 36%);
  box-shadow:
    inset 0 1px 1px color-mix(in oklab, #fff 92%, transparent),
    inset 0 -1px 1px color-mix(in oklab, var(--ink, #1d1d1f) 8%, transparent),
    0 1px 2px color-mix(in oklab, var(--ink, #1d1d1f) 8%, transparent),
    0 16px 34px -24px color-mix(in oklab, var(--ink, #1d1d1f) 40%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(190%) contrast(1.04);
  backdrop-filter: blur(18px) saturate(190%) contrast(1.04);
  transition:
    transform .56s cubic-bezier(.32,.72,0,1),
    width .56s cubic-bezier(.32,.72,0,1),
    height .56s cubic-bezier(.32,.72,0,1),
    opacity .18s cubic-bezier(.4,0,.2,1),
    box-shadow .26s cubic-bezier(.32,.72,0,1);
}
.nav-glass-eye::before,
.nav-glass-eye::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  pointer-events: none;
}
.nav-glass-eye::before {
  background:
    radial-gradient(120% 90% at 18% 0%,
      color-mix(in oklab, #fff 78%, transparent),
      transparent 48%),
    radial-gradient(90% 80% at 86% 100%,
      color-mix(in oklab, var(--selection, #007aff) 14%, transparent),
      transparent 62%);
  opacity: .72;
  mix-blend-mode: screen;
}
.nav-glass-eye::after {
  inset: auto 11px 4px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    color-mix(in oklab, #fff 72%, var(--selection, #007aff) 28%),
    transparent);
  opacity: .74;
}
.nav-links.has-glass-eye .nav-glass-eye {
  opacity: 1;
}
.nav-links.has-glass-eye.is-eye-hovered .nav-glass-eye {
  box-shadow:
    inset 0 1px 1px color-mix(in oklab, #fff 96%, transparent),
    inset 0 -1px 1px color-mix(in oklab, var(--ink, #1d1d1f) 9%, transparent),
    0 1px 2px color-mix(in oklab, var(--ink, #1d1d1f) 9%, transparent),
    0 20px 42px -26px color-mix(in oklab, var(--ink, #1d1d1f) 46%, transparent);
}
[data-theme="dark"] .nav-glass-eye {
  background:
    linear-gradient(135deg,
      color-mix(in oklab, #fff 12%, transparent),
      color-mix(in oklab, var(--surface, #1d1d1f) 70%, transparent) 52%,
      color-mix(in oklab, #fff 8%, transparent)),
    color-mix(in oklab, var(--surface, #1d1d1f) 74%, transparent);
  border-color: color-mix(in oklab, #fff 16%, var(--hairline, rgba(255,255,255,.12)));
  box-shadow:
    inset 0 1px 1px color-mix(in oklab, #fff 18%, transparent),
    inset 0 -1px 1px color-mix(in oklab, #000 70%, transparent),
    0 1px 2px rgba(0,0,0,.34),
    0 20px 38px -24px rgba(0,0,0,.72);
}
@media (prefers-reduced-motion: reduce) {
  .nav-glass-eye {
    transition: opacity .12s ease !important;
  }
}
.bar-right {
  justify-self: end !important;
}
.bar-right .cta,
.bar-right .nav-cta,
.nav-cta {
  background: #007aff !important;
  color: #fff !important;
  border-radius: 999px !important;
  min-height: 44px !important;
  padding: 0 22px !important;
  box-shadow: 0 16px 36px -20px rgba(0,122,255,.70) !important;
}
@media (max-width: 860px) {
  .bar-inner {
    grid-template-columns: minmax(0,1fr) auto !important;
    gap: 16px !important;
  }
  .nav-links {
    display: none !important;
  }
  .hamburger {
    display: inline-flex !important;
  }
}

@keyframes ap-drift-a {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(80px, 60px) scale(1.12); }
  100% { transform: translate(40px, -50px) scale(0.96); }
}
@keyframes ap-drift-b {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(-90px, -70px) scale(1.08); }
  100% { transform: translate(50px, 40px) scale(0.94); }
}
@keyframes ap-drift-c {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(-120px, 80px) scale(1.10); }
  66%  { transform: translate(60px, -90px) scale(0.92); }
  100% { transform: translate(20px, 30px) scale(1.04); }
}
@keyframes ap-drift-d {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(100px, -120px) scale(1.16); }
  100% { transform: translate(-60px, 50px) scale(0.90); }
}
@keyframes ap-drift-e {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(-70px, 90px) scale(1.06); }
  100% { transform: translate(80px, -40px) scale(0.98); }
}

/* ------------------------------------------------------------------
   2. Liquid-glass surfaces — ONE rule, applied via .ap-glass class.
   apple-polish.js scans every page for known card/tile/panel classes
   and adds .ap-glass to them. Per-page class names live in JS only —
   CSS stays maintainable.

   Backdrop-filter requires a semi-transparent background. We lower
   the surface to ~62% alpha and let the drifting blobs glow through.
   Theme-aware via [data-theme] descendant selectors.
   ------------------------------------------------------------------ */
.ap-glass {
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  position: relative;
  isolation: isolate;
}
[data-theme="light"] .ap-glass {
  background: rgba(255, 255, 255, 0.62);
  border-color: rgba(0, 0, 0, 0.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.80),
    0 2px 6px rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .ap-glass:hover {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(0, 0, 0, 0.10);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 12px 32px rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .ap-glass {
  background: rgba(29, 29, 31, 0.55);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 2px 6px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .ap-glass:hover {
  background: rgba(29, 29, 31, 0.68);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    0 16px 40px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(255, 106, 31, 0.10);
}
/* Hero pricing card + auth card variants — accent halo for emphasis */
[data-theme="light"] .ap-glass.ap-glass-accent {
  background: rgba(255, 255, 255, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 16px 48px rgba(0, 0, 0, 0.08),
    0 0 80px rgba(255, 106, 31, 0.12);
}
[data-theme="dark"] .ap-glass.ap-glass-accent {
  background: rgba(29, 29, 31, 0.62);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 24px 64px rgba(0, 0, 0, 0.5),
    0 0 80px rgba(255, 106, 31, 0.18);
}
/* Device variant — slightly more opaque, no hover */
[data-theme="light"] .ap-glass.ap-glass-device { background: rgba(255, 255, 255, 0.75); }
[data-theme="dark"]  .ap-glass.ap-glass-device { background: rgba(29, 29, 31, 0.62); }

/* ------------------------------------------------------------------
   3. Streaming shimmer on .bubble.them (the bot bubble)
   nf-ai.js adds .loaded when streaming completes — until then we mark
   the bubble with .ap-streaming and overlay a gradient sweep + caret.
   ------------------------------------------------------------------ */
.bubble.them { position: relative; }
.bubble.them.ap-streaming::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(255, 106, 31, 0.28) 50%,
    transparent 70%
  );
  background-size: 220% 100%;
  animation: ap-shimmer-sweep 1.8s linear infinite;
  pointer-events: none;
  mix-blend-mode: plus-lighter;
}
[data-theme="light"] .bubble.them.ap-streaming::before {
  background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(255, 106, 31, 0.22) 50%,
    transparent 70%
  );
  background-size: 220% 100%;
  mix-blend-mode: multiply;
}
.bubble.them.ap-streaming::after {
  content: '';
  display: inline-block;
  width: 2px; height: 1em;
  margin-left: 4px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: ap-caret-blink 0.9s steps(2, end) infinite;
  border-radius: 1px;
}
@keyframes ap-shimmer-sweep {
  0%   { background-position: 220% 0; }
  100% { background-position: -120% 0; }
}
@keyframes ap-caret-blink {
  0%, 50%  { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ------------------------------------------------------------------
   4. Count-up styling
   Reserve tabular space, prevent layout jitter while numbers tick.
   ------------------------------------------------------------------ */
[data-countup] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  display: inline-block;
  min-width: 1ch;
}

/* ------------------------------------------------------------------
   5. Sheen sweep on cost bars when they fill
   The existing CSS already grows .row-fill from 0 to var(--w) on
   .row.in. We add a one-shot sheen across the fill on reveal.
   ------------------------------------------------------------------ */
.row.in .row-fill { position: relative; overflow: hidden; }
.row.in .row-fill::after {
  content: '';
  position: absolute;
  top: 0; left: -40%;
  width: 40%; height: 100%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 255, 255, 0.40) 50%,
    transparent 100%
  );
  animation: ap-bar-sheen 1.8s ease-out 0.6s 1 forwards;
}
@keyframes ap-bar-sheen {
  0%   { left: -40%; opacity: 0; }
  20%  { opacity: 1; }
  100% { left: 110%;  opacity: 0; }
}

/* ------------------------------------------------------------------
   6. Gradient drift on hero accent + price number
   Apple keynote trick: subtle slow gradient position shift.
   ------------------------------------------------------------------ */
h1.display .accent {
  background: linear-gradient(
    160deg,
    #ff8a3d 0%,
    #ff5a0a 40%,
    #ff8a3d 80%
  );
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: ap-gradient-drift 9s ease-in-out infinite alternate;
}
.price-num [data-countup] {
  background: linear-gradient(
    120deg,
    var(--accent) 0%,
    #ff8a3d 50%,
    var(--accent) 100%
  );
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: ap-gradient-drift 8s ease-in-out infinite alternate;
}
@keyframes ap-gradient-drift {
  0%   { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

/* ------------------------------------------------------------------
   7. Icon morph on hover — works on any glass surface with an eyebrow
   ------------------------------------------------------------------ */
.ap-glass .tile-eyebrow .glyph,
.ap-glass .glyph.ap-icon,
.tile .tile-eyebrow .glyph {
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
              stroke 0.3s, filter 0.3s;
  transform-origin: center;
}
.ap-glass:hover .tile-eyebrow .glyph,
.ap-glass:hover .glyph.ap-icon,
.tile:hover .tile-eyebrow .glyph {
  transform: scale(1.22) rotate(-4deg);
  stroke: var(--accent);
  filter: drop-shadow(0 0 10px rgba(255, 106, 31, 0.45));
}

/* ------------------------------------------------------------------
   8d. PWA install pill — appears when beforeinstallprompt fires
   ------------------------------------------------------------------ */
/* Floating elements respect the tinyblue network-bar at bottom.
   --ap-bottom-base is set by apple-polish.js after measuring the
   network-bar. Falls back to safe-area when no bar present. */
:root {
  --ap-bottom-base: max(22px, env(safe-area-inset-bottom, 22px));
  /* JS sets --ap-totop-clear based on which floaters (install, ticker)
     sit below back-to-top. 0 = neither, 56 = one (desktop), 60 = one
     (mobile), 120 = both stacked (mobile). */
  --ap-totop-clear: 0px;
}
.ap-install {
  position: fixed;
  right: 22px;
  bottom: var(--ap-bottom-base);
  z-index: 8500;
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.011em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 16px 40px rgba(0, 0, 0, 0.10);
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.45s var(--ease-spring, ease), transform 0.45s var(--ease-spring, ease);
}
[data-theme="dark"] .ap-install {
  background: rgba(29, 29, 31, 0.86);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 16px 40px rgba(0, 0, 0, 0.5);
}
.ap-install.show { display: flex; opacity: 1; transform: translateY(0) scale(1); }
.ap-install-icon { color: var(--accent); display: inline-flex; }
.ap-install-icon .glyph { width: 14px; height: 14px; }
.ap-install-cta {
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  border: 0;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s, transform 0.25s;
}
.ap-install-cta:hover { background: var(--accent-press, var(--accent)); transform: translateY(-1px); }
.ap-install-close {
  width: 28px; height: 28px;
  border: 0; background: transparent; color: var(--ink-3);
  cursor: pointer; font-size: 14px; padding: 0;
  border-radius: 50%;
}
.ap-install-close:hover { color: var(--ink); background: rgba(0, 0, 0, 0.05); }
[data-theme="dark"] .ap-install-close:hover { background: rgba(255, 255, 255, 0.08); }
@media (max-width: 640px) {
  /* Full-width pill — but stay anchored to --ap-bottom-base so we sit
     ABOVE the tinyblue cross-site bar, not under it. */
  .ap-install {
    left: 12px;
    right: 12px;
    bottom: var(--ap-bottom-base);
    justify-content: space-between;
  }
}

/* ------------------------------------------------------------------
   8e. Skip-to-main link — visible only when keyboard-focused
   ------------------------------------------------------------------ */
.ap-skip-link {
  position: fixed;
  top: 12px; left: 12px;
  z-index: 9999;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.011em;
  text-decoration: none;
  box-shadow: 0 12px 28px -10px rgba(255, 106, 31, 0.5);
  transform: translateY(-180%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s var(--ease-spring, ease), opacity 0.2s ease;
}
.ap-skip-link:not(:focus):not(:focus-visible) {
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  box-shadow: none;
}
.ap-skip-link:focus,
.ap-skip-link:focus-visible {
  width: auto;
  height: auto;
  padding: 10px 18px;
  clip-path: none;
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
  color: #fff;
  outline: 2px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 12px 28px -10px rgba(255, 106, 31, 0.5);
}

/* ------------------------------------------------------------------
   8h1. Chat input focus glow — iMessage-style soft halo around the
   input pill when the user is typing. Also applies to the auth/
   meal text inputs for consistent feel.
   ------------------------------------------------------------------ */
.chat-input-stub,
#nf-hero-input {
  transition: box-shadow 0.3s var(--ease, ease), background 0.25s ease;
}
#nf-hero-input:focus,
#nf-hero-input:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(255, 106, 31, 0.18),
    0 4px 12px -2px rgba(255, 106, 31, 0.25);
  background: rgba(255, 255, 255, 0.85);
}
[data-theme="dark"] #nf-hero-input:focus,
[data-theme="dark"] #nf-hero-input:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  box-shadow:
    0 0 0 3px rgba(255, 106, 31, 0.22),
    0 4px 16px -2px rgba(255, 106, 31, 0.3);
}
.chat-input-send {
  transition: transform 0.18s var(--ease-spring, ease),
              background 0.18s ease, box-shadow 0.25s ease;
}
.chat-input-send:hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 6px 14px -4px rgba(255, 106, 31, 0.55);
}
.chat-input-send:active {
  transform: translateY(0) scale(0.96);
}

/* ------------------------------------------------------------------
   8h2. Empty-state breathing illustrations (Apple-style alive empty)
   The .empty-illo blocks (e.g., leaderboard's "no athletes yet") get
   a soft breathing scale + ambient glow ring. Reduces the "broken /
   inert" feel of empty pages.
   ------------------------------------------------------------------ */
.empty-illo {
  position: relative;
  animation: ap-empty-breathe 4.4s ease-in-out infinite;
}
.empty-illo::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 24px;
  background: radial-gradient(
    closest-side,
    rgba(255, 106, 31, 0.18),
    transparent 70%
  );
  z-index: -1;
  animation: ap-empty-aura 4.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes ap-empty-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}
@keyframes ap-empty-aura {
  0%, 100% { opacity: 0.5; transform: scale(0.95); }
  50%      { opacity: 1;   transform: scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
  .empty-illo,
  .empty-illo::before {
    animation: none !important;
  }
}

/* ------------------------------------------------------------------
   8i. Toast notifications — glass pill that slides in from top
   ------------------------------------------------------------------ */
.ap-toast-stack {
  position: fixed;
  top: 86px; /* below nav (72px) + 14px gap */
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 24px));
}
.ap-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 14px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.011em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 16px 40px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: translateY(-12px) scale(0.96);
  transition: opacity 0.35s var(--ease-spring, ease), transform 0.35s var(--ease-spring, ease);
  pointer-events: auto;
}
[data-theme="dark"] .ap-toast {
  background: rgba(29, 29, 31, 0.86);
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 16px 40px rgba(0, 0, 0, 0.55);
}
.ap-toast.show { opacity: 1; transform: translateY(0) scale(1); }
.ap-toast-icon { display: inline-flex; color: var(--accent); }
.ap-toast-icon .glyph { width: 16px; height: 16px; }
.ap-toast.ap-toast-success .ap-toast-icon { color: #22c55e; }
.ap-toast.ap-toast-error .ap-toast-icon { color: #ef4444; }
.ap-toast.ap-toast-warning .ap-toast-icon { color: #f59e0b; }

/* ------------------------------------------------------------------
   8h. Sparkline charts (Apple Health style)
   apple-polish.js renders an SVG inside any element with a
   data-spark="n1,n2,n3,..." attribute. Path draws on via
   stroke-dasharray; gradient fill underneath fades in after the draw.
   ------------------------------------------------------------------ */
.ap-spark {
  display: block;
  width: 100%;
  margin-top: 10px;
  overflow: visible;
}
.ap-spark-path {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ap-spark-area { transition: opacity 0.5s ease 0.3s; opacity: 0; }
.ap-spark.ap-spark-drawn .ap-spark-path {
  stroke-dashoffset: 0 !important;
}
.ap-spark.ap-spark-drawn .ap-spark-area { opacity: 1; }
.ap-spark-path {
  transition: stroke-dashoffset 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.ap-spark-dot {
  transition: opacity 0.3s ease 1s, r 0.4s var(--ease-spring, ease) 1s;
  opacity: 0;
  r: 0;
}
.ap-spark.ap-spark-drawn .ap-spark-dot { opacity: 1; r: 3; }
@media (prefers-reduced-motion: reduce) {
  .ap-spark-path { transition: none !important; }
  .ap-spark-area { transition: none !important; }
  .ap-spark-dot { transition: none !important; }
}

/* ------------------------------------------------------------------
   8g. Back-to-top floating button — glass pill bottom-right that
        appears past hero. Smooth-scroll to top on click.
   ------------------------------------------------------------------ */
.ap-totop {
  position: fixed;
  right: 22px;
  /* Sits above whatever stack of install/ticker is below it. JS sets
     --ap-totop-clear based on current floater stack (see initBottomSafeZone). */
  bottom: calc(var(--ap-bottom-base) + var(--ap-totop-clear, 0px));
  z-index: 7000; /* below ticker (8000) and install (8500) */
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--hairline);
  color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.80),
    0 12px 28px -10px rgba(0, 0, 0, 0.20);
  opacity: 0;
  transform: translateY(20px) scale(0.92);
  pointer-events: none;
  transition: opacity 0.35s var(--ease, ease), transform 0.35s var(--ease-spring, ease),
              background 0.2s, border-color 0.2s, color 0.2s;
}
[data-theme="dark"] .ap-totop {
  background: rgba(29, 29, 31, 0.82);
  border-color: rgba(255, 255, 255, 0.10);
  color: var(--ink-2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 12px 28px -10px rgba(0, 0, 0, 0.55);
}
.ap-totop.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.ap-totop:hover { border-color: var(--accent); color: var(--accent); }
.ap-totop .glyph { width: 18px; height: 18px; stroke-width: 2; }
/* Back-to-top vertical offset is purely driven by --ap-totop-clear which
   apple-polish.js writes based on which floaters (install + ticker) are
   currently visible and the current viewport width. No breakpoint rules
   needed — JS does the math. */

/* ------------------------------------------------------------------
   8f. Leaderboard row + podium entrance animations
   The leaderboard JS populates tbody and podium cards dynamically.
   CSS animations fire when each element is appended; staggered
   via :nth-child so rows cascade in like Apple's data displays.
   ------------------------------------------------------------------ */
.rankings-table tbody tr {
  opacity: 0;
  transform: translateY(8px);
  animation: ap-row-in 0.5s var(--ease-spring, cubic-bezier(0.32, 0.72, 0, 1)) forwards;
}
.rankings-table tbody tr:nth-child(1)  { animation-delay: 0.04s; }
.rankings-table tbody tr:nth-child(2)  { animation-delay: 0.08s; }
.rankings-table tbody tr:nth-child(3)  { animation-delay: 0.12s; }
.rankings-table tbody tr:nth-child(4)  { animation-delay: 0.16s; }
.rankings-table tbody tr:nth-child(5)  { animation-delay: 0.20s; }
.rankings-table tbody tr:nth-child(6)  { animation-delay: 0.24s; }
.rankings-table tbody tr:nth-child(7)  { animation-delay: 0.28s; }
.rankings-table tbody tr:nth-child(8)  { animation-delay: 0.32s; }
.rankings-table tbody tr:nth-child(9)  { animation-delay: 0.36s; }
.rankings-table tbody tr:nth-child(10) { animation-delay: 0.40s; }
@keyframes ap-row-in {
  to { opacity: 1; transform: translateY(0); }
}

.pod-1, .pod-2, .pod-3 {
  opacity: 0;
  transform: translateY(14px);
  animation: ap-pod-in 0.6s var(--ease-spring, cubic-bezier(0.32, 0.72, 0, 1)) forwards;
}
.pod-2 { animation-delay: 0.10s; }
.pod-1 { animation-delay: 0.20s; }  /* gold last for emphasis */
.pod-3 { animation-delay: 0.05s; }
@keyframes ap-pod-in {
  to { opacity: 1; transform: translateY(var(--pod-y, 0)); }
}
/* Pod-1 already has translateY(-12px) baseline; preserve it */
.pod-1 { --pod-y: -12px; }

@media (prefers-reduced-motion: reduce) {
  .rankings-table tbody tr,
  .pod-1, .pod-2, .pod-3 {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ------------------------------------------------------------------
   9. Live activity ticker (Tier 3) — bottom-left glass pill
   ------------------------------------------------------------------ */
.ap-ticker {
  position: fixed;
  left: 22px;
  bottom: var(--ap-bottom-base);
  z-index: 8000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 14px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--hairline);
  border-radius: 980px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 16px 40px rgba(0, 0, 0, 0.10);
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.45s var(--ease-spring), transform 0.45s var(--ease-spring);
  pointer-events: none;
  max-width: min(420px, calc(100vw - 44px));
}
[data-theme="dark"] .ap-ticker {
  background: rgba(29, 29, 31, 0.82);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 16px 40px rgba(0, 0, 0, 0.5);
}
.ap-ticker.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.ap-ticker-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  flex-shrink: 0;
  animation: ap-ticker-pulse 1.6s ease-in-out infinite;
}
@keyframes ap-ticker-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.6; transform: scale(1.3); }
}
.ap-ticker-icon {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
}
.ap-ticker-icon .glyph {
  width: 14px; height: 14px;
  stroke-width: 1.8;
}
.ap-ticker-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 640px) {
  /* Full-width — but stay anchored to --ap-bottom-base so we sit above
     the tinyblue bar. When install pill is visible, ticker stacks ABOVE
     the install pill (install pill is ~44-52px tall on mobile, give 60). */
  .ap-ticker {
    left: 12px;
    right: 12px;
    bottom: var(--ap-bottom-base);
    max-width: none;
  }
  html[data-ap-install-visible] .ap-ticker {
    bottom: calc(var(--ap-bottom-base) + 60px);
  }
}

/* ------------------------------------------------------------------
   8b. Hover lens — accent-tinted radial glow that follows the cursor
       across any .ap-glass surface. apple-polish.js sets the
       --ap-lens-x / --ap-lens-y CSS vars (in % of the element box)
       on mousemove; ::after renders the gradient.
       Disabled on touch devices via @media (hover: none).
   ------------------------------------------------------------------ */
.ap-glass { /* set vars defaults so non-hover renders are stable */
  --ap-lens-x: 50%;
  --ap-lens-y: 50%;
  --ap-lens-opacity: 0;
}
.ap-glass::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
  opacity: var(--ap-lens-opacity);
  background: radial-gradient(
    180px circle at var(--ap-lens-x) var(--ap-lens-y),
    rgba(255, 106, 31, 0.18),
    transparent 70%
  );
  transition: opacity 0.4s var(--ease, ease);
  mix-blend-mode: plus-lighter;
}
[data-theme="light"] .ap-glass::after {
  mix-blend-mode: multiply;
  background: radial-gradient(
    180px circle at var(--ap-lens-x) var(--ap-lens-y),
    rgba(255, 106, 31, 0.14),
    transparent 70%
  );
}
.ap-glass > * { position: relative; z-index: 1; }
@media (hover: none) {
  .ap-glass::after { display: none; }
}

/* ------------------------------------------------------------------
   9. Scroll progress hairline (apple.com docs pages style)
   apple-polish.js sets --ap-progress (0..1) as the page scrolls.
   The bar is positioned ABOVE the nav (z-index above 1000) so it's
   always visible.
   ------------------------------------------------------------------ */
.ap-scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 100%;
  z-index: 1101; /* above nav.bar (1000) and ap-buybar (1100) */
  background: transparent;
  pointer-events: none;
}
.ap-scroll-progress::before {
  content: '';
  display: block;
  height: 100%;
  width: calc(var(--ap-progress, 0) * 100%);
  background: linear-gradient(90deg,
    var(--accent, #ff6a1f) 0%,
    #ff8a3d 50%,
    var(--accent, #ff6a1f) 100%
  );
  background-size: 200% 100%;
  box-shadow: 0 0 8px rgba(255, 106, 31, 0.55);
  transition: width 0.05s linear;
}

/* ------------------------------------------------------------------
   10. Custom focus-visible ring (accessible + Apple-grade)
   Keyboard nav now shows a soft accent halo. Mouse clicks don't.
   Uses :focus-visible (not :focus) to avoid the click-flash.
   ------------------------------------------------------------------ */
*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--accent, #ff6a1f);
  outline-offset: 3px;
  border-radius: 6px;
  box-shadow: 0 0 0 4px rgba(255, 106, 31, 0.18);
  transition: outline-offset 0.15s var(--ease, ease), box-shadow 0.15s var(--ease, ease);
}
/* Buttons / links already round — bigger offset feels nicer */
.btn:focus-visible,
.cta:focus-visible,
.nav-cta:focus-visible,
a:focus-visible {
  outline-offset: 4px;
}

/* ------------------------------------------------------------------
   8c. Apple Watch-style ring animations
   Rings with class .ring-fill + data-percent are tagged by JS with
   stroke-dasharray = circumference and stroke-dashoffset = full
   circumference initially. On reveal we transition to the target
   offset. Stroke-linecap: round already in markup gives the rounded
   end. We add a soft drop-shadow that fades in at completion for
   the Apple Watch "glow at goal" feel.
   ------------------------------------------------------------------ */
.ring-fill.ap-ring-init {
  transition: stroke-dashoffset 1.4s cubic-bezier(0.22, 1, 0.36, 1),
              filter 0.6s ease;
  filter: drop-shadow(0 0 0 transparent);
}
.ring-fill.ap-ring-init.ap-ring-done {
  filter: drop-shadow(0 0 4px currentColor);
}
@media (prefers-reduced-motion: reduce) {
  .ring-fill.ap-ring-init { transition: none !important; }
}

/* ------------------------------------------------------------------
   10b. Page-load fade-in — entire content gently appears (Apple)
   apple-polish.js adds html.ap-loaded body after DOMContentLoaded fires
   plus a microtask. Avoids the FOUC flash and gives every route a
   consistent entrance.
   ------------------------------------------------------------------ */
html:not(.ap-loaded) body main,
html:not(.ap-loaded) body .hero,
html:not(.ap-loaded) body section.bay,
html:not(.ap-loaded) body .endcap,
html:not(.ap-loaded) body footer.foot {
  opacity: 0;
  transform: translateY(8px);
}
html.ap-loaded body main,
html.ap-loaded body .hero,
html.ap-loaded body section.bay,
html.ap-loaded body .endcap,
html.ap-loaded body footer.foot {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.6s var(--ease, ease), transform 0.6s var(--ease-spring, ease);
}
@media (prefers-reduced-motion: reduce) {
  html:not(.ap-loaded) body main,
  html:not(.ap-loaded) body .hero,
  html:not(.ap-loaded) body section.bay,
  html:not(.ap-loaded) body .endcap,
  html:not(.ap-loaded) body footer.foot {
    opacity: 1;
    transform: none;
  }
}

/* ------------------------------------------------------------------
   11. View Transitions API — Apple-style cross-page nav
   Browsers that support @view-transition (Chromium 126+) get a
   subtle cross-fade between same-origin navigations. Safe no-op
   elsewhere.
   ------------------------------------------------------------------ */
@view-transition {
  navigation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.35s;
  animation-timing-function: var(--ease-spring, cubic-bezier(0.32, 0.72, 0, 1));
}

/* ------------------------------------------------------------------
   Reduced-motion + user-disabled animations: kill everything dynamic
   ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .ap-blob,
  h1.display .accent,
  .price-num [data-countup],
  .bubble.them.ap-streaming::before,
  .bubble.them.ap-streaming::after,
  .row.in .row-fill::after,
  .ap-ticker-dot {
    animation: none !important;
  }
  .ap-ticker { transition: none !important; }
}
html[data-ap-anim="off"] .ap-blob,
html[data-ap-anim="off"] h1.display .accent,
html[data-ap-anim="off"] .price-num [data-countup],
html[data-ap-anim="off"] .bubble.them.ap-streaming::before,
html[data-ap-anim="off"] .bubble.them.ap-streaming::after,
html[data-ap-anim="off"] .row.in .row-fill::after,
html[data-ap-anim="off"] .ap-ticker-dot {
  animation: none !important;
}
html[data-ap-anim="off"] .ap-ticker,
html[data-ap-anim="off"] .ap-scroll-progress::before { transition: none !important; }
