/* ---------- The AI at work (section 26m, ai-glow.js) ----------
   A purple glow round what the AI thinks about or works on: it comes up slowly, breathes out and back while the AI
   thinks (a close glow and a wide one in turn), a brighter part of it going slowly round (three lobes, each leaning one
   way, brightening in turn), and goes slowly when the AI is done. Along an arrow, its line blooms, and while the AI
   thinks along it (an AI link, section 26n), light runs from where it starts to where it ends. Every frame of it is the
   compositor's: opacity and transform animations of layers painted once, nothing laid out or painted again. Over the
   canvas, outside #cam (nothing in #cam may be a layer in Safari's engine: objects.css, html.wk), moved with it
   (applyView); never in the side view (#aiglow.dv). */
:root { --ai-g: 118 82 246; --ai-gc: 255 255 255; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-look="day"]) { --ai-g: 158 128 255; --ai-gc: 236 230 255; } }
:root[data-theme="dark"]:not([data-look="day"]), :root[data-look="night"] { --ai-g: 158 128 255; --ai-gc: 236 230 255; }

#aiglow { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; pointer-events: none; }
#aiglow:empty, #aiglow.dv { display: none; }
/* One object's glow: its box and corners (--g: how far it reaches, by the object's size), at nothing until it is on. */
.ag { position: absolute; left: 0; top: 0; opacity: 0; transition: opacity 1.1s cubic-bezier(.33, 0, .2, 1); }
.ag.on { opacity: 1; }
.ag.out { opacity: 0; transition: opacity 1.5s cubic-bezier(.45, 0, .55, 1); }
.ag > i { position: absolute; inset: 0; border-radius: inherit; }
/* close, with a faint tint just inside the edge, and wide: breathing in turn, so the glow goes out and comes back */
.ag-c { box-shadow: 0 0 calc(var(--g) * .55) calc(var(--g) * .1) rgb(var(--ai-g) / .5), inset 0 0 calc(var(--g) * .5) rgb(var(--ai-g) / .13);
        animation: ag-c 3.6s ease-in-out infinite; }
.ag-w { box-shadow: 0 0 calc(var(--g) * 1.7) calc(var(--g) * .38) rgb(var(--ai-g) / .27); animation: ag-w 3.6s ease-in-out infinite; }
@keyframes ag-c { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes ag-w { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }
/* the brighter part going round: up, down right, down left in turn (each lobe lights at its delay + 3.6 s) */
.ag-f { opacity: 0; box-shadow: var(--fx) var(--fy) calc(var(--g) * 1.3) calc(var(--g) * .02) rgb(var(--ai-g) / .45); animation: ag-f 7.2s ease-in-out infinite; }
.ag-f.a { --fx: 0px; --fy: calc(var(--g) * -.55); animation-delay: -3.6s; }
.ag-f.b { --fx: calc(var(--g) * .48); --fy: calc(var(--g) * .28); animation-delay: -1.2s; }
.ag-f.c { --fx: calc(var(--g) * -.48); --fy: calc(var(--g) * .28); animation-delay: -6s; }
@keyframes ag-f { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
/* Many at once (a whole board asked about): each its close and wide glow in one, breathing; nothing going round. */
.ag.n > .ag-c { box-shadow: 0 0 calc(var(--g) * .6) calc(var(--g) * .12) rgb(var(--ai-g) / .45), 0 0 calc(var(--g) * 1.6) calc(var(--g) * .3) rgb(var(--ai-g) / .2),
                inset 0 0 calc(var(--g) * .5) rgb(var(--ai-g) / .1); }
.ag.n > :is(.ag-w, .ag-f) { display: none; }

/* A line's: its curve, wide and soft, breathing; while the AI thinks along it, light running from start to end. */
.agl { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; transition: opacity 1.1s cubic-bezier(.33, 0, .2, 1); }
.agl.on { opacity: 1; }
.agl.out { opacity: 0; transition: opacity 1.5s cubic-bezier(.45, 0, .55, 1); }
.agl > svg { position: absolute; overflow: visible; fill: none; stroke: rgb(var(--ai-g)); stroke-linecap: round; stroke-linejoin: round;
             filter: blur(var(--lb)); animation: ag-l 3.6s ease-in-out infinite; }
@keyframes ag-l { 0%, 100% { opacity: .5; } 50% { opacity: .95; } }
/* a spark of light, pointed along the line, bright at its head and fading behind (its path: ai-glow.js agRun) */
.agl > b { position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); margin: calc(var(--ch) / -2) 0 0 calc(var(--cw) * -.8);
           border-radius: 50%; opacity: 0; transform-origin: 80% 50%; will-change: transform, opacity;
           background: radial-gradient(closest-side at 80% 50%, rgb(var(--ai-gc) / .95), rgb(var(--ai-g) / .85) 38%, rgb(var(--ai-g) / 0)),
                       radial-gradient(closest-side, rgb(var(--ai-g) / .55), rgb(var(--ai-g) / 0)); }

@media (prefers-reduced-motion: reduce) {
  .ag > i, .agl > svg { animation: none; }
  .ag-w { opacity: .7; }
  .ag-f, .agl > b { display: none; }
  .ag, .agl { transition-duration: .3s; }
}
