/* QQuill · mini — the Stage (js/stage.js): a debate at 16:9 or 9:16, to be recorded.
   One canvas of 1920 × 1080 px (1080 × 1920 upright), scaled to the window: every size below is the
   canvas's own, so a recording at any size holds the same picture. The rows are
   the editor's (the print studio's builders), at the Stage's sizes. Night and
   daylight both: every ink is a token. */

.qq-stage {
  position: fixed; inset: 0; z-index: 80; overflow: hidden; outline: none;
  background: color-mix(in srgb, var(--bg) 62%, #000);
  color: var(--fg); font-family: var(--font-text);
}
html[data-scheme='light'] .qq-stage { background: color-mix(in srgb, var(--bg) 82%, #8a7f6e); }
html[data-stage] body { overflow: hidden; }

.qq-stage-canvas {
  position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; box-sizing: border-box;
  transform-origin: 0 0;
  display: grid; grid-template-columns: var(--vcol) var(--mcol); grid-template-rows: minmax(0, 1fr) 64px;
  justify-content: center; column-gap: 40px; row-gap: 26px; padding: 48px 56px 30px;
  background: var(--bg); overflow: hidden;
  transition: grid-template-columns 560ms var(--ease-soft);
  /* the editor's rows at the Stage's sizes */
  --scale: 1; --fade: 1;
  --k-rowFont: 22px; --k-metaFont: 14px; --k-glyphSize: 24px; --k-qnFont: 16px;
  --k-rowPadX: 12px; --k-rowPadY: 9px; --k-rowGap: 9px; --k-railIndent: 18px; --k-headGap: 8px; --k-toolSize: 0px;
  --k-spineWidth: 2.5px; --k-spineWidthH: 2.5px; --k-lipRadius: 16px; --k-boxRadius: 34px; --k-glowSize: 44px;
}
.qq-stage-canvas[data-layout='split'] { --vcol: 720px; --mcol: 1048px; }
.qq-stage-canvas[data-layout='video'] { --vcol: 1208px; --mcol: 0px; }
.qq-stage-canvas[data-layout='map'] { --vcol: 420px; --mcol: 1348px; }
/* upright (9:16, O): one column, the picture on top, the band under it, the thread under that, the ribbon at the foot.
   Q keeps all three, W gives the band the room the map had, E gives the map the band's */
.qq-stage-canvas[data-format='portrait'] {
  width: 1080px; height: 1920px; padding: 64px 40px 44px; column-gap: 0; row-gap: 24px;
  grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) 64px;
}
.qq-stage-canvas[data-format='portrait'] .qq-stage-video { gap: 20px; }
.qq-stage-canvas[data-format='portrait'] .qq-stage-band { flex: none; max-height: 470px; }
.qq-stage-canvas[data-format='portrait'][data-layout='video'] { grid-template-rows: minmax(0, 1fr) 0 64px; }
.qq-stage-canvas[data-format='portrait'][data-layout='video'] .qq-stage-band { flex: 1 1 auto; max-height: none; }
.qq-stage-canvas[data-format='portrait'][data-layout='video'] .qq-stage-band .qq-band-point { font-size: 38px; }
.qq-stage-canvas[data-format='portrait'][data-layout='video'] .qq-stage-band .qq-band[data-len='long'] .qq-band-point { font-size: 33px; }
.qq-stage-canvas[data-format='portrait'][data-layout='video'] .qq-stage-band .qq-band[data-len='more'] .qq-band-point { font-size: 28px; }
.qq-stage-canvas[data-format='portrait'][data-layout='map'] .qq-stage-band { display: none; }
.qq-stage-canvas[data-format='portrait'] .qq-stage-path { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---- the video column: the picture (moved here from the dock, not reloaded), the band under it ---- */
.qq-stage-video { display: flex; flex-direction: column; gap: 22px; min-width: 0; min-height: 0; }
.qq-stage-slot { flex: none; }
.qq-stage-slot .qq-live { position: relative; left: auto; top: auto; width: 100%; translate: none; border-radius: 14px; }
.qq-stage-slot .qq-live-media { flex: 0 0 auto; aspect-ratio: var(--live-ar, 1.7778); }
.qq-stage[data-clean='true'] .qq-stage-slot .qq-live-bar { display: none; }
.qq-stage-band { flex: 1 1 auto; min-height: 0; overflow: hidden; }
/* the band's box is the row's (the shared [data-spine] rules, the Stage's spine weight), at the Stage's lip */
.qq-stage-band .qq-band { --lip-s: 20px; padding: 18px calc(22px + var(--spine-w-eff, 0px)) 20px calc(24px + var(--spine-w-eff, 0px)); gap: 10px; }
.qq-stage-band .qq-band[data-side='right'] { padding-inline: calc(24px + var(--spine-w-eff, 0px)) calc(22px + var(--spine-w-eff, 0px)); }
.qq-stage-band .qq-band-head { gap: 12px; font-size: 17px; }
.qq-stage-band .qq-band-sign svg { width: 26px; height: 26px; }
.qq-stage-band .qq-band-who > b { font-size: 22px; }
.qq-stage-band .qq-band-at { font-size: 15px; }
.qq-stage-band .qq-band-last { font-size: 13px; }
.qq-stage-band .qq-band-path { font-size: 17px; }
.qq-stage-band .qq-band-point { font-size: 27px; line-height: 1.5; }
.qq-stage-band .qq-band[data-len='long'] .qq-band-point { font-size: 23px; }
.qq-stage-band .qq-band[data-len='more'] .qq-band-point { font-size: 20px; }
.qq-stage-band .qq-band-move { font-size: 17px; gap: 9px; }
.qq-stage-band .qq-band-dot { width: 11px; height: 11px; }
.qq-stage-band .qq-band-idle { font-size: 22px; }
.qq-stage-canvas[data-layout='video'] .qq-stage-band .qq-band-point { font-size: 32px; }
.qq-stage-canvas[data-layout='video'] .qq-stage-band .qq-band[data-len='long'] .qq-band-point { font-size: 28px; }
.qq-stage-canvas[data-layout='video'] .qq-stage-band .qq-band[data-len='more'] .qq-band-point { font-size: 24px; }
.qq-stage-canvas[data-layout='map'] .qq-stage-band .qq-band-point { font-size: 20px; }
.qq-stage-canvas[data-layout='map'] .qq-stage-band .qq-band:is([data-len='long'], [data-len='more']) .qq-band-point { font-size: 17px; }
.qq-stage-canvas[data-layout='map'] .qq-stage-band :is(.qq-band-path) { display: none; }

/* ---- the map column: the debate's title, the branch being argued, the camera on its thread, the threads so far ---- */
.qq-stage-map { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 14px; min-width: 0; min-height: 0; overflow: hidden; transition: opacity 360ms var(--ease-soft); }
.qq-stage-canvas[data-layout='video'] .qq-stage-map { opacity: 0; pointer-events: none; }
.qq-stage-head { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.qq-stage-title { font: 500 15px/1.2 var(--font-mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qq-stage-path { min-height: 1.3em; font: 600 28px/1.3 var(--font-title); color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qq-stage-sep { color: var(--fg-light); font-weight: 400; }
.qq-stage-camera { position: relative; min-height: 0; overflow: hidden; -webkit-mask-image: linear-gradient(transparent, #000 5%, #000 88%, transparent); mask-image: linear-gradient(transparent, #000 5%, #000 88%, transparent); }
.qq-stage-thread { padding: 36px 6px 120px; transition: translate 760ms var(--ease-soft); }
.qq-stage-thread[data-hand] { transition: none; } /* under your wheel, no easing */
.qq-stage-tally:empty { display: none; }
.qq-stage-tally .qq-flow { padding: 2px 0 0; }
/* the legend (N): in the map's head under the tally; when the video has the canvas (W) the map is gone, so
   under the band instead. Never over the picture or the band: each is a part of its column's flow */
.qq-stage-legend { flex: none; min-width: 0; }
.qq-stage-legend:empty, .qq-stage-canvas[data-legend='false'] .qq-stage-legend { display: none; }
.qq-stage-legend .qq-legend { --lg: 1.5; }
.qq-stage-head > .qq-stage-legend { padding-top: 4px; }
.qq-stage-video > .qq-stage-legend, .qq-stage-canvas[data-layout='video'] .qq-stage-head > .qq-stage-legend { display: none; }
.qq-stage-video > .qq-stage-legend { padding: 0 4px; }
.qq-stage-canvas[data-layout='video'][data-legend='true'] .qq-stage-video > .qq-stage-legend:not(:empty) { display: block; }
/* …and the picture gives up the legend's height, so the band keeps the room it had */
.qq-stage-canvas[data-format='landscape'][data-layout='video'][data-legend='true'] { --vcol: 1120px; }
@media (prefers-reduced-motion: reduce) { .qq-stage-thread, .qq-stage-canvas, .qq-stage-map { transition: none; } }

/* the thread: the editor's Debate rows (js/app.js stageThreadHTML), never a control */
.qq-stage-flow.qq-detail { position: relative; inset: auto; z-index: auto; display: block; background: none; animation: none; transition: none; overflow: visible; }
.qq-stage-flow .qq-outline { position: relative; }
.qq-stage-flow .rail[data-play='ahead'] { display: none; }
.qq-stage-flow .rail[data-play='said'] > .rail-head > * { opacity: 0.78; }
.qq-stage-flow .rail[data-play='said'] > .rail-head > .qq-voice-name { opacity: 1; }
.qq-stage-flow .rail > .rail-head { pointer-events: none; }
.qq-stage-flow .qq-at { cursor: default; }
.qq-stage-flow :is(.outline-content, .outline-content-md) { letter-spacing: 0.032em; word-spacing: 0.13em; line-height: 1.55; }
.qq-stage-flow :is(.outline-content, .outline-content-md) :is(h1, h2, h3, h4, h5, h6, code, pre, .katex) { letter-spacing: normal; word-spacing: normal; }
html:not([data-scheme='light']) .qq-stage-flow :is(.outline-content, .outline-content-md) { -webkit-font-smoothing: auto; -webkit-text-stroke: 0.05px currentColor; }
.qq-stage-flow .qq-voice-name { font-size: 17px; max-width: 18em; }
.qq-st-title { order: 2; flex: 0 1 auto; min-width: 0; font: 600 calc(var(--k-rowFont) * 0.86)/1.25 var(--font-title); color: color-mix(in srgb, var(--rail) 72%, var(--fg)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qq-stage-flow .rail[data-voice='b'] > .rail-head > .qq-st-title { order: 2; }
/* the levels of detail: structure (boxes, signs, titles), points (the words of the row being said and of what it answers), full */
.qq-stage-canvas[data-detail='structure'] .qq-stage-flow .rail > .rail-head > .node-main { display: none; }
.qq-stage-canvas[data-detail='points'] .qq-stage-flow .rail:not([data-play='now'], [data-answered]) > .rail-head > .node-main {
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; opacity: 0.55; max-height: 1.6em;
}
.qq-stage-canvas[data-detail='points'] .qq-stage-flow .rail:not([data-play='now'], [data-answered]):has(> .rail-head > .qq-st-title) > .rail-head > .node-main { display: none; }
.qq-stage-flow .rail[data-answered] > .rail-head { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--voice, var(--fg-light)) 45%, transparent); }
.qq-stage-flow .pr-video { display: none; }

/* the threads so far: each one's title; the one being argued lit */
.qq-stage-threads { display: flex; gap: 10px; overflow: hidden; padding: 4px 2px; -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent); mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent); }
.qq-stage-chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px; max-width: 340px; height: 38px; padding: 0 14px 0 10px;
  border: 1px solid color-mix(in srgb, var(--voice) 35%, var(--card-border)); border-radius: 999px;
  background: color-mix(in srgb, var(--voice) 6%, var(--card)); color: var(--fg-between);
  font: 500 16px/1 var(--font-title); cursor: pointer; opacity: 0.72;
  transition: opacity 300ms var(--ease-soft), background-color 300ms var(--ease-soft);
}
.qq-stage-chip > i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--el); }
.qq-stage-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qq-stage-chip[data-now='true'] { opacity: 1; color: var(--fg); background: color-mix(in srgb, var(--voice) 16%, var(--card)); border-color: color-mix(in srgb, var(--voice) 70%, transparent); }

/* ---- the ribbon, under both columns ---- */
.qq-stage-ribbon { grid-column: 1 / -1; align-self: end; }
.qq-stage .qq-ribbon { height: 64px; }
.qq-stage .qq-ribbon-tip { font-size: 15px; padding: 5px 10px; }

/* ---- the controls: outside the canvas's picture, at the foot of the window ---- */
.qq-stage-controls {
  position: absolute; left: 50%; bottom: 14px; translate: -50% 0; z-index: 2;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 32px);
  padding: 6px; border-radius: 14px; background: var(--float-bg); box-shadow: 0 0 0 0.5px var(--card-border), var(--shadow-pop);
  transition: opacity 220ms var(--ease-soft);
}
.qq-stage-group { display: inline-flex; align-items: center; gap: 2px; padding: 0 4px; }
.qq-stage-group + .qq-stage-group { border-inline-start: 0.5px solid var(--card-border); }
.qq-stage-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 9px; border: 0; border-radius: 8px;
  background: none; color: var(--fg-between); font: 500 12px/1 var(--font-text); white-space: nowrap; cursor: pointer;
}
.qq-stage-btn:hover, .qq-stage-btn:focus-visible { color: var(--fg); background: var(--hover-2); }
.qq-stage-btn[aria-pressed='true'] { color: var(--fg); background: color-mix(in srgb, var(--el-air) 16%, transparent); box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--el-air) 55%, transparent); }
.qq-stage[data-direct='true'] .qq-stage-btn[data-stage-act='direct'] { color: var(--el-fire); background: color-mix(in srgb, var(--el-fire) 14%, transparent); box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--el-fire) 60%, transparent); }
.qq-stage[data-direct='true'] .qq-stage-btn[data-stage-act='direct'] .qq-icon { animation: qq-stage-rec 1.4s ease-in-out infinite; }
@keyframes qq-stage-rec { 50% { opacity: 0.35; } }
.qq-stage[data-idle='true'] .qq-stage-controls:not(:focus-within, :hover) { opacity: 0; pointer-events: none; }
/* folded (T): one round handle in the corner, out of the picture's way */
.qq-stage[data-tools='folded'] .qq-stage-controls { left: auto; right: 14px; translate: none; padding: 2px; border-radius: 999px; }
.qq-stage[data-tools='folded'] .qq-stage-group:not(.qq-stage-fold) { display: none; }
.qq-stage[data-tools='folded'] .qq-stage-fold { padding: 0; border: 0; }
.qq-stage[data-tools='folded'] .qq-stage-btn[data-stage-act='fold'] { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 999px; }
.qq-stage[data-tools='folded'] .qq-stage-btn[data-stage-act='fold'] > span { display: none; }
.qq-stage[data-clean='true'][data-idle='true'] { cursor: none; }
@media (max-width: 1500px) { .qq-stage-btn:has(> .qq-icon) > span { display: none; } .qq-stage-btn { padding: 0 8px; } }
@media (prefers-reduced-motion: reduce) { .qq-stage[data-direct='true'] .qq-stage-btn[data-stage-act='direct'] .qq-icon { animation: none; } }
@media print { .qq-stage { display: none !important; } }
