/* ==========================================================
   ALL ROUNDER CALCULATOR — LOADING & ANIMATION SYSTEM
   Version 2.1 — Phase 1 (Premium UX Foundation)

   This file is INFRASTRUCTURE ONLY. It is not yet linked from
   any page. A future phase will decide where/when to enable it.

   Dependency: must be loaded together with assets/style.css,
   since it reuses the same design tokens (--clr-bg, --clr-primary,
   --clr-gold, --clr-text, --clr-text-muted, --clr-border, etc).
   It defines zero new colors of its own, by design — the splash
   screen and loaders always match whatever the live site theme is.

   Contains:
   1. Animation tokens (durations / easing)
   2. Reusable animation utility classes (fade / scale / blur)
   3. The single .arc-loader component (splash / transition / mini)
   4. A generic .arc-overlay backdrop utility
   5. Spinner + indeterminate progress bar primitives
   6. prefers-reduced-motion handling
   ========================================================== */

/* ---------- 1. ANIMATION TOKENS ---------- */
:root {
  --arc-duration-fast:   180ms;
  --arc-duration-base:   400ms;
  --arc-duration-slow:   700ms;
  --arc-duration-splash: 900ms;
  --arc-ease-standard:   cubic-bezier(.4, 0, .2, 1);
  --arc-ease-out:        cubic-bezier(0, 0, .2, 1);
  --arc-ease-in:         cubic-bezier(.4, 0, 1, 1);
  --arc-scale-in:        0.92;
  --arc-blur-amount:     8px;
  --arc-z-overlay:       3000;
  --arc-z-splash:        4000;
}

/* ---------- 2. REUSABLE ANIMATION UTILITY CLASSES ----------
   Applied directly to any element. Each class only animates
   transform/opacity/filter — never layout properties — so they
   never trigger layout thrashing or forced reflow. Each is a
   one-shot "enter" animation; add the class, it plays once. */

.arc-anim-fade-in {
  animation: arcFadeIn var(--arc-duration-base) var(--arc-ease-standard) both;
}

.arc-anim-fade-up {
  animation: arcFadeUp var(--arc-duration-base) var(--arc-ease-out) both;
}

.arc-anim-scale-in {
  animation: arcScaleIn var(--arc-duration-base) var(--arc-ease-out) both;
}

.arc-anim-blur-in {
  animation: arcBlurIn var(--arc-duration-slow) var(--arc-ease-standard) both;
}

/* Stagger helper: pair with the classes above, e.g.
   class="arc-anim-fade-up arc-delay-1" */
.arc-delay-1 { animation-delay: 90ms; }
.arc-delay-2 { animation-delay: 180ms; }
.arc-delay-3 { animation-delay: 270ms; }

@keyframes arcFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes arcFadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes arcScaleIn {
  from { opacity: 0; transform: scale(var(--arc-scale-in)); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes arcBlurIn {
  from { opacity: 0; filter: blur(var(--arc-blur-amount)); }
  to   { opacity: 1; filter: blur(0); }
}

/* ---------- 3. THE .arc-loader COMPONENT ----------
   One component, three presentations, controlled purely by a
   modifier class. All three share the same base rules below so
   nothing is duplicated between splash / transition / mini. */

.arc-loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--clr-bg);
  z-index: var(--arc-z-splash);
  opacity: 1;
  transition: opacity var(--arc-duration-slow) var(--arc-ease-standard);
}

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

/* Fully removed from the accessibility tree + layout once hidden */
.arc-loader[hidden] { display: none; }

.arc-loader__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 24px;
}

.arc-loader__logo {
  width: 84px;
  height: 84px;
  border-radius: 20px;
  margin-bottom: 6px;
}

.arc-loader__title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  background: linear-gradient(90deg, var(--clr-primary), var(--clr-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.arc-loader__tagline {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  margin: 0;
}

/* --- Modifier: Splash Screen ---
   Full-viewport, brand-first, shown once on cold load. Uses the
   slower --arc-duration-splash timing for a deliberate, elegant
   feel rather than a snappy UI transition. */
.arc-loader--splash .arc-loader__logo {
  animation: arcScaleIn var(--arc-duration-splash) var(--arc-ease-out) both;
}
.arc-loader--splash .arc-loader__title {
  animation: arcFadeUp var(--arc-duration-splash) var(--arc-ease-out) both;
  animation-delay: 150ms;
}
.arc-loader--splash .arc-loader__tagline {
  animation: arcFadeUp var(--arc-duration-splash) var(--arc-ease-out) both;
  animation-delay: 280ms;
}

/* --- Modifier: Page Transition Overlay ---
   Same fixed full-screen backdrop, lighter weight, no logo
   lockup animation — just a dim backdrop plus a spinner, meant
   to appear/disappear quickly between in-app navigations. */
.arc-loader--transition {
  background: color-mix(in srgb, var(--clr-bg) 92%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: opacity var(--arc-duration-fast) var(--arc-ease-standard);
}
.arc-loader--transition .arc-loader__inner { padding: 0; gap: 0; }

/* --- Modifier: Mini Loader ---
   Not fixed/full-screen — sits inline wherever it's mounted
   (e.g. inside a button or a result card) to show a small,
   localized busy state. */
.arc-loader--mini {
  position: static;
  inset: auto;
  background: transparent;
  z-index: auto;
  display: inline-flex;
  width: auto;
  height: auto;
  transition: none;
}
.arc-loader--mini .arc-loader__inner { padding: 0; gap: 0; }

/* ---------- 4. GENERIC OVERLAY BACKDROP UTILITY ----------
   For any future dimmed-backdrop need that isn't the loader
   itself (e.g. a modal backdrop). Kept separate from .arc-loader
   so it can be reused independently. */
.arc-overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--clr-bg) 80%, transparent);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--arc-duration-base) var(--arc-ease-standard);
  z-index: var(--arc-z-overlay);
}
.arc-overlay.arc-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- 5. SPINNER + PROGRESS PRIMITIVES ---------- */

.arc-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--clr-border);
  border-top-color: var(--clr-primary);
  animation: arcSpin 800ms linear infinite;
}
.arc-spinner--sm {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

@keyframes arcSpin {
  to { transform: rotate(360deg); }
}

.arc-progress {
  width: 160px;
  max-width: 60vw;
  height: 4px;
  border-radius: 4px;
  background: var(--clr-border);
  overflow: hidden;
}
.arc-progress__bar {
  height: 100%;
  width: 40%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--clr-primary), var(--clr-gold));
  animation: arcProgressIndeterminate 1.1s var(--arc-ease-standard) infinite;
}

@keyframes arcProgressIndeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

/* ---------- 6. ACCESSIBILITY: REDUCED MOTION ----------
   Every animation above collapses to an instant, static end
   state. The spinner and progress bar still need *some* motion
   to communicate "busy" to a sighted user, so they're slowed
   and simplified rather than removed outright — this matches
   the WCAG guidance that reduced motion means calmer, not
   necessarily zero, movement for indeterminate-wait indicators. */
@media (prefers-reduced-motion: reduce) {
  .arc-anim-fade-in,
  .arc-anim-fade-up,
  .arc-anim-scale-in,
  .arc-anim-blur-in,
  .arc-loader--splash .arc-loader__logo,
  .arc-loader--splash .arc-loader__title,
  .arc-loader--splash .arc-loader__tagline {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
  .arc-loader,
  .arc-loader--transition,
  .arc-overlay {
    transition-duration: 1ms !important;
  }
  .arc-spinner {
    animation-duration: 1500ms !important;
  }
  .arc-progress__bar {
    animation-duration: 2200ms !important;
  }
}

/* ==========================================================
   END OF FILE
   ========================================================== */
