/* ==========================================================================
   ANIMATIONS — keyframes, reveal-on-scroll, load sequence, reduced motion
   ========================================================================== */

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes drift { to { transform: translateX(-50%); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes load { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade-out { to { opacity: 0; visibility: hidden; } }
@keyframes ring {
  0% { box-shadow: 0 0 0 0 rgba(0, 255, 136, .45), 0 0 22px rgba(0, 255, 136, .35); }
  100% { box-shadow: 0 0 0 14px rgba(0, 255, 136, 0), 0 0 22px rgba(0, 255, 136, .35); }
}
/* CRT power-on: a bright line opens into the picture */
@keyframes power-on {
  0% { opacity: 0; transform: scale(1, .006); filter: brightness(4); }
  35% { opacity: 1; transform: scale(1, .006); filter: brightness(4); }
  70% { transform: scale(1, 1); filter: brightness(1.6); }
  100% { transform: none; filter: none; }
}

@keyframes alarm-flash { 50% { opacity: .3; } }

.alarm[data-level="red"],
html[data-alarm="red"] .num--hr .num__value { animation: alarm-flash 1s steps(1) infinite; }
.led--pulse { animation: pulse 2.4s ease-in-out infinite; }
.led--blink { animation: blink 2s steps(1) infinite; }
.tl-item--current .tl-node { animation: ring 2s ease-out infinite; }

.bg-ecg__track { animation: drift 18s linear infinite; }
.case__trace-track { animation: drift var(--speed, 3s) linear infinite; }
.case--completed .case__trace-track { animation: none; }

/* Entrance once the start-up overlay is gone (or immediately for returning visitors) */
html:not(.is-booting) .hero__intro > * { animation: rise .8s var(--ease) both; }
html:not(.is-booting) .hero__intro > :nth-child(2) { animation-delay: 60ms; }
html:not(.is-booting) .hero__intro > :nth-child(3) { animation-delay: 120ms; }
html:not(.is-booting) .hero__intro > :nth-child(4) { animation-delay: 180ms; }
html:not(.is-booting) .hero__intro > :nth-child(5) { animation-delay: 240ms; }
html:not(.is-booting) .hero__intro > :nth-child(6) { animation-delay: 300ms; }
html:not(.is-booting) .hero__intro > :nth-child(7) { animation-delay: 360ms; }
html:not(.is-booting) .monitor__screen { animation: power-on 1.1s var(--ease) .15s both; }

.boot.is-leaving { animation: fade-out .45s var(--ease) forwards; }

/* Reveal on scroll (IntersectionObserver adds .is-visible) */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .7s var(--ease) var(--d, 0ms), transform .7s var(--ease) var(--d, 0ms);
}
.js [data-reveal].is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
  .js [data-reveal] { opacity: 1; transform: none; }
}
