/* Zoutay Relay console. Palette from VFR aeronautical charts: chart paper, navy ink, airspace
   magenta; the status board is an ATC flight strip. System fonts only (nothing is fetched). */

:root {
  --paper: #edf1ee;
  --grid: rgba(19, 35, 58, .045);
  --ink: #13233a;
  --ink-2: #4a5a70;
  --line: #c6d0cc;
  --strip: #ffffff;
  --magenta: #9e2a6e;
  --magenta-ink: #ffffff;
  --go: #1f7a4d;
  --warn: #a86b12;
  --stop: #b42318;
  --focus: #1b5fc1;
  --radius-s: 6px;
  --radius-m: 10px;
  --display: "DIN Alternate", "Bahnschrift", "Roboto Condensed", "Arial Narrow", "Helvetica Neue", system-ui, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1726;
    --grid: rgba(228, 235, 243, .035);
    --ink: #e4ebf3;
    --ink-2: #9aa8ba;
    --line: #2a3a52;
    --strip: #15223a;
    --magenta: #e06aae;
    --magenta-ink: #1a0b14;
    --go: #4cc38a;
    --warn: #e5a53a;
    --stop: #f07167;
    --focus: #7fb0ff;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* class display rules must never reveal a hidden view */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 16px/1.5 var(--text);
  color: var(--ink);
  background-color: var(--paper);
  /* a chart graticule, barely there */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1, h2 { font-family: var(--display); font-weight: 700; letter-spacing: .005em; line-height: 1.15; margin: 0; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; margin-bottom: .4rem; }
p { margin: 0; }
.text { color: var(--ink-2); max-width: 62ch; }
.small { font-size: .875rem; }
.hint { color: var(--ink-2); font-size: .875rem; margin-top: .35rem; max-width: 62ch; }
.hint code, .text code { font-family: var(--mono); font-size: .85em; }
.loading, .noscript { padding: 3rem 1rem; text-align: center; color: var(--ink-2); }

/* Non-editable chrome is not selectable or draggable; fields, codes and lists stay copyable. */
.bar, .btn, .brand, .readouts dt, .switch, h1, h2, img { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
img { -webkit-user-drag: none; }

/* ------------------------------------------------------------- top bar */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .6rem 1rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; font-family: var(--display); font-weight: 700; font-size: 1.1rem; }

/* ------------------------------------------------------------- controls */
label { display: block; font-weight: 600; font-size: .9rem; margin: .9rem 0 .3rem; }
input:not([type=checkbox]) {
  width: 100%; min-height: 44px; padding: .55rem .7rem;
  font: inherit; color: var(--ink);
  background: var(--strip); border: 1px solid var(--line); border-radius: var(--radius-s);
}
input:focus-visible, .btn:focus-visible, .switch input:focus-visible + .track { outline: 3px solid var(--focus); outline-offset: 2px; }
input[aria-invalid=true] { border-color: var(--stop); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .5rem 1rem;
  font: 600 .95rem var(--text); color: var(--ink); text-decoration: none;
  background: var(--strip); border: 1px solid var(--line); border-radius: var(--radius-s);
  cursor: pointer;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--magenta); color: var(--magenta-ink); border-color: var(--magenta); }
.btn.danger { color: var(--stop); border-color: color-mix(in srgb, var(--stop) 45%, var(--line)); }
.btn.quiet { background: transparent; border-color: transparent; }
.btn.quiet:hover { border-color: var(--line); }
.btn.small { min-height: 36px; padding: .3rem .75rem; font-size: .875rem; }
.btn.wide { width: 100%; margin-top: 1rem; }
.form-error { color: var(--stop); font-size: .9rem; margin-top: .7rem; }

/* ------------------------------------------------------------- sign-in and first password */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.gate-card {
  width: min(400px, 100%);
  background: var(--strip); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 1.75rem 1.5rem 1.5rem;
}
.gate-icon { display: block; margin-bottom: 1rem; border-radius: 9px; }
.gate .lede { color: var(--ink-2); margin: .4rem 0 .5rem; }

/* ------------------------------------------------------------- console layout */
.console { max-width: 1120px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.columns { display: grid; gap: 1.25rem; margin-top: 1.25rem; }
.col { display: grid; gap: 1.25rem; align-content: start; }
@media (min-width: 900px) {
  .columns { grid-template-columns: 1.15fr 1fr; }
}
.panel {
  background: var(--strip); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 1.25rem; min-width: 0;
}
.panel > .btn, .panel > a.btn { margin-top: 1rem; }
.foot { color: var(--ink-2); font-size: .8rem; margin-top: 2rem; text-align: center; }

/* ------------------------------------------------------------- the flight strip (status) */
.strip {
  display: grid; grid-template-columns: 14px 1fr;
  background: var(--strip); border: 1px solid var(--line); border-radius: var(--radius-s);
  overflow: hidden;
}
.strip-band { background: var(--ink-2); }
.strip[data-state=online] .strip-band { background: var(--go); }
.strip[data-state=idle] .strip-band { background: var(--warn); }
.strip[data-state=down] .strip-band { background: var(--stop); }
.strip-body { padding: 1rem 1.25rem 1.1rem; }
.strip h1 { font-size: 1.6rem; }
.strip-sub { color: var(--ink-2); margin-top: .2rem; }
.readouts { display: grid; grid-template-columns: repeat(2, 1fr); margin: 1rem 0 0; border-top: 1px dashed var(--line); }
.readouts > div { padding: .6rem .75rem .2rem 0; border-right: 1px dashed var(--line); }
.readouts > div:nth-child(2n) { border-right: 0; padding-left: .75rem; }
.readouts dt { font-size: .8rem; color: var(--ink-2); }
.readouts dd { margin: 0; font: 700 1.9rem/1.1 var(--display); font-variant-numeric: tabular-nums; }
@media (min-width: 640px) {
  .readouts { grid-template-columns: repeat(4, 1fr); }
  .readouts > div, .readouts > div:nth-child(2n) { border-right: 1px dashed var(--line); padding: .6rem .75rem .2rem; }
  .readouts > div:first-child { padding-left: 0; }
  .readouts > div:last-child { border-right: 0; }
}

/* ------------------------------------------------------------- relay code */
.inline { display: flex; gap: .5rem; }
.inline input { flex: 1; min-width: 0; }
.code-box {
  margin-top: 1rem; padding: .85rem; border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--paper) 70%, var(--strip)); border: 1px solid var(--line);
}
.code { display: block; font: .95rem/1.45 var(--mono); word-break: break-all; color: var(--ink); }
.code.masked { color: var(--ink-2); letter-spacing: .04em; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.cmd { margin-top: 1rem; }
.cmd .code { margin: .3rem 0 .5rem; padding: .6rem .7rem; background: var(--paper); border-radius: var(--radius-s); border: 1px solid var(--line); }
.danger-row { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }

.facts { margin: .8rem 0 0; display: grid; gap: .6rem; }
.facts dt { font-size: .8rem; color: var(--ink-2); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.fp { font: .78rem/1.4 var(--mono); }

/* ------------------------------------------------------------- lists */
.list { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .5rem; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: .7rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-s);
}
.list .what { min-width: 0; flex: 1 1 14rem; }
.list .name { font-weight: 600; overflow-wrap: anywhere; }
.list .meta { color: var(--ink-2); font-size: .85rem; }
.list .tag { display: inline-block; font-size: .75rem; font-weight: 600; color: var(--go); margin-left: .4rem; }
.list .row-actions { display: flex; gap: .4rem; }
.empty { color: var(--ink-2); margin-top: .75rem; }

/* ------------------------------------------------------------- switch */
.switch-row { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.switch { display: flex; align-items: center; gap: .75rem; margin: 0; font-weight: 600; cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track { flex: none; width: 44px; height: 26px; border-radius: 13px; background: var(--line); position: relative; transition: background .15s; }
.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--strip); transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--magenta); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:disabled + .track { opacity: .5; }

/* ------------------------------------------------------------- dialogs and toast */
dialog {
  width: min(440px, calc(100vw - 2rem)); padding: 1.4rem;
  color: var(--ink); background: var(--strip); border: 1px solid var(--line); border-radius: var(--radius-m);
}
dialog::backdrop { background: rgba(10, 18, 30, .45); }
dialog h2 { font-size: 1.3rem; }
dialog .text { margin-top: .4rem; }
.dlg-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 2rem); padding: .7rem 1rem; border-radius: var(--radius-s);
  background: var(--ink); color: var(--paper); font-weight: 600; z-index: 20;
}
.toast[data-kind=error] { background: var(--stop); color: #fff; }

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