/* lab / instrument — page chrome follows the portfolio theme;
   the instrument plate is permanently avionics-night. */

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/plexmono-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/plexmono-600.woff2") format("woff2");
}

:root {
  /* themed page tokens (portfolio system) */
  --ground: #f3f5f6;
  --ink: #171a1e;
  --muted: #5a6470;
  --line: #d9dee1;
  --accent: #b03d00;
  /* fixed panel tokens — never themed */
  --plate: #14171b;
  --plate-ink: #e6e9ea;
  --plate-muted: #8b939c;
  --signal: #ff8a50;
  /* the plate's seat on the page: hairline edge in light, none in dark */
  --plate-edge: #d9dee1;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --pad: max(clamp(1.25rem, 5vw, 3rem), calc((100% - 60rem) / 2));
  color-scheme: light;
}
[data-theme="dark"] {
  --ground: #14171b;
  --ink: #e6e9ea;
  --muted: #8b939c;
  --line: #2a2f35;
  --accent: #ff8a50;
  --plate-edge: transparent;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #14171b;
    --ink: #e6e9ea;
    --muted: #8b939c;
    --line: #2a2f35;
    --accent: #ff8a50;
    --plate-edge: transparent;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.9375rem;
  line-height: 1.65;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration-color: var(--muted); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: var(--accent); }

:is(a, button, [tabindex="0"]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1.5rem var(--pad);
}
.wordmark {
  font-weight: 600;
  letter-spacing: 0.08em;
  text-decoration: none;
}
.wordmark .slash { color: var(--accent); }

#theme-toggle {
  font: inherit;
  font-size: 0.8125rem;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0.1rem 0.2rem;
  cursor: pointer;
  text-decoration: underline dotted; /* it's a control, not a status label */
  text-underline-offset: 0.2em;
}
#theme-toggle:hover { color: var(--ink); }

main { flex: 1; padding: 0 var(--pad) 2rem; }

/* ---- panel ---- */

.panel-wrap { display: flex; flex-direction: column; align-items: center; }

.panel {
  background: var(--plate);
  border: 1px solid var(--plate-edge);
  border-radius: 8px;
  padding: clamp(1rem, 3.5vw, 1.25rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  touch-action: pan-y;
  cursor: default;
  max-width: 100%;
  -webkit-user-select: none;
  user-select: none; /* stick drags must not select the readout */
}
.panel.man { touch-action: none; }

.gauges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(0.75rem, 2.5vw, 1.25rem);
}
.gauges canvas {
  display: block;
  width: min(78vw, 280px);
  aspect-ratio: 1;
}
/* from 768px the three gauges hold one row (the basic-T top row), sized
   fluidly; the 13rem budget covers page/panel chrome (178px) plus a classic
   space-taking scrollbar, so the row holds even on Windows. Below 768px,
   a deliberate hugging column. */
@media (min-width: 768px) {
  .gauges canvas { width: min(calc((100vw - 13rem) / 3), 280px); }
}
@media (max-width: 767px) {
  .gauges { flex-direction: column; }
}

.readout {
  margin: 0;
  color: var(--plate-ink);
  font-size: clamp(0.6875rem, 2.9vw, 0.8125rem); /* 13px caps it at gauge width */
  letter-spacing: 0.02em;
  white-space: pre;
}
.readout .flag {
  color: var(--signal);
  font-weight: 600;
}

.panel-controls {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}
.panel-controls button {
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink);
  background: none;
  border: 1px solid var(--muted);
  border-radius: 4px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
}
.panel-controls button:hover { border-color: var(--ink); }

.hint {
  color: var(--muted);
  font-size: 0.8125rem;
  margin: 0.75rem 0 0;
  text-align: center;
}
.hint span { white-space: nowrap; } /* wrap between commands, never inside */

.explainer {
  color: var(--muted);
  max-width: 34rem;
  margin: 2.5rem auto 0;
}

.site-footer {
  padding: 1.5rem var(--pad) 2rem;
  color: var(--muted);
  font-size: 0.8125rem;
}
.site-footer p { margin: 0; }

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