/*==========================================================
   css/loading.css — the concise.plus loading screen
   Works two ways:
     • as a full page (loading.php?next=/home.php)
     • as an overlay on any page (include loader.inc.php right after <body>)
   Load order on app pages: home.css, scroll.css, [page css], loading.css
   Every colour comes from the shared tokens (--accent, --bg-page …);
   the fallbacks after each comma let it also run on its own.
==========================================================*/

html.cp-lock, html.cp-lock body{ overflow:hidden; }
body.cp-page{ margin:0; background:#0a0a0c; min-height:100vh; }

.cp-loader{
    --cp-bg:var(--bg-page,#0a0a0c);
    --cp-line:var(--border-subtle,rgba(255,255,255,.08));
    --cp-line2:var(--border-strong,rgba(255,255,255,.16));
    --cp-text:var(--text-primary,#f3f3f5);
    --cp-text2:var(--text-secondary,#c8c8d0);
    --cp-muted:var(--text-muted,#93939c);
    --cp-accent:var(--accent,#ffb055);
    --cp-accent2:var(--accent-strong,#ff9a2e);
    --cp-on:var(--accent-contrast,#1a1206);
    --cp-gut:var(--gutter,18px);

    position:fixed; inset:0; z-index:9999;
    display:flex; flex-direction:column;
    overflow:hidden;
    color:var(--cp-text);
    font-family:'Montserrat', sans-serif;
    -webkit-font-smoothing:antialiased;
    background:
        radial-gradient(120% 60% at 100% 0%, rgba(255,176,85,.34) 0%, rgba(255,176,85,0) 60%),
        linear-gradient(180deg, #3a1d08 0, #1b1007 28%, var(--cp-bg) 68%);
    transition:opacity .6s ease, filter .6s ease, transform .6s cubic-bezier(.2,.8,.2,1);
}
.cp-loader *, .cp-loader *::before, .cp-loader *::after{ box-sizing:border-box; }
.cp-loader[hidden]{ display:none !important; }
/* leaving: the screen turns to glass and clears — transparency, literally */
.cp-loader.is-leaving{ opacity:0; filter:blur(10px); transform:scale(1.04); pointer-events:none; }

.cp-sr{ position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

/* ---------- thin sweeping bar across the very top ---------- */
.cp-bar{ position:absolute; left:0; right:0; top:0; height:3px; z-index:5; overflow:hidden; background:rgba(255,255,255,.05); }
.cp-bar::after{
    content:""; position:absolute; top:0; bottom:0; left:0; width:40%;
    background:linear-gradient(90deg, transparent, var(--cp-accent), var(--cp-accent2), transparent);
    animation:cpBar 1.6s cubic-bezier(.5,0,.3,1) infinite;
}
@keyframes cpBar{ from{ transform:translateX(-100%); } to{ transform:translateX(260%); } }

/* ---------- background: drifting glow, dot grid, the eclipse ring, rising sparks ---------- */
.cp-bg{ position:absolute; inset:0; overflow:hidden; pointer-events:none; z-index:0; }
.cp-blob{ position:absolute; border-radius:50%; opacity:.55; will-change:transform; }
.cp-blob.a{
    width:46vmax; height:46vmax; right:-16vmax; top:-18vmax;
    background:radial-gradient(circle, rgba(255,154,46,.55), transparent 65%);
    animation:cpDrift 16s ease-in-out infinite;
}
.cp-blob.b{
    width:38vmax; height:38vmax; left:-14vmax; bottom:-16vmax;
    background:radial-gradient(circle, rgba(255,176,85,.24), transparent 65%);
    animation:cpDrift 21s ease-in-out infinite reverse;
}
@keyframes cpDrift{ 0%,100%{ transform:translate3d(-4%,-3%,0) scale(1); } 50%{ transform:translate3d(5%,4%,0) scale(1.12); } }

.cp-grid{
    position:absolute; inset:0;
    background-image:radial-gradient(rgba(255,255,255,.1) 1px, transparent 1.6px);
    background-size:26px 26px;
    -webkit-mask-image:radial-gradient(70% 60% at 50% 45%, #000, transparent 82%);
            mask-image:radial-gradient(70% 60% at 50% 45%, #000, transparent 82%);
    opacity:.7;
}
.cp-eclipse{
    position:absolute; right:-70px; top:-60px; width:230px; height:230px; border-radius:50%;
    background:radial-gradient(circle at 50% 50%, #0a0a0c 0 58%, rgba(255,176,85,0) 59%);
    box-shadow:0 0 0 2px rgba(255,176,85,.55), 0 0 60px 8px rgba(255,154,46,.35);
    opacity:.55;
    animation:cpBreath 6s ease-in-out infinite;
}

.cp-particles{ position:absolute; inset:0; }
.cp-particles i{
    position:absolute; bottom:-12px; left:var(--x);
    width:var(--s); height:var(--s); border-radius:50%;
    background:var(--cp-accent); opacity:0;
    box-shadow:0 0 10px 1px rgba(255,176,85,.7);
    animation:cpRise var(--t) linear var(--d) infinite;
}
@keyframes cpRise{
    0%{ transform:translate3d(0,0,0); opacity:0; }
    12%{ opacity:.9; }
    80%{ opacity:.5; }
    100%{ transform:translate3d(var(--dx),-105vh,0); opacity:0; }
}

/* ---------- top row ---------- */
.cp-top{
    position:relative; z-index:2;
    display:flex; align-items:center; justify-content:space-between; gap:12px;
    padding:calc(env(safe-area-inset-top, 0px) + 16px) var(--cp-gut) 0;
}
.cp-brand{ display:inline-flex; align-items:center; gap:10px; font-size:20px; font-weight:800; letter-spacing:-.01em; }
.cp-brand img{ width:30px; height:30px; object-fit:contain; border-radius:8px; }
.cp-brand b{ color:var(--cp-accent); font-weight:800; }
.cp-tag{ font-size:12px; font-weight:600; letter-spacing:.08em; text-transform:uppercase; color:var(--cp-muted); }

/* ---------- the centre of the screen: the animated logo, and under it what is happening ---------- */
.cp-main{
    position:absolute; inset:0; z-index:2;
    --cp-pad:calc(64px + max(env(safe-area-inset-top, 0px), env(safe-area-inset-bottom, 0px)));
    padding:var(--cp-pad) var(--cp-gut);                 /* equal above and below, so the middle IS the middle */
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    gap:34px; text-align:center;
    overflow:hidden;
}
.cp-info{ display:flex; flex-direction:column; align-items:center; gap:18px; }

/* ---------- the visual: sources orbiting, a scanner sweeping, the brand at the centre ---------- */
.cp-stage{
    --S:260px;                                  /* the same on every screen */
    position:relative; flex:0 0 auto;
    width:var(--S); height:var(--S);
}
.cp-stage > *{ position:absolute; left:50%; top:50%; translate:-50% -50%; }

.cp-pulse{ width:100%; height:100%; }
.cp-pulse i{
    position:absolute; left:50%; top:50%; width:34%; height:34%; margin:-17% 0 0 -17%;
    border-radius:50%; border:1.5px solid rgba(255,176,85,.6); opacity:0;
    animation:cpPulse 3.6s ease-out infinite;
}
.cp-pulse i:nth-child(2){ animation-delay:1.2s; }
.cp-pulse i:nth-child(3){ animation-delay:2.4s; }
@keyframes cpPulse{ from{ transform:scale(.9); opacity:.75; } to{ transform:scale(2.9); opacity:0; } }

.cp-orbit{ border-radius:50%; border:1px dashed rgba(255,255,255,.14); will-change:transform; }
.cp-orbit.o1{ width:66%; height:66%; animation:cpSpin 16s linear infinite; }
.cp-orbit.o2{ width:84%; height:84%; animation:cpSpin 26s linear infinite reverse; }
.cp-orbit.o3{ width:100%; height:100%; border-style:solid; border-color:rgba(255,255,255,.07); animation:cpSpin 40s linear infinite; }

/* a "source" riding an orbit: the wrapper turns to its angle, the dot sits at the top of it */
.cp-sat{ position:absolute; inset:0; transform:rotate(var(--a)); }
.cp-sat::before{
    content:""; position:absolute; left:50%; top:0;
    width:var(--sz,9px); height:var(--sz,9px);
    margin:calc(var(--sz,9px) / -2) 0 0 calc(var(--sz,9px) / -2);
    border-radius:50%;
    background:var(--c,var(--cp-accent));
    box-shadow:0 0 12px 2px var(--g,rgba(255,176,85,.6));
}
.cp-sat.w{ --c:#f3f3f5; --g:rgba(255,255,255,.45); }
.cp-sat.r{ --c:#ef4444; --g:rgba(239,68,68,.55); }
.cp-sat.b{ --c:#3b82f6; --g:rgba(59,130,246,.55); }

/* the scanner: a wedge of amber light that sweeps round, as if checking each source */
.cp-sweep{
    width:76%; height:76%; border-radius:50%; z-index:1;
    background:conic-gradient(from 0deg, rgba(255,176,85,0) 0 68%, rgba(255,176,85,.32) 100%);
    -webkit-mask:radial-gradient(farthest-side, transparent 36%, #000 37%);
            mask:radial-gradient(farthest-side, transparent 36%, #000 37%);
    animation:cpSpin 4.2s linear infinite;
    will-change:transform;
}
.cp-sweep::after{
    content:""; position:absolute; left:50%; top:0; width:2px; height:50%; margin-left:-1px;
    background:linear-gradient(var(--cp-accent), rgba(255,176,85,0));
}

/* the amber ring from the brand mark */
.cp-ring{ width:50%; height:50%; border-radius:50%; z-index:2; }
.cp-ring::before{
    content:""; position:absolute; inset:0; border-radius:50%;
    background:conic-gradient(from 0deg, var(--cp-accent), rgba(255,176,85,0) 38%, rgba(255,176,85,0) 62%, var(--cp-accent2));
    -webkit-mask:radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
            mask:radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
    animation:cpSpin 2.6s linear infinite;
    will-change:transform;
}
.cp-ring::after{ content:""; position:absolute; inset:0; border-radius:50%; box-shadow:0 0 22px 2px rgba(255,154,46,.38), inset 0 0 18px rgba(255,154,46,.12); }

.cp-core{
    width:34%; height:34%; border-radius:50%; z-index:3;
    display:grid; place-items:center;
    background:radial-gradient(circle at 35% 30%, #2b2b32, #111114);
    border:1px solid var(--cp-line2);
    box-shadow:0 0 0 6px rgba(255,176,85,.07), 0 0 50px rgba(255,154,46,.38), inset 0 0 20px rgba(255,176,85,.16);
    animation:cpBreath 3.2s ease-in-out infinite;
}
.cp-core img{ width:62%; height:62%; object-fit:contain; }
.cp-mono{ display:none; font-weight:800; font-size:calc(var(--S) * .1); color:var(--cp-accent); }
.cp-core.no-img img{ display:none; }
.cp-core.no-img .cp-mono{ display:block; }

@keyframes cpSpin{ to{ transform:rotate(360deg); } }
@keyframes cpBreath{ 50%{ transform:scale(1.06); } }

/* ---------- status: one line at a time, with five small steps under it ---------- */
.cp-status{
    display:inline-flex; align-items:center; justify-content:center; gap:12px;
    padding:11px 22px; border-radius:999px;
    background:rgba(255,255,255,.07); border:1px solid var(--cp-line);
    font-size:15px; font-weight:700; letter-spacing:.02em; color:var(--cp-text);
}
.cp-dotsload{ display:inline-flex; gap:4px; }
.cp-dotsload i{ width:5px; height:5px; border-radius:50%; background:var(--cp-accent); animation:cpBlip 1.2s ease-in-out infinite; }
.cp-dotsload i:nth-child(2){ animation-delay:.15s; }
.cp-dotsload i:nth-child(3){ animation-delay:.3s; }
@keyframes cpBlip{ 0%,100%{ transform:scale(.4); opacity:.25; } 30%{ transform:scale(1.2); opacity:1; } }
.cp-status-t{ display:inline-block; min-width:25ch; text-align:center; }   /* the pill keeps its width as the words change */
.cp-status-t.swap{ animation:cpStatusIn .5s both; }
@keyframes cpStatusIn{ from{ opacity:0; transform:translateY(6px); } }

.cp-steps{ display:flex; align-items:center; gap:9px; }
.cp-steps i{
    width:8px; height:8px; border-radius:50%; background:rgba(255,255,255,.18);
    transition:background .4s, box-shadow .4s, transform .4s;
}
.cp-steps i.on{ background:var(--cp-accent); box-shadow:0 0 10px rgba(255,176,85,.8); }
.cp-steps i.cur{ transform:scale(1.35); }

.cp-foot{
    position:relative; z-index:3; margin-top:auto;
    padding:6px var(--cp-gut) calc(env(safe-area-inset-bottom, 0px) + 16px);
    text-align:center; font-size:12px; font-weight:500; color:var(--cp-muted);
}

/* only a screen too short to hold the scene gets a smaller one (a phone turned sideways) */
@media (max-height:540px){
    .cp-stage{ --S:190px; }
    .cp-main{ gap:22px; --cp-pad:54px; }
    .cp-foot{ display:none; }
}

/* ---------- reduced motion: no spinning or drifting; the words still change ---------- */
@media (prefers-reduced-motion:reduce){
    .cp-loader *, .cp-loader *::before, .cp-loader *::after{
        animation-duration:.001s !important; animation-iteration-count:1 !important;
        transition-duration:.001s !important;
    }
    .cp-particles{ display:none; }
}