/* Cover Genie loader — "Brass Orbit".  Load AFTER style.css and light.css.
   Design rules that keep it smooth and professional:
   1. ONE clock. Every loop below is a multiple of --ov-t (2.4s), so glow, orbit, sheen,
      title shimmer and progress line breathe together and never drift apart.
   2. Nothing is "one-shot". The glow, ring and arcs run for as long as the loader is on screen,
      and they keep running while it fades out (they are only reset after the fade has finished).
   3. Only transform / opacity are animated on the big layers, so it stays 60fps on phones.
   4. Soft enter and soft exit (no pop in, no cut off). */

:root{
  --ov-t: 2.4s;
  --ov-ease: cubic-bezier(.22,.9,.32,1);
  --ov-sine: cubic-bezier(.45,.05,.55,.95);
  --ov-size: 132px;            /* ring diameter  */
  --ov-tile-size: 72px;        /* logo tile      */
  --ov-gold-1: #F0C378;        /* = --brass-2    */
  --ov-gold-2: #D6A24A;        /* = --brass      */
  --ov-gold-3: #8A6A2C;
  --ov-glow: rgba(214,162,74,.42);
  --ov-glow-soft: rgba(214,162,74,.14);
  --ov-hair: rgba(214,162,74,.26);
  --ov-hair-2: rgba(255,255,255,.07);
  --ov-track: rgba(255,255,255,.10);
  --ov-tile-line: rgba(214,162,74,.55);
  --ov-veil: rgba(9,11,16,.80);
}
html[data-theme="light"]{
  --ov-gold-1: #E3B35A;
  --ov-gold-2: #B97F14;
  --ov-gold-3: #8A5E10;
  --ov-glow: rgba(185,127,20,.30);
  --ov-glow-soft: rgba(185,127,20,.10);
  --ov-hair: rgba(185,127,20,.30);
  --ov-hair-2: rgba(20,28,48,.07);
  --ov-track: rgba(20,28,48,.12);
  --ov-tile-line: rgba(185,127,20,.55);
  --ov-veil: rgba(238,241,246,.84);
}

/* ---------- backdrop: soft fade in / fade out, never a cut ---------- */
.app-loader{
  background:
    radial-gradient(60% 46% at 50% 46%, var(--ov-glow-soft), transparent 72%),
    var(--ov-veil);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
          backdrop-filter: blur(10px) saturate(1.1);
  transition: opacity .55s var(--ov-sine), visibility 0s linear .55s;
}
.app-loader.show{ transition: opacity .35s var(--ov-ease), visibility 0s; }
html[data-theme="light"] .app-loader{
  background:
    radial-gradient(60% 46% at 50% 46%, var(--ov-glow-soft), transparent 72%),
    var(--ov-veil);
}

/* ---------- the card is just a stage now (no box) ---------- */
.app-loader .app-loader-card,
html[data-theme="light"] .app-loader .app-loader-card{
  width:auto; min-width:0; min-height:0; padding:0; gap:0;
  border:0; border-radius:0; background:none; box-shadow:none;
  position:relative; overflow:visible; align-items:center;
}
.app-loader:not(.ov-ready) .app-loader-card{ opacity:0; }   /* nothing shows until the logo is decoded */
.app-loader .app-loader-icon{ filter:none !important; min-height:0; margin:0; font-size:0; line-height:0; }

/* ---------- logo stage ---------- */
.ov-loader-logo{
  position:relative; display:block; width:var(--ov-size); height:var(--ov-size);
  contain:layout style;
}
.ov-loader-logo > i{ position:absolute; display:block; pointer-events:none; border-radius:50%; }

/* breathing glow (two layers: the outer one fades in once, the inner one breathes forever) */
.ov-halo{ inset:-52px; }
.ov-halo::before{
  content:""; position:absolute; inset:0; border-radius:50%;
  background:radial-gradient(circle, var(--ov-glow) 0%, rgba(214,162,74,.10) 42%, transparent 66%);
  will-change:transform,opacity;
}
html[data-theme="light"] .ov-halo::before{
  background:radial-gradient(circle, var(--ov-glow) 0%, rgba(185,127,20,.08) 42%, transparent 66%);
}

/* hairline rings */
.ov-ring{ inset:0; box-shadow:inset 0 0 0 1px var(--ov-hair); }
.ov-ring-2{ inset:-13px; box-shadow:inset 0 0 0 1px var(--ov-hair-2); }

/* orbiting arcs: tail = masked conic gradient (::before), head = glowing bead (::after) */
.ov-arc{ inset:0; will-change:transform; }
.ov-arc::before{
  content:""; position:absolute; inset:0; border-radius:50%;
  background:conic-gradient(from 0deg, transparent 0deg 190deg, rgba(214,162,74,.0) 190deg, var(--ov-gold-3) 262deg, var(--ov-gold-2) 330deg, var(--ov-gold-1) 360deg);
  -webkit-mask:radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.4px), #000 calc(100% - .6px), transparent 100%);
          mask:radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.4px), #000 calc(100% - .6px), transparent 100%);
}
.ov-arc::after{
  content:""; position:absolute; top:-2.5px; left:50%; width:7px; height:7px; margin-left:-3.5px; border-radius:50%;
  background:radial-gradient(circle at 40% 35%, #fff 0, var(--ov-gold-1) 45%, var(--ov-gold-2) 100%);
  box-shadow:0 0 8px 1px var(--ov-gold-1), 0 0 18px 3px var(--ov-glow);
}
.ov-arc-2{ inset:-13px; }
.ov-arc-2::before{
  background:conic-gradient(from 0deg, transparent 0deg 250deg, var(--ov-gold-3) 330deg, var(--ov-gold-2) 360deg);
  opacity:.55;
  -webkit-mask:radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px), #000 calc(100% - .5px), transparent 100%);
          mask:radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px), #000 calc(100% - .5px), transparent 100%);
}
.ov-arc-2::after{ width:4px; height:4px; margin-left:-2px; top:-1.5px; opacity:.8; box-shadow:0 0 6px 1px var(--ov-gold-1); }

/* logo tile */
.ov-tile{
  position:absolute; left:50%; top:50%;
  width:var(--ov-tile-size); height:var(--ov-tile-size);
  margin:calc(var(--ov-tile-size) / -2) 0 0 calc(var(--ov-tile-size) / -2);
  border-radius:24%; overflow:hidden; background:#000;
  box-shadow:0 0 0 1px var(--ov-tile-line), 0 16px 30px -14px rgba(0,0,0,.75), 0 0 28px -6px var(--ov-glow);
  will-change:transform;
}
html[data-theme="light"] .ov-tile{ box-shadow:0 0 0 1px var(--ov-tile-line), 0 14px 26px -12px rgba(20,28,48,.45), 0 0 26px -8px var(--ov-glow); }
.ov-tile img{ display:block; width:100%; height:100%; object-fit:cover; border-radius:0; box-shadow:none; animation:none; }
.ov-tile::after{          /* light sheen that glides across the logo */
  content:""; position:absolute; inset:-10%;
  background:linear-gradient(115deg, transparent 36%, rgba(255,255,255,.30) 50%, transparent 64%);
  transform:translateX(-130%); will-change:transform;
}

/* ---------- text ---------- */
.app-loader .app-loader-title{
  margin-top:30px; min-height:1.3em;
  font-family:'Space Grotesk', system-ui, sans-serif; font-size:13px; font-weight:600;
  letter-spacing:.26em; text-transform:uppercase; text-indent:.26em;   /* indent re-centres the tracked text */
  color:var(--text); text-align:center; white-space:nowrap;
  background:linear-gradient(100deg, var(--text) 40%, var(--ov-gold-1) 50%, var(--text) 60%) 100% 0 / 300% 100% no-repeat;
  -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent;
}
html[data-theme="light"] .app-loader .app-loader-title{
  background:linear-gradient(100deg, var(--text) 40%, var(--ov-gold-2) 50%, var(--text) 60%) 100% 0 / 300% 100% no-repeat;
  -webkit-background-clip:text; background-clip:text;
}
.app-loader .app-loader-text{
  margin-top:9px; min-height:1.2em;
  font-family:'JetBrains Mono', ui-monospace, monospace; font-size:10px;
  letter-spacing:.2em; text-indent:.2em; text-transform:uppercase; color:var(--text-dim); text-align:center;
}
.app-loader-text.ov-swap{ animation:ovTextIn .38s var(--ov-ease) both; }

/* indeterminate progress hairline */
.ov-bar{
  position:relative; display:block; width:calc(var(--ov-size) * 1.45); height:2px; margin-top:22px;
  border-radius:2px; overflow:hidden; background:var(--ov-track);
}
.ov-bar > i{
  position:absolute; inset:0 auto 0 0; width:42%; border-radius:2px;
  background:linear-gradient(90deg, transparent, var(--ov-gold-2) 35%, var(--ov-gold-1) 60%, transparent);
  transform:translateX(-100%); will-change:transform;
}

/* ================= motion =================
   Animations exist while the loader is NOT idle.  JS adds .ov-idle only after the fade-out has
   finished, which (a) stops all animation when nothing is visible and (b) restarts the whole
   entrance from frame 0 the next time it opens. */
.app-loader.ov-ready:not(.ov-idle) .ov-halo{        animation:ovFadeIn 1s var(--ov-ease) both; }
.app-loader.ov-ready:not(.ov-idle) .ov-halo::before{ animation:ovBreathe var(--ov-t) var(--ov-sine) infinite; }
.app-loader.ov-ready:not(.ov-idle) .ov-ring{        animation:ovFadeIn .7s var(--ov-ease) .10s both; }
.app-loader.ov-ready:not(.ov-idle) .ov-ring-2{      animation:ovFadeIn .9s var(--ov-ease) .20s both; }
.app-loader.ov-ready:not(.ov-idle) .ov-arc{         animation:ovFadeIn .6s var(--ov-ease) .25s both, ovOrbit var(--ov-t) cubic-bezier(.42,.12,.58,.88) .25s infinite; }
.app-loader.ov-ready:not(.ov-idle) .ov-arc-2{       animation:ovFadeIn .6s var(--ov-ease) .35s both, ovOrbitBack calc(var(--ov-t) * 2) linear .35s infinite; }
.app-loader.ov-ready:not(.ov-idle) .ov-tile{        animation:ovTileIn .8s var(--ov-ease) both, ovFloat var(--ov-t) var(--ov-sine) .8s infinite; }
.app-loader.ov-ready:not(.ov-idle) .ov-tile::after{ animation:ovSheen var(--ov-t) var(--ov-sine) .9s infinite; }
.app-loader.ov-ready:not(.ov-idle) .app-loader-title{ animation:ovRise .7s var(--ov-ease) .30s both, ovShine var(--ov-t) var(--ov-sine) 1s infinite; }
.app-loader.ov-ready:not(.ov-idle) .app-loader-text{  animation:ovRise .7s var(--ov-ease) .40s both; }
.app-loader.ov-ready:not(.ov-idle) .app-loader-text.ov-swap{ animation:ovTextIn .38s var(--ov-ease) both; }
.app-loader.ov-ready:not(.ov-idle) .ov-bar{          animation:ovFadeIn .7s var(--ov-ease) .50s both; }
.app-loader.ov-ready:not(.ov-idle) .ov-bar > i{      animation:ovSlide var(--ov-t) cubic-bezier(.6,.02,.35,.98) .6s infinite; }

@keyframes ovFadeIn{ from{opacity:0} to{opacity:1} }
@keyframes ovRise{   from{opacity:0; transform:translateY(8px)} to{opacity:1; transform:none} }
@keyframes ovTextIn{ from{opacity:0; transform:translateY(4px)} to{opacity:1; transform:none} }
@keyframes ovTileIn{ from{opacity:0; transform:scale(.84)} to{opacity:1; transform:scale(1)} }
@keyframes ovBreathe{ 0%,100%{opacity:.55; transform:scale(.93)} 50%{opacity:1; transform:scale(1.07)} }
@keyframes ovFloat{  0%,100%{transform:translateY(0) scale(1)} 50%{transform:translateY(-3px) scale(1.035)} }
@keyframes ovOrbit{     to{transform:rotate(360deg)} }
@keyframes ovOrbitBack{ to{transform:rotate(-360deg)} }
@keyframes ovSheen{  0%{transform:translateX(-130%)} 52%,100%{transform:translateX(130%)} }
@keyframes ovShine{  0%{background-position:100% 0} 55%,100%{background-position:0 0} }
@keyframes ovSlide{  0%{transform:translateX(-100%)} 100%{transform:translateX(240%)} }

@media (max-width:480px){
  :root{ --ov-size:112px; --ov-tile-size:62px; }
  .app-loader .app-loader-title{ font-size:12px; letter-spacing:.22em; text-indent:.22em; }
}

/* reduced motion: no travel at all, only a calm glow */
@media (prefers-reduced-motion:reduce){
  .app-loader.ov-ready:not(.ov-idle) .ov-arc,
  .app-loader.ov-ready:not(.ov-idle) .ov-arc-2,
  .app-loader.ov-ready:not(.ov-idle) .ov-tile,
  .app-loader.ov-ready:not(.ov-idle) .ov-tile::after,
  .app-loader.ov-ready:not(.ov-idle) .app-loader-title{ animation:ovFadeIn .6s ease both; }
  .app-loader.ov-ready:not(.ov-idle) .ov-arc{ transform:rotate(-35deg); }
  .app-loader.ov-ready:not(.ov-idle) .ov-arc-2{ transform:rotate(120deg); }
  .app-loader.ov-ready:not(.ov-idle) .ov-tile::after{ opacity:0; }
  .app-loader.ov-ready:not(.ov-idle) .ov-bar > i{ animation:ovPulse var(--ov-t) ease-in-out infinite; transform:none; width:100%; }
  .app-loader.ov-ready:not(.ov-idle) .ov-halo::before{ animation:ovPulse calc(var(--ov-t) * 1.5) ease-in-out infinite; }
  .app-loader.ov-ready:not(.ov-idle) .app-loader-title{ -webkit-text-fill-color:var(--text); background:none; }
}
@keyframes ovPulse{ 0%,100%{opacity:.45} 50%{opacity:1} }

/* Landing / editor window brand mark (replaces the witch hat) */
.window-brand .ov-mark{ width:16px;height:16px;border-radius:24%;margin-right:5px;vertical-align:-3px;display:inline-block;object-fit:contain; }
