/*
 * Operator console.
 *
 * The whole page is one printed sheet on carbon stock. There are no
 * cards and no shadows: structure comes from ruled fields and the
 * space between them, which is what lets the client's screen be the
 * only lit object on the page once a session starts.
 */

html, body { height: 100%; }

body {
  min-height: 100dvh;
  overflow: hidden;
}

.view { min-height: 100dvh; }
.view[hidden] { display: none; }

.ico {
  width: 18px;
  height: 18px;
  flex: none;
  display: block;
}

.btn-icon { padding: 0.4375rem; }

/* ------------------------------------------------------------------ *
 * Connect
 * ------------------------------------------------------------------ */

.view-connect {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow-y: auto;
}

/* The sheet sits in the optical centre of the space below the
   masthead rather than pinned to the top, where it read as the first
   third of a page that had not finished loading. */
.view-connect > .sheet { align-self: center; }

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  font-size: var(--t-small);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.masthead-tools {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.sheet {
  width: min(1080px, 100%);
  margin-inline: auto;
  padding: clamp(var(--sp-5), 6vh, var(--sp-7)) var(--sp-6) var(--sp-7);
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: var(--sp-7);
  align-items: start;
}

.form { display: grid; gap: var(--sp-5); }

.entry { display: grid; gap: var(--sp-2); }

.entry-split {
  grid-template-columns: auto minmax(12rem, 1fr);
  gap: var(--sp-5);
  align-items: end;
}

/* A bare <label> is inline, so without this the printed label sits
   beside its field instead of above it and the two entries stop
   matching each other. */
.entry-split > div {
  display: grid;
  gap: var(--sp-2);
  min-width: 0;
}

/*
 * The number is the headline. It is set larger than the product name,
 * larger than any label, and in a face whose every glyph occupies the
 * same advance — so reading it aloud digit by digit over the phone
 * matches what the eye sees on screen.
 */
.cells {
  width: 100%;
  padding: var(--sp-2) 0;
  border: 0;
  border-bottom: 1.5px solid var(--rule-strong);
  border-radius: 0;
  background: transparent;
  color: var(--ink-strong);
  font-family: var(--face-data);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  transition: border-color var(--move);
}

.cells:hover { border-bottom-color: var(--ink-faint); }
.cells:focus {
  outline: none;
  border-bottom-color: var(--seal);
}
.cells::placeholder { color: var(--ink-faint); opacity: 0.55; }

.cells-code {
  font-size: clamp(2rem, 5.5vw, 2.875rem);
  letter-spacing: 0.06em;
}

.cells-password {
  font-size: clamp(1.5rem, 3.5vw, 1.875rem);
  letter-spacing: 0.34em;
  text-transform: uppercase;
  /* Six characters plus the trailing letter-space each one carries;
     without the allowance the sixth character is clipped. */
  width: calc(6ch + 6 * 0.34em);
}

.entry-split .input { margin-bottom: 0.35rem; }

/*
 * Deliberately not red. Seal red means "control of a machine is
 * currently released to someone else" and nothing else — spending it on
 * a mistyped password would make the one colour that must be
 * unmistakable into ordinary interface noise. A wrong password is an
 * ordinary event; the words carry it.
 */
.notice {
  margin: 0;
  padding: var(--sp-3);
  background: var(--stock-sunk);
  border-left: 1px solid var(--rule-strong);
  color: var(--ink-strong);
  font-size: var(--t-small);
}

.notice[hidden] { display: none; }

/* The primary action sits where a signature goes on a form. */
.signature {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--rule);
}

.signature-note {
  margin: 0;
  flex: 1 1 18rem;
  font-size: var(--t-small);
  color: var(--ink-muted);
  max-width: 42ch;
}

.chain {
  padding-left: var(--sp-5);
  border-left: 1px solid var(--rule);
}

.chain-list {
  list-style: none;
  margin: var(--sp-3) 0 var(--sp-4);
  padding: 0;
  display: grid;
  gap: 0;
}

.chain-list li {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: var(--sp-3);
  align-items: baseline;
  padding-block: var(--sp-3);
  border-bottom: 1px solid var(--rule);
  font-size: var(--t-small);
}

.chain-list li:last-child { border-bottom: 0; }

.chain-num {
  color: var(--ink-faint);
  font-size: var(--t-small);
}

.chain-foot {
  margin: 0;
  font-size: var(--t-small);
  color: var(--ink-muted);
}

/* ------------------------------------------------------------------ *
 * Waiting / ended
 * ------------------------------------------------------------------ */

.view-waiting {
  display: grid;
  place-items: center;
  padding: var(--sp-6);
}

.waiting-body {
  width: min(38rem, 100%);
  display: grid;
  gap: var(--sp-3);
  justify-items: start;
}

.waiting-body h1 { margin-block: var(--sp-1) var(--sp-2); }

.waiting-text {
  color: var(--ink-muted);
  font-size: var(--t-small);
  max-width: 52ch;
}

.waiting-body .btn { margin-top: var(--sp-4); }

/*
 * Three marks advancing left to right at a constant rate — sheet feed,
 * not a spinner. It reports that the request is still open, which is
 * the only thing anyone can know while a person decides.
 */
.waiting-feed {
  display: flex;
  gap: 6px;
  margin-block: var(--sp-3);
}

.waiting-feed span {
  width: 22px;
  height: 2px;
  background: var(--rule-strong);
  animation: feed 1.5s steps(1, end) infinite;
}

.waiting-feed span:nth-child(2) { animation-delay: 0.5s; }
.waiting-feed span:nth-child(3) { animation-delay: 1s; }

@keyframes feed {
  0%, 33% { background: var(--ink-muted); }
  34%, 100% { background: var(--rule-strong); }
}

.ended-summary {
  margin: var(--sp-3) 0 0;
  width: min(28rem, 100%);
}

/* ------------------------------------------------------------------ *
 * Session
 * ------------------------------------------------------------------ */

.view-session {
  position: relative;
  background: #000;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
  cursor: none;
}

.overlay {
  position: absolute;
  inset-inline: 0;
  bottom: 18%;
  display: grid;
  gap: var(--sp-2);
  justify-items: center;
  text-align: center;
  padding-inline: var(--sp-5);
  pointer-events: none;
}

.overlay[hidden] { display: none; }

/*
 * The toolbar floats over arbitrary remote pixels, so a backdrop blur
 * here is a legibility mechanism rather than a finish: without it the
 * readouts become unreadable whenever the client opens a light window.
 */
.toolbar {
  position: absolute;
  top: 0;
  inset-inline: 0;
  z-index: 20;
  padding: var(--sp-2) var(--sp-4) var(--sp-3);
  background: color-mix(in srgb, var(--stock) 86%, transparent);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-bottom: 1px solid var(--rule);
  transform: translateY(0);
  transition: transform var(--move);
}

.toolbar[data-open='false'] {
  transform: translateY(calc(-100% + 8px));
}

.toolbar-grip {
  position: absolute;
  inset-inline: 0;
  bottom: -12px;
  height: 12px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  flex-wrap: wrap;
}

.toolbar-identity {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.session-host {
  font-weight: 600;
  color: var(--ink-strong);
  font-size: var(--t-small);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 22ch;
}

.session-code {
  font-size: var(--t-micro);
  color: var(--ink-faint);
  letter-spacing: 0.05em;
}

.readout {
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  margin: 0;
  flex-wrap: wrap;
}

.readout > div { display: grid; gap: 0; }

.readout dt {
  font-size: var(--t-micro);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.readout dd {
  margin: 0;
  font-size: var(--t-small);
  color: var(--ink-strong);
  /* Fixed width per readout: a ticking timer or a moving latency value
     must never shift the controls beside it. */
  min-width: 5.5ch;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-left: auto;
}

/* ------------------------------------------------------------------ *
 * Popovers
 *
 * Fixed-positioned so they escape the toolbar rather than being
 * clipped by it.
 * ------------------------------------------------------------------ */

.pop {
  position: fixed;
  z-index: 40;
  min-width: 14rem;
  padding: var(--sp-2);
  background: var(--stock-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  display: grid;
  gap: 1px;
}

.pop[hidden] { display: none; }
.pop-wide { min-width: 24rem; gap: var(--sp-2); padding: var(--sp-3); }

.pop-item {
  appearance: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  width: 100%;
  padding: 0.4375rem var(--sp-2);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-strong);
  font: inherit;
  font-size: var(--t-small);
  text-align: left;
  cursor: pointer;
  transition: background var(--move);
}

.pop-item:hover { background: var(--stock-sunk); }
.pop-item[aria-checked='true'] { color: var(--ink-strong); font-weight: 600; }
.pop-item[aria-checked='true']::after { content: '·'; color: var(--seal); font-weight: 700; }

.pop-hint {
  color: var(--ink-faint);
  font-size: var(--t-micro);
  white-space: nowrap;
}

.pop-note {
  margin: 0;
  padding: var(--sp-2);
  font-size: var(--t-micro);
  color: var(--ink-muted);
  max-width: 40ch;
}

.pop-note-top { padding-top: 0; }

.pop-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
}

.clip-text {
  font-family: var(--face-data);
  font-size: var(--t-small);
  resize: vertical;
}

/* ------------------------------------------------------------------ *
 * Narrow screens
 *
 * Structural, not fluid: the sheet becomes one column and the toolbar
 * sheds its readouts rather than shrinking its type.
 * ------------------------------------------------------------------ */

@media (max-width: 900px) {
  .sheet {
    grid-template-columns: 1fr;
    gap: var(--sp-5);
    padding-inline: var(--sp-4);
  }

  .chain {
    padding-left: 0;
    padding-top: var(--sp-4);
    border-left: 0;
    border-top: 1px solid var(--rule);
  }

  .entry-split { grid-template-columns: 1fr; align-items: start; }
  .masthead { padding-inline: var(--sp-4); }
}

@media (max-width: 720px) {
  .readout > div:nth-child(n + 3) { display: none; }
  .toolbar-row { gap: var(--sp-3); }
  .session-host { max-width: 14ch; }
}
