/* =========================================================
   Skills test: the backdrop scene. Loaded after app.css. Markup: includes/night.php; motion: assets/js/night.js.
   KDEC navy with no photo: the logo's rising bars as a skyline, a gold point of light above the tallest bar,
   four orbits around it (one per circle of the test), quiet stars, gold dust and skill words drifting up.
   Colours are the --k-* tokens (brand/kdec.css). Motion is transform/opacity only (plus one canvas),
   and everything stands still under prefers-reduced-motion.
   ========================================================= */
:root {
    --mx: 50%;                          /* where the light sits: a fixed anchor, straight above the tallest gold bar */
    --my: 31%;
    --sky-h: max(42vh, 29.17vw);        /* height of the skyline; never less than the drawing's own 1440:420 shape */
}

.night {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background:
        radial-gradient(58% 44% at var(--mx) var(--my), color-mix(in srgb, var(--k-navy-600) 42%, transparent), transparent 72%),
        radial-gradient(46% 30% at 50% 100%, color-mix(in srgb, var(--k-gold-deep) 22%, transparent), transparent 72%),
        linear-gradient(180deg, var(--k-navy-950) 0%, var(--k-navy-900) 34%, var(--k-navy) 78%, var(--k-navy-900) 100%);
}
.night-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- an admin-chosen picture (settings.compass_background_url): shown under a navy veil ---------- */
.backdrop { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: var(--k-navy-900); }
.backdrop picture, .backdrop img, .backdrop video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.backdrop img, .backdrop video { object-fit: cover; }
.backdrop .veil { position: absolute; inset: 0; background: none; }
.backdrop ~ .night {
    background: linear-gradient(180deg, color-mix(in srgb, var(--k-navy-950) 84%, transparent) 0%, color-mix(in srgb, var(--k-navy-900) 70%, transparent) 45%, color-mix(in srgb, var(--k-navy-950) 90%, transparent) 100%);
}

/* ---------- the skyline: the logo's rising bars ---------- */
.night-skyline { position: absolute; inset-inline: 0; bottom: 0; width: 100%; height: var(--sky-h); }
.sk-bar { fill: var(--k-on-navy); opacity: var(--o, .05); }
.sk-gold { fill: url(#skyGold); }
.sk-g1 { stop-color: var(--k-gold-hi); stop-opacity: .9; }
.sk-g2 { stop-color: var(--k-gold); stop-opacity: .5; }
.sk-g3 { stop-color: var(--k-gold-deep); stop-opacity: .08; }

/* a hairline of light rising from the tallest bar's tip (40 of 420 from the top of the drawing) and fading out toward the point */
.night-beam {
    position: absolute;
    left: var(--mx);
    top: var(--my);
    bottom: calc(var(--sky-h) * .905);
    width: 1px;
    translate: -50% 0;
    background: linear-gradient(to top, color-mix(in srgb, var(--k-gold-light) 70%, transparent), color-mix(in srgb, var(--k-gold-light) 18%, transparent) 45%, transparent 92%);
}
.night-glow {
    position: absolute;
    left: var(--mx);
    top: var(--my);
    width: clamp(220px, 44vmin, 420px);
    aspect-ratio: 1;
    translate: -50% -50%;
    border-radius: 50%;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--k-gold-hi) 30%, transparent), color-mix(in srgb, var(--k-gold) 9%, transparent) 42%, transparent 72%);
}

/* ---------- four orbits around the light, one per circle of the test ---------- */
.night-rings {
    position: absolute;
    left: var(--mx);
    top: var(--my);
    width: clamp(320px, 64vmin, 620px);
    aspect-ratio: 1;
    translate: -50% -50%;
    overflow: visible;
}
.nr-line { fill: none; stroke: var(--c); stroke-width: 1; stroke-opacity: .3; vector-effect: non-scaling-stroke; }
.nr-orbit { transform-origin: 200px 200px; animation: nr-spin calc(52s + var(--i) * 14s) linear calc(var(--i) * -17s) infinite; }
.nr:nth-child(even) .nr-orbit { animation-direction: reverse; }
.nr-dot { fill: var(--c); }
.nr-core { fill: var(--k-gold-hi); }
@keyframes nr-spin { to { transform: rotate(360deg); } }

/* ---------- skills from the test drift up ---------- */
.night-words { position: absolute; inset: 0; }
.night-words span {
    position: absolute;
    left: var(--x);
    bottom: -8%;
    display: inline-flex;
    align-items: center;
    gap: .5em;
    color: var(--k-on-navy);
    font: 500 clamp(.8rem, 1.05vw, .95rem)/1.4 var(--k-font);
    white-space: nowrap;
    opacity: 0;
    animation: word-rise var(--d) linear var(--dl) infinite;
}
/* the mark's bar, small, in front of each word */
.night-words span::before { content: ""; width: 4px; height: .95em; background: var(--k-gold-grad); clip-path: polygon(0 32%, 100% 0, 100% 100%, 0 100%); }
@keyframes word-rise {
    0% { transform: translate3d(0, 0, 0); opacity: 0; }
    12% { opacity: .24; }
    80% { opacity: .16; }
    100% { transform: translate3d(0, -112vh, 0); opacity: 0; }
}
/* wide screens: the words rise in the side margins, clear of the content column */
@media (min-width: 1400px) { .night-words span { left: var(--xs, var(--x)); } }

/* ---------- phones: a lighter scene ---------- */
@media (max-width: 720px) {
    :root { --my: 21%; --sky-h: 26vh; }
    .night-rings { width: clamp(280px, 92vmin, 420px); }
    .nr-line { stroke-opacity: .22; }
    .night-beam { display: none; }
    .sk-g1 { stop-opacity: .6; }
    .sk-g2 { stop-opacity: .3; }
    .night-words { display: none; }      /* the words would cross the text on a narrow screen */
    .nr-orbit, .nr-core { display: none; } /* the rings sit behind the title here: keep them as quiet lines, no moving dots */
}
/* short landscape screens: no room between the bars and the light */
@media (max-height: 520px) { .night-beam { display: none; } }

/* ---------- reduced motion: a still scene ---------- */
@media (prefers-reduced-motion: reduce) {
    .nr-orbit, .night-words span { animation: none !important; }
    .nr-orbit { transform: rotate(calc(40deg + var(--i) * 97deg)); } /* the dots rest spread around their rings */
    .night-words span { opacity: .18; bottom: auto; top: calc(12% + var(--x) * .7); }
    .night-words span:nth-child(n + 6) { display: none; }
}
