/*
  The free drill (/drill/). Page layout only; every component comes from site.css.
  White sheet: everyone taking part. Injects arrive as canary slips, a page carries the red rule.
  The exercise log and the debrief are pink: the evaluator's record.
  State colour: green only resolved, amber only waiting on you, red only a page or a failure.
*/

/* ---------- Marking and title ---------- */
.drill-mark {
  margin-top: var(--s4);
  padding-inline: 0;
}
.drill-mark--foot {
  margin-top: var(--s8);
}
.drill-title {
  padding-top: clamp(16px, 2.4vw, 32px);
}
.drill {
  margin-top: clamp(28px, 3.4vw, 44px);
}

/* ---------- Status form: the instruments. Stays in view while you play. ---------- */
.drill-status {
  position: sticky;
  top: 0;
  z-index: 5;
}
/* a white margin above the box when it is stuck, so the feed does not show through */
.drill-status::before {
  content: "";
  position: absolute;
  inset: -12px -2px auto;
  height: 10px;
  background: var(--white);
}
.drill-status-row {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1.1fr);
}
.drill-read {
  display: block;
  font-size: var(--ty-read);
  font-weight: 700;
  line-height: 1.1;
}
.drill-sub {
  display: block;
  margin-top: 2px;
  font-size: var(--t-small);
  line-height: 1.3;
}
.drill-meter {
  display: block;
  height: 10px;
  margin-top: 8px;
  border: 1.5px solid var(--ink);
  background: var(--white);
}
.drill-meter b {
  display: block;
  width: 71%;
  height: 100%;
  background: var(--ink);
}
.drill-meter b.is-bad {
  background: var(--bad);
}
.drill-meter b.is-ok {
  background: var(--ok);
}
.drill-state {
  display: block;
  font-size: var(--t-lead);
  font-weight: 750;
  font-stretch: 80%;
  line-height: 1.15;
}

/* ---------- Grid: the feed and your moves beside the evaluator's log ---------- */
.drill-grid {
  display: grid;
  gap: var(--s7) var(--gap);
  margin-top: var(--s6);
}
.drill-main {
  min-width: 0;
}
@media (min-width: 760px) {
  .drill-grid {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    align-items: start;
  }
}

/* ---------- Before the start ---------- */
.intro {
  display: grid;
  gap: var(--s5);
}
.drill-intro-text {
  max-width: var(--measure);
  font-size: var(--t-lead);
  line-height: 1.4;
}
.drill-intro-note {
  max-width: 40em;
  color: var(--ink-soft);
  font-size: var(--t-small);
}
.drill-noscript {
  max-width: var(--measure);
  font-weight: 650;
}

/* ---------- The feed ---------- */
.drill-round {
  display: grid;
  gap: var(--s5);
}
.drill-entry {
  display: grid;
  grid-template-columns: 5.25rem minmax(0, 1fr);
  gap: 0 var(--s4);
  align-items: baseline;
}
.drill-when {
  font-size: var(--t-small);
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}
.drill-body {
  min-width: 0;
}
.drill-body > .cap {
  margin-bottom: 4px;
}
.drill-said {
  display: block;
  max-width: 64ch;
  line-height: 1.5;
}
.drill-said > p + p {
  margin-top: 0.6em;
}
.drill-said code {
  font-size: 1em;
  overflow-wrap: anywhere;
}
/* the player's own entries: a rule down the left, like a hand-marked line */
.drill-entry--you .drill-body {
  padding-left: var(--s4);
  border-left: 3px solid var(--ink);
}
.drill-entry--end p {
  font-size: var(--t-lead);
  line-height: 1.35;
}
.drill-entry--end b {
  font-weight: 750;
}
.slip .message .typed {
  overflow-wrap: anywhere;
}

/* Terminal output. Each line wraps under itself with a hanging indent, so nothing is
   clipped on a phone (DECISION.md risk 9). Wider screens fit every line unwrapped. */
.drill-term {
  margin: var(--s3) 0;
  white-space: normal;
  overflow: visible;
}
.drill-term > span {
  display: block;
  padding-left: 2ch;
  text-indent: -2ch;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* a status check: where the incident stands, typed by the Game Master */
.drill-check {
  display: flex;
  flex-wrap: wrap;
  gap: 2px var(--s5);
  padding: 7px 0 8px;
  border-block: 1px solid var(--ink);
  font-size: var(--t-small);
}
.drill-check > span:first-child {
  font-weight: 700;
}

/* earlier rounds, folded */
.drill-earlier {
  margin-bottom: var(--s5);
  border-block: 1px solid var(--ink);
  border-top-width: 2px;
}
.drill-earlier summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--s4);
  min-height: 48px;
  padding: 12px 0 11px;
  cursor: pointer;
  list-style: none;
  font-size: var(--t-small);
}
.drill-earlier summary::-webkit-details-marker {
  display: none;
}
.drill-earlier summary::after {
  content: "Show";
  margin-left: auto;
  font-weight: 650;
  font-stretch: 88%;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
}
.drill-earlier[open] summary::after {
  content: "Hide";
}
.drill-earlier summary:hover::after {
  text-decoration-thickness: 3px;
}
.drill-earlier-name {
  font-weight: 750;
  font-stretch: 85%;
}
.drill-earlier-span {
  font-size: var(--t-small);
}
.drill-earlier-n {
  color: var(--ink-soft);
}
.drill-earlier-body {
  display: grid;
  gap: var(--s5);
  padding: var(--s3) 0 var(--s5);
}

/* ---------- Your move ---------- */
.drill-move {
  margin-top: var(--s6);
}
.drill-ask {
  max-width: none;
  margin-bottom: var(--s3);
  font-size: var(--t-h3);
  font-weight: 700;
  font-stretch: 75%;
  line-height: 1.1;
}
.drill.is-over .drill-move {
  margin-top: var(--s5);
}

/* ---------- The debrief (pink: the evaluator's record) ---------- */
.drill-debrief {
  --stock: var(--pink);
  --fill: var(--carbon);
  margin-top: var(--s3);
}
.drill-debrief .form-head .name {
  max-width: none;
  font-size: 2.25rem;
  font-stretch: 62%;
  line-height: 1;
}
.drill-debrief .typed--long {
  max-width: 62ch;
}
.cell > .drill-score {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 2px;
}
.drill-outcome-note {
  display: block;
  max-width: 34em;
  margin-top: 6px;
  font-size: var(--t-small);
  line-height: 1.4;
}
.drill-question {
  max-width: 40em;
}
/* green and red readings are 28px bold here: large text, so they keep AA on pink */
.drill-debrief .state-ok,
.drill-debrief .state-bad {
  font-family: var(--sans);
  font-weight: 800;
  font-stretch: 75%;
}
.drill-next {
  display: grid;
  gap: var(--s4);
  margin-top: var(--s3);
}
.drill-next > p:first-child {
  max-width: var(--measure);
}
.drill-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s5);
  font-size: var(--t-small);
  font-weight: 650;
  font-stretch: 88%;
}
.drill-links a,
.drill-copy {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
.drill-copy {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
  cursor: pointer;
}
.drill-copy:hover {
  text-decoration-thickness: 3px;
}

/* ---------- The exercise log ---------- */
.drill-log-empty {
  padding: 8px 12px 10px;
  font-size: var(--t-small);
  line-height: 1.4;
}
#log:not(:empty) + .drill-log-empty {
  display: none;
}
@media (min-width: 760px) and (max-width: 1023px) {
  /* a slip in the narrow feed: who it is from across the top, then to and via */
  .drill-entry .slip .row.n3 {
    --n: 2;
  }
  .drill-entry .slip .row.n3 > .cell:first-child {
    grid-column: 1 / -1;
  }
  /* a narrow column: the time over each entry */
  .drill-log li {
    grid-template-columns: minmax(0, 1fr);
    padding-inline: 10px;
    font-size: var(--ty-out);
  }
}
#h-debrief:focus {
  outline: none;
}
#h-debrief:focus-visible {
  outline: 3px solid var(--carbon);
}

/* ---------- Phones ---------- */
@media (max-width: 759px) {
  /* an empty log under the button is noise on a phone; it appears once the drill starts */
  .drill:not(.is-live) .drill-log {
    display: none;
  }
}
@media (max-width: 620px) {
  /* the status form keeps to two slim rows so it can stay in view */
  .drill-status-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 1.1fr);
  }
  .drill-status .cell {
    padding: 5px 10px 7px;
  }
  .drill-status .cap {
    margin-bottom: 1px;
    font-size: 0.75rem;
  }
  .drill-read {
    font-size: 1.25rem;
  }
  .drill-sub {
    margin-top: 0;
    font-size: var(--t-cap);
  }
  .drill-meter {
    height: 7px;
    margin-top: 5px;
  }
  .drill-state-cell {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    gap: var(--s3);
  }
  .drill-state-cell .cap {
    margin: 0;
  }
  .drill-state {
    font-size: var(--t-body);
  }

  /* entries: the time over the entry, so the entry gets the full width */
  .drill-entry {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 2px;
  }
  .drill-when {
    font-size: var(--t-cap);
  }
  /* a slip: who it is from across the top, then to and via side by side */
  .drill-entry .slip .row.n3 > .cell:first-child {
    grid-column: 1 / -1;
  }
  .drill-entry .slip .row.n3 > .cell:last-child {
    grid-column: auto;
  }
  .drill-term {
    padding: 8px 9px 9px;
    font-size: 0.8125rem;
  }
  .drill-debrief .form-head .name {
    font-size: 1.875rem;
  }
  .drill-ask {
    font-size: 1.375rem;
  }
}

@media print {
  .drill-status {
    position: static;
  }
  .drill-move {
    display: none;
  }
}
