/* Viewport-stable height (mobile) */
:root { --vh: 1vh; }

/* Brand colors you can tweak */
:root {
  --loader-bg: radial-gradient(120% 120% at 50% 50%, #171717 0%, #0d0d0f 60%, #000 100%);
  --loader-fg: #ffffff;
  --loader-accent: #ff820d;
}

/* ===== Overlay ===== */
#page-loader {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: var(--loader-bg);
  color: var(--loader-fg);
  z-index: 9999;
  height: calc(var(--vh) * 100); /* stable 100vh */
  opacity: 0; transform: scale(.98);
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: all;
  /* optional soft blur over page */
  /* backdrop-filter: blur(2px); */
}
#page-loader.is-visible { opacity: 1; transform: none; }
#page-loader.fade-out   { opacity: 0; transition: opacity .5s ease; }

/* Inner stack */
#page-loader .loader-wrap {
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 1rem;
  text-align: center;
}

/* ===== Logo / Title ===== */
#loader-logo {
  opacity: 0; transform: translateY(6px) scale(.98);
  transition: opacity .6s ease, transform .6s ease;
  will-change: transform, opacity;
  /* responsive sizing whether it's <img>, <svg>, or text */
  width: clamp(140px, 30vw, 320px);
  max-width: 80vw;
}
#loader-logo.logo-visible { opacity: 1; transform: translateY(0) scale(1); }

/* Optional subtitle */
#page-loader .loader-subtitle {
  font: 500 clamp(.9rem, 1.8vw, 1.05rem) 'Sofia Pro', system-ui, sans-serif;
  opacity: .9;
}

/* ===== Progress (optional) =====
   JS can set: document.documentElement.style.setProperty('--progress', 0..1)
*/
#page-loader .loader-progress {
  --progress: 0; /* default if JS not set */
  width: min(56ch, 80vw);
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  overflow: hidden;
  position: relative;
}
#page-loader .loader-progress::before {
  content: "";
  position: absolute; inset: 0;
  transform: scaleX(var(--progress));
  transform-origin: left center;
  background: linear-gradient(90deg, var(--loader-accent), #ffb36a);
  transition: transform .25s ease;
}

/* Indeterminate shimmer if you want (remove if not) */
#page-loader[data-indeterminate="true"] .loader-progress::before {
  animation: loader-shimmer 1.2s linear infinite;
  transform: none;
}
@keyframes loader-shimmer {
  0% { transform: translateX(-100%); width: 35%; }
  50% { transform: translateX(30%);  width: 50%; }
  100%{ transform: translateX(120%); width: 35%; }
}

/* ===== Skip pill (click or ESC also works in JS) ===== */
#page-loader .loader-skip {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem .9rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.35);
  color: var(--loader-fg);
  font: 600 .9rem/1 'Sofia Pro', system-ui, sans-serif;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
  margin-top: .25rem;
}
#page-loader .loader-skip:hover { transform: translateY(-1px); background: rgba(0,0,0,.45); }
#page-loader .loader-skip:focus { outline: 2px solid var(--loader-accent); outline-offset: 2px; }

/* Dim page while loading (your behavior, kept) */
html[data-loading] body *:not(#page-loader):not(#page-loader *) { pointer-events: none; }

/* High contrast / forced colors */
@media (forced-colors: active) {
  #page-loader { background: Canvas; color: CanvasText; }
  #page-loader .loader-progress { background: GrayText; }
  #page-loader .loader-progress::before { background: Highlight; }
  #page-loader .loader-skip { border-color: ButtonBorder; background: ButtonFace; color: ButtonText; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  #page-loader, #loader-logo { transition: none; }
}

/* Print safety */
@media print { #page-loader { display: none !important; } }
