/* Home flair: an additive, decorative-only motion layer.
   - Never changes layout, copy or sizes: only pseudo-elements, `translate`/`scale`/`opacity`.
   - Every animation is gated on html.motion-ok (no reduced-motion) and body:not(.motion-paused),
     so the existing "Pause motion" control and the OS setting both switch it all off.
   - Hero loops only run while the hero is on screen (body.hero-motion-active). */
.home-page { --flair-rgb: 213, 16, 54; }

/* ---------- 1. Reading progress hairline ---------- */
.page-progress {
  position: fixed; z-index: 70; inset: 0 0 auto 0; height: 3px; pointer-events: none;
  transform-origin: 0 50%; transform: scaleX(var(--page-p, 0)); opacity: 0;
  background: linear-gradient(90deg, #ff6a85, #d30a35 55%, #8c0a1e);
  box-shadow: 0 0 10px rgba(var(--flair-rgb, 213, 16, 54), .35);
}
.page-progress.is-on { opacity: 1; transition: opacity .3s; }

/* ---------- 2. Hero: ambient drifting light + sonar ring on each heartbeat ---------- */
html.motion-ok body.home-page:not(.motion-paused) .hero > .container { z-index: 1; }
html.motion-ok body.home-page:not(.motion-paused) .hero::before,
html.motion-ok body.home-page:not(.motion-paused) .hero::after {
  content: ""; position: absolute; z-index: 0; pointer-events: none; border-radius: 50%;
  width: clamp(320px, 42vw, 620px); aspect-ratio: 1; animation-play-state: paused;
}
html.motion-ok body.home-page:not(.motion-paused) .hero::before {
  top: -24%; left: -10%;
  background: radial-gradient(circle, rgba(110, 150, 215, .17), transparent 68%);
  animation: flair-drift-a 24s ease-in-out infinite alternate;
}
html.motion-ok body.home-page:not(.motion-paused) .hero::after {
  right: -8%; bottom: -32%;
  background: radial-gradient(circle, rgba(var(--flair-rgb), .10), transparent 68%);
  animation: flair-drift-b 28s ease-in-out infinite alternate;
}
html.motion-ok body.home-page.hero-motion-active:not(.motion-paused) .hero::before,
html.motion-ok body.home-page.hero-motion-active:not(.motion-paused) .hero::after { animation-play-state: running; }

html.motion-ok body.home-page.motion-ready:not(.motion-paused) .hero__art::after {
  content: ""; position: absolute; z-index: 0; pointer-events: none; border-radius: 50%;
  left: var(--ring-x, 39%); top: var(--ring-y, 50%); width: 64%; aspect-ratio: 1;
  border: 1.5px solid rgba(var(--flair-rgb), .5);
  box-shadow: 0 0 0 10px rgba(var(--flair-rgb), .05), inset 0 0 22px rgba(var(--flair-rgb), .08);
  translate: -50% calc(-50% + var(--hp, 0) * -.045px); scale: .55; opacity: 0;
  /* Starts at the "lub" of the existing heartbeat (same .92s cycle, .2s delay), once every three beats. */
  animation: flair-sonar calc(var(--heartbeat-cycle) * 3) calc(.2s + var(--heartbeat-cycle) * .14) cubic-bezier(.2, .6, .3, 1) infinite;
  animation-play-state: paused;
}
html.motion-ok body.home-page.hero-motion-active:not(.motion-paused) .hero__art::after { animation-play-state: running; }

/* ---------- 3. Hero depth: image, trace and chips drift at different speeds on scroll ---------- */
html.motion-ok body.home-page:not(.motion-paused) .hero__art > img,
html.motion-ok body.home-page:not(.motion-paused) .hero-ecg { translate: 0 calc(var(--hp, 0) * -.045px); will-change: translate; }
html.motion-ok body.home-page:not(.motion-paused) .hero__chip--1 { translate: 0 calc(var(--hp, 0) * -.09px); }
html.motion-ok body.home-page:not(.motion-paused) .hero__chip--2 { translate: 0 calc(var(--hp, 0) * -.06px); }
html.motion-ok body.home-page:not(.motion-paused) .hero__chip--3 { translate: 0 calc(var(--hp, 0) * -.125px); }

/* ---------- 4. Headline accent: a slow light sweep (same colour at rest) ---------- */
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  html.motion-ok body.home-page:not(.motion-paused) .hero h1 > span {
    background: linear-gradient(100deg, var(--red-700, #a70b2b) 0 42%, #ff6a85 50%, var(--red-700, #a70b2b) 58% 100%) 100% 0 / 260% 100% no-repeat;
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    animation: flair-shimmer 8s 2.4s ease-in-out infinite; animation-play-state: paused;
  }
  html.motion-ok body.home-page.hero-motion-active:not(.motion-paused) .hero h1 > span { animation-play-state: running; }
}

/* Primary button, every page: keep the gradient, tighter shadow, one sheen sweep (replaces the flat dark + wide glow). */
body .btn--primary {
  background-image: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, .26) 50%, transparent 62%), linear-gradient(135deg, #e01535, #c00b28);
  background-size: 260% 100%, 100% 100%; background-position: 140% 0, 0 0; background-repeat: no-repeat; background-origin: border-box; background-clip: border-box;
  box-shadow: 0 6px 12px -6px rgba(160, 10, 36, .45), 0 1px 3px rgba(160, 10, 36, .15);
}
body .btn--primary:is(:hover, :focus-visible) {
  background-image: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, .26) 50%, transparent 62%), linear-gradient(135deg, #d51230, #b80a26);
  background-position: -40% 0, 0 0;
  box-shadow: 0 8px 14px -8px rgba(160, 10, 36, .5), 0 1px 3px rgba(160, 10, 36, .18);
  transition: background-position .8s cubic-bezier(.22, 1, .36, 1), translate .3s var(--motion-ease, ease), transform .2s ease, box-shadow .25s;
}
.home-page.motion-paused .hero__actions .btn--primary { transition: none; }

/* ---------- 6. Pointer light on the trust bar and procedure cards ---------- */
.home-page .reassurance, .home-page .proc-mini { position: relative; }
html.motion-ok body.home-page:not(.motion-paused) :is(.reassurance, .proc-mini)::after {
  content: ""; position: absolute; inset: 0; z-index: 2; border-radius: inherit; pointer-events: none; opacity: 0;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), rgba(var(--flair-rgb), .075), transparent 70%);
  transition: opacity .35s ease;
}
html.motion-ok body.home-page:not(.motion-paused) :is(.reassurance, .proc-mini).is-lit::after { opacity: 1; }

/* ---------- 7. Trust-bar icons: a small, springy response ---------- */
html.motion-ok body.home-page .reassurance li > .i {
  transition: scale .35s var(--motion-ease, cubic-bezier(.22, 1, .36, 1)), rotate .35s var(--motion-ease, cubic-bezier(.22, 1, .36, 1)), background-color .25s, color .25s;
}
@media (hover: hover) and (pointer: fine) {
  html.motion-ok body.home-page:not(.motion-paused) .reassurance li:hover > .i { scale: 1.12; rotate: -8deg; background-color: var(--red); color: #fff; }
}

/* ---------- 8. Magnetic buttons and the pinned journey scene follow the pointer a little ---------- */
html.motion-ok body.home-page:not(.motion-paused) :is(.hero__actions, .cta-band__actions, .procedures-section__all) .btn {
  translate: var(--mag-x, 0px) var(--mag-y, 0px);
  transition: translate .3s var(--motion-ease, cubic-bezier(.22, 1, .36, 1)), transform .2s ease, box-shadow .25s, background-color .2s;
}
@media (min-width: 960px) {
  html.motion-ok body.home-page:not(.motion-paused) .story.is-staged .stage .scene.is-active .scene__heart,
  html.motion-ok body.home-page:not(.motion-paused) .story.is-staged .stage .scene.is-active .scene-photo {
    translate: calc(var(--sx, 0) * 10px) calc(var(--sy, 0) * 8px);
    transition: translate .5s var(--motion-ease, cubic-bezier(.22, 1, .36, 1));
  }
}

/* ---------- 9. Story chapters: the number badge and label get a one-off ring when a beat opens ---------- */
html.motion-ok body.home-page:not(.motion-paused) .chapter.is-active .chapter__num { position: relative; }
html.motion-ok body.home-page:not(.motion-paused) .chapter.is-active .chapter__num::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%; pointer-events: none;
  border: 2px solid rgba(var(--flair-rgb), .55); animation: flair-badge-ring 1.4s .15s ease-out 1 both;
}

/* ---------- 10. Cardiac scene polish: scales with its card, softer trace, orbiting marker, layered pointer depth ---------- */
.home-page .scene.scene--cardiac { container-type: inline-size; }
.home-page .scene--cardiac .cardiac-caption strong { font-size: clamp(16px, 3.8cqw, 22px); }
.home-page .scene--cardiac .cardiac-caption small { font-size: clamp(11px, 2.2cqw, 13px); }
.home-page .scene--cardiac .cardiac-trace { -webkit-mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent); mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent); }
/* The satellite dot sits exactly on the ring, so it can travel round it. */
.home-page .scene--cardiac .cardiac-orbit--outer::after { top: 0; left: 50%; translate: -50% -50%; }
html.motion-ok body.home-page:not(.motion-paused) .scene--cardiac.is-in-view:is(.stage .is-active, .chapter.is-active .scene) .cardiac-orbit--outer { animation: flair-orbit 40s linear infinite; }
html.motion-ok body.home-page:not(.motion-paused) .scene--cardiac.is-in-view:is(.stage .is-active, .chapter.is-active .scene) .cardiac-orbit--inner { animation: flair-orbit-pulse 2.4s ease-in-out infinite; }
@media (min-width: 960px) {
  html.motion-ok body.home-page:not(.motion-paused) .story.is-staged .stage .scene--cardiac.is-active :is(.scene__cardiac-image, .cardiac-trace, .cardiac-shadow, .cardiac-orbit--outer, .cardiac-orbit--inner) {
    transition: translate .6s var(--motion-ease, cubic-bezier(.22, 1, .36, 1));
  }
  html.motion-ok body.home-page:not(.motion-paused) .story.is-staged .stage .scene--cardiac.is-active .scene__cardiac-image { translate: calc(var(--sx, 0) * 12px) calc(var(--sy, 0) * 9px); }
  html.motion-ok body.home-page:not(.motion-paused) .story.is-staged .stage .scene--cardiac.is-active .cardiac-shadow { translate: calc(var(--sx, 0) * 11px) 0; }
  html.motion-ok body.home-page:not(.motion-paused) .story.is-staged .stage .scene--cardiac.is-active .cardiac-trace { translate: calc(var(--sx, 0) * -7px) calc(var(--sy, 0) * -4px); }
  html.motion-ok body.home-page:not(.motion-paused) .story.is-staged .stage .scene--cardiac.is-active .cardiac-orbit--inner { translate: calc(var(--sx, 0) * -10px) calc(var(--sy, 0) * -7px); }
  html.motion-ok body.home-page:not(.motion-paused) .story.is-staged .stage .scene--cardiac.is-active .cardiac-orbit--outer { translate: calc(var(--sx, 0) * -16px) calc(var(--sy, 0) * -11px); }
}

@keyframes flair-drift-a { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(7%, 9%, 0) scale(1.12); } }
@keyframes flair-drift-b { from { transform: translate3d(0, 0, 0) scale(1.05); } to { transform: translate3d(-9%, -7%, 0) scale(.94); } }
@keyframes flair-sonar {
  0% { opacity: 0; scale: .55; }
  7% { opacity: .55; }
  100% { opacity: 0; scale: 1.2; }
}
@keyframes flair-shimmer { 0%, 52% { background-position: 100% 0; } 82%, 100% { background-position: 0% 0; } }
/* Orbits are centred with transform: translate(-50%, -50%), so spin/scale must live in the same transform. */
@keyframes flair-orbit { from { transform: translate(-50%, -50%) rotate(0deg); } to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes flair-orbit-pulse { 0%, 40%, 100% { transform: translate(-50%, -50%) scale(1); } 12%, 29% { transform: translate(-50%, -50%) scale(1.025); } }
@keyframes flair-badge-ring { from { opacity: 1; transform: scale(.9); } to { opacity: 0; transform: scale(1.9); } }

/* ---------- 11. Cardiac scene: a framed, clinical-monitor finish ---------- */
.home-page .scene.scene--cardiac {
  border-color: #d6e1ed;
  background:
    radial-gradient(ellipse 44% 40% at 50% 49%, #fff 0, #ffffff00 100%),
    radial-gradient(circle at 1px 1px, #a9bdd320 1px, transparent 1.5px) 0 0 / 24px 24px,
    linear-gradient(180deg, #f8fafc, #edf3f9);
}
.home-page .scene--cardiac .cardiac-orbit { top: 51%; width: 72%; border-color: #a7bfd957; }
.home-page .scene--cardiac .cardiac-orbit--inner { width: 56%; border-color: #ffffffe6; background: #ffffff2e; box-shadow: 0 0 0 1px #c3d4e62e; }
.home-page .scene--cardiac .scene__cardiac-image { top: 21%; left: 20%; width: 60%; height: 57%; filter: drop-shadow(0 18px 22px #6a1a3022); }
.home-page .scene--cardiac .cardiac-shadow { top: 77%; background: #1d3a6426; filter: blur(12px); }
.home-page .scene--cardiac .cardiac-trace__base { stroke: #c9506f; opacity: .18; }
.home-page .scene--cardiac .cardiac-trace__signal { opacity: .5; }
.home-page .scene--cardiac .cardiac-caption {
  width: auto; max-width: none; color: #3b5271;
  top: 24px; left: 24px; right: 24px;
}
.home-page .scene--cardiac .cardiac-caption strong { font-size: clamp(13px, 1.2vw, 17px); font-weight: 650; letter-spacing: -.02em; }
.home-page .scene--cardiac .scene__cardiac-image { top: 22%; height: 66%; }
.home-page .scene--cardiac .cardiac-shadow { top: 86%; }
.home-page .scene--cardiac .cardiac-orbit { top: 55%; }
.home-page .scene--cardiac .cardiac-footnote { color: #3b5271; }
@media (max-width: 959px) {
  .home-page .story.is-slider .scene--cardiac .scene__cardiac-image { top: 25%; height: 66%; }
  .home-page .scene--cardiac .cardiac-caption { top: 16px; left: 18px; right: 18px; }
  .home-page .story.is-slider .chapter > .chapter__link { margin-top: 0; font-size: 13px; }
}
@media (min-width: 960px) {
  .home-page .stage { background: linear-gradient(180deg, #fff, #f8fafd); }
  .home-page .stage[data-beat="1"]::before { opacity: 0; }
  .home-page .stage__ecg path:not(.is-done):not(.is-current) { stroke: #cdd8e6; }
  .home-page .stage .scene.scene--cardiac { inset: 112px 18px 18px; min-height: 0; border: 1px solid #d6e1ed; border-radius: 16px; }
  .home-page .stage__num { display: none; }
  .home-page .stage__beat .stage__ecg { max-width: 32px; height: 22px; }
  .home-page .story.is-staged .story__grid::before,
  .home-page .story.is-staged .story__grid::after { width: 1px; }
  .home-page .story.is-staged .story-pulse { width: 7px; height: 7px; box-shadow: 0 0 0 5px #fff; }
  html.motion-ok body.home-page:not(.motion-paused) .story.is-staged .story-pulse::after,
  html.motion-ok body.home-page:not(.motion-paused) .chapter.is-active .chapter__num::after { animation: none; }
}

/* Care journey: editorial copy beside a calm, unified illustration panel. */
.home-page .chapter__accent { color: #c20e37; }
.home-page #chapter-1 > .chapter__link {
  display: inline-flex; align-items: center; justify-content: center; gap: 20px;
  min-height: 48px; max-width: 100%; box-sizing: border-box; padding: 13px 20px;
  border: 1px solid #142e50; border-radius: 9px; background: #142e50; color: #fff;
  font-size: 13px; font-weight: 650; line-height: 1.5; text-decoration: none;
  box-shadow: 0 5px 12px -8px #142e5060;
  transition: background .2s, border-color .2s;
}
.home-page #chapter-1 > .chapter__link:hover { background: #244568; border-color: #244568; }
.home-page #chapter-1 > .chapter__link:focus-visible { outline: 3px solid #c20e37; outline-offset: 4px; }
.home-page #chapter-1 > .chapter__reassurance {
  display: flex; align-items: center; gap: 8px; margin-top: 15px; margin-bottom: 0;
  color: #65758b; font-size: 12px; line-height: 1.6;
}
.chapter__reassurance .i { flex: none; width: 15px; height: 15px; color: #7a8da3; }
.home-page .scene.scene--cardiac {
  background: radial-gradient(ellipse at 50% 52%, #fff 10%, #f0f5fa 65%, #f7f9fc 100%);
}
.home-page .scene--cardiac .cardiac-caption { top: 26px; left: 28px; right: 28px; gap: 12px; }
.home-page .scene--cardiac .cardiac-caption__icon { width: 42px; height: 42px; background: #fff; border-color: #eadde2; }
.home-page .scene--cardiac .cardiac-caption strong { font-size: clamp(15px, 3.2cqw, 19px); font-weight: 700; }
.home-page .scene--cardiac .cardiac-caption small { margin-top: 5px; font-size: clamp(10px, 2.1cqw, 12px); color: #687b91; }
.home-page .scene--cardiac .scene__cardiac-image { top: 23%; left: 20%; width: 60%; height: 61%; }
.home-page .scene--cardiac .cardiac-orbit { top: 53%; width: 66%; border-color: #b9cadb55; }
.home-page .scene--cardiac .cardiac-orbit--inner { width: 51%; border-color: #ffffffd9; background: #ffffff35; }
.home-page .scene--cardiac .cardiac-trace { top: 36%; opacity: .65; }
.home-page .scene--cardiac .cardiac-shadow { top: 82%; }
.cardiac-pathway {
  position: absolute; z-index: 3; bottom: 24px; left: 24px; right: 24px;
  display: flex; align-items: center; justify-content: center; gap: 15px;
  color: #4b627d; font-size: 11px; font-weight: 650; letter-spacing: .02em;
}
.cardiac-pathway .i { width: 15px; height: 15px; color: #b4c2d2; }
@media (min-width: 960px) {
  .home-page .story { padding-top: 52px; }
  .home-page .story.is-staged .story__grid { column-gap: clamp(44px, 6vw, 96px); }
  .home-page .story.is-staged .chapter { min-height: clamp(360px, 46vh, 440px); padding-block: 36px; }
  .home-page .chapter h3 { max-width: 22ch; font-size: clamp(30px, 2.65vw, 42px); line-height: 1.2; letter-spacing: -.04em; margin-bottom: 22px; }
  .home-page .chapter h3 .chapter__accent { display: block; margin-top: 4px; }
  .home-page .chapter p { max-width: 48ch; font-size: 15px; line-height: 1.85; }
  .home-page .chapter p.chapter__label { gap: 12px; margin-bottom: 26px; font-size: 10px; letter-spacing: .14em; }
  .home-page .chapter__num { width: 34px; height: 34px; border: 1px solid #efcbd4; border-radius: 50%; background: #fff6f8; font-size: 13px; }
  .home-page .story.is-staged .story__stage { height: min(610px, calc(100vh - 140px)); }
  .home-page .stage { border-color: #dfe6ef; border-radius: 22px; background: #fff; box-shadow: 0 16px 48px -24px #17365a25; }
  .home-page .stage__top { padding: 20px 24px 14px; gap: 11px 16px; background: #fff; }
  .home-page .stage__count { font-size: 10px; letter-spacing: .12em; }
  .home-page .stage__title { font-size: 11px; font-weight: 600; color: #5c7089; }
  .home-page .stage__bars { gap: 8px; height: 38px; }
  .home-page .stage__beat { height: 38px; min-height: 38px; border-radius: 7px; }
  .home-page .stage__beat[aria-current="step"] { border-color: #f0ced8; background: #fff4f6; }
  .home-page .stage__beat .stage__ecg { max-width: 29px; height: 20px; }
  .home-page .stage .scene.scene--cardiac { inset: 100px 0 0; min-height: 0; border: 0; border-radius: 0; }
}
@media (max-width: 959px) {
  .home-page .story.is-slider .chapter .scene.scene--cardiac { height: 310px; }
  .home-page .scene--cardiac .cardiac-caption { top: 19px; left: 20px; right: 20px; gap: 10px; }
  .home-page .scene--cardiac .cardiac-caption__icon { width: 34px; height: 34px; border-radius: 10px; }
  .home-page .story.is-slider .scene--cardiac .scene__cardiac-image { top: 25%; height: 58%; }
  .home-page .scene--cardiac .cardiac-shadow { top: 81%; }
  .home-page .story.is-slider #chapter-1 > .chapter__link { align-self: flex-start; min-height: 46px; padding: 12px 16px; font-size: 12px; gap: 12px; }
  .home-page .story.is-slider #chapter-1 > .chapter__reassurance { margin-top: 14px; margin-bottom: 0; font-size: 11px; }
  .cardiac-pathway { bottom: 19px; gap: 12px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .page-progress { transition: none; }
}
@media print { .page-progress { display: none; } }

/* Very narrow phones: the title wraps to two or three lines, so give it room above the heart. */
@media (max-width: 379px) {
  .home-page .story.is-slider .chapter .scene.scene--cardiac { height: 350px; }
  .home-page .story.is-slider .scene--cardiac .scene__cardiac-image { top: 36%; left: 22%; width: 56%; height: 44%; }
  .home-page .scene--cardiac .cardiac-orbit { top: 58%; }
  .home-page .scene--cardiac .cardiac-trace { top: 44%; }
  .home-page .scene--cardiac .cardiac-shadow { top: 80%; }
  .home-page .scene--cardiac .cardiac-caption strong { font-size: 15px; }
  .home-page .scene--cardiac .cardiac-caption small { font-size: 11px; }
}
