/* =====================================================================
   GROWS brand loader  (Figma: "GROWS loading animations", node 1-30)
   One 3.2s loop:
     1. a navy hairline grows into the GROWS box, wordmark fades in
     2. navy / red / cream dots pop in one after another
     3. dots do a typing wave
     4. everything collapses back in reverse
   A thin progress track sweeps a navy+red segment underneath.

   Markup lives in app/views/partials/loader.php; behaviour in js/loader.js.
   Scale the whole thing with --gl-s (1 = design size, 312px wide).
   ===================================================================== */

:root {
  --gl-navy:  #0F2243;
  --gl-red:   #D7362D;
  --gl-cream: #F8E1C4;
  --gl-bg:    #F6F5F8;
  --gl-track: #E3E2E5;
  --gl-dur:   3.2s;
}

/* ── Full-screen overlay ─────────────────────────────── */
.g-loader {
  --gl-s: 1;
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: var(--gl-bg);
  opacity: 0; visibility: hidden; pointer-events: none;
  /* hidden → instantly gone */
  transition: opacity .25s ease, visibility 0s linear .25s;
}
.g-loader.is-active {
  opacity: 1; visibility: visible; pointer-events: auto;
  /* Wait a beat before appearing so fast pages never flash it */
  transition: opacity .3s ease .35s, visibility 0s linear 0s;
}
/* Only spend CPU on the animation while it can be seen */
.g-loader:not(.is-active) * { animation-play-state: paused !important; }

.g-loader .gl-track {
  position: absolute; left: 50%; bottom: 9.5%;
  transform: translateX(-50%);
}

/* ── The mark: box + three dots ──────────────────────── */
.gl-mark {
  --gl-s: inherit;
  display: flex; align-items: center;
  width: calc(312px * var(--gl-s, 1));
  height: calc(50px * var(--gl-s, 1));
  gap: calc(8px * var(--gl-s, 1));
}

.gl-box {
  flex: none; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  height: calc(45px * var(--gl-s, 1));
  width: calc(150px * var(--gl-s, 1));
  background: var(--gl-navy);
  animation: gl-box var(--gl-dur) cubic-bezier(.65,0,.35,1) infinite both;
}
.gl-word {
  white-space: nowrap;
  font: 800 calc(15px * var(--gl-s, 1))/1 'Poppins','Inter','Segoe UI',Arial,sans-serif;
  letter-spacing: .32em; margin-right: -.32em; /* optically centre tracked text */
  color: #fff;
  animation: gl-word var(--gl-dur) linear infinite both;
}

.gl-dot {
  flex: none; border-radius: 50%;
  width: calc(44px * var(--gl-s, 1)); height: calc(44px * var(--gl-s, 1));
  margin-left: calc(2px * var(--gl-s, 1));
  background: var(--gl-navy);
  animation: gl-dot var(--gl-dur) cubic-bezier(.34,1.3,.64,1) infinite both;
}
.gl-dot.gl-d2 { background: var(--gl-red);   animation-delay: .16s; }
.gl-dot.gl-d3 { background: var(--gl-cream); animation-delay: .32s;
                         box-shadow: inset 0 0 0 1px rgba(15,34,67,.08); }

/* ── Progress track ──────────────────────────────────── */
.gl-track {
  display: block; overflow: hidden; border-radius: 4px;
  width: calc(120px * var(--gl-s, 1)); height: calc(4px * var(--gl-s, 1));
  background: var(--gl-track);
}
.gl-track::before {
  content: ""; display: block; height: 100%; width: 38%; border-radius: inherit;
  background: linear-gradient(90deg, var(--gl-navy) 0 58%, var(--gl-red) 58% 88%, var(--gl-cream) 88%);
  animation: gl-track var(--gl-dur) cubic-bezier(.45,.05,.55,.95) infinite both;
}

/* ── Keyframes (all share the same 3.2s period) ──────── */
@keyframes gl-box {
  0%   { width: calc(2px   * var(--gl-s, 1)); }
  6%   { width: calc(45px  * var(--gl-s, 1)); }
  15%  { width: calc(150px * var(--gl-s, 1)); }
  86%  { width: calc(150px * var(--gl-s, 1)); }
  92%  { width: calc(45px  * var(--gl-s, 1)); }
  98%, 100% { width: 0; }
}
@keyframes gl-word {
  0%, 12% { color: rgba(255,255,255,0); }
  16%     { color: rgba(255,255,255,.45); }
  22%, 80% { color: #fff; }
  85%     { color: rgba(255,255,255,.45); }
  88%, 100% { color: rgba(255,255,255,0); }
}
@keyframes gl-dot {
  0%, 24% { transform: scale(0); }
  30%     { transform: scale(1.12); }
  34%     { transform: scale(1); }
  46%     { transform: translateY(0); }
  51%     { transform: translateY(calc(-8px * var(--gl-s, 1))); }
  57%, 79% { transform: translateY(0) scale(1); }
  86%, 100% { transform: scale(0); }
}
@keyframes gl-track {
  0%, 8%  { transform: translateX(-105%); }
  78%, 100% { transform: translateX(270%); }
}

/* ── Inline variant: just the dots, for buttons / panels ──
   <span class="g-loader-dots" role="status" aria-label="Loading"><i></i><i></i><i></i></span> */
.g-loader-dots { display: inline-flex; align-items: center; gap: .3em; vertical-align: middle; }
.g-loader-dots i {
  width: .55em; height: .55em; border-radius: 50%; background: var(--gl-navy);
  animation: gl-mini 1.1s ease-in-out infinite both;
}
.g-loader-dots i:nth-child(2) { background: var(--gl-red);   animation-delay: .14s; }
.g-loader-dots i:nth-child(3) { background: var(--gl-cream); animation-delay: .28s; }
.btn .g-loader-dots i:first-child,
.g-loader-dots.is-light i:first-child { background: #fff; }
@keyframes gl-mini {
  0%, 60%, 100% { transform: translateY(0); opacity: .9; }
  30%           { transform: translateY(-.35em); opacity: 1; }
}

@media (max-width: 420px) { .g-loader { --gl-s: .85; } }

@media (prefers-reduced-motion: reduce) {
  .gl-box, .gl-word, .gl-dot, .g-loader-dots i { animation: none !important; }
  .gl-track::before { animation-duration: 6s; }
}
