/* Rangekeeper.
 *
 * A byte carries its own shell, so this file sets the page frame as well as
 * the machine's own surfaces. Measures in rem, never ch.
 */

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Set --machine, never --accent.
 *
 * logical-art.css computes `body { --accent: var(--machine, var(--la-instrument)) }`,
 * so declaring --accent here on :root is overridden for everything inside
 * body and the whole page silently renders in the fallback grey, #bdbdbd.
 * That is the trap the canon warns about in as many words, and it cost a
 * measurement to find because the rule was present and the colour was not.
 * The accent is the roster's value for rangekeeper. */
body[data-machine="rangekeeper"] { --machine: #c9a227; }

body {
  font-family: var(--la-font-ui);
  background: var(--la-page);
  color: var(--la-ink);
  line-height: var(--la-leading-body);
  -webkit-font-smoothing: antialiased;
}

.rk-main {
  max-width: var(--la-measure);
  margin: 0 auto;
  padding: 3rem 1.25rem 3rem;
}

.rk-head { margin-bottom: var(--la-space-6); }

.rk-lede {
  margin-top: var(--la-space-3);
  color: var(--la-ink-dim);
}

.rk-sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.rk-panel {
  margin-top: var(--la-space-6);
  padding: var(--la-space-4);
  border: 1px solid var(--la-hairline-strong);
  border-radius: var(--la-radius, 6px);
  background: color-mix(in srgb, var(--la-ink) 3%, transparent);
}

.rk-panel h2 { margin-bottom: var(--la-space-2); }

.rk-hint, .rk-note {
  color: var(--la-ink-dim);
  font-size: var(--la-text-sm);
  margin-top: var(--la-space-2);
}

/* ---- knobs ------------------------------------------------------------ */

.rk-knobs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--la-space-3) var(--la-space-4);
  margin-top: var(--la-space-4);
}

.rk-knob label {
  display: block;
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  color: var(--la-ink-dim);
  margin-bottom: var(--la-space-2);
}

.rk-value { color: var(--accent); }

.rk-range {
  width: 100%;
  accent-color: var(--accent);
  min-height: 1.5rem;
}

.rk-range:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---- the passes ------------------------------------------------------- */

.rk-passes {
  width: 100%;
  margin-top: var(--la-space-4);
  border-collapse: collapse;
  font-size: var(--la-text-sm);
}

.rk-passes th {
  text-align: right;
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  font-weight: 400;
  color: var(--la-ink-dim);
  padding: 0 0 var(--la-space-2) var(--la-space-2);
  border-bottom: 1px solid var(--la-hairline-strong);
}

.rk-passes th:first-child { text-align: left; }

.rk-passes td {
  text-align: right;
  padding: var(--la-space-2) 0 var(--la-space-2) var(--la-space-2);
  border-bottom: 1px solid var(--la-hairline);
  color: var(--la-ink);
}

.rk-passes td:first-child { text-align: left; color: var(--la-ink-dim); }

/* The last pass is the answer: it stops being a guess. */
.rk-passes tbody tr:last-child td { color: var(--accent); }

.rk-num { font-family: var(--la-font-mono); }

/* ---- the readout ------------------------------------------------------ */

.rk-readout {
  margin-top: var(--la-space-4);
  border-top: 1px solid var(--la-hairline);
}

.rk-row {
  display: grid;
  grid-template-columns: 14rem 1fr;
  gap: var(--la-space-3);
  padding: var(--la-space-2) 0;
  border-bottom: 1px solid var(--la-hairline);
}

.rk-row dt {
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  color: var(--la-ink-dim);
}

.rk-row dd {
  font-size: var(--la-text-sm);
  color: var(--la-ink);
  overflow-wrap: anywhere;
}

.rk-strong dd { color: var(--accent); font-weight: 600; }

.rk-why { margin-top: var(--la-space-6); }
.rk-why h2 { margin-top: var(--la-space-5); margin-bottom: var(--la-space-2); }
.rk-why p { margin-top: var(--la-space-3); color: var(--la-ink-dim); }

@media (max-width: 34rem) {
  .rk-row { grid-template-columns: 1fr; }
  .rk-row dt { color: var(--la-ink-faint); }
}

/* ---- buttons ------------------------------------------------------------
 *
 * The first version of this page had only sliders, so these did not exist and
 * the parts bench shipped with browser-default buttons jammed together. Caught
 * by looking at it, which no gate here does. */

.rk-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--la-space-2);
  margin-top: var(--la-space-3);
}

.rk-btn {
  font-family: var(--la-font-mono);
  font-size: var(--la-text-sm);
  color: var(--la-ink);
  background: color-mix(in srgb, var(--la-ink) 6%, transparent);
  border: 1px solid var(--la-hairline-strong);
  border-radius: var(--la-radius, 6px);
  padding: 0.4em 0.9em;
  cursor: pointer;
  /* 2.5.8 asks for 24 CSS pixels. */
  min-height: 2.25rem;
  min-width: 2.25rem;
}

.rk-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.rk-btn[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.rk-btn:disabled { opacity: 0.45; cursor: default; }

.rk-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---- section nav -------------------------------------------------------- */

.rk-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--la-space-3);
  margin-top: var(--la-space-4);
  padding-bottom: var(--la-space-3);
  border-bottom: 1px solid var(--la-hairline);
  font-family: var(--la-font-mono);
  font-size: var(--la-text-sm);
}

.rk-nav a { color: var(--la-ink-dim); }
.rk-nav a:hover { color: var(--accent); }

/* ---- the parts list ----------------------------------------------------- */

.rk-parts {
  margin-top: var(--la-space-4);
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: var(--la-space-3);
}

.rk-part {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: var(--la-space-3);
  border: 1px solid var(--la-hairline);
  border-left: 3px solid var(--accent);
  border-radius: var(--la-radius, 6px);
  background: color-mix(in srgb, var(--la-ink) 3%, transparent);
}

.rk-part-name { color: var(--la-ink); font-weight: 600; }
.rk-part-sub {
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  color: var(--accent);
}
.rk-part-does { font-size: var(--la-text-sm); color: var(--la-ink-dim); }
.rk-part-quote {
  font-size: var(--la-text-xs);
  color: var(--la-ink-faint);
  border-top: 1px solid var(--la-hairline);
  padding-top: 0.4rem;
  margin-top: 0.2rem;
}

/* ---- a bench ------------------------------------------------------------ */

.rk-bench {
  margin-top: var(--la-space-5);
  padding-top: var(--la-space-4);
  border-top: 1px solid var(--la-hairline-strong);
}

.rk-bench-head { color: var(--la-ink); }

.rk-bench-sub {
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  font-weight: 400;
  color: var(--accent);
}

/* ---- the cam profile ---------------------------------------------------- */

.rk-camprofile {
  position: relative;
  height: 4rem;
  margin-top: var(--la-space-3);
  border: 1px solid var(--la-hairline-strong);
  border-radius: var(--la-radius, 6px);
  background: color-mix(in srgb, var(--la-ink) 4%, transparent);
  overflow: hidden;
}

.rk-cam-row, .rk-cam-follower {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--x, 0%);
}

.rk-cam-row {
  width: 1px;
  background: color-mix(in srgb, var(--la-ink) 25%, transparent);
}

.rk-cam-follower {
  width: 3px;
  margin-left: -1px;
  background: var(--accent);
}

/* ---- the servo bar ------------------------------------------------------ */

.rk-servobar {
  position: relative;
  height: 2.2rem;
  margin-top: var(--la-space-3);
  border: 1px solid var(--la-hairline-strong);
  border-radius: var(--la-radius, 6px);
  background: color-mix(in srgb, var(--la-ink) 4%, transparent);
  overflow: hidden;
}

.rk-servo-demand, .rk-servo-shaft {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--x, 0%);
  width: 3px;
  margin-left: -1px;
}

.rk-servo-demand { background: color-mix(in srgb, var(--la-ink) 40%, transparent); }
.rk-servo-shaft { background: var(--accent); }

/* ---- the shafts --------------------------------------------------------- */

.rk-shafts {
  margin-top: var(--la-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--la-space-2);
}

.rk-shaft {
  display: grid;
  grid-template-columns: 9rem 1fr 7rem;
  gap: var(--la-space-2);
  align-items: center;
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
}

.rk-shaft-label { color: var(--la-ink-dim); }
.rk-shaft-value { text-align: right; color: var(--la-ink); }

.rk-shaft-track {
  position: relative;
  height: 0.9rem;
  border: 1px solid var(--la-hairline);
  border-radius: 2px;
  background: color-mix(in srgb, var(--la-ink) 4%, transparent);
  overflow: hidden;
}

.rk-shaft-pip {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--x, 0%);
  width: 3px;
  margin-left: -1px;
  background: color-mix(in srgb, var(--la-ink) 45%, transparent);
}

/* The two shafts that carry the ANSWER, as opposed to the two that carry
   where the target is now. Marked so the lead is visible as a gap. */
.rk-shaft[data-lead="yes"] .rk-shaft-pip { background: var(--accent); }
.rk-shaft[data-lead="yes"] .rk-shaft-value { color: var(--accent); }

@media (max-width: 34rem) {
  .rk-shaft { grid-template-columns: 1fr; gap: 0.15rem; }
  .rk-shaft-value { text-align: left; }
}

/* The spotting table. */
.rk-salvos { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: var(--la-text-sm); }
.rk-salvos th, .rk-salvos td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--la-hairline); }
.rk-salvos th { font-size: var(--la-text-xs); letter-spacing: 0.05em; text-transform: uppercase; color: var(--la-ink-dim); font-weight: 600; }
.rk-salvos td { font-family: var(--la-font-mono); font-size: 0.8rem; color: var(--la-ink-dim); font-variant-numeric: tabular-nums; }
.rk-salvos tr[data-sense="straddle"] td { color: var(--accent); }
.rk-salvos tr[data-sense="straddle"] td:first-child { border-left: 3px solid var(--accent); padding-left: 0.45rem; }
.rk-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- how small the target really is ------------------------------------- */

/* Short, hit and over are carried by the word in the last column. The rule
   down the side is a second, non-colour channel for the ones that hit. */
.rk-salvos tr[data-result="hit"] td { color: var(--accent); }
.rk-salvos tr[data-result="hit"] th {
    border-left: 3px solid var(--accent);
    padding-left: 0.45rem;
}
