/* Directory live layer (pairs with directory-live.js): hospital network and medical coordinator pages.
   Loaded last. Hidden-until-revealed states and loops are gated on html.motion-ok (no reduced-motion).
   Entrances use the individual translate / scale / opacity properties so they do not fight the
   transforms that existing hover states use. */
:is(.hospital-theme, .care-reference) { --dl-ease: cubic-bezier(.22, 1, .36, 1); }

/* ---------- 1. Reveals ---------- */
html.motion-ok body.dl-ready [data-dl] {
  transition: opacity .8s var(--dl-ease) var(--ld, 0ms), translate .9s var(--dl-ease) var(--ld, 0ms), scale .9s var(--dl-ease) var(--ld, 0ms);
}
html.motion-ok body.dl-ready [data-dl="up"]:not(.dl-in) { opacity: 0; translate: 0 24px; }
html.motion-ok body.dl-ready [data-dl="left"]:not(.dl-in) { opacity: 0; translate: 30px 0; }
html.motion-ok body.dl-ready [data-dl="card"]:not(.dl-in) { opacity: 0; translate: 0 40px; scale: .96; }
html.motion-ok body.dl-ready [data-dl="words"] { transition: none; }

html body :is(.hospital-theme, .care-reference) .lw { display: inline-block; overflow: hidden; vertical-align: top; padding: 0 .06em .16em; margin: 0 -.06em -.16em; color: inherit !important; }
html body :is(.hospital-theme, .care-reference) .lw > span { display: inline-block; color: inherit !important; }
html.motion-ok body.dl-ready [data-dl="words"] .lw > span { transition: translate .8s cubic-bezier(.2, .8, .2, 1); transition-delay: calc(var(--wi, 0) * 55ms + var(--ld, 0ms)); }
html.motion-ok body.dl-ready [data-dl="words"]:not(.dl-in) .lw > span { translate: 0 112%; }
/* the red stroke under a section heading draws after the words land */
html.motion-ok body.dl-ready .pro-section-head h2[data-dl]::after { transition: clip-path .8s var(--dl-ease) .6s; clip-path: inset(-10px 0 -10px 0); }
html.motion-ok body.dl-ready .pro-section-head h2[data-dl]:not(.dl-in)::after { clip-path: inset(-10px 100% -10px 0); }
/* eyebrow rule draws out */
html.motion-ok body.dl-ready .pro-section-head .eyebrow[data-dl]::after { transform-origin: 0 50%; transition: transform .9s var(--dl-ease) .25s; }
html.motion-ok body.dl-ready .pro-section-head .eyebrow[data-dl]:not(.dl-in)::after { transform: scaleX(0); }

/* ---------- 2. Hero ---------- */
.dl-hero { position: relative; }
.dl-hero-spot { position: absolute; z-index: 0; inset: 0; pointer-events: none; opacity: 0; transition: opacity .5s ease;
  background: radial-gradient(440px circle at var(--sx, 30%) var(--sy, 40%), rgba(255, 92, 122, .12), rgba(110, 150, 215, .07) 45%, transparent 70%); }
html.motion-ok .dl-hero-spot.is-on { opacity: 1; }

/* staged entrance */
html.motion-ok .dl-hero .proc-hero__copy > * { animation: dl-rise .8s var(--dl-ease) both; }
html.motion-ok .dl-hero .proc-hero__copy > :nth-child(1) { animation-delay: .05s; }
html.motion-ok .dl-hero .proc-hero__copy > :nth-child(2) { animation-delay: .14s; }
html.motion-ok .dl-hero .proc-hero__copy > :nth-child(3) { animation-delay: .24s; }
html.motion-ok .dl-hero .proc-hero__copy > :nth-child(4) { animation-delay: .34s; }
html.motion-ok .dl-hero .proc-hero__media { animation: dl-media-in 1.2s var(--dl-ease) .1s both; }
html.motion-ok .dl-hero .proc-hero__badge { animation: dl-pop .7s var(--dl-ease) .75s both; }
html.motion-ok .dl-hero .proc-features li { animation: dl-rise .7s var(--dl-ease) both; }
html.motion-ok .dl-hero .proc-features li:nth-child(1) { animation-delay: .5s; }
html.motion-ok .dl-hero .proc-features li:nth-child(2) { animation-delay: .6s; }
html.motion-ok .dl-hero .proc-features li:nth-child(3) { animation-delay: .7s; }
html.motion-ok .dl-hero .proc-features li:nth-child(4) { animation-delay: .8s; }
@keyframes dl-rise { from { opacity: 0; translate: 0 18px; } to { opacity: 1; translate: 0 0; } }
@keyframes dl-pop { from { opacity: 0; scale: .9; translate: 0 14px; } to { opacity: 1; scale: 1; translate: 0 0; } }
@keyframes dl-media-in { from { opacity: 0; translate: 36px 0; } to { opacity: 1; translate: 0 0; } }

/* photograph: slow drift, plus a few pixels of pointer depth */
html.motion-ok .dl-hero .proc-hero__media > img { scale: 1.06; translate: var(--px, 0px) var(--py, 0px); transition: translate .6s var(--dl-ease); }
html.motion-ok .dl-hero.dl-onscreen .proc-hero__media > img { animation: dl-drift 22s ease-in-out infinite alternate; }
@keyframes dl-drift { from { scale: 1.06; } to { scale: 1.13; } }
/* heart outline beats, ECG line carries a travelling signal */
html.motion-ok .dl-hero .proc-hero__pulse-heart { transform-box: fill-box; transform-origin: 50% 60%; }
html.motion-ok .dl-hero.dl-onscreen .proc-hero__pulse-heart { animation: dl-beat 1.1s cubic-bezier(.33, 0, .33, 1) infinite; }
html.motion-ok .dl-hero .proc-hero__pulse-line { stroke-dasharray: 1; animation: dl-draw 1.6s var(--dl-ease) .6s both; }
html.motion-ok .dl-hero.dl-onscreen .proc-hero__pulse-line { animation: dl-draw 1.6s var(--dl-ease) .6s both, dl-signal 3.3s linear 2.4s infinite; }
@keyframes dl-beat { 0%, 8%, 60%, 100% { transform: scale(1); } 18% { transform: scale(1.07); } 30% { transform: scale(.98); } 42% { transform: scale(1.04); } }
@keyframes dl-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes dl-signal { 0%, 100% { opacity: 1; } 12% { opacity: .45; } 24% { opacity: 1; } }
/* badge floats, its icon beats */
html.motion-ok .dl-hero.dl-onscreen .proc-hero__badge > .i { animation: dl-beat 1.1s cubic-bezier(.33, 0, .33, 1) infinite; }
/* feature row answers the pointer */
.dl-hero .proc-features li { transition: background-color .3s, translate .35s var(--dl-ease); }
.dl-hero .proc-features li > .i { transition: scale .35s var(--dl-ease), rotate .35s var(--dl-ease); }
@media (hover: hover) and (pointer: fine) {
  .dl-hero .proc-features li:hover { background-color: #fff5f7; }
  html.motion-ok .dl-hero .proc-features li:hover > .i { scale: 1.18; rotate: -8deg; }
}

/* ---------- 3. Cards ---------- */
:is(.hospital-theme, .care-reference) .dl-card { position: relative; }
.dl-glow { position: absolute; z-index: 3; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .35s ease;
  background: radial-gradient(300px circle at var(--mx, 50%) var(--my, 50%), rgba(196, 0, 42, .075), transparent 70%); }
html.motion-ok .dl-card.is-lit > .dl-glow { opacity: 1; }

/* hospital cards */
html body .hospital-theme .hospital-card { transition: box-shadow .35s, border-color .3s, translate .4s var(--dl-ease); }
html body .hospital-theme .reference-hospital-photo { overflow: hidden; }
html body .hospital-theme .reference-hospital-photo img { transition: scale 1.1s var(--dl-ease); }
html body .hospital-theme .hospital-card h3 { transition: color .25s; }
html body .hospital-theme .hospital-photo-source { transition: translate .4s var(--dl-ease), background-color .3s, color .3s; }
html body .hospital-theme .reference-service-tags li { transition: translate .35s var(--dl-ease), border-color .3s, background-color .3s; }
@media (hover: hover) and (pointer: fine) {
  html.motion-ok body .hospital-theme .hospital-card:hover { translate: 0 -6px; border-color: #f0b9c5; box-shadow: 0 28px 48px -28px rgba(15, 37, 71, .45); }
  html.motion-ok body .hospital-theme .hospital-card:hover .reference-hospital-photo img { scale: 1.07; }
  html body .hospital-theme .hospital-card:hover h3 { color: #c4002a; }
  html.motion-ok body .hospital-theme .hospital-card:hover .reference-service-tags li { translate: 0 -2px; }
  html.motion-ok body .hospital-theme .hospital-card:hover .reference-service-tags li:nth-child(2) { transition-delay: .05s; }
  html.motion-ok body .hospital-theme .hospital-card:hover .reference-service-tags li:nth-child(3) { transition-delay: .1s; }
  html.motion-ok .hospital-card:hover .dl-wave-trace { stroke-dasharray: 1; animation: dl-draw .9s var(--dl-ease) both; }
}
/* save heart */
.hospital-save { transition: background-color .25s, scale .25s var(--dl-ease); }
.hospital-save:active { scale: .9; }
.hospital-save svg { transition: fill .25s, stroke .25s; }
.dl-save-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid #e01535; pointer-events: none; }
/* card buttons: arrow nudge */
:is(.reference-details-button, .directory-profile-button) { transition: background-color .25s, border-color .25s, color .25s, box-shadow .3s, letter-spacing .35s var(--dl-ease); }
@media (hover: hover) and (pointer: fine) {
  html.motion-ok :is(.reference-details-button, .directory-profile-button):hover { letter-spacing: .025em; }
}
:is(.reference-details-button, .directory-profile-button, .directory-more):active { scale: .98; }

/* coordinator cards */
html[data-page="coordinators"] body .care-reference .coordinator-card { transition: box-shadow .35s, border-color .3s, translate .4s var(--dl-ease); }
html[data-page="coordinators"] body .care-reference .care-portrait-frame .coordinator-portrait { transition: scale 1s var(--dl-ease); transform-origin: 50% 35%; }
.care-reference .coordinator-photo-wave { transition: scale .6s var(--dl-ease); transform-origin: 100% 100%; }
.care-reference .coordinator-photo-icon { transition: scale .45s var(--dl-ease), rotate .45s var(--dl-ease); }
.care-reference .coordinator-role { transition: translate .35s var(--dl-ease); }
.care-reference .language-chip { transition: border-color .3s, background-color .3s, color .3s; }
@media (hover: hover) and (pointer: fine) {
  html.motion-ok[data-page="coordinators"] body .care-reference .coordinator-card:hover { translate: 0 -6px; }
  html.motion-ok[data-page="coordinators"] body .care-reference .coordinator-card:hover .care-portrait-frame .coordinator-portrait { scale: 1.06; }
  html.motion-ok .care-reference .coordinator-card:hover .coordinator-photo-wave { scale: 1.18; }
  html.motion-ok .care-reference .coordinator-card:hover .coordinator-photo-icon { scale: 1.2; rotate: -8deg; }
  html.motion-ok .care-reference .coordinator-card:hover .coordinator-role { translate: 3px 0; }
  .care-reference .coordinator-card:hover .language-chip { border-color: #f0b9c5; background-color: #fff5f7; }
}

/* support cards: wave rises, icons respond */
:is(.pro-support-grid, .care-reference-support) article { transition: translate .4s var(--dl-ease), box-shadow .35s, border-color .3s; }
:is(.pro-support-grid, .care-reference-support) article .support-card-wave { transition: scale .6s var(--dl-ease); transform-origin: 50% 100%; }
:is(.pro-support-grid, .care-reference-support) article .support-card-corner { transition: scale .45s var(--dl-ease), rotate .45s var(--dl-ease); }
:is(.pro-support-grid, .care-reference-support) article .pro-support-icon, .care-reference-support article > .i { transition: scale .4s var(--dl-ease), rotate .4s var(--dl-ease); }
@media (hover: hover) and (pointer: fine) {
  html.motion-ok :is(.pro-support-grid, .care-reference-support) article:hover { translate: 0 -6px; box-shadow: 0 26px 44px -28px rgba(15, 37, 71, .4); }
  html.motion-ok :is(.pro-support-grid, .care-reference-support) article:hover .support-card-wave { scale: 1 1.28; }
  html.motion-ok :is(.pro-support-grid, .care-reference-support) article:hover .support-card-corner { scale: 1.22; rotate: -10deg; }
  html.motion-ok :is(.pro-support-grid, .care-reference-support) article:hover .pro-support-icon { scale: 1.08; rotate: -5deg; }
  html.motion-ok .care-reference-support article:hover > .i { scale: 1.12; rotate: -6deg; }
}

/* ---------- 4. Filters ---------- */
/* sliding indicator under the chosen role */
.care-role-tabs { position: relative; }
.dl-tab-bar { display: none; }
.care-role-tabs.has-bar .dl-tab-bar { display: block; position: absolute; left: 0; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: linear-gradient(90deg, #c4002a, #ff3b5c); pointer-events: none; }
html.motion-ok .care-role-tabs.has-bar .dl-tab-bar { transition: translate .5s var(--dl-ease), width .5s var(--dl-ease); }
.care-role-tabs.has-bar button[aria-pressed=true] { border-color: transparent; }
.care-role-tabs button { transition: color .25s, background-color .25s; }
.care-role-tabs button:hover { color: var(--red); background-color: #fff5f7; }
.care-role-tabs button:active, .directory-countries button:active { scale: .97; }
/* fields */
.network-filters :is(input, select) { transition: border-color .25s, box-shadow .25s; }
.network-filters :is(input, select):hover { border-color: #b9c8dc; }
.network-filters :is(input, select):focus { border-color: #c4002a; box-shadow: 0 0 0 4px rgba(196, 0, 42, .12); outline: none; }
html.motion-ok [data-network-empty]:not([hidden]) { animation: dl-rise .5s var(--dl-ease) both; }

/* ---------- 5. Dialog ---------- */
html.motion-ok .directory-dialog[open] { animation: dl-dialog-in .42s var(--dl-ease) both; }
html.motion-ok .directory-dialog[open]::backdrop { animation: dl-fade .35s ease both; }
html.motion-ok .directory-dialog[open] > div > * { animation: dl-rise .55s var(--dl-ease) both; }
html.motion-ok .directory-dialog[open] > div > :nth-child(1) { animation-delay: .08s; }
html.motion-ok .directory-dialog[open] > div > :nth-child(2) { animation-delay: .15s; }
html.motion-ok .directory-dialog[open] > div > :nth-child(3) { animation-delay: .22s; }
html.motion-ok .directory-dialog[open] > div > :nth-child(4) { animation-delay: .29s; }
html.motion-ok .directory-dialog[open] > div > :nth-child(n+5) { animation-delay: .36s; }
html.motion-ok .directory-dialog[open] .hospital-modal__photo { animation: dl-photo-settle 1.4s var(--dl-ease) both; }
@keyframes dl-dialog-in { from { opacity: 0; scale: .95; translate: 0 22px; } to { opacity: 1; scale: 1; translate: 0 0; } }
@keyframes dl-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dl-photo-settle { from { scale: 1.12; } to { scale: 1; } }
.directory-dialog-close { transition: background-color .25s, color .25s, rotate .35s var(--dl-ease); }
.directory-profile-chips span, .directory-profile-list li { transition: translate .3s var(--dl-ease); }
.directory-profile-list li:hover { translate: 4px 0; }

/* ---------- 6. Closing band ---------- */
html body .conversation-section .cta-band > .dl-band-spot { position: absolute; z-index: 0; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s ease;
  background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .2), transparent 70%); }
html.motion-ok body .conversation-section .cta-band > .dl-band-spot.is-on { opacity: 1; }
:is(.hospital-theme-join, .care-reference-join) a { transition: color .25s, letter-spacing .35s var(--dl-ease); }

@media (prefers-reduced-motion: reduce) {
  [data-dl], :is(.hospital-theme, .care-reference) .lw > span { opacity: 1 !important; translate: none !important; scale: none !important; }
}
@media print {
  [data-dl], :is(.hospital-theme, .care-reference) .lw > span { opacity: 1 !important; translate: none !important; scale: none !important; }
  .dl-hero-spot, .dl-glow, .dl-tab-bar { display: none !important; }
}
