/* =============================================================================
   loader.css — the logo-assembly loader (the curtain that hands off to #hero)
   ----------------------------------------------------------------------------
   • Full-screen, theme-aware backdrop above everything (--z-loader).
   • loader.js drives the 5-square ASSEMBLY + the FLIP handoff with GSAP, so
     this file does NOT keyframe the assembly itself — it only styles the
     resting layout, a subtle word pulse, the reduced-motion (static) path,
     and the hidden end-state used during/after the handoff.
   • <html.no-js> hides the loader entirely so no-JS users get content.
   ========================================================================== */

.loader {
  position: fixed;
  inset: 0;
  z-index: var(--z-loader);
  display: grid;
  place-items: center;
  grid-auto-flow: row;
  gap: clamp(1rem, 3vw, 1.75rem);
  /* theme-aware backdrop (flips with [data-theme]) */
  background-color: var(--surface-bg);
  color: var(--text-muted);
  /* paint containment — the loader is its own isolated layer */
  isolation: isolate;
  contain: layout style;
  /* fade handled by .loader--hidden / GSAP autoAlpha */
  transition:
    opacity var(--dur-slow, .8s) var(--ease-cinematic, ease),
    visibility var(--dur-slow, .8s) var(--ease-cinematic, ease);
}

/* No-JS: never trap content behind a curtain the JS can't remove. */
.no-js .loader { display: none; }

/* ---------- THE MARK ---------- */
.loader__mark {
  inline-size: clamp(96px, 18vw, 160px);
  block-size: clamp(96px, 18vw, 160px);
  /* the injected <svg> fills this box; rects animate about their own centers
     (transform-box:fill-box is also set defensively by loader.js via gsap.set) */
  display: block;
  will-change: transform;
}

.loader__mark .logomark {
  inline-size: 100%;
  block-size: 100%;
  display: block;
  overflow: visible; /* let scattered rects fly in from outside the viewBox */
}

/* each square scales/rotates about its own centre during assembly + handoff */
.loader__mark .logomark__sq {
  transform-box: fill-box;
  transform-origin: center center;
}

/* ---------- THE LOCKUP (mark + bilingual wordmark, like the real logo) ---------- */
.loader__lockup {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(.9rem, 2.6vw, 1.5rem);
  text-align: center;
}

/* the two name lines sit together under the mark.
   Visible by DEFAULT (no opacity:0) so the page paints text immediately —
   this guarantees First Contentful Paint even if GSAP/rAF is throttled
   (e.g. a backgrounded tab during Lighthouse). loader.js only slides them. */
.loader__words {
  display: grid;
  justify-items: center;
  gap: clamp(.15rem, .6vw, .35rem);
}

.loader__name-ar {
  font-family: var(--font-ar);
  font-weight: 700;
  font-size: clamp(1.5rem, 5.5vw, 2.6rem);
  /* the brand Arabic face has DEEP descenders (the final م of "برايم") — too
     little line-height lets that tail touch the "P" of "Prime" on the line
     below, so give the line plenty of room */
  line-height: 1.5;
  letter-spacing: .01em;
  /* keep a clear gap between the two words "مدارس" / "برايم" — the brand Arabic
     face renders the inter-word space too tight, so they read as one word */
  word-spacing: .2em;
  color: var(--brand-primary);   /* purple (light) / light-purple (dark) */
}

.loader__name-en {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: clamp(.95rem, 3vw, 1.55rem);
  line-height: 1.1;
  margin-block-start: .15em;   /* extra clearance under the Arabic descenders */
  letter-spacing: .12em;
  color: var(--brand-secondary); /* pink, mirrors the brand lockup */
}

/* ---------- HIDDEN END-STATE (set by JS after the handoff) ---------- */
.loader--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* =============================================================================
   REDUCED MOTION — show the assembled mark statically (no scatter); JS removes
   the loader quickly. We also stop the word pulse and just hold it visible.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .loader {
    transition: opacity var(--dur, .4s) linear, visibility var(--dur, .4s) linear;
  }
  .loader__words {
    opacity: .95;
  }
  /* squares rest in their home positions — loader.js will not scatter them */
  .loader__mark .logomark__sq {
    transform: none;
    opacity: 1;
  }
}
