/* Slide rendering: projector stage, editor preview, bar charts. The stage is always light
   (projectors wash out dark themes); the code panel is always dark. */

.stage-wrap { container-type: inline-size; width: 100%; }
.stage {
  --s-bg: #fbfbf8;
  --s-text: #151b28;
  --s-muted: #5b6577;
  --s-border: #e2e4e9;
  --s-accent: #4f46e5;
  --s-ok: #16a34a;
  --s-ok-soft: #dcf5e4;
  --s-neutral: #94a3b8;
  --s-grey: #cbd2dc;
  --s-code-bg: #fdf6e3;
  position: relative; overflow: hidden;
  aspect-ratio: 16 / 9; width: 100%;
  background: var(--s-bg); color: var(--s-text);
  font-family: var(--font, system-ui, sans-serif);
  font-size: 1.85cqw; line-height: 1.35;
  color-scheme: light;
}
.stage .slide { position: absolute; inset: 0 0 3.2em 0; display: flex; flex-direction: column; padding: 1.2em 1.8em 0.8em; }
.stage.no-footer .slide { inset: 0; }
.stage .md :is(h1, h2, h3) { margin: 0 0 .35em; letter-spacing: -.01em; }
.stage .md h1 { font-size: 2.2em; }
.stage .md h2 { font-size: 1.55em; }
.stage .md h3 { font-size: 1.25em; }
.stage .md p, .stage .md ul, .stage .md ol { margin: .35em 0; }
.stage .md li { margin: .2em 0; }
.stage .md code { font-family: var(--mono); font-size: .9em; background: #eceef3; padding: .05em .3em; border-radius: .25em; }
.stage .md pre code { background: none; padding: 0; }
.stage .md blockquote { margin: .5em 0; padding: .2em .9em; border-left: .25em solid var(--s-accent); color: var(--s-muted); }
.stage .md table { border-collapse: collapse; }
.stage .md th, .stage .md td { border: 1px solid var(--s-border); padding: .2em .6em; }

/* content slides */
.slide--content .slide-body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.slide--content .slide-body > :first-child:is(h1) { font-size: 2.6em; }
.slide--content pre.highlight { font-size: .82em; padding: .7em 1em; border-radius: .4em; margin: .5em 0; }

/* question slides */
.slide--question .slide-head { display: flex; align-items: flex-start; gap: 1em; margin-bottom: .6em; }
.slide--question .slide-head .md { flex: 1; min-width: 0; }
.slide--question .slide-head .md > :last-child { margin-bottom: 0; }
.slide-status { display: flex; gap: .5em; align-items: center; flex: none; font-variant-numeric: tabular-nums; }
.chip {
  display: inline-flex; align-items: center; gap: .35em; padding: .2em .65em; border-radius: 999px;
  background: #eef0f4; color: var(--s-muted); font-weight: 650; font-size: .8em; white-space: nowrap;
}
.chip.open { background: #dcf5e4; color: #15803d; }
.chip.closed { background: #fdecec; color: #b91c1c; }
.chip.timer.low { background: #fde68a; color: #92400e; }
.slide-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 55fr 45fr; gap: 1.2em; }
.slide--question.no-code .slide-main { grid-template-columns: 1fr; }
.slide--question.no-code .answer-panel { max-width: 75%; margin: 0 auto; width: 100%; }
.code-panel {
  /* Shrinks to the snippet; fitCode() scales the font so it never exceeds the available area. */
  min-height: 0; min-width: 0; max-height: 100%; align-self: start; overflow: hidden;
  background: var(--s-code-bg); border: 1px solid #e8dfc4; border-radius: .45em; display: flex; align-items: flex-start;
}
.code-panel pre.highlight { margin: 0; padding: .8em 1em; font-size: 1em; line-height: 1.45; width: 100%; background: transparent; }
.answer-panel { min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: .5em; overflow: hidden; }

.options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45em; }
.options li {
  display: flex; align-items: center; gap: .7em; padding: .45em .7em; border: 2px solid var(--s-border);
  border-radius: .45em; background: #fff; font-family: var(--mono); font-size: .95em;
}
.options .letter {
  flex: none; display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: .35em;
  background: var(--s-accent); color: #fff; font-family: var(--font, sans-serif); font-weight: 700; font-size: .85em;
}
.options li.key { border-color: var(--s-ok); background: var(--s-ok-soft); }
.options li.key::after { content: "✓"; margin-left: auto; color: var(--s-ok); font-weight: 800; }
.state-note { color: var(--s-muted); font-size: .85em; margin-top: auto; }
.text-hint {
  border: 2px dashed var(--s-border); border-radius: .5em; padding: 1em; color: var(--s-muted);
  text-align: center; font-size: .95em;
}
.text-hint .accept { margin-top: .4em; font-family: var(--mono); color: var(--s-ok); }
.multi-hint { color: var(--s-muted); font-size: .8em; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* footer join bar */
.join-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3.2em; display: flex; align-items: center; gap: 1em;
  padding: 0 1.8em; border-top: 1px solid var(--s-border); background: #fff; font-size: .9em; color: var(--s-muted);
}
.join-bar .url { font-weight: 600; color: var(--s-text); }
.join-bar .code { font-family: var(--mono); font-weight: 800; letter-spacing: .08em; color: var(--s-text); font-size: 1.25em; }
.join-bar .spacer { flex: 1; }
.join-bar img { height: 2.6em; width: 2.6em; image-rendering: pixelated; }
.join-bar .pos { font-variant-numeric: tabular-nums; }

/* ---------- bars (also used on student/admin pages, which set --text etc.) ---------- */
.bars { display: flex; flex-direction: column; gap: .5em; }
.bars-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1em; font-size: .85em; color: var(--s-muted, var(--muted)); }
.bars-head strong { color: var(--s-text, var(--text)); font-size: 1.1em; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr); gap: .15em; }
.bar-label { display: flex; align-items: center; gap: .5em; font-family: var(--mono); font-size: .9em; overflow: hidden; }
.bar-label .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-label .letter {
  flex: none; display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; border-radius: .3em;
  background: #64748b; color: #fff; font-family: var(--font, sans-serif); font-weight: 700; font-size: .8em;
}
.bar-track { position: relative; height: 1.5em; border-radius: .3em; background: color-mix(in srgb, #94a3b8 16%, transparent); }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: .3em; background: #94a3b8; min-width: .25em; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.bar-n { position: absolute; right: .5em; top: 50%; transform: translateY(-50%); font-weight: 700; font-size: .85em; font-variant-numeric: tabular-nums; }
.bar.correct .bar-fill { background: #16a34a; }
.bar.correct .letter { background: #16a34a; }
.bar.correct .bar-label::after { content: "✓"; color: #16a34a; font-weight: 800; }
.bar.poll .bar-fill { background: #6366f1; }
.bar.poll .letter { background: #6366f1; }
.bar.ungraded .bar-fill, .bar.other .bar-fill { background: #cbd2dc; }
.bar.ungraded .bar-label { font-style: italic; }
.bars-empty { color: var(--s-muted, var(--muted)); font-style: italic; }

/* ---------- projector page ---------- */
body.present { margin: 0; background: #000; overflow: hidden; height: 100vh; cursor: default; }
body.present .stage-wrap { position: fixed; inset: 0; display: grid; place-items: center; container-type: normal; }
body.present .stage { width: min(100vw, 177.78vh); font-size: calc(min(100vw, 177.78vh) * .0185); }
.overlay { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; }
.overlay.blank { background: #000; }
.overlay.qr { background: rgba(251, 251, 248, .97); flex-direction: column; gap: .6em; text-align: center; }
.stage .logo { color: var(--s-text); }
.stage .logo .br { color: var(--s-accent); }
.stage .logo-tagline { color: var(--s-muted); font-size: .55em; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin-top: -.3em; }
.overlay.qr img { height: min(56%, 21em); width: auto; aspect-ratio: 1; image-rendering: pixelated; }
.overlay.qr .big-url { font-size: 1.6em; font-weight: 700; }
.overlay.qr .big-code { font-family: var(--mono); font-size: 3em; font-weight: 800; letter-spacing: .1em; }
.overlay.ended { background: rgba(251, 251, 248, .97); flex-direction: column; gap: .6em; }
.overlay.dialog { background: rgba(10, 14, 22, .55); }
.overlay .box { background: #fff; border-radius: .6em; padding: 1.2em 1.6em; box-shadow: 0 1em 3em rgba(0,0,0,.3); max-width: 60%; }
.overlay .box h3 { margin: 0 0 .5em; }
.overlay .box .btn-row { display: flex; gap: .6em; justify-content: flex-end; margin-top: 1em; }
.overlay .box button { font: inherit; font-size: .9em; padding: .4em 1em; border-radius: .4em; border: 1px solid #d0d5dd; background: #fff; cursor: pointer; }
.overlay .box button.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.help-table { font-size: .8em; border-collapse: collapse; }
.help-table td { padding: .2em .8em .2em 0; }
.help-table kbd { font-family: var(--mono); background: #f1f3f6; border: 1px solid #d0d5dd; border-radius: .25em; padding: 0 .35em; }

.conn-lost {
  position: absolute; top: .6em; left: 50%; transform: translateX(-50%); z-index: 20;
  background: #b91c1c; color: #fff; padding: .25em .9em; border-radius: 999px; font-size: .75em; font-weight: 650;
}

.p-toolbar {
  position: fixed; left: 50%; bottom: 10px; transform: translate(-50%, 0); z-index: 30;
  display: flex; gap: 4px; padding: 5px; border-radius: 12px; background: rgba(17, 24, 39, .88);
  opacity: 0; transition: opacity .25s; font: 13px/1 system-ui, sans-serif;
}
.p-toolbar.show, .p-toolbar:hover, .p-toolbar:focus-within { opacity: 1; }
.p-toolbar button {
  font: inherit; color: #e5e7eb; background: transparent; border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.p-toolbar button:hover { background: rgba(255,255,255,.12); }
.p-toolbar button.danger { color: #fca5a5; }

/* ---------- editor preview ---------- */
.preview-frame { border-radius: 8px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,.12); border: 1px solid var(--border); }
.preview-frame .stage { font-size: 1.85cqw; }

/* ---------- code (Pygments "solarized-light" from /pygments.css; light for projectors/blackboards) ---------- */
/* Solarized's default foreground is low-contrast when projected: use its darker base02 for plain text.
   (`pre.highlight` outranks pygments.css's `.highlight`, which loads after this file.) */
pre.highlight { padding: .8em 1em; tab-size: 4; color: #073642; }
pre.highlight code { font-family: var(--mono); }
pre.highlight .linenos {
  color: #93a1a1; background: transparent; padding: 0 1.1em 0 0; user-select: none; -webkit-user-select: none;
  display: inline-block; min-width: 1.6em; text-align: right; margin-right: .2em;
}
pre.highlight .hll {
  display: block; background: rgba(181, 137, 0, .17) !important;
  box-shadow: inset .3em 0 0 #b58900; margin: 0 -1em; padding: 0 1em;
}
pre.highlight .hll .linenos { color: #586e75; }
/* Same for the tokens Solarized draws in base00 (names, punctuation, operators' neighbours…). */
pre.highlight :is(.n, .na, .nx, .py, .p, .pm, .w, .l, .ld, .x, .esc, .g, .go) { color: #073642; }
pre.highlight .o { color: #586e75; }
pre.highlight.plain { background: #fdf6e3; color: #073642; }
/* Outside the projector (student/admin pages) give the light code block a visible edge. */
.s-code pre.highlight, .s-content pre.highlight, .q-grid pre.highlight { border: 1px solid #e8dfc4; }
