/* Instructor UI of normandy. Light theme for projectors. Colour carries state:
   amber is the active problem, green is resolved and 2xx, red is a failure or a destructive action, blue is an action.
   The action badges of the notes: green is wait, amber is cancel the run, grey is a run that ends.
   The status badges of the runs: blue is running, green is completed, red is failed or timed out, grey is another end. */

:root {
  --ink: #1d1d1f;
  --ink-2: #555b63;
  --paper: #f5f5f7;
  --panel: #fff;
  --line: #d2d2d7;
  --line-soft: #e8e8ed;
  --blue: #0a62c9;
  --blue-tint: #e8f0fb;
  --amber: #e8a317;
  --amber-tint: #fdf2db;
  --green: #2f8a4f;
  --green-ink: #22693b;
  --red: #c9372c;
  --red-ink: #a62b22;
  --red-tint: #fbecea;
  --field: #8e8e93;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Liberation Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --masthead: 53px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--paper); }

h1, h2, h3, h4, p { margin: 0; }
h2 { font-size: 18px; font-weight: 650; line-height: 1.3; }
h3 { font-size: 15px; font-weight: 650; line-height: 1.3; }
h4 { font-size: 13px; font-weight: 650; color: var(--ink-2); margin-top: 10px; }
ul, ol { margin: 0; padding-left: 1.3em; }
li + li { margin-top: 3px; }
a { color: var(--blue); text-underline-offset: 2px; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
code { overflow-wrap: anywhere; }
strong { font-weight: 650; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.hint, .meta { color: var(--ink-2); font-size: 14px; }
.hint code { white-space: nowrap; } /* short names such as user_timeout */
.hint.error, .form-error { color: var(--red-ink); }
.form-error:empty { display: none; }
.empty { color: var(--ink-2); }
.warn { color: var(--red-ink); font-size: 14px; }

/* Controls */

button {
  font: inherit;
  font-size: 14px;
  line-height: 1.25;
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--blue);
  cursor: pointer;
}
button:hover { background: var(--blue-tint); }
button:disabled { cursor: not-allowed; color: #8a9097; background: var(--paper); }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
button.primary:hover { background: #084fa3; }
button.primary:disabled { background: #9db8dc; border-color: #9db8dc; }
button.danger:enabled { color: var(--red-ink); }
button.danger:enabled:hover { background: var(--red-tint); }
button.danger-fill { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
button.danger-fill:hover { background: var(--red-ink); }
button.quiet, button.link { border-color: transparent; background: none; }
button.quiet:hover, button.link:hover { text-decoration: underline; }
button.quiet:disabled { background: none; color: #a1a6ad; text-decoration: none; }
button.link { min-height: 24px; padding: 0 2px; }

input, select, textarea {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--field);
  border-radius: 6px;
  padding: 6px 8px;
  min-width: 0;
  min-height: 32px;
}
input:disabled, select:disabled { background: var(--paper); color: #8a9097; border-color: var(--line); }
input:user-invalid, textarea:user-invalid { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
textarea { width: 100%; font-family: var(--mono); font-size: 13px; line-height: 1.45; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--blue); }
input.mono { font-family: var(--mono); font-size: 13px; }

summary { cursor: pointer; color: var(--blue); font-weight: 600; width: fit-content; min-height: 24px; }

.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row > a, .run-rows a { display: inline-flex; align-items: center; min-height: 24px; }
.row.end { justify-content: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label, legend { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; font-size: 14px; cursor: pointer; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; }

/* Header */

.masthead { background: var(--panel); border-bottom: 1px solid var(--line); }
.top { display: flex; flex-wrap: wrap; align-items: stretch; column-gap: 28px; max-width: 1400px; margin: 0 auto; padding: 0 24px; min-height: 52px; }
.wordmark { align-self: center; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.top nav { display: flex; }
.top nav a {
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--ink-2);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}
.top nav a:hover { color: var(--ink); }
.top nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--blue); }
.top nav a:focus-visible { outline-offset: -3px; }
.status { margin-left: auto; align-self: center; display: flex; flex-wrap: wrap; align-items: center; column-gap: 20px; padding: 8px 0; font-size: 14px; color: var(--ink-2); }
.header-state { display: inline-flex; align-items: center; gap: 8px; min-height: 24px; color: var(--ink); font-weight: 600; text-decoration: none; }
.header-state:hover { text-decoration: underline; }
.header-state::before { content: ""; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--field); }
.header-state[data-state="active"]::before { background: var(--amber); border-color: var(--amber); }
.header-state[data-state="done"]::before { background: var(--green); border-color: var(--green); }
.header-state[data-state="running"]::before { background: var(--blue); border-color: var(--blue); }

/* The messages float at the bottom, so they never move the page. The message of the run ends is above the other
   messages. The box of the messages is as wide as the widest message, so only the messages take clicks. */
.messages {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 20;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(46rem, calc(100vw - 32px));
  pointer-events: none;
}
.message {
  pointer-events: auto;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  color: #fff;
  background: #2c2c2e;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message:empty { display: none; }
.message.error { background: var(--red-ink); }

main { max-width: 1400px; margin: 0 auto; padding: 24px 24px 96px; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.015em; overflow-wrap: anywhere; }

/* Tables */

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td > code { white-space: nowrap; overflow-wrap: normal; }
td details pre { margin-top: 6px; max-width: 44rem; }
td details[open] { min-width: 18rem; }
td button { white-space: nowrap; }

pre {
  margin: 0;
  padding: 10px 12px;
  background: #f6f6f8;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code { font-variant-numeric: tabular-nums; white-space: nowrap; }
.code::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #a1a6ad; vertical-align: 1px; }
.code.ok::before { background: var(--green); }
.code.bad { color: var(--red-ink); font-weight: 600; }
.code.bad::before { background: var(--red); }
.code.run::before { background: none; border: 2px solid var(--ink-2); width: 9px; height: 9px; }
.ok-text { color: var(--green-ink); font-weight: 600; }

/* Run tab: steps 1 to 3 on the left, step 4 on the right */

.session { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.setup, .watch { display: grid; gap: 16px; }
.step { display: grid; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.setup h2, .watch > h2 { display: flex; align-items: center; gap: 10px; }
.step-number { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; color: #fff; background: var(--ink); }
.watch > h2 { padding: 4px 0 0; }
.watch .panel { display: grid; gap: 10px; }

.segmented { margin: 0; padding: 0; border: 0; min-width: 0; }
.segmented legend { padding: 0 0 4px; }
.track { display: flex; flex-wrap: wrap; gap: 2px; width: fit-content; max-width: 100%; padding: 2px; border-radius: 9px; background: var(--line-soft); }
.segmented label { position: relative; }
.segmented input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.segmented span { display: block; padding: 5px 16px; border-radius: 7px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.segmented input:checked + span { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.18); }
.segmented input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 1px; }
#template { width: 100%; }
#workflow-id { flex: 1; }
#rollback-window { width: 8em; }
#window-text { font-weight: 600; }
.picks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.picks button { min-height: 28px; padding: 3px 10px; }
.picks button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.gets { font-weight: 600; }
.editor textarea { margin-top: 10px; }
.editor .hint { margin-top: 6px; }
.settings { padding: 0 4px; }
#build-time { display: grid; gap: 10px; margin-top: 10px; }
#build-seconds { width: 7em; }

.list-title { font-weight: 650; }
.problem-rows, .run-rows, .needs-rows { list-style: none; padding: 0; display: grid; gap: 0; }
.problem-rows li, .run-rows > li, .needs-rows li { margin: 0; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.problem-rows li:first-child, .run-rows > li:first-child, .needs-rows li:first-child { border-top: 0; }
.problem-rows li { display: flex; align-items: flex-start; gap: 12px; }
.problem-rows .marker { width: 26px; height: 26px; font-size: 13px; }
.problem-rows [data-key^="run-remove-"] { margin-left: auto; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.live { font-size: 14px; color: var(--ink-2); }
.state { color: var(--ink); }
[data-state="active"] .state { background: var(--amber-tint); border-radius: 4px; padding: 0 6px; }
[data-state="resolved"] .state { color: var(--green-ink); }
[data-state="resolved"] .row-title { color: var(--ink-2); }
.run-rows > li { display: grid; gap: 4px; }
.run-rows > li > p:first-child { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; }
.needs { border-color: var(--amber); box-shadow: inset 4px 0 0 var(--amber); }
.needs-rows li { display: grid; gap: 6px; }
.active-card { display: grid; gap: 6px; }
.active-card .row { margin-top: 6px; gap: 14px; }
.notes { display: grid; gap: 6px; }
.notes code { background: #eff0f3; border-radius: 4px; padding: 0 3px; font-size: 12.5px; }
.notes details { margin-top: 6px; }
.action { width: fit-content; border-radius: 4px; padding: 1px 8px; font-size: 13px; font-weight: 600; }
.action[data-action="wait"] { background: #e3f2e8; color: var(--green-ink); }
.action[data-action="cancel"] { background: var(--amber-tint); color: #7a5300; }
.action[data-action="ended"] { background: var(--line-soft); color: var(--ink-2); }
.action[data-status] { background: var(--line-soft); color: var(--ink-2); }
.action[data-status="running"] { background: var(--blue-tint); color: var(--blue); }
.action[data-status="completed"] { background: #e3f2e8; color: var(--green-ink); }
.action[data-status="failed"], .action[data-status="timed_out"] { background: var(--red-tint); color: var(--red-ink); }

/* Problems tab */

.problems-page { display: grid; gap: 16px; max-width: 920px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.page-head .meta { margin-top: 2px; }
.chain-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.chain-list > li { margin: 0; }
.marker {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--panel);
  border: 2px solid var(--ink-2);
}
[data-state="active"] > .marker, [data-state="active"] > .card-head .marker, .active-card .marker { background: var(--amber); border-color: var(--amber); }
[data-state="resolved"] > .marker, [data-state="resolved"] .card-head .marker { background: var(--line-soft); border-color: var(--line); color: var(--ink-2); }
.card { display: grid; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; }
.card[data-state="active"] { border-color: var(--amber); box-shadow: inset 4px 0 0 var(--amber); }
.card[data-state="resolved"] { background: transparent; }
.card-head { display: flex; align-items: center; gap: 12px; }
.card-head h3 { font-size: 17px; overflow-wrap: anywhere; }
.card .live, .card .where, .card .warn, .card .param-line, .card-notes { margin-left: 44px; }
.param-line { font-size: 14px; color: var(--ink-2); }
.card-notes > summary { font-size: 14px; }
.card-notes[open] > summary { margin-bottom: 4px; }
.card-notes code { background: #eff0f3; border-radius: 4px; padding: 0 3px; font-size: 12.5px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.card-actions [data-key^="remove-"] { margin-left: auto; }

/* Dialogs */

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; max-width: min(34rem, calc(100vw - 32px)); color: var(--ink); box-shadow: 0 16px 48px rgb(0 0 0 / 0.25); }
dialog::backdrop { background: rgb(0 0 0 / 0.3); }
#confirm p { margin-bottom: 18px; font-size: 16px; }
#login { width: min(24rem, calc(100vw - 32px)); }
#login form { display: grid; gap: 14px; }
#login input { width: 100%; }
/* The head stays in view, and only the body under it scrolls. The scroll padding keeps the focus ring in view.
   The body is positioned, so the .vh text in it stays in its scroll range and the dialog itself does not scroll.
   The display is set only on an open dialog: on a closed dialog it would show the dialog. */
dialog.sheet { width: min(52rem, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 48px); padding: 0; }
dialog.sheet[open] { display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 22px; padding: 16px 0 10px; border-bottom: 1px solid var(--line-soft); }
.sheet-body { position: relative; overflow-y: auto; padding: 6px 22px 22px; scroll-padding: 8px 0; }
.sheet-head h2 { overflow-wrap: anywhere; }
.scenario-group { margin-top: 16px; }
.scenario-group ul { list-style: none; padding: 0; }
.scenario { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 0; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.scenario p { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.scenario .meta { font-size: 13px; }
.scenario .meta strong { color: var(--green-ink); }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 4px 24px; margin-top: 8px; }
.palette-group h3 { font-size: 13px; color: var(--ink-2); padding: 10px 0 4px; border-bottom: 1px solid var(--line); }
.palette-group ul { list-style: none; padding: 0; }
.palette-group li { margin: 0; }
.block { width: 100%; display: grid; gap: 2px; text-align: left; color: var(--ink); background: none; border-color: transparent; border-radius: 8px; padding: 8px; }
.block span { font-size: 14px; color: var(--ink-2); }
.block .warn { color: var(--red-ink); }
.block:disabled { background: none; }
.block:disabled strong { color: #8a9097; }
.problem-form { display: grid; gap: 14px; margin-top: 10px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); gap: 12px 16px; }
.fields .wide { grid-column: 1 / -1; }
.fields select, .fields input:not([type="checkbox"]) { width: 100%; }
.unit, .count-field { display: flex; align-items: center; gap: 8px; }
.count-field input[type="number"] { width: 5em !important; }

/* Traffic tab */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin-bottom: 14px; }
#traffic-count { margin-left: auto; }
.traffic-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.traffic-list { overflow-anchor: none; }
.traffic-list .empty { padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.traffic-list td { white-space: nowrap; overflow-wrap: normal; }
.traffic-list .form { display: block; font-size: 12px; color: var(--ink-2); white-space: normal; overflow-wrap: anywhere; }
.traffic-list td.by { white-space: normal; overflow-wrap: anywhere; min-width: 8rem; }
.traffic-list tbody tr { cursor: pointer; }
.traffic-list tbody tr:hover { background: #f7f8fa; }
.traffic-list tr.selected { background: var(--blue-tint); box-shadow: inset 4px 0 0 var(--blue); }
.row-open { min-height: 24px; padding: 0; border: 0; background: none; font-variant-numeric: tabular-nums; }
.row-open:hover { background: none; text-decoration: underline; }
.by::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; background: var(--amber); transform: rotate(45deg); vertical-align: 1px; }
.traffic-entry { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; display: grid; gap: 8px; }
.traffic-entry .back { display: none; }
.traffic-entry h2 { font-family: var(--mono); font-size: 14px; overflow-wrap: break-word; }
.traffic-entry h3 { margin-top: 8px; font-size: 14px; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 16px; margin: 4px 0 0; font-size: 14px; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Records tab */

.jump { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.jump span { color: var(--ink-2); }
#reset { margin-left: auto; }
.record-block { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 28px; }
.state-cell { display: grid; gap: 6px; justify-items: start; }
.state-cell input { width: 6em; }

/* Logs tab */

.logs, .log-lines { display: grid; gap: 10px; }
.logs { margin-top: 14px; overflow-anchor: none; }
.log-lines { list-style: none; padding: 0; }
.log-lines li { margin: 0; display: grid; gap: 2px; }

/* The header stays on screen when the window is high enough. */
@media (min-height: 600px) {
  .masthead { position: sticky; top: 0; z-index: 10; }
  html { scroll-padding-top: calc(var(--masthead) + 16px); }
  .traffic-entry { top: calc(var(--masthead) + 16px); max-height: calc(100vh - var(--masthead) - 32px); }
}

/* Narrow windows */

@media (max-width: 1100px) {
  .traffic-grid { grid-template-columns: minmax(0, 1fr); }
  .traffic-entry { position: static; max-height: none; }
  .traffic-entry .back { display: inline-flex; justify-self: start; }
  .traffic-grid.showing-detail .traffic-list, .traffic-grid:not(.showing-detail) .traffic-entry { display: none; }
}
@media (max-width: 900px) {
  .session { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .top { padding: 0 14px; column-gap: 12px; }
  .top nav a { padding: 0 10px; }
  .status { margin-left: 0; }
  main { padding: 16px 14px 96px; }
  .card .live, .card .where, .card .warn, .card .param-line, .card-notes { margin-left: 0; }
}
