/* Coriva public website: proposed motion layer (prototype).
   Tokens: DESIGN_SYSTEM §8 (ease-out, ease-color, durations, 40 ms stagger family).
   Gate: marketing pages, seen once or occasionally per visit (find-animation-opportunities):
   explanation and first-impression motion only; nothing loops; forms, FAQ text and data never move for style.
   Properties: transform, opacity, clip-path only (animate, animation-performance).
   html.m-on is set by an inline head script only when motion is allowed; without it nothing is hidden. */
:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-draw: cubic-bezier(0.33, 1, 0.68, 1);
  interpolate-size: allow-keywords;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ---------- 1. Hero entrance: one per page (choreograph: lead, support, decoration) ---------- */
@keyframes m-rise { from { opacity: 0; transform: translateY(var(--m-dist, 10px)); } }
@keyframes m-fade { from { opacity: 0; } }
@keyframes m-settle { from { opacity: 0.35; transform: scale(1.04); } }

.m-on :is(.hero-inner, .pf-intro .wrap, .doc-hero-in > div:first-child) > * {
  animation: m-rise 560ms var(--ease-out) both;
}
.m-on :is(.hero-inner, .pf-intro .wrap, .doc-hero-in > div:first-child) > :is(.chip, .eyebrow, .chip-ink, .eyebrow-ink) {
  animation: m-fade 400ms ease both;          /* decoration: fades in place */
}
.m-on :is(.hero-inner, .pf-intro .wrap, .doc-hero-in > div:first-child) > h1 {
  --m-dist: 18px;                              /* lead travels the furthest */
  animation-duration: 700ms;
  animation-delay: 60ms;
}
.m-on :is(.hero-inner, .pf-intro .wrap, .doc-hero-in > div:first-child) > :nth-child(3) { animation-delay: 170ms; }
.m-on :is(.hero-inner, .pf-intro .wrap, .doc-hero-in > div:first-child) > :nth-child(4) { --m-dist: 8px; animation-delay: 260ms; }
.m-on :is(.hero-inner, .pf-intro .wrap, .doc-hero-in > div:first-child) > :nth-child(n+5) { --m-dist: 6px; animation-delay: 330ms; }
.m-on :is(.hero > img, .doc-photo img) { animation: m-settle 1200ms var(--ease-out) both; }

/* ---------- 2. Section reveal: once, one entrance per section, two beats ---------- */
.m-on [data-reveal] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 600ms var(--ease-out), transform 700ms var(--ease-out);
  transition-delay: var(--m-delay, 0ms);
}
.m-on [data-reveal].is-in { opacity: 1; transform: none; }

/* ---------- 3. Home: the day draws as a role is chosen (explanation: time passes) ---------- */
@keyframes m-line-x { from { transform: scaleX(0); } }
@keyframes m-line-y { from { transform: scaleY(0); } }
@keyframes m-moment { from { opacity: 0; transform: translateY(12px); } }
.m-on .day.m-draw::before { transform-origin: top left; animation: m-line-y 640ms var(--ease-draw) both; }
@media (min-width: 1024px) {
  .m-on .day.m-draw::before { animation-name: m-line-x; }
}
.m-on .day.m-draw > .moment { animation: m-moment 460ms var(--ease-out) both; }
.m-on .day.m-draw > .moment:nth-child(1) { animation-delay: 40ms; }
.m-on .day.m-draw > .moment:nth-child(2) { animation-delay: 170ms; }
.m-on .day.m-draw > .moment:nth-child(3) { animation-delay: 280ms; }
.m-on .day.m-draw > .moment:nth-child(4) { animation-delay: 370ms; }

/* ---------- 4. Platform: the plan's path fills as you read it (scroll-linked, off the main thread) ---------- */
.trace::after {
  content: "";
  position: absolute;
  left: 27px; top: 28px; bottom: 28px; width: 2px;
  background: #0F766E;
  transform-origin: top;
  transform: scaleY(0);
  pointer-events: none;
}
@keyframes m-fill { to { transform: scaleY(1); } }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .trace::after { animation: m-fill linear both; animation-timeline: view(block 60% 40%); animation-range: cover 0% cover 100%; }
  }
}
@media (max-width: 640px) { .trace::after { left: 21px; } }
.num { position: relative; z-index: 1; transition: background-color 300ms ease, color 300ms ease, box-shadow 300ms ease; }
.station.is-reached .num { background: #0F766E; color: #FFFFFF; box-shadow: inset 0 0 0 3px #0F766E; }
.station.key.is-reached .num { background: #F36F56; color: #192B3A; box-shadow: 0 0 0 8px rgba(243, 111, 86, 0.2); }
.station.key .num::after {
  content: ""; position: absolute; inset: -8px; border-radius: 50%;
  box-shadow: 0 0 0 2px #F36F56; opacity: 0; pointer-events: none;
}
@keyframes m-pulse { from { opacity: 0.6; transform: scale(0.7); } to { opacity: 0; transform: scale(1.5); } }
.m-on .station.key.is-reached .num::after { animation: m-pulse 800ms var(--ease-out) 1 both; }

/* ---------- 5. Partners: the surfaces grow out of one core (explanation: one system) ---------- */
@media (min-width: 1001px) {
  .m-on .orbit .bus { clip-path: inset(50% 50% 50% 50%); transition: clip-path 760ms var(--ease-draw) 120ms; }
  .m-on .orbit .core { opacity: 0; transform: scale(0.96); transition: opacity 500ms var(--ease-out), transform 600ms var(--ease-out); }
  .m-on .orbit .sat { opacity: 0; transition: opacity 500ms var(--ease-out), transform 600ms var(--ease-out); }
  .m-on .orbit :is(.s0, .s1, .s2) { transform: translateY(14px); }
  .m-on .orbit :is(.s3, .s4, .s5) { transform: translateY(-14px); }
  .m-on .orbit :is(.s1, .s4) { transition-delay: 160ms; }
  .m-on .orbit :is(.s0, .s2, .s3, .s5) { transition-delay: 300ms; }
  .m-on .orbit.is-in .bus { clip-path: inset(0); }
  .m-on .orbit.is-in :is(.core, .sat) { opacity: 1; transform: none; }
}

/* ---------- 6. Doctors: the example dashboard fills in, top to bottom ---------- */
.m-on .glimpse > * { opacity: 0; transform: translateY(6px); transition: opacity 420ms var(--ease-out), transform 480ms var(--ease-out); }
.m-on .glimpse.is-in > * { opacity: 1; transform: none; }
.m-on .glimpse.is-in > :nth-child(2) { transition-delay: 60ms; }
.m-on .glimpse.is-in > :nth-child(3) { transition-delay: 140ms; }
.m-on .glimpse.is-in > :nth-child(4) { transition-delay: 200ms; }
.m-on .glimpse.is-in > :nth-child(n+5) { transition-delay: 250ms; }

/* ---------- 7. Waitlist and contact: the sent check draws (rare, high-emotion moment) ---------- */
.sent-ic svg path { stroke-dasharray: 24; stroke-dashoffset: 0; }
@keyframes m-draw-check { from { stroke-dashoffset: 24; } }
@keyframes m-pop { from { opacity: 0; transform: scale(0.85); } }
.m-on .sent.m-play .sent-ic { animation: m-pop 320ms var(--ease-out) both; }
.m-on .sent.m-play .sent-ic svg path { animation: m-draw-check 420ms var(--ease-draw) 140ms both; }
.m-on .sent.m-play > :is(h2, p) { animation: m-rise 480ms var(--ease-out) both; --m-dist: 8px; }
.m-on .sent.m-play > h2 { animation-delay: 120ms; }
.m-on .sent.m-play > p { animation-delay: 200ms; }

/* ---------- 8. FAQ answers open instead of jumping (state indication) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .faq details::details-content {
    block-size: 0; overflow: clip;
    transition: block-size 280ms var(--ease-out), content-visibility 280ms allow-discrete;
  }
  .faq details[open]::details-content { block-size: auto; }
  .faq summary::after { transition: transform 200ms var(--ease-out); }
}
.faq summary::after { content: "+" !important; }
.faq details[open] summary::after { transform: rotate(45deg); }

/* ---------- 9. Header returns on scroll-up (UX brief §8: sticky on scroll-up only) ---------- */
.hdr.hdr-pinned { position: fixed; background: rgba(25, 43, 58, 0.97); transform: translateY(-100%); }
.hdr.hdr-pinned.hdr-show { transform: none; }
@media (prefers-reduced-motion: no-preference) {
  .hdr.hdr-pinned { transition: transform 260ms var(--ease-out); }
}

/* ---------- Reduced motion: fewer and gentler, not zero (opacity only, no delays, no travel) ---------- */
.m-on.m-reduce :is(.hero-inner, .pf-intro .wrap, .doc-hero-in > div:first-child) > *,
.m-on.m-reduce :is(.hero > img, .doc-photo img) { animation: m-fade 200ms ease both !important; animation-delay: 0ms !important; }
.m-on.m-reduce [data-reveal], .m-on.m-reduce .glimpse > * { transform: none !important; transition: opacity 200ms ease !important; transition-delay: 0ms !important; }
.m-on.m-reduce .day.m-draw::before, .m-on.m-reduce .day.m-draw > .moment,
.m-on.m-reduce .sent.m-play *, .m-on.m-reduce .station.key .num::after { animation: none !important; }
.m-on.m-reduce .orbit :is(.bus, .core, .sat) { clip-path: none !important; transform: none !important; opacity: 1 !important; transition: none !important; }

/* ---------- Patients: almost still for older readers: opacity only ---------- */
.m-on[data-page="patients"] :is(.doc-hero-in > div:first-child) > *,
.m-on[data-page="patients"] .doc-photo img { animation-name: m-fade !important; }
.m-on[data-page="patients"] [data-reveal] { transform: none; }
