/* British Rails - interface styling.
   The chrome follows the British Rail corporate identity of 1965-1997:
   Rail Blue, Pearl Grey, a tightly tracked grotesque set in capitals for
   signage, and the double arrow. Regional colours identify the companies. */

:root {
  --rail-blue: #1f3a4d;
  --rail-blue-dk: #142935;
  --rail-blue-lt: #2d5570;
  --ink: #0d1b24;
  --pearl: #c9cec9;
  --pearl-lt: #e4e7e3;
  --paper: #f2efe6;
  --warning: #f0b323;
  --signal-red: #b32a20;
  --sea: #7fb2ce;
  --land: #e6e3da;

  --co-1: #8a4b2a;
  --co-2: #1d6b3f;
  --co-3: #a32235;
  --co-4: #1f4fa8;
  --co-5: #e2701c;
  --co-6: #2e86c8;

  --sans: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  --panel-w: 348px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--rail-blue-dk);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

button {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--paper);
  background: var(--rail-blue-lt);
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 2px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 120ms ease, transform 60ms ease;
}
button:hover:not(:disabled) { background: #3a6a8c; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.38; cursor: default; }
button.primary { background: var(--warning); color: var(--ink); }
button.primary:hover:not(:disabled) { background: #ffc844; }
button.danger { background: var(--signal-red); }
button:focus-visible,
[tabindex]:focus-visible { outline: 3px solid var(--warning); outline-offset: 2px; }

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

#topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--rail-blue);
  border-bottom: 3px solid var(--warning);
  padding: 8px 14px;
  flex: 0 0 auto;
}
#topbar .arrows { width: 46px; height: 22px; flex: 0 0 auto; }
#topbar h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
#topbar .spacer { flex: 1 1 auto; }
#topbar .tools { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

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

#board { position: relative; flex: 1 1 auto; min-width: 0; background: var(--sea); }
#board canvas { display: block; width: 100%; height: 100%; touch-action: none; }

#maptools {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 6px;
}
#maptools button { padding: 7px 10px; background: rgba(20, 41, 53, 0.86); }

#hint {
  position: absolute;
  left: 12px;
  top: 12px;
  max-width: 60%;
  background: rgba(20, 41, 53, 0.9);
  color: var(--paper);
  border-left: 4px solid var(--warning);
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.4;
  border-radius: 2px;
  pointer-events: none;
}
#hint.warn { border-left-color: var(--signal-red); }

/* ------------------------------------------------------------- panel */
#panel {
  flex: 0 0 var(--panel-w);
  width: var(--panel-w);
  background: var(--pearl);
  border-left: 3px solid var(--rail-blue-dk);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sect { border-bottom: 1px solid rgba(13, 27, 36, 0.18); padding: 12px 14px; }
.sect h2 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--rail-blue);
}

/* the turn header reads like a platform indicator */
#turnhead {
  background: var(--ink);
  color: var(--paper);
  padding: 10px 14px;
  border-bottom: 3px solid var(--warning);
}
#turnhead .who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}
#turnhead .swatch {
  width: 15px; height: 15px; border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  flex: 0 0 auto;
}
#turnhead .stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 8px;
  margin-top: 8px;
  font-size: 12px;
}
#turnhead .stats b {
  display: block;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--warning);
}
#turnhead .stats span {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 10px;
  opacity: 0.75;
}

.actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* consignment notes */
.card {
  background: var(--paper);
  border: 1px solid rgba(13, 27, 36, 0.3);
  border-radius: 2px;
  margin-bottom: 8px;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}
.card .hdr {
  background: repeating-linear-gradient(
    90deg, var(--rail-blue) 0 6px, var(--rail-blue-lt) 6px 12px);
  color: #fff;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 4px 8px;
  display: flex;
  justify-content: space-between;
}
.card .row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px dashed rgba(13, 27, 36, 0.25);
  font-size: 13px;
  line-height: 1.3;
}
.card .row:first-of-type { border-top: 0; }
.card .row .to {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  font-size: 11px;
  color: var(--rail-blue);
}
.card .row .pay {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.card .row.live { background: #fff6d8; }
.card .row.live .pay { color: var(--signal-red); }
.card .row.aboard .to::after {
  content: " - aboard";
  color: var(--signal-red);
  letter-spacing: 0.04em;
}

/* loads and produce */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 11px;
  border: 1px solid rgba(13, 27, 36, 0.35);
  background: var(--pearl-lt);
  cursor: pointer;
}
.chip:hover:not(:disabled) { background: #fff; }
.chip.deliver { background: var(--warning); border-color: #8a6413; font-weight: 700; }
.chip:disabled { opacity: 0.4; cursor: default; }
.empty { font-size: 12px; opacity: 0.6; font-style: italic; }

/* company table */
table.co { width: 100%; border-collapse: collapse; font-size: 12px; }
table.co th {
  text-align: left;
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--rail-blue);
  padding: 0 4px 4px 0;
  font-weight: 700;
}
table.co td { padding: 3px 4px 3px 0; border-top: 1px solid rgba(13, 27, 36, 0.14); }
table.co td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.co tr.turn td { background: rgba(240, 179, 35, 0.28); font-weight: 700; }
table.co .dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 2px; margin-right: 6px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  vertical-align: -1px;
}

#log {
  font-size: 12px;
  line-height: 1.45;
  max-height: 168px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid rgba(13, 27, 36, 0.22);
  padding: 7px 9px;
}
#log div { padding: 2px 0; border-top: 1px solid rgba(13, 27, 36, 0.09); }
#log div:first-child { border-top: 0; }
#log .ev { color: var(--signal-red); font-weight: 700; }

/* ------------------------------------------------------------ dialogs */
.veil {
  position: fixed;
  inset: 0;
  background: rgba(13, 27, 36, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 40;
}
.veil[hidden] { display: none; }
.sheet {
  background: var(--pearl);
  border-top: 5px solid var(--warning);
  border-radius: 2px;
  width: min(560px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 20px 22px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}
.sheet h2 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rail-blue);
}
.sheet p.lede { margin: 0 0 16px; font-size: 13px; line-height: 1.5; }
.seat {
  display: grid;
  grid-template-columns: 18px 1fr 116px 128px;
  gap: 8px;
  align-items: center;
  margin-bottom: 7px;
}
.seat .dot { width: 14px; height: 14px; border-radius: 2px; border: 1px solid #0006; }
.seat input, .seat select {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 7px;
  border: 1px solid rgba(13, 27, 36, 0.4);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  width: 100%;
}
.sheet .foot { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.sheet .foot .spacer { flex: 1 1 auto; }
.sheet dl { margin: 0; font-size: 13px; line-height: 1.5; }
.sheet dt {
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  font-size: 11px; color: var(--rail-blue); margin-top: 10px;
}
.sheet dd { margin: 2px 0 0; }

#result .tally { font-size: 14px; margin: 10px 0 0; }
#result .tally div { padding: 4px 0; border-top: 1px solid rgba(13, 27, 36, 0.16); }

/* --------------------------------------------------------- responsive */
@media (max-width: 860px) {
  :root { --panel-w: 300px; }
  #topbar h1 { font-size: 15px; letter-spacing: 0.14em; }
}
@media (max-width: 700px) {
  #main { flex-direction: column; }
  #panel {
    flex: 0 0 46%;
    width: 100%;
    border-left: 0;
    border-top: 3px solid var(--rail-blue-dk);
  }
  .seat { grid-template-columns: 16px 1fr 104px; }
  .seat select.skill { grid-column: 2 / 4; }
}

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