/* ═══════════════════════════════════════════════════════════════
   SITE LOADER — first-paint loading screen shown on initial site
   load AND reused by PageLoader.vue for per-view data fetches.
   Design language matches the landing hero: light-blue gradient,
   giant "10x" watermark, gradient wordmark typewriter animation,
   gradient progress bar anchored at the top of the viewport.
   Apple-inspired: clean, spacious, intentional motion.
   ═══════════════════════════════════════════════════════════════ */

/* Default: contained — used by <PageLoader /> inside a view's
   content area so the nav/header/footer stay visible around it. */
.site-loader {
  position: relative;
  width: 100%;
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  direction: ltr;
  background: linear-gradient(170deg, #D6E8FF 0%, #E8F1FF 30%, #F4F8FF 60%, #FFFFFF 100%);
  transition: opacity 243ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Opt-in full-screen modifier — used ONLY by the startup splash
   declared in index.html, not for intrasite route transitions. */
.site-loader--fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  min-height: 0;
}

/* Subtle ambient depth layered over the hero gradient —
   two soft brand-tinted radial pools for visual richness. */
.site-loader::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 900px 520px at 38% 48%, rgba(8, 148, 255, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 760px 440px at 62% 52%, rgba(189, 50, 214, 0.06) 0%, transparent 60%);
  filter: blur(18px);
  pointer-events: none;
  animation: site-loader-glow 2.24s ease-in-out infinite alternate;
  z-index: 0;
}

@keyframes site-loader-glow {
  0%   { opacity: 0.75; transform: scale(1); }
  100% { opacity: 1;    transform: scale(1.03); }
}

.site-loader.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Pause in-page animations until the site is ready so hero
   entrance animations are seen, not consumed by the loader. */
#app {
  opacity: 0;
  transition: opacity 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

#app.site-ready {
  opacity: 1;
}

#app:not(.site-ready),
#app:not(.site-ready) * {
  animation-play-state: paused !important;
}

/* ─── Giant "10x" watermark (mirrors .landing-hero::before) ─── */
.site-loader__watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-52%, -35%);
  font-family: 'Helvetica Neue', 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 62vw;
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 0.85;
  background: linear-gradient(
    160deg,
    rgba(0, 113, 227, 0.10) 0%,
    rgba(0, 90, 180, 0.018) 40%,
    rgba(100, 160, 240, 0.25) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  z-index: 0;
  animation: site-loader-watermark-in 630ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes site-loader-watermark-in {
  from { opacity: 0; transform: translate(-52%, -35%) scale(0.985); }
  to   { opacity: 1; transform: translate(-52%, -35%) scale(1); }
}

/* ─── Stage & wordmark ─── */
.site-loader__stage {
  position: relative;
  z-index: 1;
  padding: 32px 48px;
}

/* 30% smaller than the native 593×105 artwork = 415×73.5 */
.site-loader__wrap {
  position: relative;
  width: 415px;
  height: 74px;
  max-width: min(85vw, 415px);
}

.site-loader__wrap svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 24px rgba(8, 148, 255, 0.18));
}

.site-loader__icon-flicker {
  animation: site-loader-icon-blink 0.412s linear 0s infinite;
}

@keyframes site-loader-icon-blink {
  0%, 49%   { opacity: 0; }
  50%, 99%  { opacity: 1; }
  100%      { opacity: 0; }
}

/* Character-by-character typewriter reveal */
.site-loader__text {
  clip-path: inset(0 100% 0 0);
  animation: site-loader-type 0.42s steps(13, end) 252ms forwards;
}

@keyframes site-loader-type {
  to { clip-path: inset(0 0 0 0); }
}

/* Caret tracks the reveal. Positions expressed as percentages so
   the caret lands correctly regardless of logo scale. */
.site-loader__cursor {
  position: absolute;
  top: 17%;
  width: 2.5px;
  height: 67%;
  border-radius: 2px;
  background: linear-gradient(180deg, #0894FF, #BD32D6);
  opacity: 0;
  animation:
    site-loader-cursor-move 0.42s steps(13, end) 252ms forwards,
    site-loader-cursor-blink 0.202s steps(2, start) 252ms infinite,
    site-loader-cursor-fade 0.109s ease 756ms forwards;
}

@keyframes site-loader-cursor-move {
  0%   { left: 19.22%; opacity: 1; }
  100% { left: 100%;   opacity: 1; }
}

@keyframes site-loader-cursor-blink {
  0%   { opacity: 1; }
  50%  { opacity: 0; }
}

@keyframes site-loader-cursor-fade {
  to { opacity: 0; }
}

/* ─── Under-wordmark fill bar (mirrors the original typewriter HTML).
   Sits flush with the baseline of the logo and fills in lock-step
   with the typewriter reveal. Separate from the top-of-viewport bar. */
.site-loader__underline {
  position: absolute;
  bottom: -10px;
  left: 15px;
  right: 0;
  height: 3px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(25, 26, 35, 0.06);
  opacity: 0;
  animation: site-loader-underline-in 0.01s 109ms forwards;
}

.site-loader__underline-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    #0894FF 0%,
    #BD32D6 35%,
    #6462EA 50%,
    #0894FF 70%,
    #FFA304 100%
  );
  box-shadow: 0 0 12px rgba(8, 148, 255, 0.4), 0 0 4px rgba(189, 50, 214, 0.3);
  animation: site-loader-underline-fill 0.546s steps(15, end) 109ms forwards;
}

@keyframes site-loader-underline-in {
  to { opacity: 1; }
}

@keyframes site-loader-underline-fill {
  to { width: 100%; }
}

/* ─── Top-of-viewport gradient progress bar ─── */
.site-loader__bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  overflow: hidden;
  background: rgba(25, 26, 35, 0.04);
  z-index: 2;
  pointer-events: none;
}

.site-loader__bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(8, 148, 255, 0)    0%,
    rgba(8, 148, 255, 0.85) 12%,
    rgba(100, 98, 234, 0.95) 28%,
    rgba(189, 50, 214, 0.95) 44%,
    rgba(100, 98, 234, 0.95) 60%,
    rgba(8, 148, 255, 0.95)  76%,
    rgba(255, 163, 4, 0.85)  92%,
    rgba(255, 163, 4, 0)    100%
  );
  background-size: 200% 100%;
  animation: site-loader-bar-slide 0.84s linear infinite;
  box-shadow: 0 0 8px rgba(100, 98, 234, 0.4);
}

@keyframes site-loader-bar-slide {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ─── Tight inline variant (callers passing `inline` prop) ─── */
.site-loader--inline {
  min-height: 360px;
}

.site-loader--inline .site-loader__watermark {
  font-size: 38vw;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .site-loader__stage    { padding: 24px 16px; }
  .site-loader__wrap     { height: auto; }
  .site-loader__watermark { font-size: 78vw; }
}

@media (prefers-reduced-motion: reduce) {
  .site-loader::before,
  .site-loader__watermark,
  .site-loader__icon-flicker,
  .site-loader__text,
  .site-loader__cursor,
  .site-loader__underline,
  .site-loader__underline-fill,
  .site-loader__bar::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-fill-mode: forwards !important;
  }
  .site-loader__text { clip-path: inset(0 0 0 0); }
}
