/*
 * The config page. Dark and monospace throughout, because the thing being
 * configured is a red-on-black LED sign and the preview should not sit in the
 * middle of a white page pretending otherwise.
 */

:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --panel: #161a20;
  --line: #262c35;
  --text: #e6e9ef;
  --muted: #8b95a5;
  --bad: #ff8080;
  --good: #7fd88f;
  --accent: #ff2d2d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 24px 16px 64px;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
}

main {
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
}

header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.vitals {
  color: var(--muted);
  font-size: 0.78rem;
}

.vitals.stale {
  color: var(--bad);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

label.inline {
  display: inline;
  margin: 0;
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  background: #0b0d10;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
  line-height: 1.5;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #3b4657;
  outline-offset: 1px;
}

button {
  margin-top: 14px;
  width: 100%;
  padding: 9px 12px;
  background: var(--text);
  color: #0d0f12;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.narrow {
  width: auto;
  margin: 0;
}

/* --- tabs ---------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tabs button {
  width: auto;
  margin: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 400;
}

.tabs button.on {
  background: var(--line);
  color: var(--text);
}

/* --- the preview --------------------------------------------------------- */

/*
 * The canvas is the panel's real 64x32 and is scaled up by CSS with nearest
 * neighbour, so a pixel on the sign is a square here and nothing is invented in
 * between. The gradient overlay draws the gaps between the LEDs.
 */
.panel-frame {
  position: relative;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  overflow: hidden;
}

.panel-frame canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  image-rendering: pixelated;
}

.panel-frame::after {
  content: "";
  position: absolute;
  inset: 10px;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to right,
      rgba(0, 0, 0, 0.45) 0 1px,
      transparent 1px calc(100% / 64)
    ),
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.45) 0 1px,
      transparent 1px calc(100% / 32)
    );
}

.panel-frame.dead {
  opacity: 0.35;
}

/* --- rows, chips, status ------------------------------------------------- */

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.row select {
  width: auto;
  flex: 0 1 14rem;
}

.grow {
  flex: 1;
}

.chip {
  width: auto;
  margin: 0;
  padding: 3px 9px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}

.chip.on {
  background: var(--line);
  color: var(--text);
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.hash {
  color: var(--muted);
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.status {
  margin-top: 10px;
  min-height: 1.4em;
  font-size: 0.78rem;
  color: var(--muted);
}

.status.error {
  color: var(--bad);
}

.status.ok {
  color: var(--good);
}

/*
 * Problems carry the path of the field they are about, because they come from
 * the same validator the worker rejects with. Notes are softer: a missing var
 * still draws.
 */
.problems {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-size: 0.78rem;
}

.problems li {
  padding: 3px 0 3px 10px;
  border-left: 2px solid var(--bad);
  color: var(--bad);
  margin-bottom: 3px;
}

.problems li.note {
  border-left-color: var(--muted);
  color: var(--muted);
}

.problems li .path {
  color: var(--text);
  margin-right: 6px;
}

/* --- the schedule builder ------------------------------------------------- */

/*
 * One row per schedule entry: which scene, for how long, and when it is
 * eligible. The raw JSON is still there under a fold, but it should not be how
 * you say "play the clock, always".
 */
.entries {
  list-style: none;
  margin: 0;
  padding: 0;
}

.entry {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
  background: #0b0d10;
}

.entry .line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.entry .line + .line {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.entry select {
  width: auto;
  flex: 1 1 12rem;
  min-width: 0;
}

.entry .move {
  margin-left: auto;
}

input.short {
  width: auto;
  flex: 0 1 12rem;
}

input.tiny {
  width: auto;
  flex: 0 0 6rem;
}

label.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

label.check input {
  width: auto;
}

.days {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.days label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
}

.days label:has(input:checked) {
  background: var(--line);
  color: var(--text);
}

.days input {
  width: auto;
  margin: 0;
}

.tiny-button {
  width: auto;
  margin: 0;
  padding: 2px 9px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.tiny-button:hover:not(:disabled) {
  color: var(--text);
}

.settings {
  gap: 10px;
}

.revisions {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-size: 0.78rem;
}

.revisions li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.revisions button {
  width: auto;
  margin: 0;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 400;
}

details summary {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
}

.spec {
  margin: 12px 0 0;
  padding: 12px;
  max-height: 60vh;
  overflow: auto;
  background: #0b0d10;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.hidden {
  display: none;
}
