/* vLAB motion layer: an ambient "live range" backdrop and richer UI motion.
 *
 * The backdrop (.vbg) is decoration and always shows; it only MOVES when <html> has the
 * .mo class. .mo is set by _motion_head.html before first paint and kept in sync by
 * motion.js: Animations "Auto" follows the device's reduced-motion setting, "On"/"Off"
 * override it (remembered per browser). Everything here is tinted by the portal's
 * --accent, so admin / game master / Academy / student each keep their own colour.
 *
 * Entrances use fill-mode "backwards" and the individual translate/scale properties, so
 * nothing is left on an element afterwards (no lingering transform/filter that would
 * re-anchor fixed-position modals inside it).
 */

body { isolation: isolate; }

/* ── Backdrop ─────────────────────────────────────────────────────────── */
.vbg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.vbg i { position: absolute; display: block; }
.vbg .au { width: 70vmax; height: 70vmax; border-radius: 50%; filter: blur(80px); }
.vbg .a1 { left: -22vmax; top: -34vmax; background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 42%, transparent), transparent); }
.vbg .a2 { right: -34vmax; top: -6vmax; background: radial-gradient(closest-side, rgba(96,165,250,.20), transparent); }
.vbg .a3 { left: 12vw; bottom: -50vmax; background: radial-gradient(closest-side, rgba(251,191,36,.12), transparent); }
.vbg .gd {
    inset: -64px;
    background-image: linear-gradient(rgba(162,89,255,.05) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(162,89,255,.05) 1px, transparent 1px);
    background-size: 64px 64px;
    -webkit-mask-image: radial-gradient(ellipse 85% 70% at 60% 20%, #000, transparent 78%);
    mask-image: radial-gradient(ellipse 85% 70% at 60% 20%, #000, transparent 78%);
}
.vbg .rd {
    right: -24vmax; top: -24vmax; width: 64vmax; height: 64vmax; border-radius: 50%; opacity: .35;
    background: conic-gradient(from 0deg, color-mix(in srgb, var(--accent) 30%, transparent), transparent 16%, transparent);
    -webkit-mask-image: radial-gradient(closest-side, #000 25%, transparent);
    mask-image: radial-gradient(closest-side, #000 25%, transparent);
}
.vbg .pk { left: 0; width: 24vw; height: 1px; opacity: .5; background: linear-gradient(90deg, transparent, var(--c, #B88AFF)); display: none; }
.vbg .pk::after {
    content: ""; position: absolute; right: -3px; top: -2px; width: 5px; height: 5px; border-radius: 50%;
    background: var(--c, #B88AFF); box-shadow: 0 0 12px 3px var(--c, #B88AFF);
}
.vbg .sc { left: 0; right: 0; top: 0; height: 30vh; background: linear-gradient(180deg, transparent, rgba(162,89,255,.045), transparent); display: none; }
.vbg .fl {
    left: -45%; right: -45%; bottom: -8%; height: 48vh;
    background-image: linear-gradient(color-mix(in srgb, var(--accent) 28%, transparent) 1px, transparent 1px),
                      linear-gradient(90deg, color-mix(in srgb, var(--accent) 28%, transparent) 1px, transparent 1px);
    background-size: 64px 64px;
    transform: perspective(420px) rotateX(64deg); transform-origin: 50% 100%;
    -webkit-mask-image: linear-gradient(to top, #000, transparent 82%);
    mask-image: linear-gradient(to top, #000, transparent 82%);
}

.mo .vbg .a1 { animation: vbgA 32s ease-in-out infinite alternate; }
.mo .vbg .a2 { animation: vbgB 41s ease-in-out infinite alternate; }
.mo .vbg .a3 { animation: vbgC 47s ease-in-out infinite alternate; }
.mo .vbg .gd { animation: vbgPan 20s linear infinite; }
.mo .vbg .rd { animation: vbgSpin 16s linear infinite; }
.mo .vbg .pk { display: block; animation: vbgPk var(--d, 10s) linear var(--w, 0s) infinite; }
.mo .vbg .sc { display: block; animation: vbgScan 12s cubic-bezier(.45,0,.55,1) infinite; }
.mo .vbg .fl { animation: vbgFloor 3.4s linear infinite; }
@keyframes vbgA { to { transform: translate(18vw, 14vh) scale(1.18); } }
@keyframes vbgB { to { transform: translate(-16vw, 20vh) scale(.86); } }
@keyframes vbgC { to { transform: translate(-10vw, -12vh) scale(1.24); } }
@keyframes vbgPan { to { transform: translate(64px, 64px); } }
@keyframes vbgSpin { to { transform: rotate(360deg); } }
@keyframes vbgPk { from { transform: translateX(-26vw); } to { transform: translateX(126vw); } }
@keyframes vbgScan { from { transform: translateY(-32vh); } to { transform: translateY(112vh); } }
@keyframes vbgFloor { to { background-position: 0 64px, 0 0; } }

/* ── Page load trace ─────────────────────────────────────────────────── */
.mo body::before {
    content: ""; position: fixed; left: 0; top: 0; width: 100%; height: 2px; z-index: 10000; pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--accent), #FBBF24, transparent);
    transform-origin: left; opacity: 0;
    animation: vLoadTrace 1.5s cubic-bezier(.6,0,.2,1) .05s;
}
@keyframes vLoadTrace { 0% { transform: scaleX(0); opacity: 1; } 70% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }

/* ── Entrances: page sections, stat cards, sign-in card ──────────────── */
@keyframes vRise { from { opacity: 0; translate: 0 16px; } }
@keyframes vFocus { from { filter: blur(6px); } }
.mo .main > *, .mo .student-main > *, .mo .login-card {
    animation: vRise .65s cubic-bezier(.2,.8,.2,1) backwards, vFocus .65s ease-out backwards;
}
.mo .main > :nth-child(2), .mo .student-main > :nth-child(2) { animation-delay: .06s; }
.mo .main > :nth-child(3), .mo .student-main > :nth-child(3) { animation-delay: .12s; }
.mo .main > :nth-child(4), .mo .student-main > :nth-child(4) { animation-delay: .18s; }
.mo .main > :nth-child(5), .mo .student-main > :nth-child(5) { animation-delay: .24s; }
.mo .main > :nth-child(n+6), .mo .student-main > :nth-child(n+6) { animation-delay: .3s; }
.mo .stats-grid > * { animation: vRise .6s cubic-bezier(.2,.8,.2,1) backwards; }
.mo .stats-grid > :nth-child(2) { animation-delay: .08s; }
.mo .stats-grid > :nth-child(3) { animation-delay: .16s; }
.mo .stats-grid > :nth-child(4) { animation-delay: .24s; }
.mo .stats-grid > :nth-child(n+5) { animation-delay: .32s; }
/* modals and the overlay never animate as page sections */
.mo .main > .modal-overlay, .mo .student-main > .modal-overlay { animation: none; }

/* ── Cards: lift + accent glow ───────────────────────────────────────── */
.mo .stat-card, .mo .card { transition: translate .3s cubic-bezier(.2,.8,.2,1), box-shadow .3s, border-color .3s; }
.mo .stat-card:hover {
    translate: 0 -3px;
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
    box-shadow: 0 22px 44px -26px color-mix(in srgb, var(--accent) 80%, transparent);
}
.mo .card:hover { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent), 0 24px 48px -32px color-mix(in srgb, var(--accent) 70%, transparent); }

/* ── Buttons: sheen on primary, press feedback ───────────────────────── */
.mo .btn-primary, .mo .btn-gm, .mo .btn-ac { position: relative; overflow: hidden; }
.mo .btn-primary::after, .mo .btn-gm::after, .mo .btn-ac::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 55%; pointer-events: none;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,.35), transparent);
    transform: translateX(-170%) skewX(-14deg);
    animation: vSheen 5.6s cubic-bezier(.4,0,.2,1) 1.4s infinite;
}
@keyframes vSheen { 0%, 72% { transform: translateX(-170%) skewX(-14deg); } 100% { transform: translateX(280%) skewX(-14deg); } }
.mo .btn:active { scale: .97; }
.mo .btn-ghost:hover { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }

/* ── Navigation ──────────────────────────────────────────────────────── */
.mo .sidebar .nav-link:hover { translate: 3px 0; }
.mo .sidebar-brand .dot { animation: vPing 2.4s cubic-bezier(0,0,.2,1) infinite; }
@keyframes vPing { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,.55); } 80%, 100% { box-shadow: 0 0 0 8px rgba(52,211,153,0); } }

/* ── Modals ──────────────────────────────────────────────────────────── */
.mo .modal-overlay.active { animation: vFade .2s ease-out backwards; }
.mo .modal-overlay.active > .modal { animation: vPop .28s cubic-bezier(.2,.8,.2,1) backwards; }
@keyframes vFade { from { opacity: 0; } }
@keyframes vPop { from { opacity: 0; scale: .96; translate: 0 10px; } }

/* ── Charts and statistics (.vx kit, see motion.js) ──────────────────────
 * The HUD look (corner brackets, glow, dashed grid, read-out tip) always applies. The
 * entrances play only with .mo, and stay paused until motion.js adds .vx-in to the
 * chart (it has scrolled into view). Entrance classes: vx-draw (a path drawn on; give
 * it pathLength="1"), vx-wipe (left-to-right reveal), vx-rise (bar grows up from its
 * base), vx-grow (grows out from the left), vx-arc (donut segment sweeps round; give it
 * pathLength="100"), vx-pop, vx-fade. Delay each with --dl. Ambient: vx-spin, vx-ping,
 * vx-scan (one sweep across; set --w to the distance). */
.vx { position: relative; }
.vx svg { display: block; overflow: visible; }
.vx-frame {
    --vx-c: color-mix(in srgb, var(--accent) 60%, transparent);
    padding: 12px 12px 6px;
    background:
        linear-gradient(var(--vx-c), var(--vx-c)) 0 0 / 12px 1px, linear-gradient(var(--vx-c), var(--vx-c)) 0 0 / 1px 12px,
        linear-gradient(var(--vx-c), var(--vx-c)) 100% 0 / 12px 1px, linear-gradient(var(--vx-c), var(--vx-c)) 100% 0 / 1px 12px,
        linear-gradient(var(--vx-c), var(--vx-c)) 0 100% / 12px 1px, linear-gradient(var(--vx-c), var(--vx-c)) 0 100% / 1px 12px,
        linear-gradient(var(--vx-c), var(--vx-c)) 100% 100% / 12px 1px, linear-gradient(var(--vx-c), var(--vx-c)) 100% 100% / 1px 12px;
    background-repeat: no-repeat;
}
.vx-ax { fill: var(--dim); font: 500 10px var(--mono, monospace); letter-spacing: .06em; text-transform: uppercase; }
.vx-val { fill: var(--ink-soft, #E6E1F2); font: 600 11px var(--mono, monospace); font-variant-numeric: tabular-nums; }
.vx-big { fill: var(--white); font: 800 30px var(--display, sans-serif); font-stretch: 75%; font-variant-numeric: tabular-nums; }
.vx-grid { stroke: color-mix(in srgb, var(--accent) 18%, transparent); stroke-dasharray: 2 5; }
.vx-base { stroke: color-mix(in srgb, var(--accent) 55%, transparent); }
.vx-glow { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--c, var(--accent)) 75%, transparent)); }
.vx-hit { fill: transparent; }
[data-vx-tip] { cursor: crosshair; transition: opacity .2s, stroke-width .2s; }
.vx:has([data-vx-tip]:hover) [data-vx-tip].vx-dim:not(:hover) { opacity: .35; }
.vx-tip {
    position: fixed; left: 0; top: 0; z-index: 10001; pointer-events: none; white-space: nowrap;
    padding: 6px 10px; border-radius: 8px; font: 500 11.5px var(--mono, monospace); letter-spacing: .02em;
    color: #F1EDF8; background: rgba(10, 8, 16, .94);
    border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
    box-shadow: 0 12px 32px -12px color-mix(in srgb, var(--accent) 80%, transparent);
    translate: -50% calc(-100% - 14px); opacity: 0; transition: opacity .12s;
}
.vx-tip.on { opacity: 1; }

/* chart panels: a faint light sweep passes over them now and then */
.vx-panel { position: relative; overflow: hidden; }
.mo .vx-panel::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 35%; pointer-events: none;
    background: linear-gradient(100deg, transparent, color-mix(in srgb, var(--accent) 9%, transparent), transparent);
    translate: -110% 0; animation: vxPanelSweep 11s cubic-bezier(.45, 0, .55, 1) var(--sweep, 2.5s) infinite;
}
@keyframes vxPanelSweep { 0% { translate: -110% 0; } 28%, 100% { translate: 320% 0; } }

@keyframes vxDraw { from { stroke-dashoffset: 1; } }
@keyframes vxWipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes vxRise { from { transform: scaleY(0); } }
@keyframes vxGrow { from { transform: scaleX(0); } }
@keyframes vxArc { from { stroke-dasharray: 0 100; } }
@keyframes vxPop { 0% { opacity: 0; transform: scale(0); } 65% { opacity: 1; transform: scale(1.5); } }
@keyframes vxFade { from { opacity: 0; } }
@keyframes vxSpin { to { transform: rotate(360deg); } }
@keyframes vxPing { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(3.4); opacity: 0; } }
@keyframes vxScan { 0% { transform: translateX(0); opacity: 0; } 8% { opacity: 1; } 92% { opacity: 1; } 100% { transform: translateX(var(--w, 300px)); opacity: 0; } }
@keyframes vxTick { from { text-shadow: 0 0 22px var(--accent-hi, #C29BFF); color: #fff; } }
@keyframes vxCap { from { transform: translateY(var(--bh, 0px)); opacity: 0; } 20% { opacity: 1; } }
@keyframes vxBloom { from { transform: scale(.12); opacity: 0; } }

.mo .vx-draw { stroke-dasharray: 1; animation: vxDraw 1.6s cubic-bezier(.55, 0, .25, 1) var(--dl, 0s) backwards paused; }
/* vx-bloom: a shape grows out from a point; set transform-origin inline (e.g. a radar centre) */
.mo .vx-bloom { transform-box: view-box; animation: vxBloom 1.1s cubic-bezier(.2, .8, .2, 1) var(--dl, 0s) backwards paused; }
.mo .vx-wipe { animation: vxWipe 1.6s cubic-bezier(.55, 0, .25, 1) var(--dl, 0s) backwards paused; }
.mo .vx-rise { transform-box: fill-box; transform-origin: 50% 100%; animation: vxRise .9s cubic-bezier(.2, .9, .3, 1.12) var(--dl, 0s) backwards paused; }
.mo .vx-grow { transform-box: fill-box; transform-origin: 0 50%; animation: vxGrow 1.1s cubic-bezier(.2, .8, .2, 1) var(--dl, 0s) backwards paused; }
.mo .vx-arc { animation: vxArc 1.1s cubic-bezier(.6, 0, .2, 1) var(--dl, 0s) backwards paused; }
.mo .vx-pop { transform-box: fill-box; transform-origin: center; animation: vxPop .5s cubic-bezier(.34, 1.56, .64, 1) var(--dl, 0s) backwards paused; }
.mo .vx-fade { animation: vxFade .6s ease-out var(--dl, 0s) backwards paused; }
.mo .vx-cap { animation: vxCap .9s cubic-bezier(.2, .9, .3, 1.12) var(--dl, 0s) backwards paused; }
.mo .vx-in :is(.vx-draw, .vx-wipe, .vx-rise, .vx-grow, .vx-arc, .vx-pop, .vx-fade, .vx-cap, .vx-bloom) { animation-play-state: running; }
/* a chart re-drawn after a resize, or a live panel re-rendered by polling, keeps still */
.mo .vx-still :is(.vx-draw, .vx-wipe, .vx-rise, .vx-grow, .vx-arc, .vx-pop, .vx-fade, .vx-cap, .vx-bloom, .vx-scan),
.mo .vx-still .c-bar > i, .mo .vx-still .c-spark .line { animation: none; }
.vx-ping, .vx-scan { opacity: 0; }
.mo .vx-in .vx-spin { transform-box: fill-box; transform-origin: center; animation: vxSpin var(--spin, 36s) linear infinite; }
.mo .vx-in .vx-spin.rev { animation-direction: reverse; }
.mo .vx-in .vx-ping { transform-box: fill-box; transform-origin: center; animation: vxPing 2.2s cubic-bezier(0, 0, .2, 1) var(--dl, 1.6s) infinite backwards; }
.mo .vx-in .vx-scan { animation: vxScan 1.7s cubic-bezier(.55, 0, .25, 1) var(--dl, 0s) backwards; }

/* statistics: glow while counting, flash when a live value changes */
.vx-counting { text-shadow: 0 0 18px color-mix(in srgb, currentColor 55%, transparent); }
.mo .vx-tick { animation: vxTick 1.2s ease-out; }

/* existing console bars and sparklines also wait until they are on screen */
.mo .c-bar:not(.vx-in) > i, .mo .c-spark:not(.vx-in) .line { animation-play-state: paused; }

/* HTML bar fills: put .vx on the track and .vx-grow (or .vx-rise for a column) on the fill;
   .vx-head adds a glowing leading edge in --c. Stagger with --dl. */
.vx-head { position: relative; box-shadow: 0 0 12px -3px var(--c, var(--accent)); }
.vx-head::after { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 2px; background: #fff; opacity: .9;
    box-shadow: 0 0 8px 2px var(--c, var(--accent)); }
.vx-tl { position: relative; }   /* HTML column of a time chart */
.vx-tl::after { content: ''; position: absolute; left: 0; right: 0; top: -1px; height: 2px; border-radius: 1px; background: var(--c, var(--accent-hi, var(--accent)));
    box-shadow: 0 0 8px var(--c, var(--accent)); }

/* ── Shared HUD charts (static/charts.js) ─────────────────────────────── */
.cx-empty { color: var(--dim); font-size: 13px; padding: 14px; }
.cx-donut { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cx-seg { transition: opacity .2s, filter .2s; }
.cx-donut.focus .cx-seg:not(.on) { opacity: .28; }
.cx-seg.on { filter: drop-shadow(0 0 10px var(--c)); }
.cx-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; font-size: 11px; color: var(--muted); }
.cx-legend li { display: inline-flex; align-items: center; gap: 6px; padding: 2px 5px; border-radius: 4px; cursor: crosshair; transition: background .2s, color .2s; }
.cx-legend li i { width: 8px; height: 8px; border-radius: 2px; background: var(--c); box-shadow: 0 0 6px var(--c); }
.cx-legend li b { color: var(--white); font-weight: 600; font-variant-numeric: tabular-nums; }
.cx-legend li.on { background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--white); }
.cx-hb { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.cx-hb-row { display: grid; grid-template-columns: auto minmax(0, 130px) minmax(0, 1fr) auto; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-size: 12px; }
.cx-hb.norank .cx-hb-row { grid-template-columns: minmax(0, 130px) minmax(0, 1fr) auto; }
.cx-hb-rank { font: 600 10px var(--mono, monospace); color: var(--dim); letter-spacing: .06em; }
.cx-hb-name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.cx-hb-row:hover .cx-hb-name, a.cx-hb-row:focus-visible .cx-hb-name { color: var(--white); }
.cx-hb-track { position: relative; height: 8px; border-radius: 2px;
    background: repeating-linear-gradient(90deg, color-mix(in srgb, var(--c) 22%, transparent) 0 1px, transparent 1px 10%), var(--track, rgba(148,163,184,.1)); }
.cx-hb-track > i { position: absolute; inset: 0 auto 0 0; border-radius: 2px; background: linear-gradient(90deg, color-mix(in srgb, var(--c) 22%, transparent), var(--c));
    box-shadow: 0 0 10px -2px var(--c); }
.cx-hb-track > i::after { content: ''; position: absolute; right: -1px; top: -3px; bottom: -3px; width: 2px; border-radius: 1px; background: #fff; box-shadow: 0 0 8px 1px var(--c); }
.cx-hb-val { font: 600 12px var(--mono, monospace); color: var(--white); font-variant-numeric: tabular-nums; min-width: 2.5ch; text-align: right; }
.cx-gauge { display: flex; align-items: center; gap: 10px; }
.cx-gauge-seg { flex: 1; display: grid; grid-auto-flow: column; gap: 2px; height: 10px; }
.cx-gauge-seg i { border-radius: 1px; background: var(--track, rgba(148,163,184,.14)); }
.cx-gauge-seg i.on { background: var(--c); box-shadow: 0 0 6px -1px var(--c); }
.cx-gauge-v { font: 12px var(--mono, monospace); color: var(--muted); white-space: nowrap; }
.cx-gauge-v b { color: var(--white); }
.cx-radar { display: flex; justify-content: center; }
.cx-rd-grid { fill: none; stroke: color-mix(in srgb, var(--accent) 20%, transparent); stroke-width: 1; }
.cx-rd-grid.outer { stroke: color-mix(in srgb, var(--accent) 40%, transparent); }
.cx-rd-prev { fill: rgba(173, 166, 194, .06); stroke: var(--dim); stroke-width: 1.4; stroke-dasharray: 4 4; transition: opacity .3s; }
.cx-rd-prev.gone { opacity: 0; }
.cx-rd-lbl { fill: var(--muted); opacity: .55; }
.cx-rd-lbl.on { fill: var(--white); opacity: .9; }
.cx-rd-sweep { opacity: 0; pointer-events: none; }
.mo .vx-in .cx-rd-sweep { opacity: 1; transition: opacity .8s 1.3s; }
.cx-ring { display: inline-flex; flex-direction: column; align-items: center; gap: 5px; }
.cx-ring-v { fill: var(--white); font-weight: 800; font-family: var(--display, inherit); font-variant-numeric: tabular-nums; }
.cx-ring-s { fill: var(--muted); font-size: .5em; font-weight: 600; }
.cx-ring-c { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .5px; }
.cx-spark svg { display: block; }

/* ── Animations switch (sidebar row + student top-bar icon) ──────────── */
.motion-toggle { color: var(--dim); background: none; border: none; width: 100%; cursor: pointer; font: inherit; text-align: left; }
.motion-toggle:hover { color: var(--white); }
.motion-toggle .mt-state { color: var(--muted); }
.mo .motion-toggle svg { color: var(--accent); }
