/* Control screen (BELANGRIJKE_VRAAG.leo): the rigged "zelf controle houden" question + its escalation.
   Layout: .ctl-view (question window, Henk, and this screen's own overlay layer) above .ctl-bar (DAAN).
   The bar is a flex item below the view, so it never covers a control, and it stacks above the layer,
   so no overlay ever covers DAAN. Sizes per step come from --ctl-zelf-k / --ctl-daan-k (set from JS). */

.scr-control {
  --ctl-zelf-k: 1;
  --ctl-daan-k: 1;
  position: relative;
  height: 100%;
  padding: 0;
  gap: 0;
  align-items: stretch;
  overflow: hidden;
}

/* this screen is exactly as tall as the stage: the shared slide-in would make the stage scroll for a moment */
.scr-control.is-in { animation-name: ctl-screen-in; }

@keyframes ctl-screen-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.scr-control .ctl-view {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.scr-control .ctl-main {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(12px, 4vh, 48px) var(--gutter) 20px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.scr-control .ctl-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: var(--win-max);
}

/* big screens: the window + Henk sit in the middle; Henk's row keeps its height so bubbles never move the window */
@media (min-width: 600px) and (min-height: 760px) {
  .scr-control .ctl-stack { margin-block: auto; }
  .scr-control .ctl-henkrow { min-height: 132px; }
}

/* ---------- the question window ---------- */
/* Henk introduces himself first; until then the window keeps its place, invisible (and untappable) */
.scr-control .ctl-qwin.is-waiting { visibility: hidden; }

.scr-control .ctl-qwin .win__title { font-size: var(--fs-xs); }

@media (max-width: 340px) {
  .scr-control .ctl-qwin .win__icon { display: none; }
}

.scr-control .ctl-question {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(var(--fs-m), 5.6vw, var(--fs-l));
  line-height: 1.25;
}

.scr-control .ctl-strike {
  transition: color var(--t-med) steps(3);
}

/* the crossed-out "zelf de controle houden" (after the crash): a red pixel line drawn left to right */
.scr-control .ctl-strike.is-struck {
  color: var(--lav-d);
  background-image: linear-gradient(var(--red), var(--red));
  background-repeat: no-repeat;
  background-position: 0 58%;
  background-size: 100% 4px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  animation: ctl-strike calc(450ms / var(--speed)) steps(6) both;
}

.scr-control .ctl-strike.is-static { animation: none; }

@keyframes ctl-strike {
  from { background-size: 0 4px; }
  to { background-size: 100% 4px; }
}

.scr-control .ctl-zelfslot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  margin-top: 18px;
}

/* ZELF: the <button> keeps a tap area of at least 44px; the visible face inside it shrinks per step */
.scr-control .ctl-zelf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  min-height: var(--tap);
  max-width: 100%;
  padding: 0;
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
}

.scr-control .ctl-zelf__face {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: calc(1.15em + 1.1em + 6px);
  padding: 0.55em 0.9em;
  font-family: var(--font-ui);
  font-size: calc(var(--fs-s) * var(--ctl-zelf-k));
  line-height: 1.15;
  text-align: center;
  text-transform: uppercase;
  text-wrap: balance;
  background: var(--lav);
  border: var(--bw) solid var(--ink);
  box-shadow: var(--shadow);
  transition: font-size var(--t-med) steps(3), background-color var(--t-fast) steps(2);
}

.scr-control .ctl-zelf:active .ctl-zelf__face {
  transform: translate(var(--sh), var(--sh));
  background: var(--lav-d);
  box-shadow: none;
}

.scr-control .ctl-zelf[aria-disabled="true"] { cursor: default; }
.scr-control .ctl-zelf[aria-disabled="true"]:active .ctl-zelf__face { transform: none; box-shadow: var(--shadow); }

/* step 8: the button retyped itself as DAAN */
.scr-control .ctl-zelf.is-daan .ctl-zelf__face {
  --ctl-zelf-k: 1.25;
  background: var(--pink);
}

.scr-control .ctl-zelf.is-daan:active .ctl-zelf__face { background: var(--pink-d); }

.scr-control .ctl-zelf__caret {
  display: none;
  width: 0.55em;
  height: 1em;
  margin-left: 2px;
  background: var(--ink);
  animation: blink calc(500ms / var(--speed)) steps(1) infinite;
}

.scr-control .ctl-zelf.is-typing .ctl-zelf__caret { display: inline-block; }

/* ---------- Henk (lives here instead of the shared Henk layer, so nothing covers DAAN) ---------- */
.scr-control .ctl-henkrow {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-height: 48px;
}

.scr-control .ctl-henk {
  flex: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.scr-control .ctl-henk__sprite { display: block; }

.scr-control .ctl-henkrow.is-away .ctl-henk { visibility: hidden; }

.scr-control .ctl-bubble {
  flex: 0 1 auto;
  margin: 0 0 14px 12px;
  font-size: var(--fs-s);
  line-height: 1.3;
}

/* the same pixel tail as the shared Henk bubble, pointing left at Henk */
.scr-control .ctl-bubble::before {
  content: "";
  position: absolute;
  left: -12px;
  bottom: 8px;
  width: 12px;
  height: 9px;
  background:
    linear-gradient(var(--ink), var(--ink)) 0 6px / 12px 3px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 3px 3px / 3px 3px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 6px 0 / 6px 3px no-repeat,
    linear-gradient(var(--paper), var(--paper)) 6px 3px / 6px 3px no-repeat;
}

/* Henk is away (offended): an out-of-office note instead of a speech bubble */
.scr-control .ctl-henkrow.is-away .ctl-bubble {
  margin-left: -40px;
  background: var(--shade);
  border-style: dashed;
  box-shadow: none;
}

.scr-control .ctl-henkrow.is-away .ctl-bubble::before { display: none; }

.scr-control .ctl-part.is-hidden { display: none; }

.scr-control .ctl-say { animation: pop-in var(--t-fast) steps(3) both; }

/* ---------- the DAAN bar ---------- */
.scr-control .ctl-bar {
  position: relative;
  z-index: 10;
  flex: none;
  display: flex;
  justify-content: center;
  padding: 10px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: var(--lav-l);
  border-top: var(--bw) solid var(--ink);
}

.scr-control .ctl-daan__bob {
  position: relative;
  display: flex;
  width: min(100%, var(--win-max), calc(240px * var(--ctl-daan-k)));
  transition: width var(--t-med) steps(3);
}

.scr-control .ctl-daan {
  flex: 1 1 auto;
  min-height: calc(56px * var(--ctl-daan-k));
  padding: 6px 16px;
  font-size: calc(var(--fs-l) * var(--ctl-daan-k));
  transition: min-height var(--t-med) steps(3), font-size var(--t-med) steps(3);
}

.scr-control .ctl-daan__label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.scr-control .ctl-daan.is-chosen { background: var(--pink-d); }

.scr-control .ctl-grow { animation: ctl-grow calc(330ms / var(--speed)) steps(3) both; }

@keyframes ctl-grow {
  0% { transform: scale(1, 1); }
  40% { transform: scale(1.06, 0.9); }
  70% { transform: scale(0.98, 1.06); }
  100% { transform: none; }
}

.scr-control .ctl-burst {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 0;
  pointer-events: none;
}

.scr-control .ctl-heart {
  position: absolute;
  bottom: 0;
  pointer-events: none;
  animation: ctl-heart-up calc(1100ms / var(--speed)) steps(6) both;
}

@keyframes ctl-heart-up {
  0% { transform: translateY(8px); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(-60px); opacity: 0; }
}

/* ---------- this screen's overlay layer ---------- */
.scr-control .ctl-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.scr-control .ctl-layer > * { pointer-events: auto; }

.scr-control .ctl-block {
  position: absolute;
  inset: 0;
}

.scr-control .ctl-block.is-dim {
  background: rgba(41, 42, 51, 0.24);
  animation: fade-in var(--t-fast) steps(2) both;
}

/* centres an overlay window; scrolls (instead of clipping) when it doesn't fit */
.scr-control .ctl-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 12px var(--gutter);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.scr-control .ctl-center > * { margin: auto; }

.scr-control .ctl-win {
  flex: none;
  width: 100%;
  max-width: 360px;
}

.scr-control .ctl-pop { animation: pop-in var(--t-med) steps(4) both; }

.scr-control .ctl-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.scr-control .ctl-row--top { align-items: flex-start; }
.scr-control .ctl-row--split { justify-content: space-between; }
.scr-control .ctl-row > svg { flex: none; }

.scr-control .ctl-text {
  margin: 0;
  font-size: var(--fs-m);
  line-height: 1.3;
}

.scr-control .ctl-text--big {
  font-size: var(--fs-l);
  font-weight: 700;
  line-height: 1.15;
}

.scr-control .ctl-text--small { font-size: var(--fs-s); }

.scr-control .ctl-status {
  min-height: 1.3em;
  margin: 0;
  font-size: var(--fs-m);
  font-weight: 700;
  line-height: 1.3;
}

.scr-control .ctl-status:empty { min-height: 0; }
.scr-control .win__body > .ctl-status:empty { margin-top: 0; }

/* step 1: transfer stuck at 99% */
.scr-control .ctl-glass { flex: none; display: block; }
.scr-control .ctl-glass.is-turning { animation: ctl-turn calc(900ms / var(--speed)) linear infinite; }

@keyframes ctl-turn {
  0%, 32% { transform: rotate(0deg); }
  33%, 65% { transform: rotate(90deg); }
  66%, 100% { transform: rotate(180deg); }
}

.scr-control .ctl-load .loadbar__seg { height: 16px; }

.scr-control .loadbar__seg.ctl-seg-stuck {
  background: repeating-linear-gradient(90deg, var(--lav) 0 3px, var(--paper) 3px 6px);
  animation: blink calc(600ms / var(--speed)) steps(1) infinite;
}

.scr-control .ctl-note { font-size: var(--fs-s); }

.scr-control .ctl-pct {
  font-family: var(--font-ui);
  font-size: var(--fs-m);
}

.scr-control .ctl-win--error .ctl-text { font-size: var(--fs-m); }

/* step 2: the runaway JA */
.scr-control .ctl-ja-slot { display: inline-flex; }
.scr-control .ctl-ja, .scr-control .ctl-nee { min-width: 92px; }

.scr-control .ctl-ja.is-loose {
  position: absolute;
  z-index: 4;
  margin: 0;
  transition: left var(--t-fast) steps(3), top var(--t-fast) steps(3);
}

.scr-control .ctl-ja.is-caught { background: var(--lav-d); }
.scr-control .btn[aria-disabled="true"] { pointer-events: none; }

/* step 3: the queue */
.scr-control .ctl-q__hold {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  text-transform: uppercase;
}

.scr-control .ctl-q__ticket {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  padding: 8px 10px;
  background: var(--yellow);
  border: var(--bw) solid var(--ink);
  box-shadow: inset 0 -4px 0 0 rgba(41, 42, 51, 0.15);
}

.scr-control .ctl-q__label {
  font-family: var(--font-ui);
  font-size: var(--fs-s);
}

.scr-control .ctl-q__num {
  display: inline-block;
  min-width: 3ch;
  font-family: var(--font-ui);
  font-size: calc(44px * var(--text-scale));
  line-height: 1;
  text-align: center;
}

.scr-control .ctl-bump { animation: ctl-bump calc(330ms / var(--speed)) steps(3) both; }

@keyframes ctl-bump {
  0% { transform: translateY(-8px); }
  60% { transform: translateY(2px); }
  100% { transform: none; }
}

.scr-control .ctl-q__music {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: var(--fs-s);
}

.scr-control .ctl-q__note { flex: none; display: block; }

/* step 4: confirm on the pixel keyboard */
.scr-control .ctl-win--kbd .win__body { padding: 10px; }
.scr-control .ctl-win--kbd .win__body > * + * { margin-top: 10px; }

/* one line kept free for "Wissen is uitgeschakeld." / "Autocorrectie…", so the window never jumps */
.scr-control .ctl-win--kbd .ctl-status,
.scr-control .ctl-win--kbd .win__body > .ctl-status:empty {
  min-height: 1.3em;
  margin-top: 6px;
  font-size: var(--fs-s);
}

/* short phones (iPhone SE): tighter, so the whole keyboard fits above the DAAN bar, also with LEESBRIL.
   Only the non-tappable parts get smaller; the keys stay 44px tall. */
@media (max-height: 620px) {
  .scr-control .ctl-bar { padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .scr-control .ctl-daan { min-height: calc(48px * var(--ctl-daan-k)); } /* still +8% per step */
  .scr-control .ctl-center { padding-top: 4px; padding-bottom: 4px; }
  .scr-control .ctl-win--kbd .win__bar { min-height: 28px; padding-top: 2px; padding-bottom: 2px; }
  .scr-control .ctl-win--kbd .win__body { padding: 6px 8px; }
  .scr-control .ctl-win--kbd .win__body > * + * { margin-top: 5px; }
  .scr-control .ctl-win--kbd .ctl-field { min-height: 38px; padding-top: 2px; padding-bottom: 2px; }
  .scr-control .ctl-win--kbd .ctl-status,
  .scr-control .ctl-win--kbd .win__body > .ctl-status:empty { min-height: 1.15em; margin-top: 4px; line-height: 1.15; }
  .scr-control .kbd { gap: 3px; padding: 3px; }
  .scr-control .ctl-crash__face { font-size: calc(48px * var(--text-scale)); }
  .scr-control .ctl-crash__inner { gap: 10px; }
}

.scr-control .ctl-phrase {
  display: inline-block;
  padding: 0 4px;
  font-family: var(--font-ui);
  font-size: var(--fs-s);
  font-weight: 400;
  background: var(--yellow);
}

.scr-control .ctl-field {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 8px 10px;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: max(18px, var(--fs-m));
  white-space: nowrap;
  background: var(--paper);
  border: var(--bw) solid var(--ink);
  box-shadow: inset 3px 3px 0 0 var(--shade);
}

.scr-control .ctl-field__caret {
  flex: none;
  width: 10px;
  height: 1.1em;
  margin-left: 2px;
  background: var(--ink);
  animation: blink calc(800ms / var(--speed)) steps(1) infinite;
}

.scr-control .ctl-field.is-done { background: var(--mint); box-shadow: none; }
.scr-control .ctl-nope { animation: shake calc(330ms / var(--speed)) steps(4) 1; }

.scr-control .kbd {
  display: grid;
  grid-template-columns: repeat(20, minmax(0, 1fr));
  grid-auto-rows: 44px;
  gap: 4px;
  padding: 5px;
  background: var(--lav-l);
  border: var(--bw) solid var(--ink);
}

.scr-control .kbd__key {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 100%;
  padding: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  line-height: 1;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 0 3px 0 0 var(--ink);
  cursor: pointer;
}

.scr-control .kbd__key:not(.kbd__key--letter) { background: var(--lav); }

.scr-control .kbd__key:active {
  transform: translateY(3px);
  background: var(--pink);
  box-shadow: none;
}

.scr-control .kbd__key.is-hit { animation: ctl-kbd-hit calc(150ms / var(--speed)) steps(1); }

@keyframes ctl-kbd-hit {
  0%, 99% { transform: translateY(3px); background: var(--pink); box-shadow: none; }
}

.scr-control .kbd.is-disabled .kbd__key { color: var(--lav-d); cursor: default; }

/* step 5: Henk lies on the button */
.scr-control .ctl-lie {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.scr-control .ctl-lie__sprite { display: block; }

.scr-control .ctl-land { animation: ctl-land calc(330ms / var(--speed)) steps(4) both; }

@keyframes ctl-land {
  0% { transform: translateY(-36px); opacity: 0; }
  50% { transform: translateY(3px); opacity: 1; }
  100% { transform: none; opacity: 1; }
}

.scr-control .ctl-lie.is-leaving {
  transform: translateX(var(--ctl-leave-x, 120vw));
  transition: transform calc(var(--ctl-leave-ms, 500ms) / var(--speed)) steps(5);
}

.scr-control .ctl-lie__hearts {
  position: absolute;
  left: 0;
  right: 0;
  top: 6px;
  height: 0;
}

.scr-control .ctl-lie__bubble {
  position: absolute;
  z-index: 4;
  margin: 0;
  font-size: var(--fs-s);
}

/* tail pointing down at Henk (or up when the bubble sits below him) */
.scr-control .ctl-lie__bubble::after {
  content: "";
  position: absolute;
  left: var(--tail-x, 24px);
  bottom: -12px;
  width: 12px;
  height: 12px;
  background:
    linear-gradient(var(--ink), var(--ink)) 0 0 / 3px 12px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 3px 6px / 3px 3px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 6px 3px / 3px 3px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 9px 0 / 3px 3px no-repeat,
    linear-gradient(var(--paper), var(--paper)) 3px 0 / 6px 6px no-repeat;
}

.scr-control .ctl-lie__bubble.is-below::after {
  top: -12px;
  bottom: auto;
  transform: scaleY(-1);
}

/* step 6: the avalanche of errors */
.scr-control .ctl-pile {
  position: absolute;
  inset: 0;
}

.scr-control .ctl-popup {
  position: absolute;
  max-width: none;
  box-shadow: 3px 3px 0 0 var(--ink);
  animation: pop-in calc(150ms / var(--speed)) steps(3) both;
}

/* titles sit at the top of the bar, so they stay readable in the strip the next window leaves free */
.scr-control .ctl-popup .win__bar {
  align-items: flex-start;
  min-height: 30px;
  padding: 3px 6px 2px 8px;
}

.scr-control .ctl-popup .win__title { font-size: var(--fs-xs); }
.scr-control .ctl-popup .win__dot { width: 10px; height: 10px; }
.scr-control .ctl-popup .win__body { padding: 10px; }

.scr-control .ctl-popup__text {
  margin: 0;
  font-size: var(--fs-s);
  line-height: 1.25;
}

.scr-control .ctl-popup.is-fading {
  opacity: 0;
  transition: opacity var(--t-med) steps(3);
}

.scr-control .ctl-closeall-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  padding: 10px var(--gutter) 14px;
}

.scr-control .ctl-closeall-dock.is-gone { visibility: hidden; }

/* step 7: the crash */
.scr-control .ctl-crash {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  padding: 16px var(--gutter);
  overflow-y: auto;
  color: var(--ink);
  background: var(--lav);
}

.scr-control .ctl-crash__inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: var(--win-max);
  margin: auto;
}

.scr-control .ctl-crash p { margin: 0; }

.scr-control .ctl-crash__face {
  font-family: var(--font-ui);
  font-size: calc(64px * var(--text-scale));
  line-height: 1;
}

.scr-control .ctl-crash__row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.scr-control .ctl-crash__henk { flex: none; display: block; }

.scr-control .ctl-crash__title {
  font-size: var(--fs-l);
  font-weight: 700;
  line-height: 1.15;
}

.scr-control .ctl-crash__cause {
  margin-top: 6px !important;
  font-size: var(--fs-s);
  line-height: 1.3;
}

.scr-control .ctl-crash__row--qr { align-items: center; }

.scr-control .ctl-crash__code {
  flex: none;
  display: block;
  padding: 6px;
  background: var(--paper);
  border: var(--bw) solid var(--ink);
}

.scr-control .ctl-crash__info {
  flex: 1 1 auto;
  min-width: 0;
}

.scr-control .ctl-crash__dump {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--fs-s);
  line-height: 1.3;
}

.scr-control .ctl-crash__dump[hidden] { display: none; }

.scr-control .ctl-crash__restart { display: flex; flex-direction: column; gap: 8px; }
.scr-control .ctl-crash__restart[hidden] { display: none; }

.scr-control .ctl-crash__restart-text {
  font-family: var(--font-ui);
  font-size: var(--fs-s);
  text-transform: uppercase;
}

.scr-control .ctl-crash__bar { border-color: var(--ink); }

/* ---------- revisit: already answered ---------- */
.scr-control .ctl-answer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
}

.scr-control .ctl-answer__label {
  font-family: var(--font-ui);
  font-size: var(--fs-s);
  text-transform: uppercase;
}

.scr-control .ctl-answer__tag {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  font-family: var(--font-ui);
  font-size: var(--fs-l);
  text-transform: uppercase;
  background: var(--pink);
  border: var(--bw) solid var(--ink);
  box-shadow: var(--shadow);
}
