/* ════════════════════════════════════════════════════════════════════
   PAGE LOADER — minimalist cinematic premium.
   Apple / Linear / Stripe vibe: dark, calm, brand wordmark reveal +
   ultra-thin progress line. NO rings, NO orbs, NO particles.
   ════════════════════════════════════════════════════════════════════ */

#tm-page-loader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  grid-template-rows: 1fr auto;
  background: #02040c;
  overflow: hidden;
}

/* Subtle radial brand glow behind the wordmark — barely visible,
   adds depth without being noisy. */
#tm-page-loader::before {
  content: '';
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(ellipse 50% 35% at 50% 50%,
      rgba(var(--brand-primary-rgb, 99, 102, 241), 0.12) 0%,
      transparent 60%),
    radial-gradient(ellipse 40% 30% at 35% 60%,
      rgba(var(--brand-accent-rgb, 6, 182, 212), 0.08) 0%,
      transparent 60%),
    radial-gradient(ellipse 40% 30% at 65% 40%,
      rgba(var(--brand-secondary-rgb, 236, 72, 153), 0.08) 0%,
      transparent 60%);
  filter: blur(60px);
  z-index: 0;
  animation: tm-pl2-drift 18s ease-in-out infinite;
  pointer-events: none;
}
@keyframes tm-pl2-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(2%, -1%) scale(1.04); }
  66%      { transform: translate(-1%, 2%) scale(0.97); }
}

body.light #tm-page-loader {
  background: #f8faff;
}
body.light #tm-page-loader::before {
  opacity: 0.5;
}

/* Center stage holds the wordmark. */
.tm-pl2-stage {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  gap: 18px;
  padding: 24px;
  align-self: center;
  justify-self: center;
}

/* The wordmark — clean fade-in (whole word, safe with any script). */
.tm-pl2-wordmark {
  display: inline-flex;
  align-items: center;
  font-family: 'Cairo', sans-serif;
  font-weight: 900;
  font-size: clamp(28px, 5vw, 52px);
  letter-spacing: clamp(2px, 0.4vw, 6px);
  line-height: 1.1;
  text-align: center;
}
.tm-pl2-text {
  display: inline-block;
  background: linear-gradient(135deg,
    #ffffff 0%,
    var(--brand-primary, #6366f1) 55%,
    var(--brand-accent,  #06b6d4) 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  opacity: 0;
  transform: translateY(16px);
  filter: blur(8px);
  animation: tm-pl2-fade-in 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.15s forwards;
  text-shadow: 0 0 40px rgba(var(--brand-primary-rgb, 99, 102, 241), 0.25);
}
@keyframes tm-pl2-fade-in {
  to { opacity: 1; transform: none; filter: blur(0); }
}

body.light .tm-pl2-text {
  background: linear-gradient(135deg,
    #0f172a 0%,
    var(--brand-primary, #6366f1) 60%,
    var(--brand-secondary, #ec4899) 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
}

/* Logo image variant (used when BRAND.logoUrl is set). */
.tm-pl2-logo-img {
  max-width: clamp(180px, 30vw, 320px);
  max-height: clamp(70px, 10vh, 120px);
  opacity: 0;
  transform: translateY(12px);
  filter: drop-shadow(0 8px 30px rgba(var(--brand-primary-rgb, 99, 102, 241), 0.35));
  animation: tm-pl2-logo-in 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.15s forwards;
}
@keyframes tm-pl2-logo-in {
  to { opacity: 1; transform: none; }
}

/* Optional tagline slot — empty for now, easy to fill via JS later. */
.tm-pl2-tagline {
  font-family: 'Cairo', sans-serif;
  font-size: 11px;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 6px;
}
body.light .tm-pl2-tagline { color: rgba(15, 23, 42, 0.40); }

/* Ultra-thin progress line at the very bottom. */
.tm-pl2-progress {
  position: relative;
  z-index: 2;
  height: 2px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.tm-pl2-progress span {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg,
    var(--brand-primary, #6366f1),
    var(--brand-accent,  #06b6d4),
    var(--brand-secondary, #ec4899));
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 14px rgba(var(--brand-primary-rgb, 99, 102, 241), 0.5);
}
[dir="rtl"] .tm-pl2-progress span { transform-origin: right; }

body.light .tm-pl2-progress { background: rgba(15, 23, 42, 0.08); }

/* Hide / fade-out. */
#tm-page-loader.tm-pl2-hide {
  opacity: 0;
  transform: scale(1.03);
  filter: blur(8px);
  transition: opacity 0.55s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              filter 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

/* Respect reduced-motion users. */
@media (prefers-reduced-motion: reduce) {
  .tm-pl2-letter,
  .tm-pl2-logo-img {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
  #tm-page-loader::before { animation: none !important; }
}

/* ════════════════════════════════════════════════════════════════════
   ADMIN AUTO-OPTIMIZE PILL (unchanged feature)
   ════════════════════════════════════════════════════════════════════ */
.pf-opt-pill {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px 12px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, #0f172a 0%, #0a0e1d 100%);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #e2e8f0;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  min-width: 280px;
  animation: pf-opt-pill-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes pf-opt-pill-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}
.pf-opt-pill.done   { border-color: rgba(34, 197, 94, 0.5); }
.pf-opt-pill.error  { border-color: rgba(239, 68, 68, 0.5); }

.pf-opt-pill-spin {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(236, 72, 153, 0.3));
  border: 1px solid rgba(99, 102, 241, 0.5);
  display: grid;
  place-items: center;
  font-size: 14px;
  color: #c7d2fe;
  animation: pf-opt-pill-spin 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pf-opt-pill-spin {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}
.pf-opt-pill.done .pf-opt-pill-spin { animation: none; background: rgba(34, 197, 94, 0.5); border-color: rgba(34, 197, 94, 0.7); color: #fff; }

.pf-opt-pill-body { flex: 1; min-width: 0; }
.pf-opt-pill-title {
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 4px;
}
.pf-opt-pill-text {
  font-size: 11px;
  color: rgba(226, 232, 240, 0.65);
  margin-bottom: 6px;
}
.pf-opt-pill-bar {
  width: 100%;
  height: 3px;
  background: rgba(99, 102, 241, 0.15);
  border-radius: 999px;
  overflow: hidden;
}
.pf-opt-pill-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand-primary, #6366f1), var(--brand-secondary, #ec4899));
  border-radius: inherit;
  transition: width 0.3s ease;
}

/* Hero canvas return jump fix. */
.cine-hero #heroFrameCanvas { transition-duration: 0s !important; }

/* ════════════════════════════════════════════════════════════════════
   SCROLL OPTIMIZATION — while body.is-scrolling is on, disable the
   heaviest effects so scrolling is buttery. They snap back on stop.
   ════════════════════════════════════════════════════════════════════ */
body.is-scrolling *,
body.is-scrolling *::before,
body.is-scrolling *::after {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
body.is-scrolling .bg-orb,
body.is-scrolling .hv3-fog-layer,
body.is-scrolling .hv3-beam,
body.is-scrolling .cine-particle,
body.is-scrolling .cine-hero-streak,
body.is-scrolling .cine-hero-glow {
  filter: blur(20px) !important;
  opacity: 0.5 !important;
}
body.is-scrolling .tm-anim-cover-frame { animation-play-state: paused; }
/* Removed: was killing reveal transitions during scroll, causing the
   "section jumps then takes time to fade in" feeling. Let reveal play. */

