/*
 * Nugget Ops TV board — instrument-panel dark theme.
 *
 * Scale: the whole board is designed on a 120rem × 67.5rem stage (16:9).
 * html font-size is derived from the viewport so 1rem = 16px on a 1920×1080
 * TV and everything scales proportionally on any screen.
 *
 * Palette: dataviz reference dark categorical/status steps, validated against
 * the card surface #14171c (CVD ΔE 23.7, all ≥3:1). Text wears ink tokens
 * only; series color lives on marks and key-dots.
 */

:root {
  /* planes & chrome */
  --plane:      #0c0e11;
  --surface:    #14171c;
  --surface-2:  #1a1f26;
  --surface-3:  #222834;
  --hairline:   #262c35;
  --baseline:   #333b46;
  --ink:        #f2f4f6;
  --ink-2:      #a9b2bd;
  --ink-3:      #6d7683;

  /* categorical series — service projects (fixed assignment, never re-ranked) */
  --c-pm:        #3987e5;  /* Preventive Maintenance */
  --c-installs:  #199e70;  /* Installs */
  --c-training:  #c98500;  /* Training */
  --c-refurb:    #9085e9;  /* Refurb & QC */
  --c-emergency: #e66767;  /* Emergency Callouts */
  --c-shipping:  #d55181;  /* Shipping & Packing */
  --c-repairs:   #d95926;  /* Repairs */

  /* status — reserved, always paired with icon + label */
  --s-good:     #0ca30c;
  --s-warn:     #fab219;
  --s-serious:  #ec835a;
  --s-critical: #d03b3b;

  --font-ui:   "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --font-cond: "IBM Plex Sans Condensed", "IBM Plex Sans", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius: 0.75rem;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: min(calc(100vw / 120), calc(100vh / 67.5)); }

body {
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font-ui);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
}

/* faint microplate well-grid on the page plane — the room tone, not a graphic */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle 1px at 1px 1px, rgba(255,255,255,0.045) 1px, transparent 1.5px);
  background-size: 1.75rem 1.75rem;
  pointer-events: none;
}

.stage {
  position: relative;
  width: 120rem;
  height: 67.5rem;
  display: flex;
  flex-direction: column;
  padding: 0 1rem;
}

/* ---------- top bar ---------- */

.topbar {
  height: 4.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 0.5rem;
}

.wordmark {
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: 0.14em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
}

.plate-glyph {
  width: 1.9rem;
  height: 1.25rem;
  background-image: radial-gradient(circle 0.17rem at 50% 50%, var(--c-pm) 0.17rem, transparent 0.19rem);
  background-size: 0.63rem 0.63rem;
  background-position: 0 0;
}

.board-title {
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 1.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
  padding-left: 1.25rem;
  border-left: 1px solid var(--hairline);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.chip {
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.25rem 0.6rem;
  border-radius: 0.35rem;
  border: 1px solid var(--hairline);
  color: var(--ink-2);
  letter-spacing: 0.06em;
}
.chip-sample { color: var(--s-warn); border-color: rgba(250,178,25,0.35); }
.chip-live { color: var(--s-good); border-color: rgba(12,163,12,0.35); }
.chip-quiet { border: none; color: var(--ink-3); letter-spacing: 0; }

.clock {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.rotate-dots { display: flex; gap: 0.5rem; }
.rotate-dots button {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  border: none;
  background: var(--surface-3);
  cursor: pointer;
  padding: 0;
}
.rotate-dots button[aria-selected="true"] { background: var(--ink-2); }
.rotate-dots button:focus-visible { outline: 2px solid var(--c-pm); outline-offset: 2px; }

/* ---------- boards & cards ---------- */

.board {
  flex: 1;
  display: grid;
  gap: 1.25rem;
  padding: 0.25rem 0.5rem 1rem;
  min-height: 0;
  opacity: 1;
  transition: opacity 0.5s ease;
}
.board.fading { opacity: 0; }
.board[hidden] { display: none; }

.board-service {
  grid-template-columns: 74.75rem 1fr;
  grid-template-rows: 28.5rem 20rem 1fr;
  grid-template-areas:
    "map pipeline"
    "map working"
    "schedule priority";
}
.card-map       { grid-area: map; display: flex; flex-direction: column; }
.card-pipeline  { grid-area: pipeline; display: flex; flex-direction: column; }
.card-working   { grid-area: working; }
.card-schedule  { grid-area: schedule; }
.card-priority  { grid-area: priority; display: flex; flex-direction: column; }
.card-sku       { display: flex; flex-direction: column; } /* dormant — warehouse board */

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  min-height: 0;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.card-head h2 {
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.dot-eyebrow {
  width: 1rem;
  height: 0.4rem;
  background-image: radial-gradient(circle 0.11rem at 50% 50%, var(--ink-3) 0.11rem, transparent 0.13rem);
  background-size: 0.36rem 0.36rem;
  opacity: 0.9;
}
.head-note { margin-left: auto; font-size: 0.85rem; color: var(--ink-3); }
.card-foot { margin-top: auto; font-size: 0.85rem; color: var(--ink-3); padding-top: 0.6rem; }

/* ---------- map ---------- */

.map-count { margin-left: auto; display: flex; align-items: baseline; gap: 0.6rem; }
.map-count strong { font-size: 2.4rem; font-weight: 600; line-height: 1; }
.map-count span { font-size: 0.95rem; color: var(--ink-2); }

.map-wrap { flex: 1; min-height: 0; }
.map-wrap svg { width: 100%; height: 100%; display: block; }

.map-state { fill: var(--surface-2); stroke: var(--hairline); stroke-width: 1; }

.pin { stroke: var(--surface); stroke-width: 2; cursor: default; }
.pin:focus-visible { outline: none; stroke: var(--ink); stroke-width: 2.5; }

.pulse-halo {
  fill: none;
  stroke: var(--c-emergency);
  stroke-width: 2;
  transform-box: fill-box;
  transform-origin: center;
  animation: pulse 2.2s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(2.1); opacity: 0; }
}

.map-legend {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding-top: 0.8rem;
  font-size: 0.9rem;
  color: var(--ink-2);
  flex-wrap: wrap;
}
.legend-key { display: flex; align-items: center; gap: 0.45rem; }
.legend-key .swatch { width: 0.7rem; height: 0.7rem; border-radius: 50%; }
.legend-sep { width: 1px; height: 1.1rem; background: var(--hairline); }
.legend-size { display: flex; align-items: center; gap: 0.4rem; color: var(--ink-3); }
.legend-size .ghost { border: 1.5px solid var(--ink-3); border-radius: 50%; }

/* ---------- stage pipeline ---------- */

.pipeline { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; min-height: 0; }

.stage-row {
  display: grid;
  grid-template-columns: 11.5rem 1fr 6.25rem;
  align-items: center;
  gap: 0.9rem;
}
.stage-row.is-hold { border-top: 1px solid var(--hairline); padding-top: 0.55rem; }
.stage-name { font-size: 0.95rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-track { position: relative; height: 1.15rem; }
.stage-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--c-pm);
  border-radius: 0 4px 4px 0;
  min-width: 0.25rem;
}
.stage-row.is-hold .stage-bar { background: var(--ink-3); }
.stage-count {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.05rem;
  font-weight: 600;
}
.stage-dwell { text-align: right; font-size: 1rem; color: var(--ink-2); white-space: nowrap; }
.stage-dwell strong { color: var(--ink); font-weight: 600; font-size: 1.15rem; }

/* ---------- shared bits ---------- */

.mono { font-family: var(--font-mono); font-size: 0.95rem; color: var(--ink-2); }

/* ---------- working now ---------- */

.work-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  justify-content: space-evenly;
  height: calc(100% - 2.2rem);
}
.work-row {
  display: grid;
  grid-template-columns: 5.6rem 1fr 5.2rem;
  align-items: center;
  gap: 0.9rem;
}
.work-main { min-width: 0; }
.work-client { font-size: 1.05rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work-people { font-size: 0.85rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work-hours { text-align: right; font-size: 0.95rem; color: var(--ink-2); white-space: nowrap; }
.work-hours strong { font-size: 1.3rem; font-weight: 600; color: var(--ink); }
.work-hours.is-zero, .work-hours.is-zero strong { color: var(--ink-3); font-weight: 400; }
.work-empty, .work-more { font-size: 0.9rem; color: var(--ink-3); }

/* ---------- ribbon row ---------- */

.card-ribbon { padding-top: 0.85rem; padding-bottom: 0.85rem; }
.card-ribbon .card-head { margin-bottom: 0.55rem; }

.s-ico { width: 1.15rem; text-align: center; }
.wh-dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-right: 0.4rem; }

/* ---------- schedule pile-up strip ---------- */

.sched-cells { display: flex; align-items: stretch; height: calc(100% - 2.6rem); }
.sched-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.sched-cell.is-past { border-left: 1px solid var(--hairline); }
.sched-cell.is-past .sched-bar { background: var(--s-critical); }
.sched-cell.is-past .sched-count { color: var(--s-critical); }
.sched-cell.is-past .sched-label { color: var(--s-critical); font-weight: 600; }
.sched-cell.is-off { border-left: 1px solid var(--hairline); }
.sched-count { font-size: 0.95rem; font-weight: 600; line-height: 1.2; }
.sched-count.is-zero { color: var(--ink-3); font-weight: 400; }
.sched-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; padding: 0.15rem 0 0.2rem; }
.sched-bar { width: 1.5rem; background: var(--c-pm); border-radius: 4px 4px 0 0; }
.sched-cell.is-off .sched-bar { background: var(--ink-3); }
.sched-label {
  font-size: 0.78rem;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
}
.sched-cell.is-now .sched-label { color: var(--ink-2); font-weight: 600; letter-spacing: 0.06em; }

/* ---------- open tickets by priority ---------- */

.prio-cells { flex: 1; display: flex; align-items: center; }
.prio-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  border-left: 1px solid var(--hairline);
}
.prio-cell:first-child { border-left: none; }
.prio-cell.is-off { border-left-color: var(--baseline); }
.prio-cell.is-off:not(.is-zero) .prio-count { color: var(--s-warn); }
.prio-count { font-size: 2.2rem; font-weight: 600; line-height: 1; }
.prio-cell.is-zero .prio-count { color: var(--ink-3); font-weight: 400; }
.prio-label { font-size: 0.85rem; color: var(--ink-2); display: flex; align-items: center; }

/* ---------- SKU audit meter (dormant — reserved for the warehouse board) ---------- */

.sku-meter { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 0.55rem; }
.sku-figures { display: flex; align-items: baseline; gap: 0.7rem; }
.sku-pct { font-size: 2.4rem; font-weight: 600; line-height: 1; }
.sku-frac { font-size: 1rem; color: var(--ink-2); }
.meter-track {
  height: 0.85rem;
  border-radius: 0.45rem;
  background: rgba(57, 135, 229, 0.16);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  background: var(--c-pm);
  border-radius: 0 0.45rem 0.45rem 0;
  min-width: 0.45rem;
}
.sku-caption { font-size: 0.82rem; color: var(--ink-3); }

/* ---------- fullscreen button ---------- */

.fs-btn {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.7rem;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--ink-2);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.fs-btn.show { opacity: 1; pointer-events: auto; }
.fs-btn .fs-icon-compress { display: none; }
body.is-fullscreen .fs-btn .fs-icon-compress { display: block; }
body.is-fullscreen .fs-btn .fs-icon-expand { display: none; }
.fs-btn:hover { background: var(--surface-3); color: var(--ink); }
.fs-btn:focus-visible { outline: 2px solid var(--c-pm); outline-offset: 2px; opacity: 1; pointer-events: auto; }

/* ---------- tooltip ---------- */

.tooltip {
  position: fixed;
  z-index: 40;
  background: var(--surface-3);
  border: 1px solid var(--baseline);
  border-radius: 0.5rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.92rem;
  color: var(--ink-2);
  box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.45);
  pointer-events: none;
  max-width: 20rem;
}
.tooltip strong { color: var(--ink); font-weight: 600; }
.tooltip .tt-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.1rem 0; }
.tooltip .tt-key { width: 0.85rem; height: 0.2rem; border-radius: 1px; }

/* ---------- lock screen ---------- */

.lock[hidden] { display: none; }
.lock {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8,10,13,0.88);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lock-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 1rem;
  padding: 2.5rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  text-align: center;
}
.lock-title { color: var(--ink-2); font-size: 1.05rem; }
.pin-dots { display: flex; gap: 0.9rem; }
.pin-dots span {
  width: 1rem; height: 1rem;
  border-radius: 50%;
  border: 1.5px solid var(--baseline);
}
.pin-dots span.on { background: var(--ink); border-color: var(--ink); }
.keypad { display: grid; grid-template-columns: repeat(3, 4.2rem); gap: 0.8rem; }
.keypad button {
  height: 4.2rem;
  border-radius: 0.7rem;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1.5rem;
  cursor: pointer;
}
.keypad button:hover { background: var(--surface-3); }
.keypad button:focus-visible { outline: 2px solid var(--c-pm); outline-offset: 2px; }
.pad-blank { visibility: hidden; }
.lock-hint { font-size: 0.85rem; color: var(--ink-3); max-width: 24rem; line-height: 1.5; }
.lock-error { font-size: 0.95rem; color: var(--s-critical); font-weight: 500; }

/* ---------- a11y ---------- */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .pulse-halo { animation: none; opacity: 0; }
  .board { transition: none; }
}
