/*
 * STAND BY MARITIME — the PC interface.
 *
 * NOT THE PHONE, ENLARGED. The phone shows one thing at a time because a thumb
 * reaches a corner and a screen holds a single card; every constant in that
 * layout is an argument about reach. A mouse reaches everywhere and this screen
 * is wide, so the shape here is the one the phone cannot have: a persistent
 * list beside a live map beside the detail of whatever is selected, all three
 * readable at once, nothing covering anything else.
 *
 * The palette is the app's own (app/src/format.js) so it is recognisably the
 * same product — black ground, amber for anything live or selected, the USACE
 * blue reserved for locks and never spent on a vessel.
 *
 * Type is system UI for the chrome and tabular figures wherever numbers line
 * up in a column, because a mile, a stage and a delay are read by comparing
 * them down the page.
 */

:root {
  /* Straight from app/src/format.js — one product, one palette. */
  --ink: #FFFFFF;
  --dim: #999999;
  --faint: #666666;
  --surface: #111111;
  --surface2: #0A0A0A;
  --line: #1A1A1A;
  --amber: #FFB020;
  --amber-soft: rgba(255, 176, 32, 0.13);
  --amber-line: rgba(255, 176, 32, 0.45);
  --red: #FF453A;
  --green: #30D158;
  --lock: #5A96D2;
  --lock-dim: #46586B;
  --dark: #000000;

  /* The app's splash ground, used for the window chrome so an installed
   * window matches its own icon. */
  --chrome: #12151A;

  --rail: 320px;
  --panel: 380px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--dark);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  overflow: hidden;                 /* the panes scroll, the page never does */
}

/* ------------------------------------------------------------------ shell */

/*
 * Three columns and a bar. The rail and the panel are fixed-width and the map
 * takes what is left, so widening the window gives the space to the water
 * rather than stretching a list nobody wanted wider.
 */
#shell {
  display: grid;
  grid-template-columns: var(--rail) 1fr 0;
  grid-template-rows: 52px 1fr;
  grid-template-areas:
    "bar bar bar"
    "rail map panel";
  height: 100vh;
  /*
   * No transition on the columns. There was a 140 ms ease here; a hidden
   * document pauses transitions, so a panel opened while the tab was not on
   * screen sat at 274 px of its 380 forever and every row wrapped one word
   * per line. A detail panel appearing at once is what a desk expects anyway.
   */
}

#shell.detail { grid-template-columns: var(--rail) 1fr var(--panel); }
#shell.norail { grid-template-columns: 0 1fr var(--panel); }

#bar   { grid-area: bar; }
#rail  { grid-area: rail; }
#map   { grid-area: map; }
#panel { grid-area: panel; }

/* -------------------------------------------------------------------- bar */

#bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.5px;
  font-size: 14px;
  white-space: nowrap;
  user-select: none;
}
.brand span { color: var(--amber); }

/*
 * THE STATUS CHIP IS NOT DECORATION.
 *
 * It is the answer to "is what I am looking at actually live", and it is the
 * first thing the eye lands on. Green only when a fix really is recent; amber
 * and red mean exactly what they mean in the phone app, from the same
 * thresholds in app/src/format.js.
 */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--dim);
  font-size: 12px;
  white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.chip.live  .dot { background: var(--green); }
.chip.aging .dot { background: var(--amber); }
.chip.stale .dot { background: var(--red); }
.chip.live  { color: var(--ink); }

/* search ------------------------------------------------------------------ */

.searchwrap { position: relative; flex: 1 1 auto; max-width: 460px; min-width: 160px; }

#search {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink);
  font: inherit;
  outline: none;
}
#search:focus { border-color: var(--amber-line); background: var(--surface); }
#search::placeholder { color: var(--faint); }

#results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  max-height: 62vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  z-index: 40;
  display: none;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6);
}
#results.on { display: block; }

.hit { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.hit:last-child { border-bottom: 0; }
.hit:hover, .hit.sel { background: var(--amber-soft); }
.hit-name { font-weight: 600; }
.hit-sub  { color: var(--dim); font-size: 11px; margin-top: 2px; }

/* ------------------------------------------------------------------- rail */

/*
 * The list the phone has no room for. It stays open while the map is used, so
 * a reader can watch a lock queue and the water at the same time — which is
 * the entire reason to have a bigger screen.
 */
#rail {
  background: var(--surface2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tab {
  flex: 1;
  padding: 10px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--faint);
  cursor: pointer;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}
.tab:hover { color: var(--dim); }
.tab.on { color: var(--amber); border-bottom-color: var(--amber); }

.railbody { flex: 1 1 auto; overflow-y: auto; }

.item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.item:hover { background: var(--surface); }
.item.on { background: var(--amber-soft); box-shadow: inset 2px 0 0 var(--amber); }
.item-main { flex: 1 1 auto; min-width: 0; }
.item-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-sub { color: var(--dim); font-size: 11px; margin-top: 2px; }
.item-right { flex: none; font-variant-numeric: tabular-nums; color: var(--dim); font-size: 11px; }

/* ------------------------------------------------------------------- map */

#map { position: relative; background: var(--dark); min-width: 0; }

/* The map canvas fills the cell; every overlay is a SIBLING of it, never a
 * child, because Maps empties the element it is handed. */
#gmap { position: absolute; inset: 0; }

/*
 * The attribution sits ON the map, small and permanent. Some of the AIS
 * licences make crediting a condition of use rather than a courtesy, so it
 * does not get to be a thing you open.
 */
#attrib {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.72);
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.3px;
  pointer-events: none;
  z-index: 5;
}
#attrib b { color: var(--dim); font-weight: 600; }

.mapctl {
  position: absolute;
  top: 12px; right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 6;
}
.mapbtn {
  width: 46px;
  padding: 7px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  background: var(--surface);
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.mapbtn:hover { color: var(--ink); border-color: var(--faint); }
.mapbtn.on { color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }

/* ----------------------------------------------------------------- panel */

#panel {
  background: var(--surface2);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  min-width: 0;
}
#shell:not(.detail) #panel { border-left: 0; }

.panel-head {
  position: sticky;
  top: 0;
  background: var(--surface2);
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  z-index: 2;
}
.panel-title { flex: 1 1 auto; font-size: 15px; font-weight: 700; min-width: 0; }
.panel-kind { color: var(--faint); font-size: 10px; letter-spacing: 0.8px; font-weight: 700; margin-top: 3px; }
.x {
  background: none; border: 0; color: var(--faint);
  font-size: 18px; cursor: pointer; line-height: 1; padding: 0 2px; font-family: inherit;
}
.x:hover { color: var(--ink); }

.panel-body { padding: 12px 14px 28px; }

.sec {
  color: var(--faint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.9px;
  margin: 18px 0 6px;
}
.sec:first-child { margin-top: 0; }

/*
 * A ROW IS A FACT AND ITS PUBLISHER.
 *
 * Three parts on purpose: what it is, what it says, and who said it. The third
 * is not optional for a reading — the whole product rests on a reader being
 * able to check any number against the body that published it.
 */
.row {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 4px 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.row-k { color: var(--dim); font-size: 12px; }
.row-v { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* The phone's Row dot: 8 px, sits before the value. On a vessel card it IS the
 * marker colour. */
.row-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 7px; vertical-align: 1px;
}

/* ---------------------------------------------------- vessel card blocks */

/* The phone's headline state line: a dot and a coloured caps label. */
.poshead { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; }
.poshead .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.poshead-text { font-size: 11px; font-weight: 800; letter-spacing: 0.9px; }

/* Big speed, unit, then course or nav status — the phone's cardSpeed row. */
.speedrow { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.mph   { font-size: 34px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.unit  { color: var(--dim); font-size: 11px; font-weight: 700; letter-spacing: 0.8px; }
.state { color: var(--dim); font-size: 11px; font-weight: 700; letter-spacing: 0.6px; margin-left: auto; text-align: right; }

.histnote { color: var(--dim); line-height: 1.5; margin: 0 0 12px; }

/* SHOW TRACK / TRACK bars. */
.trackbar { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.trackbtn {
  padding: 6px 11px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 11px;
  font-weight: 800; letter-spacing: 0.7px; cursor: pointer; white-space: nowrap;
}
.trackbtn.on { border-color: var(--amber-line); color: var(--amber); background: var(--amber-soft); }
.trackmeta { color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tracknote { color: var(--faint); font-size: 11px; line-height: 1.5; margin: -4px 0 10px; }

/* LAST USACE MOVEMENT — the phone's lockCard block. Its own box so it can
 * never read as a GPS position. */
.usace { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; margin: 0 0 12px; }
.usace-head { color: var(--lock); font-size: 10px; font-weight: 800; letter-spacing: 0.8px; margin-bottom: 5px; }
.usace-line { line-height: 1.45; }
.usace-meta { color: var(--dim); font-size: 12px; line-height: 1.45; }
.usace-note { color: var(--faint); font-size: 11px; line-height: 1.45; margin-top: 3px; }

/* ------------------------------------------------------ lock card blocks */

/* NO LONGER A WORKING LOCK / STANDING NOTICE (panels.js:344-360): an amber
 * box, because two of the feeds change whether the lock is a lock at all. */
.notice {
  margin: 10px 0; padding: 10px; border-radius: 10px;
  border: 1px solid var(--amber); background: rgba(255, 176, 32, 0.06);
}
.notice-head { color: var(--amber); font-size: 11px; font-weight: 900; letter-spacing: 0.7px; }
.notice-text { color: var(--ink); font-size: 12px; line-height: 17px; margin-top: 4px; }
.notice-src  { color: var(--faint); font-size: 10px; margin-top: 4px; }

/* n NOTICE(S) TO NAVIGATION IN EFFECT — the count only; words on the route. */
.notecount { margin: 8px 0 4px; }
.notecount-head { color: var(--amber); font-size: 11px; font-weight: 800; letter-spacing: 0.5px; }

/* WAITING and LOCKED THROUGH: two headings so the two lists cannot be read as
 * one — one group is still sitting there, the other is long gone. */
.queuehead, .lockedhead {
  font-size: 10px; font-weight: 800; letter-spacing: 0.9px;
  margin: 14px 0 2px;
}
.queuehead  { color: var(--amber); }
.lockedhead { color: var(--lock); }

/* A VTS zone's limits, under its row. */
.zonelimit { color: var(--faint); font-size: 11px; line-height: 1.45; padding: 0 0 6px; }

/* A row that is a link (the phone number): keep the row's look, add the cue. */
.rowlink { color: inherit; text-decoration: none; display: block; }
.rowlink:hover .row-v { color: var(--amber); }

/* The per-layer failure banner (App.js:483-492, 2779-2783): named layers that
 * did not load, joined with a dot. On the map, above the attribution. */
.layerfail {
  position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%);
  padding: 5px 12px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.78); border: 1px solid rgba(255, 69, 58, 0.55);
  color: var(--red); font-size: 10px; font-weight: 800; letter-spacing: 0.7px;
  white-space: nowrap; pointer-events: none; z-index: 6;
}
.row-src {
  grid-column: 2;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.2px;
}

.unknown {
  color: var(--dim);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 2px solid var(--faint);
  padding: 8px 10px;
  border-radius: 6px;
  margin: 8px 0;
  line-height: 1.45;
}

.btn {
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.btn:hover { border-color: var(--faint); }
.btn-primary { border-color: var(--amber-line); background: var(--amber-soft); color: var(--amber); }
.btn:disabled { opacity: 0.4; cursor: default; }

/* --------------------------------------------------------------- blocker */

/*
 * NO LIVE DATA, SAID PLAINLY.
 *
 * This map shows real AIS or nothing. The reader is told the feed is away and
 * that it is not their doing — never handed a shell command, and never shown a
 * plausible-looking map built from nothing.
 */
#blocker {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}
#blocker.on { display: flex; }
.bcard {
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  line-height: 1.55;
}
.bcard h2 { margin: 0 0 8px; font-size: 17px; }
.bcard p { margin: 8px 0 0; color: var(--dim); }

/* ------------------------------------------------------------- utilities */

.empty { padding: 22px 14px; color: var(--faint); text-align: center; line-height: 1.5; }
.spin  { padding: 22px 14px; color: var(--dim); text-align: center; }

:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface2); }
::-webkit-scrollbar-thumb { background: #23262b; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #33373d; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
