/* the lobby — a switch panel, not a dashboard.
 *
 * The subject is marine instrumentation: this is a panel of breakers, one per
 * client, thrown by hand. Dark gunmetal by default because that is what an
 * instrument panel is; a brushed-aluminium daylight variant because the
 * operator is often outdoors in the Caribbean and a dark screen in that sun is
 * unreadable.
 *
 * Flat surfaces and hairline separators throughout. The only gradient in the
 * file is the lamp lens, which is the one place light physically belongs.
 *
 * No @font-face, no @import, no url() to anywhere. The CSP forbids it and the
 * VPS must never make an outbound request to render a page.
 */

:root {
  --panel:        #171b1f;
  --raised:       #1e2429;
  --raised-hi:    #252c32;
  --etch:         #2c343b;
  --etch-strong:  #3a444c;
  --ink:          #e8edf0;
  --label:        #93a2ad;
  --label-dim:    #6c7a85;

  --lamp-live:    #3ea76a;
  --lamp-warn:    #d99a2b;
  --lamp-bad:     #c4553d;
  --lamp-off:     #2a3138;

  --focus:        #6fb2d2;

  --gap:          1rem;
  --radius:       3px;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono",
          "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* Daylight panel: brushed aluminium. Same layout, same lamps, inverted ground. */
@media (prefers-color-scheme: light) {
  :root {
    --panel:       #d9dcde;
    --raised:      #eceeef;
    --raised-hi:   #f6f7f8;
    --etch:        #c2c7cb;
    --etch-strong: #a8b0b6;
    --ink:         #14181b;
    --label:       #4d585f;
    --label-dim:   #6e7981;
    --lamp-off:    #b9c0c5;
    --focus:       #1c6a91;
  }
}

* { box-sizing: border-box; }

html {
  background: var(--panel);
  /* Keeps the panel colour under the notch and past the scroll ends. */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: clamp(1rem, 4vw, 2.5rem) clamp(0.75rem, 4vw, 2rem) 3rem;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.5;
}

.panel { max-width: 34rem; margin: 0 auto; }
.panel--wide { max-width: 44rem; }

/* --- masthead ------------------------------------------------------------ */
/* A stencilled panel legend. The one place with an engraved treatment; body
 * text stays flat so it survives a cheap phone screen in bad light. */

.masthead {
  border-bottom: 1px solid var(--etch);
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
}

.wordmark {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: light) {
  .wordmark { text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7); }
}

.legend {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--label-dim);
  letter-spacing: 0.02em;
}

/* --- client rows --------------------------------------------------------- */

.clients { display: flex; flex-direction: column; gap: 0.75rem; }

.client {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "id     switch"
    "meta   meta";
  gap: 0.75rem var(--gap);
  align-items: center;
  padding: var(--gap);
  background: var(--raised);
  border: 1px solid var(--etch);
  border-radius: var(--radius);
}

.client--dead { opacity: 0.72; }

.client__id {
  grid-area: id;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.client__names { min-width: 0; }

.client__name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.client__domain {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--label);
  overflow-wrap: anywhere;
}

.client__meta { grid-area: meta; min-width: 0; }

/* --- the lamp ------------------------------------------------------------ */
/* The signature. A real lens: dark glass, an inner highlight, and a bloom that
 * exists only when the circuit is live. An unlit lamp is not an error state —
 * it is a dead circuit, which is exactly what "the laptop is off" means. */

.lamp {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--lamp-off);
  border: 1px solid var(--etch-strong);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.55);
  position: relative;
}

/* the glass highlight */
.lamp::after {
  content: "";
  position: absolute;
  top: 14%;
  left: 20%;
  width: 42%;
  height: 32%;
  border-radius: 50%;
  background: linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
}

.lamp--up {
  background: var(--lamp-live);
  border-color: var(--lamp-live);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.35),
    0 0 0 3px rgba(62, 167, 106, 0.16),
    0 0 14px 2px rgba(62, 167, 106, 0.45);
  animation: breathe 2.6s ease-in-out infinite;
}

.lamp--down {
  background: var(--lamp-off);
  border-color: var(--lamp-bad);
}

.lamp--unconfigured {
  background: transparent;
  border-style: dashed;
  border-color: var(--etch-strong);
  box-shadow: none;
}

.lamp--unconfigured::after { display: none; }

/* Slow, shallow. It says "this reading is being refreshed", nothing more. */
@keyframes breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.82; }
}

/* --- the switch ---------------------------------------------------------- */
/* Two positions, and you can see which one the breaker is in. Not a slider:
 * a slider implies a continuum and leaves you guessing which end is current. */

.switch {
  grid-area: switch;
  display: flex;
  margin: 0;
  border: 1px solid var(--etch-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}

.switch__pos {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0 0.9rem;
  min-height: 44px;   /* thumb target */
  min-width: 3.75rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--label-dim);
  background: var(--raised-hi);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.switch__pos + .switch__pos { border-left: 1px solid var(--etch-strong); }

.switch__pos:hover { color: var(--ink); }

/* The set position reads as pressed in: recessed, lit, and unmistakably the
 * current one even in direct sunlight. */
.switch__pos.is-set {
  color: var(--ink);
  background: var(--panel);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.switch__pos--on.is-set  { color: var(--lamp-live); }
.switch__pos--off.is-set { color: var(--lamp-warn); }

@media (prefers-color-scheme: light) {
  .switch__pos.is-set { box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.18); }
}

.switch--dead {
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 7.5rem;
  border-style: dashed;
  background: transparent;
}

.switch__blank { color: var(--label-dim); font-size: 0.9rem; }

/* --- readouts ------------------------------------------------------------ */

.readout {
  margin: 0;
  font-size: 0.78rem;
  color: var(--label);
  overflow-wrap: anywhere;
}

.readout__origin { color: var(--label-dim); }
.readout__num    { color: var(--ink); }
.readout__bad    { color: var(--lamp-bad); }
.readout__age    { color: var(--label-dim); }
.dot             { padding: 0 0.45rem; color: var(--etch-strong); }

.mode {
  margin: 0.3rem 0 0;
  font-size: 0.78rem;
  color: var(--label-dim);
}

.mode--off { color: var(--lamp-warn); }
.mode--unknown { color: var(--lamp-bad); }

/* --- notices ------------------------------------------------------------- */
/* Errors state what happened and what to do. They do not apologise. */

.notice {
  margin: 0 0 1rem;
  padding: 0.75rem var(--gap);
  border-radius: var(--radius);
  border: 1px solid var(--etch-strong);
  border-left-width: 3px;
  background: var(--raised);
  font-size: 0.82rem;
}

.notice p { margin: 0; }
.notice--good { border-left-color: var(--lamp-live); }
.notice--bad  { border-left-color: var(--lamp-bad); }
.notice--warn { border-left-color: var(--lamp-warn); margin-top: 0.5rem; }

.notice__detail {
  margin: 0.5rem 0 0;
  padding: 0.5rem;
  background: var(--panel);
  border-radius: var(--radius);
  font-size: 0.75rem;
  color: var(--label);
  white-space: pre-wrap;
  overflow-x: auto;
}

.notice__foot { margin-top: 0.5rem !important; color: var(--label-dim); }

/* --- sign-in ------------------------------------------------------------- */

.signin { display: flex; flex-direction: column; gap: var(--gap); }

.field { display: flex; flex-direction: column; gap: 0.35rem; }

.field__label {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--label-dim);
}

.field__input {
  font: inherit;
  padding: 0.7rem 0.75rem;
  min-height: 44px;
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--etch-strong);
  border-radius: var(--radius);
}

.button {
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.8rem;
  min-height: 44px;
  padding: 0 1.25rem;
  color: var(--ink);
  background: var(--raised-hi);
  border: 1px solid var(--etch-strong);
  border-radius: var(--radius);
  cursor: pointer;
}

.button:hover { background: var(--raised); }

/* --- footer -------------------------------------------------------------- */

.footfoot {
  margin-top: 1.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--etch);
}

.linkish {
  font: inherit;
  font-size: 0.78rem;
  color: var(--label);
  background: none;
  border: 0;
  padding: 0.5rem 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.linkish:hover { color: var(--ink); }

/* --- the quality floor --------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 26rem) {
  .client {
    grid-template-columns: 1fr;
    grid-template-areas: "id" "switch" "meta";
  }
  .switch, .switch--dead { justify-self: stretch; }
  .switch__pos { flex: 1; }
}
