:root {
  --paper: #eef1f0;
  --paper-2: #e2e7e5;
  --ink: #0b2236;
  --ink-2: #4a5d6c;
  --rule: #c3ccd0;
  --water: #c9d6dc;
  --starboard: #00843d;
  --caution: #9c6f00;
  --port: #c8102e;
  --mast: #0b2236;
  --mast-ink: #eef1f0;
  --mast-2: #c9d6dc;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", sans-serif;
  --figures: "Barlow", sans-serif;
  color-scheme: light;
}

/* boot.js sets data-theme and data-scheme from the reader's settings before first paint. */
:root[data-theme="dark"] {
  --paper: #0f1b24;
  --paper-2: #172732;
  --ink: #e3e9e7;
  --ink-2: #9db0bc;
  --rule: #2d3f4b;
  --water: #22394a;
  --starboard: #3fae6a;
  --caution: #d9a21e;
  --port: #ec5466;
  --mast: #08131b;
  --mast-ink: #e3e9e7;
  --mast-2: #9db0bc;
  color-scheme: dark;
}

/* Blue, orange and magenta stay apart under protanopia, deuteranopia and tritanopia. */
:root[data-scheme="colourblind"] { --starboard: #0072b2; --caution: #a26c00; --port: #9e0059; }
:root[data-scheme="colourblind"][data-theme="dark"] { --starboard: #2f86c4; --caution: #c47f00; --port: #cf5099; }

:root[data-scheme="contrast"] {
  --paper: #ffffff;
  --paper-2: #eef0ef;
  --ink: #000000;
  --ink-2: #26333d;
  --rule: #59656d;
  --water: #bcd0da;
  --starboard: #00599a;
  --caution: #a35f00;
  --port: #8a0050;
  --mast: #000000;
  --mast-ink: #ffffff;
  --mast-2: #bcd0da;
}

:root[data-scheme="contrast"][data-theme="dark"] {
  --paper: #000000;
  --paper-2: #141a1f;
  --ink: #ffffff;
  --ink-2: #d2dce2;
  --rule: #8a99a3;
  --water: #2a4555;
  --starboard: #5ab8f0;
  --caution: #f0a500;
  --port: #f06cb8;
  --mast: #000000;
  --mast-ink: #ffffff;
  --mast-2: #bcd0da;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 0.9375rem/1.45 var(--body);
  font-variant-numeric: tabular-nums;
}

a { color: inherit; }

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.masthead { background: var(--mast); color: var(--mast-ink); }

/* High contrast's dark paper is as black as the masthead, so a rule marks where the page starts. */
:root[data-scheme="contrast"][data-theme="dark"] .masthead { border-bottom: 1px solid var(--rule); }

.masthead-inner,
main,
footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Wraps rather than overflowing when the reader picks a larger text size. */
.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 24px;
  min-height: 56px;
  padding-top: 14px;
}

.masthead nav a, .settings-open { white-space: nowrap; }

.wordmark {
  font: 700 1.625rem/1 var(--display);
  letter-spacing: 0.02em;
  text-decoration: none;
  text-transform: uppercase;
}

.wordmark span { color: var(--mast-2); }

.masthead nav { display: flex; gap: 4px; margin-inline-start: 24px; align-self: stretch; }

.masthead nav a {
  font: 600 0.9375rem var(--display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  /* Puts the link text on the masthead's baseline, while the link stretches to its bottom edge. */
  padding: 13px 10px 0;
  border-bottom: 3px solid transparent;
  color: var(--mast-2);
}

.masthead nav a:hover { color: var(--mast-ink); }
.masthead nav a[aria-current="page"] { color: var(--mast-ink); border-bottom-color: var(--mast-ink); }

#clock { margin-inline-start: auto; font: 500 0.9375rem var(--figures); }

.settings-open {
  font: 600 0.9375rem var(--display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mast-2);
  background: none;
  border: 0;
  padding: 0;
  padding-inline-start: 10px;
  min-height: 44px;
  cursor: pointer;
}

.settings-open:hover { color: var(--mast-ink); }

main { padding-top: 32px; padding-bottom: 48px; }

h1 {
  font: 600 2.5rem/1.05 var(--display);
  margin: 0 0 4px;
  letter-spacing: 0.01em;
}

h2 {
  font: 600 0.8125rem var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 8px;
}

.lede { color: var(--ink-2); margin: 0 0 24px; max-width: 70ch; }

/* Figures row: one ruled strip, read like the header of a departure board. */
.figures {
  display: flex;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 24px;
}

.figure { padding-block: 10px 12px; padding-inline: 0 24px; margin-inline-end: 24px; border-inline-end: 1px solid var(--rule); }
.figure:last-child { border-inline-end: 0; }

.figure b {
  display: block;
  font: 600 2.75rem/1.05 var(--display);
  letter-spacing: 0.01em;
}

.figure span {
  font: 600 0.75rem var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; }

.panel { border: 1px solid var(--rule); background: var(--paper); }

#map { height: 600px; }
#map.tall { height: 640px; }

.board { max-height: 600px; overflow-y: auto; }

table { width: 100%; border-collapse: collapse; }

th {
  font: 600 0.75rem var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-align: start;
  padding: 8px 10px;
  border-bottom: 2px solid var(--ink);
  position: sticky;
  top: 0;
  background: var(--paper);
}

td { padding: 0 10px; height: 34px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
tbody tr:nth-child(even) td { background: var(--paper-2); }
tbody tr:hover td { background: var(--water); }

th.group { text-align: start; border-bottom: 1px solid var(--rule); }
tbody th { position: static; padding-top: 16px; border-bottom: 1px solid var(--rule); }
.wide-table { overflow-x: auto; }
.block { margin-bottom: 32px; }

/* Delays such as +2:07 have no strong direction, so right-to-left pages would put the sign last. */
.figure b, .num, .status { unicode-bidi: plaintext; }

.num { text-align: end; font-family: var(--figures); font-variant-numeric: tabular-nums; }
.mono { font-family: var(--figures); }
.dim { color: var(--ink-2); }
.wrap { white-space: normal; }

.line-code {
  display: inline-block;
  min-width: 38px;
  font: 600 0.8125rem/1.125rem var(--display);
  letter-spacing: 0.04em;
  text-align: center;
  border: 1.5px solid var(--ink);
  padding: 0 4px;
}

.status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--figures); }
.status::before { content: ""; width: 9px; height: 9px; flex: none; }
.status.ok::before { background: var(--starboard); border-radius: 50%; }
.status.late::before { background: var(--caution); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.status.bad::before { background: var(--port); }
.status.none::before { border: 1.5px solid var(--ink-2); border-radius: 50%; }

.toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }

.segmented { display: inline-flex; border: 1.5px solid var(--ink); }

.segmented button {
  font: 600 0.8125rem var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: none;
  color: var(--ink);
  border: 0;
  border-inline-end: 1.5px solid var(--ink);
  padding: 6px 14px;
  cursor: pointer;
  position: relative;
}

/* Pads the tap target to 44px without drawing the control bigger. */
.segmented button::after { content: ""; position: absolute; inset: 50% 0 auto; height: 44px; transform: translateY(-50%); }

.segmented button:last-child { border-inline-end: 0; }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.legend { display: flex; gap: 1rem; font-size: 0.8125rem; color: var(--ink-2); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-bottom: 32px; }

/* Charts and the timetable diagram read left to right in every language, as time does on a clock face. */
.chart, .diagram { direction: ltr; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font: 400 0.6875rem var(--figures); fill: var(--ink-2); }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .bar { fill: var(--ink); }
/* Clippers are drawn over the all-vessels bar, so they need 3:1 against both the ink and the paper. */
.chart .bar.sub { fill: var(--water); stroke: var(--ink); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .hit:hover + .bar, .chart .bar:hover { fill: var(--ink-2); }

.meter { display: inline-block; width: 120px; height: 8px; background: var(--paper-2); vertical-align: middle; margin-inline-end: 8px; }
.meter i { display: block; height: 100%; background: var(--ink); }

.note {
  border-inline-start: 3px solid var(--caution);
  padding: 8px 16px;
  margin: 0 0 24px;
  background: var(--paper-2);
  max-width: 80ch;
}

.note code { font: 0.8125rem var(--figures); }

.closures { list-style: none; }
.closures li + li { margin-top: 4px; }
.closures .line-code { margin-inline-end: 6px; }

/* Shown only to keyboards, as the first stop in the map's panel. */
.panel:has(> .skip) { position: relative; }
.skip { position: absolute; z-index: 2; margin: 8px; padding: 10px 14px; min-height: 44px; font: inherit; background: var(--ink); color: var(--paper); border: 0; }
.skip:not(:focus) { clip-path: inset(50%); width: 1px; height: 1px; padding: 0; margin: 0; overflow: hidden; }

.offline { max-width: 1180px; margin: 16px auto 0; }

.empty { color: var(--ink-2); padding: 24px 10px; white-space: normal; }

#tip {
  position: fixed;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  font: 0.75rem/1.4 var(--figures);
  padding: 6px 8px;
  z-index: 10;
  white-space: pre;
}

/* Help: a "?" toggletip on a heading or label, shown on hover and opened by a tap or a key press. */
.help-wrap { position: relative; display: inline-block; margin-inline-start: 6px; vertical-align: middle; line-height: 1; }

.help {
  position: relative;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1.5px solid var(--ink-2);
  border-radius: 50%;
  background: none;
  color: var(--ink-2);
  font: 600 0.6875rem/1 var(--body);
  cursor: pointer;
}

/* Pads the tap target to 44px without drawing the control bigger. */
.help::after { content: ""; position: absolute; inset: -13px; }
.help:hover, .help[aria-expanded="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* The transparent top border bridges the gap, so the pointer can move onto the tip without closing it. */
.help-wrap .help-tip {
  display: none;
  position: absolute;
  top: 100%;
  border-top: 6px solid transparent;
  background-clip: padding-box;
  inset-inline-start: 0;
  z-index: 10;
  width: max-content;
  max-width: 260px;
  padding: 6px 8px;
  background: var(--ink);
  color: var(--paper);
  font: 400 0.75rem/1.4 var(--body);
  letter-spacing: normal;
  text-transform: none;
  white-space: normal;
  text-align: start;
}

.help-wrap:hover .help-tip, .help[aria-expanded="true"] + .help-tip { display: block; }

footer { font-size: 0.75rem; color: var(--ink-2); padding-bottom: 2rem; }
footer p { margin: 0 0 4px; }
.signoff { margin-top: 8px; }

.maplibregl-ctrl-attrib { display: none; }

@media (pointer: coarse) {
  .maplibregl-ctrl-group button { width: 44px; height: 44px; }
}

/* Arrivals */

.arrivals { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 32px; }

.pier-list { display: flex; flex-direction: column; border-top: 2px solid var(--ink); align-self: start; }

.pier-list a {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  font-size: 0.875rem;
}

.pier-list a:hover { background: var(--paper-2); }
.pier-list a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.pier-list .codes { font: 600 0.75rem var(--display); letter-spacing: 0.06em; color: var(--ink-2); white-space: nowrap; }
.pier-list a[aria-current="page"] .codes { color: var(--water); }

tr.past td { color: var(--ink-2); }
tr.next td { border-block: 2px solid var(--ink); }
tr.next td:first-child { border-inline-start: 2px solid var(--ink); }
tr.next td:last-child { border-inline-end: 2px solid var(--ink); }

.distance {
  font: 600 0.8125rem var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 8px;
}

.distance:empty { display: none; }
.nearby { margin: -12px 0 16px; color: var(--ink-2); }
.nearby:empty { display: none; }
.nearby a { color: var(--ink); font-weight: 600; }
.strong { font-weight: 600; }

/* Vessel panel */

tr.pick { cursor: pointer; }
tr.pick td { height: 44px; }

.pick button {
  position: relative;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  text-align: start;
  cursor: pointer;
}

/* Pads the tap target to 44px without drawing the control bigger. */
.pick button::after { content: ""; position: absolute; inset: 50% 0 auto; height: 44px; transform: translateY(-50%); }

table.vessels { margin-top: 24px; }

.detail { padding: 16px; }
.detail .dim { margin: 0 0 12px; }
.detail .small { font-size: 0.75rem; }
/* The side panel is narrow, so its tables run to its edges and wrap rather than scroll sideways. */
.detail table { margin-inline: -16px; width: calc(100% + 32px); }
.detail th, .detail td { padding-inline: 6px; }
.detail td { white-space: normal; }

.back {
  font: 400 0.9375rem var(--body);
  letter-spacing: normal;
  text-transform: none;
  background: none;
  border: none;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 12px 0;
  cursor: pointer;
  margin-bottom: 16px;
}

/* The arrow is drawn, not typed, so screen readers don't announce it. */
.back::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  margin-block: 0 1px;
  margin-inline: 2px 8px;
}
[dir="rtl"] .back::before { transform: rotate(-135deg); }
.back:hover { text-decoration-thickness: 3px; }

.photo { position: relative; margin: 0 0 12px; }
.photo img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: var(--paper-2); }
.no-photo {
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 2;
  background: var(--paper-2);
  font: 600 0.8125rem var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.photo figcaption { font-size: 0.6875rem; color: var(--ink-2); margin-top: 0.25rem; }

.vessel-name {
  font: 600 1.875rem/1.05 var(--display);
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--ink);
  margin: 0 0 2px;
}

.trip { border-top: 2px solid var(--ink); padding-top: 10px; margin-bottom: 16px; }
.trip dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0 0; }
.trip dt { color: var(--ink-2); font-size: 0.8125rem; }
.trip dd { margin: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--rule);
  border-inline-start: 1px solid var(--rule);
  margin-bottom: 8px;
}

.stat-grid div { padding: 8px 10px; border-inline-end: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.stat-grid b { display: block; font: 600 1.625rem/1.1 var(--display); }

.stat-grid span {
  font: 600 0.6875rem var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.detail h3 {
  font: 600 0.8125rem var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 20px 0 4px;
}

/* Timetable diagram */

.diagram { display: flex; }
.diagram-labels { position: relative; flex: none; width: 180px; border-right: 1px solid var(--rule); }

.diagram-labels span {
  position: absolute;
  right: 10px;
  transform: translateY(-50%);
  font-size: 0.75rem;
  white-space: nowrap;
  color: var(--ink-2);
}

.diagram-scroll { overflow-x: auto; flex: 1; }
.diagram svg { display: block; }
.diagram text { font: 500 0.6875rem var(--figures); fill: var(--ink-2); }
.diagram .grid { stroke: var(--paper-2); stroke-width: 1; }
.diagram .grid.hour { stroke: var(--rule); }
.diagram .planned { fill: none; stroke: var(--ink-2); stroke-width: 1; }
.diagram .run { stroke-width: 2.5; stroke-linecap: round; stroke: var(--ink-2); }
.diagram .run.ok { stroke: var(--starboard); }
.diagram .run.late { stroke: var(--caution); }
.diagram .run.bad { stroke: var(--port); }
.diagram .run.predicted { stroke-dasharray: 3 4; }
.diagram .run:hover { stroke-width: 5; }
.diagram .now { stroke: var(--ink); stroke-width: 1.5; }

.swatch.planned {
  display: inline-block;
  width: 18px;
  border-top: 1px solid var(--ink-2);
  vertical-align: middle;
  margin-inline-end: 6px;
}

.swatch.all, .swatch.clippers { display: inline-block; width: 10px; height: 10px; margin-inline-end: 6px; background: var(--ink); }
.swatch.clippers { background: var(--water); border: 1px solid var(--ink); }

.legend { flex-wrap: wrap; align-items: center; }

@media (max-width: 900px) {
  .split, .grid-2, .arrivals { grid-template-columns: 1fr; }
  .masthead-inner { padding-bottom: 0; gap: 12px; }
  .masthead nav { margin-inline-start: 0; width: 100%; overflow-x: auto; order: 2; }
  .settings-open { margin-inline-start: auto; }
  .masthead nav a { white-space: nowrap; padding: 12px 10px 11px; }
  #clock { display: none; }
  main, .masthead-inner, footer { padding-left: 16px; padding-right: 16px; }
  main { padding-top: 20px; }
  h1 { font-size: 2rem; }
  .figure { flex: 1 1 40%; padding-inline-end: 12px; margin-inline-end: 12px; }
  .figure b { font-size: 2.25rem; }
  #map { height: 420px; }
  .board { max-height: none; }
  .pier-list { flex-direction: row; overflow-x: auto; border-top: 0; }
  .pier-list a { flex: none; border: 1px solid var(--rule); margin-inline-end: 4px; }
  .pier-list .codes { display: none; }
  .diagram-labels { width: 110px; overflow: hidden; }
  .diagram-labels span { max-width: 100px; overflow: hidden; text-overflow: ellipsis; }
  td, th { padding-inline: 0.375rem; font-size: 0.875rem; }
  .toolbar { flex-wrap: wrap; }
  .masthead nav, .pier-list { scrollbar-width: none; }
  /* The status column already carries the delay, so the expected time can go. */
  .wide-only { display: none; }
  /* Pinned to the foot of the screen, so a tip near the edge can't widen the page. */
  .help-wrap .help-tip { position: fixed; top: auto; inset-inline: 16px; bottom: 16px; width: auto; max-width: none; }
}

/* The side panel is narrow, and the status column already carries the delay. */
.board .wide-only { display: none; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.125rem 0.75rem; margin: 0 0 1rem; font-size: 0.8125rem; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; }

/* Settings */

.settings {
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  padding: 24px;
  width: min(480px, calc(100vw - 32px));
}

.settings::backdrop { background: rgb(0 0 0 / 0.4); }
.settings h2 { font: 600 1.625rem/1.1 var(--display); letter-spacing: 0.01em; text-transform: none; color: var(--ink); margin: 0 0 1rem; }

.choice { border: 0; padding: 0; margin: 0 0 20px; }
.choice legend, .settings .language {
  font: 600 0.75rem var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 0;
  margin-bottom: 8px;
}

.choice .segmented { flex-wrap: wrap; }

.choice label {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font: 600 0.8125rem var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-inline-end: 1.5px solid var(--ink);
  padding: 12px 14px;
  cursor: pointer;
}

.choice label:last-child { border-inline-end: 0; }
.choice label:has(:checked) { background: var(--ink); color: var(--paper); }
.choice label:has(:focus-visible) { outline: 2px solid var(--caution); outline-offset: 2px; }

.settings .language { display: flex; flex-direction: column; gap: 8px; }

.settings select {
  font: 400 0.9375rem var(--body);
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--ink);
  min-height: 44px;
  padding: 0 8px;
}

.settings .done {
  font: 600 0.9375rem var(--display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 24px;
  min-height: 44px;
  padding: 0 20px;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  cursor: pointer;
}
