/* ==========================================================================
   loader.css - site-wide loading experience (see js/loader.js)
   1. full-screen loader on first visit and quick one between pages
   2. shimmer placeholders while images load
   3. buffering ring while a capability video loads
   The overlay only exists when JavaScript runs (html.js), so the site is never blocked without it.
   ========================================================================== */

.page-loader {
  display: none; position: fixed; inset: 0; z-index: 200; place-items: center; text-align: center; color: #fff;
  background:
    radial-gradient(55% 50% at 80% 15%, rgba(79, 237, 240, 0.2), transparent 70%),
    radial-gradient(45% 50% at 10% 90%, rgba(255, 122, 89, 0.15), transparent 70%),
    var(--navy);
  transition: opacity 0.5s ease, visibility 0.5s;
}
.js .page-loader { display: grid; }
/* returning visitors: no intro overlay (it is still available to the send-inquiry loader) */
.js.seen .page-loader:not(.is-manual) { display: none; }
.page-loader.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
/* safety net: if scripts stall, the overlay still disappears after 8 seconds */
.js .page-loader.is-initial { animation: plFailsafe 0.01s 8s forwards; }
@keyframes plFailsafe { to { opacity: 0; visibility: hidden; pointer-events: none; } }
.page-loader.is-quick { transition-duration: 0.25s; }

.pl-inner { width: min(300px, 80vw); display: grid; justify-items: center; gap: 14px; }
.pl-mark { position: relative; width: 76px; height: 76px; display: grid; place-items: center; }
.pl-mark img { height: 64px; width: auto; max-width: 150px; object-fit: contain; position: relative; z-index: 1; animation: plFloat 2.4s ease-in-out infinite; }
.pl-mark::before, .pl-mark::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--cyan);
  animation: plRing 2.4s ease-out infinite;
}
.pl-mark::after { animation-delay: 1.2s; }
@keyframes plRing { from { transform: scale(0.7); opacity: 0.8; } to { transform: scale(1.7); opacity: 0; } }
@keyframes plFloat { 50% { transform: translateY(-5px); } }

.pl-word { font: 800 1.5rem var(--font-head); letter-spacing: 0.34em; padding-left: 0.34em; }
.pl-ecg { width: 100%; height: 44px; overflow: visible; }
.pl-ecg path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pl-ecg .base { stroke: rgba(79, 237, 240, 0.2); stroke-width: 2.5; }
.pl-ecg .run {
  stroke: var(--cyan); stroke-width: 3; stroke-dasharray: 24 76; stroke-dashoffset: 24;
  filter: drop-shadow(0 0 6px var(--cyan)); animation: plRun 1.5s linear infinite;
}
@keyframes plRun { to { stroke-dashoffset: -76; } }

.pl-bar { width: 100%; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.pl-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--blue)); transition: width 0.25s ease-out; }
.pl-text { margin: 0; font-size: 0.9rem; color: var(--on-dark-mut); letter-spacing: 0.04em; min-height: 1.4em; }
.page-loader.is-quick .pl-word, .page-loader.is-quick .pl-text { opacity: 0.0; }
.page-loader.is-quick .pl-inner { gap: 18px; }

/* hold the hero entrance animations until the loader lifts */
.page-loader:not(.is-hidden) ~ main .hero__text > *,
.page-loader:not(.is-hidden) ~ main .hero__img,
.page-loader:not(.is-hidden) ~ main .deck,
.page-loader:not(.is-hidden) ~ main .hero h1 .line { animation-play-state: paused; }

/* success state (contact form): the logo is replaced by an animated check mark */
.pl-check { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transform: scale(0.4); overflow: visible; }
.pl-check circle { fill: var(--cyan); }
.pl-check path { fill: none; stroke: #04222a; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 100; stroke-dashoffset: 100; }
.page-loader.is-done .pl-mark img { opacity: 0; transition: opacity 0.2s; }
.page-loader.is-done .pl-mark::before, .page-loader.is-done .pl-mark::after { animation-duration: 1.2s; }
.page-loader.is-done .pl-check { opacity: 1; transform: none; transition: opacity 0.2s, transform 0.45s cubic-bezier(0.2, 1.4, 0.4, 1); z-index: 2; }
.page-loader.is-done .pl-check path { animation: plCheck 0.5s 0.2s ease forwards; }
@keyframes plCheck { to { stroke-dashoffset: 0; } }
.page-loader.is-done .pl-ecg, .page-loader.is-done .pl-bar { opacity: 0; transition: opacity 0.2s; }
.page-loader.is-done .pl-text { color: #fff; font-weight: 700; font-size: 1.05rem; }

/* ---------- image placeholders ---------- */
.img-wait { position: relative; }
.img-wait::before {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(100deg, transparent 20%, rgba(79, 237, 240, 0.16) 50%, transparent 80%) var(--navy-2);
  background-size: 220% 100%; animation: plShimmer 1.2s linear infinite;
}
@keyframes plShimmer { from { background-position: 220% 0; } to { background-position: -120% 0; } }

/* ---------- video buffering ---------- */
[data-video].is-buffering::before {
  content: ""; position: absolute; left: 50%; top: 50%; z-index: 3; width: 42px; height: 42px; margin: -21px 0 0 -21px;
  border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.35); border-top-color: var(--cyan);
  animation: sl-spin 0.8s linear infinite; pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .page-loader { display: none !important; }
  .img-wait::before { animation: none; }
}
