/* ===================================================================
   Deck frame: a 1600×900 stage scaled to the screen.
   =================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--text);
  font-size: 30px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body.handout { overflow: auto; }

.deck { position: fixed; inset: 0; }
.stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1600px;
  height: 900px;
  transform: translate(-50%, -50%) scale(var(--scale, 1));
  transform-origin: 50% 50%;
  background: var(--ground);
  overflow: hidden;
}

.slide {
  position: absolute;
  inset: 0;
  visibility: hidden;
  opacity: 0;
  transition: opacity 180ms var(--ease-out), visibility 0s linear 180ms;
}
.slide.is-active {
  visibility: visible;
  opacity: 1;
  transition: opacity 260ms var(--ease-out);
}
.slide .notes { display: none; }

/* Handout mode (phones / narrow screens): every slide stacked, scaled to width */
body.handout .deck { position: static; }
body.handout .stage { position: static; transform: none; width: auto; height: auto; background: none; overflow: visible; }
body.handout .slide-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; margin: 0 0 14px; background: var(--ground); box-shadow: 0 1px 0 var(--rule); }
body.handout .slide { visibility: visible; opacity: 1; width: 1600px; height: 900px; transform-origin: 0 0; transform: scale(var(--hscale, 0.2)); inset: auto; left: 0; top: 0; }
body.handout .rail, body.handout .help { display: none; }
.handout-head { display: none; }
body.handout .handout-head { display: block; padding: 20px 16px 8px; }
body.handout .handout-head h1 { font-family: var(--display); font-weight: 400; font-size: 44px; line-height: 1; margin: 0; text-transform: uppercase; }
body.handout .handout-head p { font-size: 16px; line-height: 1.45; margin: 8px 0 12px; }
body.handout .handout-head a { color: var(--navy); font-weight: 700; text-underline-offset: 3px; }

/* ===================================================================
   Running head (practice-manual style)
   =================================================================== */
.run {
  position: absolute;
  left: 64px;
  right: 64px;
  top: 26px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  font-family: var(--display);
  font-size: 25px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding-bottom: 9px;
  border-bottom: 2px solid var(--navy);
}
.run > :nth-child(2) { text-align: center; }
.run > :last-child { text-align: right; color: var(--ink-soft); }

/* Slide title block */
.title {
  position: absolute;
  left: 64px;
  top: 92px;
  right: 64px;
}
.title h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 108px;
  line-height: 0.9;
  letter-spacing: 0.004em;
  text-transform: uppercase;
  text-wrap: balance;
}
.title .lede {
  margin: 14px 0 0;
  font-size: 31px;
  line-height: 1.32;
  max-width: 46ch;
  color: var(--ink);
  text-wrap: pretty;
}
.body { position: absolute; left: 64px; right: 64px; top: 290px; bottom: 100px; }

/* ===================================================================
   Exchange components
   =================================================================== */
.panel {
  background: var(--navy);
  color: var(--paper);
  border-radius: 6px;
  padding: 18px 22px;
}
.panel-h {
  font-family: var(--display);
  font-size: 27px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  line-height: 1;
  margin: 0 0 12px;
}

.strip {
  background: var(--paper);
  color: var(--navy);
  font-family: var(--mono);
  font-size: 20px;
  line-height: 1.45;
  padding: 6px 12px;
  font-variant-numeric: tabular-nums;
}

/* Numbered control circle */
.ctl {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  border: 3px solid var(--navy);
  font-family: var(--display);
  font-size: 30px;
  line-height: 1;
  color: var(--navy);
  background: var(--paper);
}
.ctl.is-on { background: var(--amber); }
.ctl.is-done { background: var(--navy); color: var(--paper); }

/* Lamps */
.lamp { display: inline-block; width: 20px; height: 20px; border-radius: 50%; background: var(--lamp-off); flex: none; vertical-align: middle; }
.lamp.on { background: radial-gradient(circle at 40% 35%, #fff4cf, var(--amber) 55%, #b98100); box-shadow: 0 0 16px 3px var(--amber-glow); }
.lamp.b1 { background: radial-gradient(circle at 40% 35%, #d7e2ff, var(--b1) 60%); }
.lamp.b2 { background: radial-gradient(circle at 40% 35%, #ffd9d9, var(--b2) 60%); }
.lamp.b3 { background: radial-gradient(circle at 40% 35%, #d6f5e2, var(--b3) 60%); }

/* Config sheet with numbered gutter */
.sheet {
  background: var(--paper);
  border: 2px solid var(--navy);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sheet-h {
  background: var(--navy);
  color: var(--paper);
  font-family: var(--display);
  font-size: 25px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 16px 6px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.sheet-h span:last-child { color: #aab3c8; }
.sheet-body { padding: 10px 0; overflow: hidden; }
.cl {
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: center;
  min-height: 31px;
  padding-right: 14px;
  font-family: var(--mono);
  font-size: 20px;
  line-height: 1.55;
  white-space: pre;
  transition: background-color 220ms var(--ease-out);
}
.cl > i {
  justify-self: center;
  font-style: normal;
  display: inline-grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  border: 2px solid var(--navy);
  font-family: var(--display);
  font-size: 19px;
  line-height: 1;
}
.cl > i:empty { border-color: transparent; }
.cl.is-done > i:not(:empty) { background: var(--navy); color: var(--paper); }
.cl.is-on { background: linear-gradient(90deg, rgba(242, 169, 0, 0.45), rgba(242, 169, 0, 0.14) 80%); }
.cl.is-on > i:not(:empty) { background: var(--amber); }
.cl .k { color: var(--navy); font-weight: 700; }
.cl .c { color: var(--ink-faint); }
.cl .v { color: var(--b1); }

/* Keys: the switchboard's controls */
.keys { display: flex; flex-wrap: wrap; gap: 10px; }
.key {
  appearance: none;
  border: 2px solid var(--navy);
  background: var(--paper);
  color: var(--navy);
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
  padding: 9px 13px 7px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: background-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), transform 120ms var(--ease-out);
}
.key kbd {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  padding: 1px 5px 0;
  opacity: 0.75;
}
.key:hover { background: var(--amber-soft); }
.key:active { transform: translateY(1px); }
.key:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--amber); }
.key.is-on { background: var(--navy); color: var(--paper); }
.key.is-on kbd { opacity: 0.9; }
.key[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Decision tape: one chip per request */
.tape { display: flex; flex-wrap: wrap; gap: 6px; min-height: 40px; align-content: flex-start; }
.chip {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 6px;
  border-radius: 4px;
  font-family: var(--display);
  font-size: 24px;
  line-height: 1;
  color: #fff;
  background: var(--navy);
  animation: chip-in 320ms var(--ease-out);
}
.chip.b1 { background: var(--b1); }
.chip.b2 { background: var(--b2); }
.chip.b3 { background: var(--b3); }
.chip.fail { background: var(--paper) repeating-linear-gradient(135deg, var(--down) 0 3px, transparent 3px 8px); color: var(--navy); border: 2px solid var(--navy); text-decoration: line-through 3px; }
.chip.hit { background: var(--amber); color: var(--navy); }
.chip.ok { background: var(--navy); }
.chip.wait { background: var(--paper); color: var(--navy); border: 2px dashed var(--navy); }
@keyframes chip-in { from { transform: translateY(-10px) scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }

.cap {
  font-family: var(--mono);
  font-size: 20px;
  line-height: 1.4;
  color: var(--ink-faint);
}
.sim-label {
  font-family: var(--mono);
  font-size: 20px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

/* Step caption under a stepped simulation */
.stepline {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 28px;
  line-height: 1.25;
  min-height: 52px;
  white-space: nowrap;
  overflow: hidden;
}
.stepline > span:not(.ctl):not(.t) { overflow: hidden; text-overflow: ellipsis; }
.stepline .t { font-family: var(--mono); font-size: 19px; color: var(--ink-faint); white-space: nowrap; }

/* SVG drawing helpers */
svg { overflow: visible; }
svg text { font-family: var(--mono); }
.svg-display { font-family: var(--display); letter-spacing: 0.08em; }
.draw { stroke-dasharray: var(--len, 1200); stroke-dashoffset: var(--len, 1200); animation: draw 620ms var(--ease-out) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.fade-in { animation: fade-in 420ms var(--ease-out) both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ===================================================================
   Jack rail: one jack per slide, presenters on the designation strip
   =================================================================== */
.rail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 70px;
  background: var(--navy);
  display: flex;
  padding: 0 40px;
  z-index: 5;
}
.rail-seg { position: relative; display: flex; align-items: flex-end; justify-content: space-around; padding: 0 8px 12px; }
.rail-seg + .rail-seg { border-left: 2px solid var(--navy-3); }
.rail-who {
  position: absolute;
  left: 12px;
  top: 7px;
  font-family: var(--display);
  font-size: 17px;
  letter-spacing: 0.14em;
  color: #aab3c8;
  text-transform: uppercase;
  white-space: nowrap;
}
.rail-seg.is-current .rail-who { color: var(--paper); }
.jack {
  appearance: none;
  border: 0;
  padding: 0;
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #0b1224;
  box-shadow: inset 0 0 0 4px #a98d45, 0 0 0 1px #000;
  cursor: pointer;
}
.jack::before {
  content: "";
  position: absolute;
  left: 5px;
  top: -16px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #3c4866;
  transition: background-color 300ms var(--ease-out), box-shadow 300ms var(--ease-out);
}
.jack.is-past::before { background: #e9ecf3; box-shadow: 0 0 6px rgba(233, 236, 243, 0.6); }
.jack.is-now::before { background: var(--amber); box-shadow: 0 0 12px 3px var(--amber-glow); }
.jack:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
.flag {
  position: absolute;
  left: 27px;
  top: 1px;
  background: var(--amber);
  color: var(--navy);
  font-family: var(--display);
  font-size: 18px;
  line-height: 1;
  padding: 3px 7px 2px 11px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 6px 50%);
  pointer-events: none;
  white-space: nowrap;
}

/* Keyboard help overlay */
.help {
  position: absolute;
  right: 40px;
  bottom: 86px;
  z-index: 6;
  background: var(--navy);
  color: var(--paper);
  padding: 18px 22px;
  border-radius: 6px;
  font-size: 20px;
  line-height: 1.6;
  display: none;
}
.help.is-open { display: block; }
.help b { font-family: var(--mono); font-weight: 600; color: var(--amber); }

/* Rehearsal notes overlay (N). The real speaker view is P. */
.notes-overlay {
  position: absolute;
  left: 40px;
  right: 40px;
  bottom: 86px;
  z-index: 6;
  background: rgba(20, 33, 61, 0.96);
  color: var(--paper);
  padding: 18px 24px;
  border-radius: 6px;
  font-size: 22px;
  line-height: 1.45;
  display: none;
}
.notes-overlay.is-open { display: block; }

/* ===================================================================
   Presenter view (?presenter)
   =================================================================== */
body.presenter { overflow: auto; background: var(--navy); color: var(--paper); }
body.presenter .deck { display: none; }
.pv { display: none; }
body.presenter .pv { display: grid; grid-template-columns: 1fr 380px; gap: 28px; padding: 28px 32px; min-height: 100vh; }
.pv h1 { font-family: var(--display); font-weight: 400; font-size: 56px; line-height: 1; margin: 0; text-transform: uppercase; }
.pv .pv-meta { font-family: var(--mono); font-size: 18px; color: #aab3c8; margin: 10px 0 18px; }
.pv .pv-notes { font-size: 27px; line-height: 1.5; max-width: 60ch; }
.pv .pv-notes p { margin: 0 0 14px; }
.pv aside { border-left: 2px solid var(--navy-3); padding-left: 24px; }
.pv .pv-timer { font-family: var(--display); font-size: 110px; line-height: 1; }
.pv .pv-next { margin-top: 28px; font-size: 22px; color: #aab3c8; }
.pv .pv-next b { display: block; color: var(--paper); font-family: var(--display); font-weight: 400; font-size: 34px; text-transform: uppercase; }
.pv .keys { margin-top: 24px; }
.pv .key { background: var(--navy-2); color: var(--paper); border-color: #aab3c8; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
