/* Empire Builder -- interface styling.
 *
 * The register is an Interstate Commerce Commission valuation map: a pale
 * linen-sage sheet, india-ink line work, iron-oxide red for the major
 * terminals, oxidised brass for the instrument chrome.  Condensed caps for
 * timetable headings, a serif for prose, typewriter figures for money.
 */

:root {
  /* A survey plate: drafting linen, plate ink, verdigris for anything the
     hand touches, iron oxide kept for the major terminals and warnings. */
  --linen: #e8e2d4;
  --linen-lift: #f1ece0;
  --linen-deep: #d8d0be;
  --paper: #e8e2d4;
  --paper-warm: #f1ece0;
  --ink: #1c2529;
  --plate: #1c2529;
  --rule: #9a9384;
  --rule-soft: #b9b2a1;
  --oxide: #a8332a;
  --oxide-dim: #7d2a24;
  --verdigris: #1f6f78;
  --verdigris-lit: #2c8f9a;
  --brass: #9a7b33;
  --brass-lit: #7a6026;
  --slate: #e8e2d4;
  --slate-deep: #cfc7b4;
  --slate-lift: #ded6c4;
  --steel: #94a9b8;
  --sage: #7f9078;

  --face-display: "Arial Narrow", "Liberation Sans Narrow", "Helvetica Neue",
    "Roboto Condensed", sans-serif;
  --face-body: Georgia, "Times New Roman", "Liberation Serif", serif;
  --face-data: "Courier New", "Nimbus Mono PS", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--linen-deep);
  color: var(--plate);
  font-family: var(--face-body);
  font-size: 15px;
  overflow: hidden;
}

button {
  font-family: var(--face-display);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 12px;
  font-weight: 700;
  color: var(--plate);
  background: var(--linen-lift);
  border: 1px solid var(--plate);
  border-radius: 0;
  padding: 7px 11px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--verdigris); color: var(--linen-lift); border-color: var(--verdigris); }
button:focus-visible { outline: 2px solid var(--verdigris); outline-offset: 2px; }
button:disabled { opacity: 0.38; cursor: default; }
button.primary { background: var(--oxide); border-color: var(--oxide); color: var(--linen-lift); }
button.primary:hover:not(:disabled) { background: var(--verdigris); border-color: var(--verdigris); }
button.on { background: var(--verdigris); border-color: var(--verdigris); color: var(--linen-lift); }

/* ------------------------------------------------------------- shell */

#app { display: flex; flex-direction: column; height: 100%; }

#masthead {
  display: grid;
  grid-template-columns: auto auto 1fr repeat(5, minmax(0, auto));
  align-items: baseline;
  gap: 6px 16px;
  padding: 8px 16px;
  background: var(--linen);
  border-bottom: 2px solid var(--plate);
  flex: 0 0 auto;
  min-width: 0;
}
#masthead h1 {
  margin: 0;
  font-family: var(--face-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--plate);
}
#masthead .sub {
  font-family: var(--face-display);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--oxide-dim);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#masthead .spacer { display: none; }
.readout {
  font-family: var(--face-display);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6f6a5c;
  min-width: 0;
}
.readout b {
  display: block;
  font-family: var(--face-data);
  font-size: 17px;
  letter-spacing: 0;
  color: var(--plate);
  text-transform: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.readout.hot b { color: var(--oxide); }

#body { display: flex; flex: 1 1 auto; min-height: 0; min-width: 0; }

#stage { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; background: #10161a; }
#board { display: block; width: 100%; height: 100%; cursor: crosshair; }

#tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--linen-lift);
  border: 1px solid var(--plate);
  padding: 5px 9px;
  font-family: var(--face-display);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--plate);
  white-space: nowrap;
  display: none;
  z-index: 5;
}
#tooltip .cost { color: var(--oxide); }

#mapctl {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 5px;
}
#mapctl button { padding: 5px 9px; }

#banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--verdigris);
  color: var(--linen-lift);
  font-family: var(--face-display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  padding: 7px 18px;
  border: 1px solid var(--plate);
  display: none;
  z-index: 6;
}

/* ------------------------------------------------------------- panel */

#panel {
  flex: 0 0 344px;
  min-width: 0;
  background: var(--linen);
  border-left: 2px solid var(--plate);
  overflow-y: auto;
  padding: 12px 13px 20px;
}
#panel section { margin-bottom: 16px; }
#panel h2 {
  margin: 0 0 7px;
  font-family: var(--face-display);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--oxide-dim);
  border-bottom: 1px solid var(--plate);
  padding-bottom: 4px;
}

/* the order book -- three waybills on cotton rag */

.waybill {
  background: var(--linen-lift);
  color: var(--ink);
  border: 1px solid var(--rule);
  margin-bottom: 8px;
  padding: 7px 9px 6px 20px;
  position: relative;
  background-image: repeating-linear-gradient(
    to bottom, transparent 0 21px, rgba(27, 33, 38, 0.09) 21px 22px);
}
.waybill::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--linen);
  box-shadow: 0 22px 0 var(--linen), 0 44px 0 var(--linen);
}
.demand {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  cursor: pointer;
  font-family: var(--face-display);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.demand:hover { background: rgba(31, 111, 120, 0.14); }
.demand.picked { background: rgba(31, 111, 120, 0.22); box-shadow: inset 3px 0 0 var(--verdigris); }
.demand .chip {
  width: 10px; height: 10px;
  border: 1px solid var(--ink);
  flex: 0 0 auto;
}
.demand .where { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.demand .fee {
  font-family: var(--face-data);
  font-size: 13px;
  color: var(--oxide);
  letter-spacing: 0;
}
.demand.ready .where { color: var(--oxide); font-weight: 700; }

/* consist */

.consist { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 6px; }
.car {
  display: flex; align-items: center; gap: 5px;
  background: var(--linen-lift);
  border: 1px solid var(--rule);
  padding: 3px 7px;
  font-family: var(--face-display);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.car .chip { width: 9px; height: 9px; border: 1px solid var(--ink); }
.car.empty { opacity: 0.4; font-style: italic; }

.pickrow { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }

/* where the freight is raised -- the caption under the order book */
#loadhint {
  border-left: 3px solid var(--verdigris);
  background: rgba(31, 111, 120, 0.10);
  padding: 7px 9px;
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.45;
}
#loadhint[hidden] { display: none; }
#loadhint .lead {
  font-family: var(--face-display);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--oxide-dim);
  display: block;
  margin-bottom: 3px;
}
#loadhint .placelink {
  font-family: var(--face-display);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: none;
  border: none;
  border-bottom: 1px dotted var(--verdigris);
  color: var(--plate);
  padding: 0 1px;
  cursor: pointer;
}
#loadhint .placelink:hover { background: var(--verdigris); color: var(--linen-lift); }
#loadhint .mp { font-family: var(--face-data); font-size: 11px; color: #6f6a5c; }

/* standings */

table.standings { width: 100%; border-collapse: collapse; }
table.standings td {
  font-family: var(--face-data);
  font-size: 12px;
  padding: 3px 2px;
  border-bottom: 1px solid rgba(141, 145, 135, 0.28);
}
table.standings td.nm {
  font-family: var(--face-display);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-size: 11px;
}
table.standings tr.turnof td { background: rgba(31, 111, 120, 0.13); }
.swatch {
  display: inline-block; width: 9px; height: 9px;
  margin-right: 5px; border: 1px solid var(--ink);
}

/* dispatch log */

#log {
  max-height: 172px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.4;
}
#log p { margin: 0 0 4px; color: var(--plate); opacity: 0.9; }
#log p .stamp { font-family: var(--face-data); font-size: 11px; color: var(--rule); }
#log p.event { color: var(--brass); }
#log p.money { color: #2f6b3d; }
#log p.win { color: var(--oxide); font-weight: 700; }

/* action bar */

#actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  padding: 9px 16px;
  background: var(--linen);
  border-top: 2px solid var(--plate);
  min-width: 0;
}
#actions .hint {
  font-family: var(--face-display);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6f6a5c;
  margin-left: auto;
  text-align: right;
  min-width: 0;
}

/* ------------------------------------------------------------ dialog */

.veil {
  position: fixed; inset: 0;
  background: rgba(28, 37, 41, 0.84);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
  padding: 20px;
}
.veil[hidden] { display: none; }
.sheet {
  background: var(--linen-lift);
  color: var(--ink);
  border: 2px solid var(--brass);
  max-width: 620px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 26px 20px;
}
.sheet h2 {
  margin: 0 0 3px;
  font-family: var(--face-display);
  font-size: 24px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}
.sheet .rule { height: 3px; background: var(--oxide); margin: 8px 0 14px; }
.sheet h3 {
  font-family: var(--face-display);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--oxide-dim);
  margin: 15px 0 5px;
}
.sheet p, .sheet li { line-height: 1.5; }
.sheet ul { margin: 4px 0; padding-left: 20px; }
.sheet .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.sheet button { color: var(--plate); background: var(--linen); }
.sheet button:hover:not(:disabled) { background: var(--verdigris); color: var(--linen-lift); }
.sheet label {
  font-family: var(--face-display);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}
.sheet select, .sheet input[type="text"] {
  font-family: var(--face-data);
  font-size: 14px;
  padding: 5px 7px;
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.sheet .field { margin-bottom: 12px; }
.sheet a.doclink {
  display: inline-block;
  font-family: var(--face-display);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  background: var(--paper-warm);
  border: 1px solid var(--brass);
  padding: 7px 11px;
  text-decoration: none;
}
.sheet a.doclink:hover { background: var(--oxide); color: var(--paper); }
.sheet a.doclink:focus-visible { outline: 2px solid var(--brass-lit); outline-offset: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 13px; height: 13px; display: inline-block; border: 1px solid var(--ink); }

@media (max-width: 900px) {
  #body { flex-direction: column; }
  #panel { flex: 0 0 auto; max-height: 44%; border-left: none; border-top: 2px solid var(--brass); }
  #masthead h1 { font-size: 15px; letter-spacing: 0.2em; }
}

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