/* GAP's page is the film's frame, made touchable: the picture fills the screen and the words sit on it the way the
   film sets its on-screen text (episodes/ep18/shots/kit.py: Overpass; ink on paper; white with a soft dark outline
   on the aerial and 3D worlds, never a box; red = braking, cyan = only self-driving cars, amber = human time). */
@font-face { font-family: Overpass; src: url(../fonts/Overpass-var.woff) format('woff'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Overpass Mono'; src: url(../fonts/OverpassMono-var.woff) format('woff'); font-weight: 300 700; font-display: swap; }

:root {
  --paper: #F1ECE2; --ink: #1E2329; --slate: #3E4A57; --red: #E2382D; --cyan: #1FC6DA; --amber: #F2A93B;
  --gut: 18px;
  --fg: var(--ink); --fg2: rgba(30, 35, 41, .62); --rule: rgba(30, 35, 41, .16); --shadow: none;
}
.aerial { --fg: #FFFFFF; --fg2: rgba(255, 255, 255, .78); --rule: rgba(255, 255, 255, .3);
  --shadow: 0 0 2px rgba(0, 0, 0, .55), 0 0 7px rgba(0, 0, 0, .45), 0 1px 12px rgba(0, 0, 0, .3); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #111; overscroll-behavior: none; overflow: hidden; }
body { font-family: Overpass, system-ui, sans-serif; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }

#app { position: relative; height: 100dvh; overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; background: var(--paper); color: var(--fg); text-shadow: var(--shadow);
  transition: background .6s; }
#app.aerial { background: #59645F; }
#stage { position: absolute; inset: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
#hud { position: absolute; inset: 0; pointer-events: none; }

#head { position: absolute; top: 0; left: 0; right: 0; padding: 16px var(--gut) 0; pointer-events: none; }
#chapter { display: flex; justify-content: space-between; align-items: baseline; font-weight: 900; font-size: 13px; letter-spacing: .2em; color: var(--fg2); }
#levelno { font-family: 'Overpass Mono', monospace; font-weight: 500; letter-spacing: 0; }
#question { margin: 6px 0 0; max-width: 17em; font-weight: 800; font-size: clamp(25px, 7vw, 40px); line-height: 1.06; letter-spacing: -.01em; }

#bottom { position: absolute; left: 0; right: 0; bottom: 0; pointer-events: none; }
#bottom > * { pointer-events: auto; }
.aerial #bottom::before { content: ''; position: absolute; inset: -60px 0 0; z-index: -1; pointer-events: none;
  background: linear-gradient(to bottom, rgba(20, 26, 24, 0), rgba(20, 26, 24, .45)); }
#bottom > #talk { padding: 0 var(--gut); pointer-events: none; }
#controls { pointer-events: auto; }
#say { margin: 0; max-width: 30em; font-size: 18px; line-height: 1.3; font-weight: 600; min-height: 3.9em; }
#say b { font-weight: 800; }
#say .red { color: var(--red); }
.aerial #say .red { color: #FF7B6E; } #say .cyan { color: var(--cyan); } #say .amber { color: var(--amber); }
#controls { display: flex; gap: 8px 18px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
#controls { min-height: 34px; }

#onward { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; padding: 12px var(--gut) 6px; }
#film { color: var(--fg2); font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; padding-bottom: 6px; }
#film::before { content: '▸ '; color: var(--red); }
/* Next is the film's own motif: a phrase sitting over a gap bracket */
#next { border: 0; background: none; cursor: pointer; text-align: right; padding: 4px 0 12px; position: relative; color: var(--fg2);
  font-weight: 800; font-size: 17px; line-height: 1.15; max-width: 74%; opacity: .55; transition: opacity .5s, color .5s; text-shadow: inherit; }
#next::after { content: ''; position: absolute; right: 0; bottom: 3px; height: 7px; width: 100%; border: 2.5px solid currentColor; border-top: 0;
  transform-origin: right; transform: scaleX(.25); transition: transform .7s cubic-bezier(.2, .7, .2, 1); }
#next.ready { opacity: 1; color: var(--fg); }
#next.ready::after { transform: scaleX(1); border-color: var(--red); }
#next .k { display: block; font-size: 11px; letter-spacing: .2em; font-weight: 900; color: var(--fg2); margin-bottom: 2px; }
#next .arrow { display: inline-block; margin-left: 5px; color: var(--red); }

#path { position: relative; }
#pathbar { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; border-top: 1px solid var(--rule);
  padding: 9px var(--gut) calc(9px + env(safe-area-inset-bottom)); cursor: pointer; color: var(--fg2); text-shadow: inherit; }
#dots { display: flex; align-items: center; flex: 1 1 auto; min-width: 0; gap: 9px; }
#dots .grp { display: flex; gap: 3px; }
#dots i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; display: block; opacity: .8; }
#dots i.done { background: currentColor; }
#dots i.here { background: var(--red); border-color: var(--red); transform: scale(1.3); opacity: 1; }
#dots i.soon { opacity: .35; }
#pathlabel { font-size: 12px; font-weight: 900; letter-spacing: .16em; white-space: nowrap; }
#pathcaret { font-size: 13px; transition: transform .3s; }
#pathbar[aria-expanded=true] #pathcaret { transform: rotate(180deg); }

/* the whole path: the film's paper, whatever the scene */
#pathlist { position: absolute; left: 0; right: 0; bottom: 100%; max-height: 74dvh; overflow-y: auto; background: var(--paper); color: var(--ink);
  text-shadow: none; padding: 6px var(--gut) 18px; box-shadow: 0 -10px 30px rgba(0, 0, 0, .18); border-radius: 14px 14px 0 0; }
#pathlist .title { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 0 2px; }
#pathlist .title b { font-size: 34px; font-weight: 900; letter-spacing: .02em; }
#pathlist .title span { font-size: 13px; color: rgba(30, 35, 41, .6); }
#pathlist h3 { margin: 16px 0 4px; font-size: 12px; font-weight: 900; letter-spacing: .2em; color: rgba(30, 35, 41, .55); }
#pathlist a { display: flex; gap: 12px; align-items: baseline; padding: 9px 0; color: var(--ink); text-decoration: none; border-bottom: 1px solid rgba(30, 35, 41, .08); }
#pathlist a .n { font-family: 'Overpass Mono', monospace; font-size: 12px; color: rgba(30, 35, 41, .45); width: 20px; flex: none; }
#pathlist a .q { font-weight: 700; font-size: 17px; line-height: 1.2; flex: 1; }
#pathlist a .st { font-size: 13px; color: rgba(30, 35, 41, .55); flex: none; }
#pathlist a.here .q { color: var(--red); }
#pathlist a.done .st::before { content: '✓'; }
#pathlist a.soon { opacity: .4; pointer-events: none; }
#pathlist a.soon .st::before { content: 'soon'; font-size: 11px; letter-spacing: .1em; }
#pathlist .foot { margin-top: 18px; font-size: 13px; color: rgba(30, 35, 41, .6); line-height: 1.45; }
#pathlist .foot button { background: none; border: 0; padding: 0; text-decoration: underline; color: inherit; cursor: pointer; }

/* controls, in the film's type: words to touch, the chosen one carries the film's bracket */
.pick { display: inline-flex; gap: 4px 14px; align-items: baseline; flex-wrap: wrap; }
.pick button { white-space: nowrap; }
.pick .lab { font-size: 12px; font-weight: 900; letter-spacing: .16em; color: var(--fg2); }
.pick button { border: 0; background: none; padding: 6px 0 9px; font-weight: 800; font-size: 16px; color: var(--fg2); cursor: pointer; position: relative; text-shadow: inherit; }
.pick button.on { color: var(--fg); }
.pick button.on::after { content: ''; position: absolute; left: 0; right: 0; bottom: 2px; height: 5px; border: 2px solid var(--fg); border-top: 0; }
.pick button.on.cyan { color: var(--cyan); } .pick button.on.cyan::after { border-color: var(--cyan); }
.act { border: 0; background: none; padding: 6px 0; font-weight: 800; font-size: 16px; cursor: pointer; color: var(--fg); text-shadow: inherit; }
.act::before { content: '● '; color: var(--red); }
.fade-in { animation: fadein .6s ease both; }
/* new words wait until the picture has made room for them (app.js safe()) */
#say.fade-in, #controls .fade-in { animation-delay: .4s; }
@keyframes fadein { from { opacity: 0; transform: translateY(5px); } }

/* the chapter card between chapters: drawn on the canvas; this only dims the words while it plays */
#app.card #head, #app.card #bottom { opacity: 0; transition: opacity .3s; }
#head, #bottom { transition: opacity .6s; }

@media (min-width: 900px) {
  :root { --gut: 40px; }
  #head { padding-top: 32px; }
  #question { font-size: 44px; }
  #say { font-size: 21px; }
  #next { font-size: 19px; }
}

/* ---- the explanation sheet: the film's paper, set like the film's own type ---- */
#leftlinks { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding-bottom: 6px; }
#how { white-space: nowrap; border: 0; background: none; padding: 4px 0; font-weight: 800; font-size: 14px; color: var(--fg); cursor: pointer; text-shadow: inherit; letter-spacing: .01em; }
#how .caret, #sheetclose .caret { display: inline-block; margin-left: 3px; color: var(--red); }
#sheet { position: absolute; inset: 0; z-index: 20; background: var(--paper); color: var(--ink); text-shadow: none; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .45s cubic-bezier(.2, .7, .2, 1); }
#sheet.open { transform: translateY(0); }
#sheet[hidden], #settings[hidden] { display: none; }
#sheetbar { display: flex; justify-content: space-between; align-items: center; padding: 14px var(--gut) 10px; border-bottom: 1px solid rgba(30,35,41,.12); }
#sheetch { font-weight: 900; font-size: 13px; letter-spacing: .2em; color: rgba(30,35,41,.6); }
#sheetclose { border: 0; background: none; font-weight: 800; font-size: 14px; color: var(--ink); cursor: pointer; padding: 4px 0; }
#sheetbody { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 22px var(--gut) 60px; user-select: text; -webkit-user-select: text; }
#sheetbody > * { max-width: 640px; margin-left: auto; margin-right: auto; }
#sheetbody .kicker { font-weight: 900; font-size: 12px; letter-spacing: .22em; color: var(--red); margin: 0 auto 8px; }
#sheetbody h2 { font-weight: 800; font-size: clamp(27px, 7.4vw, 42px); line-height: 1.06; letter-spacing: -.012em; margin: 0 auto 26px; }
#sheetbody h3 { font-weight: 900; font-size: 12px; letter-spacing: .2em; color: var(--ink); margin: 34px auto 14px; padding-bottom: 9px; position: relative; display: block; }
#sheetbody h3::after { content: ''; position: absolute; left: 0; bottom: 0; width: 46px; height: 6px; border: 2px solid var(--ink); border-top: 0; }
#sheetbody p { font-size: 17px; line-height: 1.55; font-weight: 450; margin: 0 auto 14px; }
#sheetbody p b { font-weight: 800; }
#sheetbody .facts { display: flex; flex-wrap: wrap; gap: 18px 0; margin: 22px auto 22px; }
#sheetbody .fact { flex: 1 1 140px; padding: 2px 16px 2px 0; margin-right: 16px; border-right: 1px solid rgba(30,35,41,.14); }
#sheetbody .fact:last-child { border-right: 0; }
#sheetbody .fact .big { font-family: 'Overpass Mono', monospace; font-weight: 600; font-size: clamp(26px, 7vw, 36px); line-height: 1.05; letter-spacing: -.02em; color: var(--ink); }
#sheetbody .fact .small { font-size: 13px; line-height: 1.35; font-weight: 700; color: rgba(30,35,41,.62); margin-top: 6px; }
#sheetbody figure { margin: 24px auto; }
#sheetbody figure img { width: 100%; height: auto; display: block; border-radius: 3px; background: #ddd6c9; }
#sheetbody figcaption { font-size: 14px; line-height: 1.45; font-weight: 600; margin-top: 9px; }
#sheetbody figcaption .credit { display: block; font-size: 12px; font-weight: 500; color: rgba(30,35,41,.55); margin-top: 3px; }
#sheetbody .fine { margin-top: 36px; padding-top: 14px; border-top: 1px solid rgba(30,35,41,.14); font-size: 13px; line-height: 1.5; color: rgba(30,35,41,.7); font-weight: 600; }
#sheetbody .sources { margin-top: 18px; }
#sheetbody .sources h4 { font-weight: 900; font-size: 11px; letter-spacing: .2em; color: rgba(30,35,41,.55); margin: 0 0 8px; }
#sheetbody .sources ol { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.5; color: rgba(30,35,41,.78); }
#sheetbody .sources li { margin-bottom: 6px; }
#sheetbody .sources a { color: inherit; text-decoration-color: rgba(226,56,45,.6); text-underline-offset: 2px; word-break: break-word; }
#sheetbody .back { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 34px; }
#sheetbody .back button { border: 0; background: none; font-weight: 800; font-size: 16px; color: var(--ink); cursor: pointer; padding: 6px 0 10px; position: relative; text-align: left; }
#sheetbody .back button::after { content: ''; position: absolute; left: 0; right: 0; bottom: 2px; height: 6px; border: 2px solid var(--red); border-top: 0; }
@media (min-width: 900px) { #sheetbody { padding-top: 48px; } #sheetbody p { font-size: 18px; } }
#sheetbody figure.small img { width: auto; max-width: 100%; }

/* the sandbox's settings drawer: closed by default, the road comes first */
.drawer { display: none; flex-direction: column; gap: 6px; width: 100%; padding: 4px 0 2px; max-height: 34dvh; overflow-y: auto; overscroll-behavior: contain; }
.drawer.open { display: flex; }
.act.drawer-toggle::before { content: '⌃ '; color: var(--red); display: inline-block; transition: transform .3s; }
.act.drawer-toggle.open::before { content: '⌄ '; }

/* while settings are open the message steps aside, so the picture keeps its room */
#app.drawer-open #say { display: none; }

/* the sandbox's settings: a sheet on the film's paper over the lower half; the road stays live above it */
#settings { position: absolute; left: 0; right: 0; bottom: 0; height: min(54dvh, 460px); z-index: 15; background: var(--paper); color: var(--ink);
  text-shadow: none; border-radius: 14px 14px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.22); display: flex; flex-direction: column;
  transform: translateY(105%); transition: transform .4s cubic-bezier(.2, .7, .2, 1); }
#settings.open { transform: translateY(0); }
#setbar { display: flex; justify-content: space-between; align-items: center; padding: 14px var(--gut) 8px; }
#settitle { font-weight: 900; font-size: 12px; letter-spacing: .2em; color: rgba(30,35,41,.6); }
#setclose { border: 0; background: none; font-weight: 800; font-size: 15px; color: var(--ink); cursor: pointer; padding: 4px 0; }
#setclose .caret { color: var(--red); margin-left: 3px; }
#setbody { flex: 1; overflow-y: auto; padding: 0 var(--gut) 18px; overscroll-behavior: contain; }
#setbody .pick { display: flex; flex-wrap: wrap; gap: 0 16px; padding: 10px 0 6px; border-top: 1px solid rgba(30,35,41,.1); }
#setbody .pick .lab { width: 100%; color: rgba(30,35,41,.55); margin-bottom: 2px; }
#setbody .pick button { color: rgba(30,35,41,.55); text-shadow: none; }
#setbody .pick button.on { color: var(--ink); }
#setbody .pick button.on::after { border-color: var(--ink); }
#setbody .pick button.on.cyan { color: #0E9DB0; }
#setbody .pick button.on.cyan::after { border-color: #0E9DB0; }

/* the way back to the film: a frame of this moment, the film's red play mark; tapping it plays the film here */
#sheetbody figure.film { margin: 0 auto 28px; }
#sheetbody figure.film .poster { position: relative; display: block; width: 100%; padding: 0; border: 0; background: #111; cursor: pointer; border-radius: 4px; overflow: hidden; aspect-ratio: 16 / 9; }
#sheetbody figure.film .poster img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .92; transition: opacity .3s; }
#sheetbody figure.film .poster:hover img { opacity: 1; }
#sheetbody figure.film .play { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%;
  background: var(--red); box-shadow: 0 4px 18px rgba(0,0,0,.35); }
#sheetbody figure.film .play::after { content: ''; position: absolute; left: 26px; top: 20px; border-left: 18px solid #fff; border-top: 12px solid transparent; border-bottom: 12px solid transparent; }
#sheetbody figure.film iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; display: block; border-radius: 4px; background: #111; }
#sheetbody figure.film figcaption { font-weight: 800; font-size: 15px; }
#sheetbody figure.film figcaption .tc { font-family: 'Overpass Mono', monospace; font-weight: 600; }
