/* The Codex, watched (lib/codex-show.js): a full-screen narrated film over learn.html.
   The engine's own pieces (progress dots, voice/sound/speed controls, flash) are in cinema.css. */
.cs-go { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; margin: 18px 0 16px; }
.cs-play { display: inline-flex; align-items: center; gap: 10px; border: 1px solid rgba(168,230,255,.6); background: linear-gradient(180deg, rgba(168,230,255,.18), rgba(168,230,255,.06)); color: #eef6ff; border-radius: 12px; padding: 12px 20px; font: 650 16px var(--df-sans, system-ui); cursor: pointer; box-shadow: 0 0 22px rgba(168,230,255,.18); transition: box-shadow .25s, border-color .25s, transform .25s; }
.cs-play span { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #a8e6ff; color: #04121a; font-size: 12px; box-shadow: 0 0 0 0 rgba(168,230,255,.5); animation: cs-ping 2.6s ease-in-out infinite; }
.cs-play:hover { border-color: #a8e6ff; box-shadow: 0 0 30px rgba(168,230,255,.32); transform: translateY(-1px); }
@keyframes cs-ping { 0%, 100% { box-shadow: 0 0 0 0 rgba(168,230,255,.45); } 50% { box-shadow: 0 0 0 9px rgba(168,230,255,0); } }
.cs-resume { border: 1px solid var(--df-line-strong, rgba(190,210,255,.22)); background: rgba(6,8,14,.6); color: #d6e9f5; border-radius: 10px; padding: 10px 14px; font: 500 14px var(--df-sans, system-ui); cursor: pointer; }
.cs-resume b { color: #a8e6ff; font-weight: 600; }
.cs-resume:hover { border-color: #a8e6ff; }
.cs-go-t { font-size: 13px; color: var(--df-muted, #aeb7c8); max-width: 560px; flex-basis: 100%; }
.cs-lw { margin-left: auto; background: none; border: 1px solid rgba(168,230,255,.3); color: #a8e6ff; border-radius: 999px; padding: 4px 11px; font: 600 11.5px var(--df-sans, system-ui); cursor: pointer; white-space: nowrap; }
.cs-lw:hover { border-color: #a8e6ff; background: rgba(168,230,255,.08); }
.cx-layer > header { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }

html.cs-open, html.cs-open body { overflow: hidden; }
.cs { position: fixed; inset: 0; z-index: 2000; background: #03050a; color: #e8eef7; overflow: hidden; font-family: var(--df-sans, system-ui); }
.cs[hidden] { display: none; }
/* the backdrop: an endless dive into this chapter's fractal (lib/cinema.js) */
.cs-bgw { position: absolute; inset: 0; }
.cs-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .38; filter: saturate(1.1); }
.cs-bg.cine-gl { opacity: .9; filter: none; }
.cs-bg.cine-cpu { left: 50%; top: 50%; width: max(110vw, 110vh); height: max(110vw, 110vh); inset: auto; transform: translate(-50%, -50%); border-radius: 50%; opacity: .32; animation: cs-turn 160s linear infinite; }
@keyframes cs-turn { to { transform: translate(-50%, -50%) rotate(360deg); } }
.cs-vig { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 44%, rgba(3,5,10,0) 35%, rgba(3,5,10,.82) 100%); }
.cs::before, .cs::after { content: ""; position: absolute; left: 0; right: 0; height: 0; background: #000; z-index: 3; animation: cs-bars .9s cubic-bezier(.2,.8,.2,1) forwards; pointer-events: none; }
.cs::before { top: 0; } .cs::after { bottom: 0; }
@keyframes cs-bars { to { height: 3vh; } }

/* the top: the film's timeline (one segment per chapter), then the chapter and the buttons */
.cs-top { position: absolute; z-index: 5; top: 3vh; left: 0; right: 0; padding: 10px 18px 0; }
.cs-tl { display: flex; gap: 4px; margin-bottom: 10px; }
.cs-seg { flex: 1; height: 16px; border: 0; padding: 6px 0; background: none; cursor: pointer; }
.cs-seg i { display: block; height: 3px; border-radius: 3px; background: #a8e6ff; transform-origin: left; transform: scaleX(0); transition: transform .6s ease; box-shadow: 0 0 8px rgba(168,230,255,.6); }
.cs-seg { background-image: linear-gradient(rgba(255,255,255,.14), rgba(255,255,255,.14)); background-size: 100% 3px; background-position: 0 50%; background-repeat: no-repeat; }
.cs-seg:hover { background-image: linear-gradient(rgba(168,230,255,.4), rgba(168,230,255,.4)); }
.cs-seg.cur { background-image: linear-gradient(rgba(168,230,255,.26), rgba(168,230,255,.26)); }
.cs-seg:focus-visible { outline: 2px solid #a8e6ff; outline-offset: 2px; border-radius: 3px; }
.cs-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.cs-k { font: 600 12px var(--df-mono, monospace); letter-spacing: .14em; text-transform: uppercase; color: #a8e6ff; text-shadow: 0 0 10px rgba(0,0,0,.9); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-tb { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
.cs-b { border: 1px solid rgba(168,230,255,.32); background: rgba(4,7,14,.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: #d6e9f5; border-radius: 9px; padding: 8px 12px; font: 500 13px var(--df-sans, system-ui); cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; line-height: 1.1; }
.cs-b:hover { border-color: #a8e6ff; color: #fff; }
.cs-b:focus-visible { outline: 2px solid #a8e6ff; outline-offset: 2px; }
.cs-b.main { background: #a8e6ff; color: #04121a; border-color: #a8e6ff; font-weight: 650; box-shadow: 0 0 18px -4px rgba(168,230,255,.6); }
.cs-b.main:hover { background: #c9f0ff; color: #04121a; }
.cs-b.cs-ic { min-width: 38px; justify-content: center; padding: 8px 10px; }
.cs-b[aria-pressed="true"]#csPause { color: #ffd27a; border-color: rgba(255,210,122,.5); }

/* the picture: a 16:9 window that zooms toward each beat's subject, with soft edges */
.cs-stage { position: absolute; z-index: 2; left: 4%; right: 4%; top: calc(3vh + 82px); bottom: calc(3vh + 214px); display: grid; place-items: center; }
.cs-cam { position: relative; width: min(100%, calc((100vh - 6vh - 310px) * 16 / 9)); aspect-ratio: 16 / 9; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 4%, #000 96%, transparent 100%), linear-gradient(180deg, transparent 0, #000 5%, #000 95%, transparent 100%);
  -webkit-mask-composite: source-in; mask-image: linear-gradient(90deg, transparent 0, #000 4%, #000 96%, transparent 100%), linear-gradient(180deg, transparent 0, #000 5%, #000 95%, transparent 100%); mask-composite: intersect; }
.cs-move { position: absolute; inset: 0; transform-origin: 0 0; transition: transform 1.9s cubic-bezier(.45,.05,.2,1); will-change: transform; }
.cs-drift { position: absolute; inset: 0; animation: cs-drift 24s ease-in-out infinite alternate; transform-origin: 50% 50%; }
@keyframes cs-drift { from { transform: scale(1) translate(0, 0); } to { transform: scale(1.025) translate(.5%, -.4%); } }
.cs-drift svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.cs-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cs-stage text { font-family: var(--df-mono, monospace); }
.cs-stage .lbl { font-size: 13px; font-weight: 600; }
.cs-stage .sm { font-size: 10.5px; fill: #8e97a9; }
.cs-stage .fade { opacity: 0; transition: opacity .9s ease; }
.cs-stage.b1 .r1, .cs-stage.b2 .r2, .cs-stage.b3 .r3, .cs-stage.b4 .r4, .cs-stage.b5 .r5, .cs-stage.b6 .r6, .cs-stage.b7 .r7, .cs-stage.b8 .r8, .cs-stage.b9 .r9, .cs-stage.b10 .r10 { opacity: 1; }
.cs-stage.b2 .h2, .cs-stage.b3 .h3, .cs-stage.b4 .h4, .cs-stage.b5 .h5 { opacity: 0; }

/* the chapter card */
.cs-card { position: absolute; z-index: 4; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; opacity: 0; }
.cs-card.on { animation: cs-card 2.2s ease forwards; }
.cs-card .k { font: 600 13px var(--df-mono, monospace); letter-spacing: .4em; text-transform: uppercase; color: #a8e6ff; }
.cs-card .t { font: 700 clamp(30px, 5.4vw, 74px)/1.05 var(--df-wide, var(--df-sans)); color: #eef6ff; margin: 12px auto 0; text-shadow: 0 0 30px rgba(168,230,255,.5), 0 0 90px rgba(168,230,255,.22); padding: 0 16px; max-width: min(1100px, calc(100vw - 32px)); box-sizing: border-box; text-wrap: balance; overflow-wrap: break-word; }
.cs-card .m { font: 500 11px var(--df-mono, monospace); letter-spacing: .3em; text-transform: uppercase; color: #6f7a8e; margin-top: 16px; }
.cs-card .ln { display: block; height: 1px; width: min(520px, 70vw); margin: 16px auto 0; background: linear-gradient(90deg, transparent, rgba(168,230,255,.9), transparent); box-shadow: 0 0 12px rgba(168,230,255,.8); transform: scaleX(0); }
.cs-card.on .ln { animation: cs-streak 2.2s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes cs-card { 0% { opacity: 0; letter-spacing: .3em; } 20% { opacity: 1; letter-spacing: 0; } 75% { opacity: 1; } 100% { opacity: 0; } }
@keyframes cs-streak { 0% { transform: scaleX(0); opacity: 0; } 25% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1.15); opacity: 0; } }

/* between chapters, and at the end */
.cs-up { position: absolute; z-index: 6; left: 50%; top: calc(3vh + 96px); transform: translateX(-50%); width: min(560px, calc(100% - 32px)); box-sizing: border-box; border: 1px solid rgba(168,230,255,.35); border-radius: 16px; background: rgba(4,7,14,.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: 16px 18px; box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 40px -12px rgba(168,230,255,.4); animation: cs-up .5s cubic-bezier(.2,.8,.2,1); }
.cs-up[hidden] { display: none; }
.cs-up .k { margin: 0; font: 600 11px var(--df-mono, monospace); letter-spacing: .2em; text-transform: uppercase; color: #a8e6ff; }
.cs-up .k span { color: #6f7a8e; letter-spacing: .1em; margin-left: 6px; }
.cs-up .t { margin: 8px 0 0; font: 600 19px/1.3 var(--df-wide, var(--df-sans)); color: #eef6ff; }
.cs-up .t b { color: #a8e6ff; font-weight: 700; }
.cs-up .s { margin: 8px 0 0; font-size: 14px; line-height: 1.55; color: #b9c1d1; }
.cs-up .b { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.cs-up.end { top: 50%; transform: translate(-50%, -50%); text-align: center; padding: 26px 24px; }
.cs-up.end .t { font-size: clamp(20px, 2.4vw, 28px); }
.cs-up.end .b { justify-content: center; }
@keyframes cs-up { from { opacity: 0; transform: translate(-50%, -10px); } }
.cs-up.end { animation: cs-pop .6s cubic-bezier(.2,1.3,.4,1); }
@keyframes cs-pop { from { opacity: 0; transform: translate(-50%, -50%) scale(.92); } }

/* the caption: what the narrator says, the code it is about, and the controls */
.cs-cap { position: absolute; z-index: 5; left: 50%; bottom: calc(3vh + 12px); transform: translateX(-50%); width: min(940px, calc(100% - 32px)); box-sizing: border-box; border: 1px solid rgba(168,230,255,.28); border-radius: 16px; background: rgba(4,7,14,.86); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding: 16px 20px 14px; box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 20px 60px rgba(0,0,0,.6), 0 0 40px -10px rgba(168,230,255,.3); }
.cs-say { margin: 0; min-height: 2.9em; font-size: clamp(16px, 1.5vw, 20px); line-height: 1.45; color: #eef6ff; }
.cs-say .cur { display: inline-block; width: 8px; height: 1.05em; vertical-align: -2px; background: #a8e6ff; margin-left: 2px; animation: cs-blink 1s steps(1) infinite; }
@keyframes cs-blink { 50% { opacity: 0; } }
.cs-code { margin: 8px 0 0; font: 12.5px/1.5 var(--df-mono, monospace); color: #a8e6ff; opacity: 0; transition: opacity .5s ease .15s; overflow-wrap: anywhere; display: inline-block; max-width: 100%; box-sizing: border-box; padding: 3px 9px; border-radius: 6px; background: rgba(168,230,255,.06); border: 1px solid rgba(168,230,255,.14); }
.cs-code:empty { display: none; }
.cs-code.on { opacity: 1; } .cs-code::before { content: '› '; color: #6f7a8e; }
.cs-prog { display: flex; align-items: center; margin-top: 10px; min-height: 22px; }
.cs-ctl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.cs-ctl .sp { flex: 1; }
.cs-ctl .cine-b:not(.cine-spd) .l { display: none; }
.cs-ctl .cine-b { min-width: 38px; justify-content: center; padding: 8px 9px; border-color: rgba(168,230,255,.28); background: rgba(4,7,14,.72); color: #d6e9f5; }

/* the chapter list */
.cs-list { position: absolute; z-index: 7; top: calc(3vh + 74px); right: 18px; width: min(380px, calc(100% - 36px)); max-height: 70vh; overflow: auto; border: 1px solid rgba(168,230,255,.3); border-radius: 12px; background: rgba(4,7,14,.96); padding: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.cs-li { display: flex; align-items: baseline; gap: 6px; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; color: #e8eef7; padding: 9px 10px; font: 14px var(--df-sans, system-ui); cursor: pointer; }
.cs-li b { display: inline-block; min-width: 92px; font: 600 11px var(--df-mono, monospace); letter-spacing: .1em; text-transform: uppercase; color: #a8e6ff; }
.cs-li span { margin-left: auto; font: 11px var(--df-mono, monospace); color: #6f7a8e; white-space: nowrap; }
.cs-li:hover, .cs-li:focus-visible { background: rgba(168,230,255,.08); outline: none; }

@media (max-width: 700px) {
  .cs-stage { left: 0; right: 0; top: calc(3vh + 96px); bottom: calc(3vh + 236px); }
  .cs-cam { width: 100%; }
  .cs-cap { bottom: calc(3vh + 8px); padding: 12px 14px; width: calc(100% - 20px); }
  .cs-say { min-height: 4.4em; font-size: 15.5px; }
  .cs-top { padding: 8px 10px 0; }
  .cs-bar { flex-wrap: wrap; }
  .cs-k { flex-basis: 100%; font-size: 10.5px; letter-spacing: .1em; }
  .cs-tb { justify-content: flex-start; }
  .cs-tb .cs-b { padding: 7px 9px; font-size: 12px; }
  .cs-tb .cs-b .l { display: none; }
  .cs-lw { margin-left: 0; }
  .cs-ctl .cine-sel { max-width: 110px; }
  .cs-up { top: calc(3vh + 120px); }
}
@media (prefers-reduced-motion: reduce) {
  .cs-drift, .cs-play span, .cs-bg.cine-cpu, .cs::before, .cs::after { animation: none; }
  .cs::before, .cs::after { height: 3vh; }
  .cs-stage .fade, .cs-move, .cs-seg i { transition: none; }
}
