/* Nursing hero intro (js/nursing-hero-intro.js).
   html.intro-pending hides the hero until the script has measured the page; html.intro-run plays the timeline
   (animations fill backwards, so each part waits in its first frame until its delay). Individual transform
   properties (scale, translate) are used so the page's own transforms are kept. html.intro-flow is the version
   that follows the recruit page's closing panels. */
html.intro-pending :is(.hero-copy__lead, .hero-copy__text, .motion-visual, .hero-media, .scroll-cue, .sample-header, .tabbar, .ambient-shape) { opacity: 0; }
html.intro-run .ambient-shape { transition: opacity 1.4s ease 3.17s; }
html.intro-flow.intro-run .ambient-shape { transition-delay: 3.45s; }

/* The heading's ".hero-copy h1 span" style (a small pink subtitle) must not reach the split phrases. */
.hero-copy .hero-copy__lead .intro-phrase {
  display: inline-block;
  margin: 0;
  color: inherit;
  font-size: 1em;
  letter-spacing: inherit;
  line-height: inherit;
  white-space: nowrap;
  -webkit-mask-image: linear-gradient(90deg, #000 40%, transparent 60%);
  mask-image: linear-gradient(90deg, #000 40%, transparent 60%);
  -webkit-mask-size: 250% 100%;
  mask-size: 250% 100%;
}

@keyframes nursing-intro-fade { from { opacity: 0; } }
@keyframes nursing-intro-rise { from { opacity: 0; translate: 0 16px; } }
@keyframes nursing-intro-sweep { from { -webkit-mask-position: 100% 0; mask-position: 100% 0; } to { -webkit-mask-position: 0 0; mask-position: 0 0; } }
@keyframes nursing-intro-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes nursing-intro-out { to { opacity: 0; } }
@keyframes nursing-intro-fill { from { opacity: 0; filter: saturate(0.2) brightness(1.4); } }
@keyframes nursing-intro-zoom { from { scale: 1.08; } }

/* Direct visit: one stroke (heartbeat, or an arc on phones) runs into the brain and traces its outline inside the
   hero; as it fades the brain fills in, then the heading, the paragraph, the photo and the header follow, in the
   same order as after the recruit transition (the heading waits so the heartbeat never crosses it). The stroke timing comes from the script
   (--flow-start, --flow-duration, --flow-right-*, --flow-out). */
html.intro-run .motion-visual { animation: nursing-intro-fill 1.1s ease 1.72s both; }
html.intro-run .hero-copy__lead { opacity: 1; }
html.intro-run .intro-phrase { animation: nursing-intro-sweep 1.1s ease calc(2.17s + var(--p) * 0.45s) both; }
html.intro-run .hero-copy__text { animation: nursing-intro-rise 1.1s ease 2.77s both; }
html.intro-run .hero-media { animation: nursing-intro-fade 1.6s ease 2.97s both; }
html.intro-run .hero-video { animation: nursing-intro-zoom 2.4s cubic-bezier(0.22, 1, 0.36, 1) 2.97s both; }
html.intro-run :is(.sample-header, .tabbar) { animation: nursing-intro-fade 0.9s ease 3.47s both; }
html.intro-run .scroll-cue { animation: nursing-intro-fade 0.9s ease 3.77s both; }

/* From the recruit page: on the closed panels one stroke draws the heartbeat (a gentle arc on phones), runs into the
   brain's left edge and traces the left lobe; the right lobe follows a moment later. Then the panels open, the
   stroke fades as the brain fills in, and the heading, the paragraph, the photo and the header follow in turn. */
.intro-flow-draw { position: fixed; z-index: 31001; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.intro-flow-draw--hero { position: absolute; z-index: 6; }
.intro-flow-draw path { fill: none; stroke: #d84f72; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
/* Phones show the drawing much smaller, so its stroke is thinner (as in css/recruit-navigation.css). */
@media (max-width: 767px) { .intro-flow-draw path { stroke-width: 2; } }
html.intro-run .intro-flow-draw__main { animation: nursing-intro-draw var(--flow-duration, 1.6s) cubic-bezier(0.42, 0, 0.58, 1) var(--flow-start, 0.05s) both; }
html.intro-run .intro-flow-draw__right { animation: nursing-intro-draw var(--flow-right-duration, 0.7s) cubic-bezier(0.42, 0, 0.58, 1) var(--flow-right-delay, 1.1s) both; }
html.intro-run .intro-flow-draw { animation: nursing-intro-out 0.9s ease var(--flow-out, 3.35s) both; }

html.intro-flow.intro-run .motion-visual { animation-delay: 2.2s; }
html.intro-flow.intro-run .intro-phrase { animation-delay: calc(2.45s + var(--p) * 0.45s); }
html.intro-flow.intro-run .hero-copy__text { animation-delay: 3.05s; }
html.intro-flow.intro-run :is(.hero-media, .hero-video) { animation-delay: 3.3s; }
html.intro-flow.intro-run :is(.sample-header, .tabbar) { animation-delay: 3.8s; }
html.intro-flow.intro-run .scroll-cue { animation-delay: 4.05s; }

/* From the recruit page with its finished drawing (html.intro-glide): the timeline is held behind the closed panels
   (intro-hold) while the hero is drawn once, all but invisible, so nothing stalls later. When the outline glides onto
   the brain and the panels open, the brain fills in as the outline arrives, then the heading and the rest follow. */
html.intro-hold :is(.motion-visual, .intro-phrase, .hero-copy__text, .hero-media, .hero-video, .sample-header, .tabbar, .scroll-cue) { animation-play-state: paused !important; }
html.intro-hold :is(.motion-visual, .hero-copy__lead, .hero-copy__text, .hero-media, .scroll-cue, .sample-header, .tabbar) { opacity: 0.01 !important; }
html.intro-hold .ambient-shape { transition: none !important; opacity: 0 !important; }
html.intro-flow.intro-glide.intro-run .motion-visual { animation-delay: 0.75s; }
html.intro-flow.intro-glide.intro-run .intro-phrase { animation-delay: calc(1.2s + var(--p) * 0.45s); }
html.intro-flow.intro-glide.intro-run .hero-copy__text { animation-delay: 1.8s; }
html.intro-flow.intro-glide.intro-run :is(.hero-media, .hero-video) { animation-delay: 2.05s; }
html.intro-flow.intro-glide.intro-run :is(.sample-header, .tabbar) { animation-delay: 2.55s; }
html.intro-flow.intro-glide.intro-run .scroll-cue { animation-delay: 2.8s; }
html.intro-flow.intro-glide.intro-run .ambient-shape { transition-delay: 2.2s; }

@media (prefers-reduced-motion: reduce) {
  html.intro-pending :is(.hero-copy__lead, .hero-copy__text, .motion-visual, .hero-media, .scroll-cue, .sample-header, .tabbar, .ambient-shape) { opacity: 1; }
  html.intro-run *, html.intro-run *::before, html.intro-run *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; }
  .intro-flow-draw { display: none; }
}
