/* Spaceship IDE's style 01, "instrument" (extra/style-1.html in github.com/chuanqisun/spaceship;
   MIT, see builder/THIRD_PARTY_LICENSES.md), shared by the field monitor and the link builder.
   No accent color. Hierarchy comes from five steps of white ink and two stroke weights only;
   whatever the hand touches goes to full white and everything else steps back. Three sizes:
   12/20 body, 10/14 labels and readouts, 9 numerals. Influence reads in font weight alone.
   Motion: 120ms linear for hover, links and dimming; 200ms for weight; 300ms for a measured
   value; 600ms out-expo only for a knob travelling to where it lands. */

@property --fill { syntax: "<number>"; inherits: false; initial-value: 0; }
@property --spin { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

:root {
  color-scheme: dark;
  --bg: #000;
  --ink: #fff;
  --ink-2: rgb(255 255 255 / 0.64);
  --ink-3: rgb(255 255 255 / 0.4);
  --ink-4: rgb(255 255 255 / 0.22);
  --ink-5: rgb(255 255 255 / 0.1);
  --shade-1: rgb(255 255 255 / 0.06);
  --shade-2: rgb(255 255 255 / 0.1);
  --shade-3: rgb(255 255 255 / 0.15);
  --shade-4: rgb(255 255 255 / 0.21);
  --shade-5: rgb(255 255 255 / 0.28);
  --hair: 1px;
  --stroke: 1.5px;
  --fs: 12px;
  --fs-s: 10px;
  --fs-xs: 9px;
  --lh: 20px;
  --gap: 8px;
  --knob: 16px;
  --knob-future: 14px;
  --dash: 3 3;
  --fast: 120ms;
  --settle: 300ms;
  --pin: 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --lightest: 200;
  --boldest: 800;
  --tray-height: 18px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg);
  color: var(--ink);
  font: var(--fs) / var(--lh) var(--mono);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

html, body { background: var(--bg); }
body {
  margin: 0;
  /* set on body too: an artifact's page skeleton gives body its own system font */
  font: var(--fs) / var(--lh) var(--mono);
  color: var(--ink);
  overflow-x: clip;
  padding-block: 0 calc(var(--tray-height) + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
h1, h2, h3, p { margin: 0; font: inherit; }
a { color: var(--ink); text-underline-offset: 3px; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: var(--hair) solid var(--ink); outline-offset: 3px; }
::selection { background: var(--shade-4); }
.dim { color: var(--ink-3); }
.note { font-size: var(--fs-s); line-height: 16px; color: var(--ink-3); max-width: 64ch; }

/* ------------------------------------------------------------------ style 01 controls */
button.text {
  justify-self: start;
  min-height: 24px; padding: 2px 8px;
  border: var(--hair) solid var(--ink-4); background: none; color: var(--ink-2);
  font: inherit; cursor: pointer;
  transition: color var(--fast) linear, border-color var(--fast) linear;
}
button.text:hover { color: var(--ink); border-color: var(--ink-2); }
button.text:active, button.text[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
fieldset.choice { display: flex; flex-wrap: wrap; gap: 0; margin: 0; padding: 0; border: none; min-width: 0; }
fieldset.choice legend { padding: 0 0 6px; color: var(--ink-3); font-size: var(--fs-s); }
fieldset.choice label { position: relative; padding: 2px 8px; border: var(--hair) solid var(--ink-4); margin-left: -1px; color: var(--ink-2); cursor: pointer; transition: color var(--fast) linear, border-color var(--fast) linear; }
fieldset.choice label:first-of-type { margin-left: 0; }
fieldset.choice label:has(:checked) { background: var(--ink); color: var(--bg); border-color: var(--ink); }
fieldset.choice label:hover:not(:has(:checked)) { color: var(--ink); border-color: var(--ink-2); }
fieldset.choice label:has(:focus-visible) { outline: var(--hair) solid var(--ink); outline-offset: 2px; }
fieldset.choice input { position: absolute; opacity: 0; pointer-events: none; }
dl.readouts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; }
dl.readouts dt { color: var(--ink-3); }
dl.readouts dd { margin: 0; text-align: end; }
.bar { position: relative; height: 3px; margin-top: 4px; background: var(--ink-5); }
.bar i { position: absolute; inset: 0 auto 0 0; width: calc(var(--v, 0) * 100%); background: var(--ink); transition: width var(--fast) linear; }
/* a state that needs the hand: the inverted name, ink plate and page-colored text */
.flag { display: inline-block; padding: 0 4px; background: var(--ink); color: var(--bg); }
/* something running: one rotating quadrant, 0.9s a turn */
.spinner { display: inline-block; position: relative; width: 10px; height: 10px; vertical-align: -1px; border: var(--hair) solid var(--ink-4); border-radius: 50%; }
.spinner[data-on]::after { content: ""; position: absolute; inset: -1px; border: var(--hair) solid transparent; border-top-color: var(--ink); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { rotate: 1turn; } }

/* ------------------------------------------------------------------ tray: polybar-style modules in one row */
#tray {
  position: fixed; inset: auto 0 0; z-index: 50;
  /* safe: when the modules overflow a narrow screen, they start at the left edge and scroll */
  display: flex; justify-content: safe center; align-items: center;
  min-height: var(--tray-height);
  padding: 0 calc(1.5 * var(--gap)) env(safe-area-inset-bottom, 0px);
  border-top: var(--hair) solid var(--ink-5);
  background: var(--bg); color: var(--ink-3);
  font-size: var(--fs-xs); line-height: var(--tray-height);
  white-space: nowrap; overflow-x: auto; scrollbar-width: none;
}
#tray .zone { display: flex; }
#tray .zone + .zone, #tray .zone + button, #tray .zone + a { border-left: var(--hair) solid var(--ink-5); }
#tray [data-field] { padding-inline: var(--gap); }
#tray [data-field] + [data-field] { border-left: var(--hair) solid var(--ink-5); }
#tray abbr { margin-right: 0.5ch; text-decoration: none; cursor: help; }
#tray b { display: inline-block; margin-left: 0.5ch; font-weight: inherit; color: var(--ink); }
#tray abbr + b { margin-left: 0; }
#tray small { font-size: inherit; color: var(--ink-3); }
#tray .flag { color: var(--bg); padding: 0 3px; }
#tray button, #tray a {
  padding: 0 var(--gap); border: none; border-left: var(--hair) solid var(--ink-5); background: none;
  color: color-mix(in srgb, var(--ink) calc(var(--near, 0) * 100%), var(--ink-2));
  font: inherit; cursor: pointer; text-decoration: none; min-height: var(--tray-height);
}
#tray button:hover, #tray a:hover { color: var(--ink); }
#tray button b { margin-left: 0.5ch; }
#tray #sound-toggle[aria-pressed="false"] { color: var(--ink-4); }

/* ------------------------------------------------------------------ the page pointer: crosshair, ring and pip, alignment ticks */
html[data-cursor="custom"], html[data-cursor="custom"] * { cursor: none !important; }
#cursor {
  --x: -1000px; --y: -1000px;
  --line: var(--ink-5);
  --tick: color-mix(in srgb, var(--ink-2) calc(var(--tn, 0) * 100%), transparent);
  position: fixed; inset: 0; z-index: 1000; overflow: hidden; pointer-events: none;
}
html:not([data-cursor="custom"]) #cursor { display: none; }
#cursor[data-live] { --line: var(--ink-3); --tick: var(--ink); }
#cursor .hairline { position: absolute; top: 0; left: 0; }
/* each hairline leaves a gap around the point for the ring, so the point itself is never covered */
#cursor .vertical { bottom: 0; width: 1px; translate: var(--x) 0; background: linear-gradient(to bottom, var(--line) calc(var(--y) - 11px), transparent 0 calc(var(--y) + 11px), var(--line) 0); }
#cursor .horizontal { right: 0; height: 1px; translate: 0 var(--y); background: linear-gradient(to right, var(--line) calc(var(--x) - 11px), transparent 0 calc(var(--x) + 11px), var(--line) 0); }
#cursor .ring {
  position: absolute; top: 0; left: 0; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border: var(--hair) solid var(--ink-3); border-radius: 50%;
  translate: var(--x) var(--y); transition: border-color var(--fast) linear;
}
#cursor .ring .pip { position: absolute; inset: calc(50% - 1px); border-radius: 50%; background: var(--ink-2); }
#cursor[data-live] .ring { border-color: var(--ink); }
#cursor[data-live] .ring .pip { background: var(--ink); }
#cursor :is(.tick-x, .tick-y) { position: absolute; top: 0; left: 0; background: var(--tick); }
#cursor :is(.tick-x, .tick-y)[hidden] { display: none; }
#cursor .tick-x { width: 1px; height: 9px; margin: -4px 0 0; }
#cursor .tick-y { width: 9px; height: 1px; margin: 0 0 0 -4px; }
#cursor .marks { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#cursor .marks path, #cursor .marks line { fill: none; stroke-width: var(--hair); }
#cursor .corners { stroke: var(--ink-2); }
#cursor .grabbable .corners { stroke: var(--ink); stroke-width: var(--stroke); }
#cursor .tether { stroke: var(--ink-3); stroke-dasharray: var(--dash); }
#cursor :is(.vector, .vector-ticks) { display: none; }
#cursor .readout { position: absolute; top: 0; left: 0; padding: 0 3px; background: var(--bg); white-space: nowrap; font-size: var(--fs-xs); line-height: 12px; color: var(--ink-3); }
#cursor .readout b { font-weight: inherit; color: var(--ink); }
#cursor .readout:empty { display: none; }

/* ------------------------------------------------------------------ map chrome (MapLibre) in ink */
.map-label { font: var(--fs-xs) / 1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; color: var(--ink-2); text-shadow: 0 0 3px #000, 0 0 3px #000; pointer-events: none; }
.maplibregl-ctrl-attrib { background: rgb(0 0 0 / 0.7) !important; font: var(--fs-xs) var(--mono); }
.maplibregl-ctrl-attrib a { color: var(--ink-3) !important; }
.maplibregl-ctrl-group { background: #000 !important; border: var(--hair) solid var(--ink-4); border-radius: 0 !important; }
.maplibregl-ctrl-group button + button { border-top: var(--hair) solid var(--ink-4) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
