/* The async lab: the hero's two lanes, the key card, the live monitor, the steps' extras, the API table, and the
   monitor alone (?monitor=1, for the projector). Course tokens only (javascript.css); the monitor and the hero are
   night panels. Colours of the calls, the same in the hero, the monitor and its legend: announcements sky (--host),
   me amber (--you), courses purple (--engine), grade rose (--lib). */

/* ---------- Hero: the same four calls in line, then side by side ---------- */
.lab-art { aspect-ratio: auto; display: flex; flex-direction: column; justify-content: center; }
.lab-art__in { position: relative; z-index: 1; padding: 9% 7% 0; }
.lab-art__k { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 8px; font: 600 .74rem/1.2 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--night-ink-2); }
.lab-art__t { font-size: .95rem; letter-spacing: .02em; color: var(--night-ink); }
.lab-art__lane { position: relative; height: 34px; margin: 0 0 28px; border-radius: 10px; background: rgba(255, 255, 255, .04); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07); }
.lab-art__lane--async { height: 64px; }
.lab-art__bar {
  position: absolute; top: 5px; height: 24px; left: calc(var(--s) / 8 * 100% + 2px); width: calc(var(--d) / 8 * 100% - 4px);
  display: block; padding: 0 6px; border-radius: 7px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font: 600 .66rem/24px var(--font-mono); color: #0b0d17;
}
.lab-art__lane--async .lab-art__bar { top: 35px; }
.lab-art__lane--async .lab-art__bar--top { top: 5px; }
.lab-art__bar--ann { background: #7dd3fc; }
.lab-art__bar--l1 { background: #fbbf24; }
.lab-art__bar--l2 { background: #c084fc; }
.lab-art__bar--l3 { background: #ff6aa9; }
.lab-art__lane--sync::after {   /* the frozen page: hatched over the whole wait */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(255, 138, 128, .2) 0 6px, transparent 6px 12px);
}
/* The caption under the lanes, as chapter 01's (how-javascript-runs/capsule.css). */
.lab-art .stage__cap {
  position: relative; z-index: 3; margin: 18px 7% 0; padding-bottom: 8%;
  font: 500 .86rem/1.45 var(--font-body); color: var(--night-ink-2); text-wrap: pretty;
}
@media (max-width: 600px) { .lab-art .stage__cap { font-size: .8rem; line-height: 1.42; } }
@media (max-width: 520px) { .lab-art__bar { font-size: .58rem; padding: 0 4px; } }

/* ---------- The status line under the starting point (the session is silent) ---------- */
.lab-ready { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 0 0; min-height: 1.5em; }
.lab-ready__msg { margin: 0 !important; font-size: .9rem; color: var(--ink-3); }
.lab-ready__msg:empty { display: none; }
.lab-ready:is([data-state="down"], [data-state="busy"]) .lab-ready__msg { color: var(--no); }
.lab-ready:not([data-state="down"]):not([data-state="busy"]) [data-lab-retry] { display: none; }
.lab-btn {
  min-height: 40px; padding: 8px 16px; border-radius: 12px; border: 1px solid var(--control); background: var(--surface); color: var(--ink);
  font: 600 .9rem/1.2 var(--font-body); cursor: pointer;
}
.lab-btn:hover { border-color: var(--accent); }
.lab-btn--quiet { font-weight: 500; color: var(--ink-2); }
.lab-small { font-size: .88rem !important; color: var(--ink-3); }
.lab-small a { color: inherit; }

a.pg-open[aria-disabled="true"], a[data-lab-monitor-link][aria-disabled="true"] { opacity: .55; pointer-events: none; }
/* Under each step's title: back to the student's own code, in the same playground tab. */
.lab-minelink { display: inline-block; margin: 0 0 10px; font-size: .88rem; font-weight: 600; }
.lab-minelink[hidden], :root.is-presenting .lab-minelink { display: none; }
.lab-minelink--repair { margin-left: 16px; font-weight: 500; color: var(--ink-3); }
@media (pointer: coarse) { .mon .mon__rename { width: 40px; height: 40px; margin: -12px -10px -12px -14px; } .lab-minelink { padding: 10px 0; } .mon .mon__label-in { font-size: 16px; } }

/* ---------- Lists, Break it, solutions ---------- */
.lab-list { list-style: none; padding: 0 !important; margin: 16px 0 !important; }
.lab-list > li { position: relative; padding-left: 22px; margin: 0 0 8px !important; }
.lab-list > li::before { content: ""; position: absolute; left: 4px; top: .62em; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.lab-break {
  position: relative; margin: 14px 0; padding: 12px 16px 12px 18px; border-radius: var(--r);
  background: color-mix(in srgb, var(--no) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--no) 28%, var(--rule));
}
.lab-break::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--no); }
.lab-break__k { display: block; margin: 0 0 4px; font: 600 .68rem/1.3 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--no); }
.lab-break p { margin: 0 !important; }
details.lab-sol { margin: 14px 0 0; border: 1px dashed var(--rule-strong); border-radius: var(--r); padding: 0 16px; }
details.lab-sol > summary { padding: 12px 0; cursor: pointer; font-weight: 600; color: var(--ink-2); }
details.lab-sol[open] { padding-bottom: 14px; }
details.lab-sol > summary:hover { color: var(--accent); }
details.lab-sol .code { margin: 6px -6px 10px; }
details.lab-sol--why { margin-top: 8px; }
details.lab-more { margin: 10px 0 0; }
details.lab-more > summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
details.lab-more > p { margin: 8px 0 0 !important; }
details.lab-more > .lab-list { margin: 10px 0 0 !important; }

/* ---------- The live monitor (a night panel) ---------- */
.mon { margin: 18px 0 10px; padding: 14px 16px 16px; border-radius: var(--r-lg); background: var(--night); color: var(--night-ink); box-shadow: inset 0 0 0 1px var(--night-rule); }
.mon__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 10px; font-size: .88rem; color: var(--night-ink-2); }
.mon__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--night-ink-3); }
.mon[data-live="open"] .mon__dot { background: #5fd3a0; box-shadow: 0 0 0 4px rgba(95, 211, 160, .18); }
.mon:is([data-live="lost"], [data-live="busy"]) .mon__dot { background: #fbbf24; }
.mon:is([data-live="off"], [data-live="expired"]) .mon__dot { background: #ff8a80; }
.mon__legend { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-left: auto; font: 500 .72rem/1 var(--font-mono); color: var(--night-ink-3); }
.mon__lg { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; margin-left: 6px; }
.mon__sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.mon__sw--ann, .mon__bar--ann { background: #7dd3fc; }
.mon__sw--l1, .mon__bar--l1 { background: #fbbf24; }
.mon__sw--l2, .mon__bar--l2 { background: #c084fc; }
.mon__sw--l3, .mon__bar--l3 { background: #ff6aa9; }
.mon__bar--other { background: var(--night-ink-3); }
.mon .lab-btn { background: transparent; color: var(--night-ink-2); border-color: var(--night-rule); min-height: 34px; padding: 5px 12px; }
.mon .lab-btn:hover { border-color: var(--night-ink-3); color: var(--night-ink); }
.mon__empty { margin: 10px 0 !important; color: var(--night-ink-3); font-size: .92rem; }
.mon__run { padding: 10px 0 4px; border-top: 1px solid var(--night-rule); }
.mon__run:not(.is-latest) { opacity: .8; }
.mon__rh { display: flex; flex-wrap: wrap; align-items: center; gap: .3em 1.1em; margin: 0 0 8px !important; font: 500 .78rem/1.3 var(--font-mono); color: var(--night-ink-2); }
.mon__rh b { color: var(--night-ink); }
.mon__rh .mon__dur { font-size: 1.3em; }
/* The run's name: its number, then its time or the name the professor gave it (the pencil), and "latest". */
.mon__title { white-space: nowrap; }
.mon__time { color: var(--night-ink-3); margin-left: -4px; }
.mon__label { margin-left: -4px; font-weight: 600; color: #c4b5fd; }
.mon__label-in { margin-left: -4px; width: 11em; padding: 2px 7px; border-radius: 6px; border: 1px solid #8b7cf6; background: rgba(255, 255, 255, .08); color: var(--night-ink); font: inherit; outline: none; }
.mon__rename { display: inline-grid; place-items: center; font: inherit; width: 1.9em; height: 1.9em; margin: -.3em -.45em -.3em -.75em; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--night-ink-3); cursor: pointer; }
.mon__rename:hover, .mon__rename:focus-visible { color: var(--night-ink); background: rgba(255, 255, 255, .08); }
.mon__rename svg { width: 1.05em; height: 1.05em; }
.mon__latest { order: 1; margin-left: auto; padding: 2px 8px; border-radius: 999px; background: rgba(95, 211, 160, .14); color: #7ee2b8; font-size: .86em; letter-spacing: .03em; }
.mon--dock :is(.mon__latest, .mon__rename, .mon__label-in) { display: none; }
/* Dashed lines at 6 s and 8 s across the rows, and their ticks a little brighter. */
.mon__goal { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed rgba(255, 255, 255, .34); pointer-events: none; }
.mon__tick.mon__tick--goal { color: var(--night-ink); font-weight: 700; }
.mon__more { margin: 0 0 5px !important; padding-left: calc(7.5em + 10px); font: 500 .7rem/1.3 var(--font-mono); color: var(--night-ink-3); }
.mon__rows { list-style: none; padding: 0 !important; margin: 0 !important; }
.mon__row { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); align-items: center; gap: 10px; margin: 0 0 5px !important; font-size: 1em; }
.mon__name { font: 500 .74rem/1 var(--font-mono); color: var(--night-ink-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mon__track { position: relative; height: 20px; border-radius: 6px; background: rgba(255, 255, 255, .035); overflow: hidden; }
.mon__bar { position: absolute; top: 2px; bottom: 2px; min-width: 6px; border-radius: 5px; display: flex; align-items: center; justify-content: flex-end; overflow: hidden; }
.mon__tag { padding: 0 6px; font: 600 .66rem/1 var(--font-mono); color: #0b0d17; white-space: nowrap; }
.mon__bar.is-waiting { background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, .35) 0 5px, transparent 5px 10px); }
.mon__bar.is-error { box-shadow: inset 0 0 0 2px #ff8a80; background: rgba(255, 138, 128, .35); }
.mon__bar.is-error .mon__tag { color: #ffd2cd; }
.mon__bar.is-aborted { opacity: .45; }
/* A bar too narrow for its label (an error, a cancelled call, a short call): the label sits beside it. */
.mon__bar.is-narrow { overflow: visible; }
.mon__bar.is-narrow .mon__tag { position: absolute; left: calc(100% + 6px); color: var(--night-ink); background: var(--night); padding: 1px 4px; border-radius: 4px; }
.mon__bar.is-narrow.is-error .mon__tag { color: #ffb4ab; }
.mon__bar.is-narrow.is-late .mon__tag { left: auto; right: calc(100% + 6px); }

/* The latest run, docked in a corner of the slides in presentation mode (lab.js; M toggles it). */
.mon--dock { display: none; }
:root.is-presenting .mon--dock:not(.is-off) {
  display: block; position: fixed; right: 18px; bottom: 60px; z-index: 10012; width: min(500px, 26vw); margin: 0; padding: 8px 12px 10px;
  font-size: clamp(13px, 1vw, 19px); max-height: calc(100vh - 140px); overflow: hidden;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .6), inset 0 0 0 1px var(--night-rule);
}
/* The dock's text follows the dock's size (the monitor's own sizes are in rem): about 17 px at 1920 px. */
:root.is-presenting .mon--dock :is(.mon__rh, .mon__name, .mon__tag, .mon__more) { font-size: .9em; }
:root.is-presenting .mon--dock :is(.mon__tick, .mon__dock-k) { font-size: .72em; }
:root.is-presenting .mon--dock .mon__track { height: 1.3em; }
/* A narrow projector: only the run's line stays in the corner, over no text. */
@media (max-width: 1279px) { :root.is-presenting .mon--dock :is(.mon__rows, .mon__axis) { display: none; } }
:root.is-presenting .mon--dock .mon__run { border-top: 0; padding-top: 0; opacity: 1; }
.mon--dock .mon__tick:not(:nth-child(2n+1)) { display: none; }
.mon__dock-k { display: flex; align-items: center; gap: 4px; margin: 0 0 4px !important; font: 600 .62rem/1.2 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--night-ink-3); }
.mon__dock-t { margin-right: auto; }
.mon__dock-t--read, .mon__dock-b { display: none; }
/* The dock in reading mode (lab.js place()): a wide screen, a step being read, the monitor out of view. */
:root:not(.is-presenting) .mon--dock.is-reading {
  display: block; position: fixed; right: 14px; bottom: 14px; z-index: 30; margin: 0; padding: 8px 12px 10px;
  max-height: calc(100vh - 110px); overflow: hidden; box-shadow: 0 22px 48px -20px rgba(0, 0, 0, .55), inset 0 0 0 1px var(--night-rule);
  animation: mon-in .22s ease-out;
}
.mon--dock.is-reading .mon__run { border-top: 0; padding-top: 0; opacity: 1; }
.mon--dock.is-reading .mon__dock-t--pp { display: none; }
.mon--dock.is-reading .mon__dock-t--read { display: inline; }
.mon--dock.is-reading .mon__dock-b:not([hidden]) { display: inline-grid; }
.mon--dock.is-mini :is(.mon__rows, .mon__axis) { display: none; }
.mon--dock.is-mini .mon__rh { margin: 0 !important; }
.mon--dock.is-mini :is(.mon__n, .mon__time, .mon__label) { display: none; }
:root[data-theme="dark"] .mon--dock.is-reading { background: var(--night-2); box-shadow: 0 22px 48px -20px rgba(0, 0, 0, .8), inset 0 0 0 1px rgba(255, 255, 255, .16); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .mon--dock.is-reading { background: var(--night-2); box-shadow: 0 22px 48px -20px rgba(0, 0, 0, .8), inset 0 0 0 1px rgba(255, 255, 255, .16); } }
.mon__dock-b { place-items: center; width: 26px; height: 26px; margin: -4px 0; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--night-ink-3); cursor: pointer; }
.mon__dock-b:hover, .mon__dock-b:focus-visible { background: rgba(255, 255, 255, .09); color: var(--night-ink); }
.mon__dock-b svg { width: 15px; height: 15px; transition: transform .18s ease; }
.mon__dock-b.is-open svg { transform: rotate(180deg); }
@keyframes mon-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .mon--dock.is-reading, .mon__dock-b svg { animation: none; transition: none; } }
:root.is-presenting [data-i18n="s1-phone"] { display: none; }
:root.is-presenting:has(#monitor.is-pp-current, #top.is-pp-current, #api.is-pp-current, #quiz.is-pp-current, #recap.is-pp-current) .mon--dock,
:root.is-presenting .mon--dock:has(.mon__runs:empty),
:root.is-presenting:has(.pp-end:not([hidden])) .mon--dock { display: none; }
.mon__axis { position: relative; height: 16px; margin: 4px 0 0 calc(7.5em + 10px); }
.mon__tick { position: absolute; top: 0; transform: translateX(-50%); font: 500 .62rem/1 var(--font-mono); color: var(--night-ink-3); white-space: nowrap; }
.mon__tick:first-child { transform: none; }
.mon__tick--end { transform: translateX(-100%); }
.lab-monlink { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--accent) !important; }
.lab-monlink svg { width: 16px; height: 16px; }
@media (max-width: 520px) {
  .mon__row { grid-template-columns: 6em minmax(0, 1fr); gap: 6px; }
  .mon__axis { margin-left: calc(6em + 6px); }
  .mon__legend { order: 3; flex-basis: 100%; margin-left: 0; }
  .mon__clear { margin-left: auto; }
  .mon__tick:not(:nth-child(2n+1)) { display: none; }
}

/* ---------- Predict the order (steps 03 and 05), Freeze it yourself (step 03) ---------- */
.lab-order { margin: 22px 0; padding: 14px 16px 4px; border-radius: var(--r); border: 1px solid var(--rule); background: var(--surface); }
.lab-order > .predict { margin-top: 0 !important; }
.lab-order > .code { margin: 12px 0; }
.lab-order > .predict { border-radius: 10px; }
.lab-order > details.check { margin-bottom: 10px; }
@media (max-width: 520px) { .lab-order { padding: 12px 10px 2px; } .lab-order > .code { margin: 10px 0; } }
.lab-break--freeze { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 26%, var(--rule)); }
.lab-break--freeze::before { background: var(--accent); }
.lab-break--freeze .lab-break__k { color: var(--accent); }

/* ---------- Slide 1 in presentation mode: the page's address and its QR code ---------- */
.lab-qr { display: none; }
:root.is-presenting .lab-qr { display: flex; align-items: center; gap: 20px; margin: 30px 0 0; }
.lab-qr__code { display: block; flex: none; width: 150px; height: 150px; padding: 13px; border-radius: 16px; background: #fff; box-shadow: 0 0 0 1px var(--rule), 0 14px 30px -18px rgba(0, 0, 0, .35); }
.lab-qr__code svg { display: block; width: 100%; height: 100%; }
:root[lang="fr"] .lab-qr__code--en, :root:not([lang="fr"]) .lab-qr__code--fr { display: none; }
.lab-qr__t { display: flex; flex-direction: column; gap: 6px; margin: 0 !important; font-size: 1rem; color: var(--ink-3); }
.lab-qr__t b { font: 600 1.1rem/1.35 var(--font-mono); color: var(--ink); }
:root.is-presenting .lab-qr__code { width: min(26vh, 260px); height: min(26vh, 260px); padding: 16px; }
.lab-qr__nobr { white-space: nowrap; }
:root[lang="fr"] .lab-qr__url--en, :root:not([lang="fr"]) .lab-qr__url--fr { display: none; }

/* ---------- API documentation ---------- */
table.lab-api { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.lab-api :is(th, td) { text-align: left; vertical-align: top; padding: 11px 14px; border-bottom: 1px solid var(--rule); }
table.lab-api thead th { font: 600 .7rem/1.3 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
table.lab-api tbody th { font-weight: 500; }
table.lab-api code { white-space: normal; overflow-wrap: normal; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
table.lab-api tbody tr:last-child :is(th, td) { border-bottom: 0; }
table.lab-api td span { display: block; margin-top: 3px; color: var(--ink-3); font-size: .86rem; }

/* ---------- The monitor alone (?monitor=1): only the monitor, large, for the projector ---------- */
html.lab-monitor-only, .lab-monitor-only body { background: var(--night); }
.lab-monitor-only :is(.site-head, .site-foot, .skip-link, .wire, .course-nav, .course-nav__scrim) { display: none !important; }
.lab-monitor-only .module-main { padding: 0 !important; }
.lab-monitor-only .module-main > .wrap { max-width: none !important; padding: 2vw 3vw !important; }
.lab-monitor-only .prose > :not(#monitor), .lab-monitor-only .hero, .lab-monitor-only .article > :not(.prose) { display: none !important; }
.lab-monitor-only .article, .lab-monitor-only .prose { max-width: none !important; margin: 0 !important; padding: 0 !important; }
.lab-monitor-only #monitor { max-width: none !important; width: auto !important; margin: 0 !important; padding: 0 !important; background: transparent; border: 0; box-shadow: none; color: var(--night-ink); overflow: visible !important; }
.lab-monitor-only #monitor > :is(p, .card__kicker) { display: none; }
.lab-monitor-only #monitor > h2 { color: var(--night-ink); font-size: clamp(1.6rem, 2.6vw, 2.6rem) !important; margin-bottom: 1vw !important; }
.lab-monitor-only .mon { font-size: clamp(.875rem, min(1.35vw, 2.1vh), 1.5rem); padding: 1.4vw 1.8vw; }
.lab-monitor-only .jsc-live { top: 0; left: 0; }
.lab-monitor-only .mon__goal { border-left-width: 2px; }
.lab-monitor-only .mon__row { grid-template-columns: 9em minmax(0, 1fr); }
.lab-monitor-only .mon__axis { margin-left: calc(9em + 10px); }
.lab-monitor-only .mon__track { height: 1.6em; }
.lab-monitor-only :is(.mon__name, .mon__rh, .mon__tag, .mon__legend, .mon__more) { font-size: .9em; }
.lab-monitor-only .mon__more { padding-left: calc(9em + 10px); }
.lab-monitor-only .mon__head { font-size: .8em; }
.lab-monitor-only .mon__tick { font-size: .75em; }
.lab-monitor-only .mon__axis { height: 1.2em; }

/* ---------- Code colours (the code panels are night panels in both themes) ---------- */
.code__pre .hl-kw { color: #c792ea; }
.code__pre .hl-str { color: #a5e3a1; }
.code__pre .hl-num { color: #f9c56b; }
.code__pre .hl-fn { color: #82cfff; }
.code__pre .hl-lit { color: #ff9cc5; }
.code__pre .hl-cm { color: #8e93ab; font-style: italic; }

/* Phones: code wraps instead of hiding words past the edge; short code chips stay on one line (lab.js .nobr). */
@media (max-width: 520px) {
  .code__pre { white-space: pre-wrap; overflow-wrap: anywhere; }
  .prose code.nobr { white-space: nowrap; }
}

@media print {
  .mon, .lab-ready, #monitor, .lab-qr { display: none !important; }
  .code__pre :is(.hl-kw, .hl-str, .hl-num, .hl-fn, .hl-lit) { color: #16161f !important; }
  .code__pre .hl-cm { color: #5c5c6a !important; }
}
