/* The particle world behind every page except the home page (which carries its own copy of these rules). */
#gl { display:none; }
.motion #gl, .still #gl { display:block; position:fixed; inset:0; width:100%; height:100vh; height:100lvh; z-index:-1; }

/* Words sit on a soft shadow, so the world can stay visible around them. */
.has-world.motion section > .wrap, .has-world.still section > .wrap { position:relative; z-index:0; }
.has-world.motion section > .wrap::before, .has-world.still section > .wrap::before {
  content:''; position:absolute; inset:-36px -70px; z-index:-1; pointer-events:none;
  background:radial-gradient(ellipse 78% 86% at 40% 50%, rgba(10,5,2,.9) 0%, rgba(10,5,2,.8) 58%, rgba(10,5,2,0) 100%); }
.has-world section { overflow-x:clip; }
/* Narrow screens: there is no room beside the words, so the shape sits behind them. A lighter shadow lets it read as a backdrop. */
@media (max-width:1040px) {
  .has-world.motion section > .wrap::before { inset:-24px -12px; background:radial-gradient(ellipse 96% 92% at 50% 50%, rgba(10,5,2,.62) 0%, rgba(10,5,2,.52) 70%, rgba(10,5,2,0) 100%); }
}
.has-world.motion footer { background:rgba(10,5,2,.9); position:relative; }

/* Reading progress: one thin ember line. */
#prog { position:fixed; top:0; left:0; right:0; height:2px; z-index:600; pointer-events:none; }
#prog i { display:block; height:100%; transform-origin:0 50%; transform:scaleX(0); background:linear-gradient(90deg,#cc1a00,#ff4500 40%,#ffb38a); }

/* Chapter rail: where you are on this page. */
#rail { display:flex; flex-direction:column; gap:12px; position:fixed; right:18px; top:50%; transform:translateY(-50%); z-index:400; margin:0; padding:0; }
#rail a { display:flex; align-items:center; justify-content:flex-end; gap:10px; text-decoration:none; color:#d9cbbd; font-family:'DM Mono',ui-monospace,monospace; font-size:11px; letter-spacing:.12em; text-transform:uppercase; }
#rail a span { opacity:0; transform:translateX(6px); transition:opacity .25s, transform .25s; text-shadow:0 1px 10px rgba(10,5,2,.95); white-space:nowrap; max-width:220px; overflow:hidden; text-overflow:ellipsis; }
#rail a i { width:7px; height:7px; border-radius:50%; background:#5a4636; transition:background .25s, transform .25s, box-shadow .25s; flex:none; }
#rail a:hover span, #rail a:focus-visible span, #rail a[aria-current="true"] span { opacity:1; transform:none; }
#rail a[aria-current="true"] { color:#f0e8e0; }
#rail a[aria-current="true"] i { background:#ff4500; transform:scale(1.5); box-shadow:0 0 12px rgba(255,69,0,.8); }
#rail a:hover i { background:#ff7a33; }
@media (max-width:1280px) { #rail { display:none; } }

#pause { display:none; }
.motion #pause { display:block; position:fixed; right:14px; bottom:14px; z-index:450; background:rgba(10,5,2,.72); color:#d9cbbd; border:1px solid #5a4636; border-radius:6px; padding:7px 11px; font:500 13px 'Barlow',sans-serif; cursor:pointer; }
#pause:hover { color:#f0e8e0; }

/* Moving between pages cross-fades, so the world never blinks out. */
@view-transition { navigation:auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration:.5s; }

/* Names on the agents, placed by the world each frame. Behind the page's words, in front of the particles. */
#labels { display:none; }
.motion #labels { display:block; position:fixed; inset:0; z-index:-1; pointer-events:none; overflow:hidden; }
#labels span { position:absolute; left:0; top:0; white-space:nowrap; font-family:'DM Mono',ui-monospace,monospace; font-size:11px; letter-spacing:.14em; text-transform:uppercase; color:#e9dccd;
               padding:3px 7px; border-left:1px solid #ff7a33; background:rgba(10,5,2,.5); opacity:0; will-change:transform,opacity; transition:color .3s, border-color .3s; }
#labels span.hot { color:#ff8d7c; border-color:#ff3b2a; }
#labels span.ok { color:#9ff0b4; border-color:#58d67c; }
#labels span.cool { color:#d6ecff; border-color:#bfe0ff; }
@media (max-width:1040px) { .motion #labels { display:none; } }
