@font-face {
  font-family: "Inter";
  src: url("../vendor/inter/inter-latin-400-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("../vendor/inter/inter-latin-500-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("../vendor/inter/inter-latin-600-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("../vendor/inter/inter-latin-700-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  --font-ui: "Inter", "Arial", sans-serif;

  --colour-ink-strong: #292a2e;
  --colour-ink: #45474c;
  --colour-ink-muted: #70737a;
  --colour-surface: #ffffff;
  --colour-surface-subtle: #f5f5f3;
  --colour-surface-raised: #fafaf9;
  --colour-border: #d7d9dc;
  --colour-border-strong: #aeb2b7;
  --colour-water: #ddecf3;
  --colour-focus: #126a9c;
  --colour-danger: #b32632;
  --colour-warning: #a86100;

  --radius-control: 8px;
  --radius-panel: 12px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  --dock-width: 72px;
  --dock-height-mobile: calc(72px + env(safe-area-inset-bottom, 0px));

  color: var(--colour-ink);
  font-family: var(--font-ui);
  font-synthesis: none;
}

:root[data-theme="dark"] {
  --colour-ink-strong: #f3f4f4;
  --colour-ink: #d9dbdd;
  --colour-ink-muted: #a9adb2;
  --colour-surface: #202226;
  --colour-surface-subtle: #17191c;
  --colour-surface-raised: #2a2d31;
  --colour-border: #3d4147;
  --colour-border-strong: #656a72;
  --colour-focus: #62b4df;
  --colour-danger: #ff7f89;
  --colour-warning: #f0b24a;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body,
.viewer-shell {
  height: 100%;
  margin: 0;
  width: 100%;
}

body {
  background: var(--colour-surface-subtle);
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

.viewer-shell {
  isolation: isolate;
  overflow: hidden;
  position: relative;
}

body.map-is-loading .viewer-shell, body.map-is-loading .viewer-shell *,
.viewer-shell:has(.selection-stop-departures[data-state="loading"]),
.viewer-shell:has(.selection-stop-departures[data-state="loading"]) * {
  cursor: wait !important;
}

body.map-is-loading .map { pointer-events: none; }

.map {
  background: var(--colour-water);
  bottom: 0;
  left: var(--dock-width);
  position: absolute;
  right: 0;
  top: 0;
}

.viewer-shell.dock-collapsed .map {
  left: 0;
}

.map-loading-backdrop {
  background: var(--colour-surface);
  bottom: 0;
  left: var(--dock-width);
  position: absolute;
  right: 0;
  top: 0;
  z-index: 3;
}

.map-loading-backdrop[hidden] { display: none; }
.viewer-shell.dock-collapsed .map-loading-backdrop { left: 0; }

.map-loading-overlay {
  align-items: center;
  background: color-mix(in srgb, var(--colour-surface) 90%, transparent);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-panel);
  box-shadow: 0 5px 18px rgba(20, 24, 28, 0.12);
  color: var(--colour-ink-strong);
  display: flex;
  font-size: 14px;
  font-weight: 600;
  gap: var(--space-3);
  bottom: var(--space-6);
  max-width: min(360px, calc(100vw - var(--dock-width) - var(--space-8)));
  padding: 13px 17px;
  pointer-events: none;
  position: absolute;
  right: var(--space-6);
  z-index: 5;
}

.map-loading-overlay[hidden] {
  display: none;
}

.map-loading-overlay.is-error {
  border-color: color-mix(in srgb, var(--colour-danger) 45%, var(--colour-border));
  color: var(--colour-danger);
}

.map-loading-spinner {
  animation: map-loading-spin 0.8s linear infinite;
  border: 2px solid var(--colour-border);
  border-radius: 50%;
  border-top-color: var(--colour-focus);
  height: 18px;
  width: 18px;
}

.map-loading-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.map-loading-progress { background: var(--colour-border); border-radius: 99px; display: block; height: 3px; margin-top: 7px; overflow: hidden; width: 100%; }
.map-loading-progress[hidden] { display: none; }
.map-loading-progress > span { animation: map-loading-progress 1.5s ease-in-out infinite; background: var(--colour-focus); border-radius: inherit; display: block; height: 100%; width: 40%; }
@keyframes map-loading-progress { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

#map-loading-note {
  color: var(--colour-ink-muted);
  font-size: 12px;
  font-weight: 400;
  max-width: 310px;
}

.viewer-shell.dock-collapsed .map-loading-overlay { max-width: min(360px, calc(100vw - var(--space-8))); }

@keyframes map-loading-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .map-loading-spinner { animation: none; }
  .map-loading-progress > span { animation: none; width: 100%; }
}

.app-dock {
  align-items: center;
  background: var(--colour-surface);
  border-right: 1px solid var(--colour-border);
  bottom: 0;
  display: flex;
  flex-direction: column;
  left: 0;
  padding: var(--space-2) 0;
  position: absolute;
  top: 0;
  width: var(--dock-width);
  z-index: 6;
}

.viewer-shell.dock-collapsed .app-dock {
  display: none;
}

.app-identity {
  align-items: center;
  display: flex;
  height: 56px;
  justify-content: center;
  width: 56px;
}

.app-mark {
  fill: var(--colour-surface);
  height: 36px;
  stroke: var(--colour-ink-strong);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 36px;
}

.app-mark path {
  fill: none;
}

.dock-primary,
.dock-secondary {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
}

.dock-primary {
  border-top: 1px solid var(--colour-border);
  margin-top: var(--space-2);
  padding-top: var(--space-3);
}

.dock-secondary {
  margin-top: auto;
}

.dock-button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  color: var(--colour-ink-muted);
  cursor: pointer;
  display: flex;
  height: 52px;
  justify-content: center;
  padding: 0;
  position: relative;
  width: 52px;
}

.dock-button:hover {
  background: var(--colour-surface-raised);
  color: var(--colour-ink-strong);
}

.dock-button[aria-expanded="true"] {
  background: color-mix(in srgb, var(--colour-focus) 13%, var(--colour-surface));
  border-color: color-mix(in srgb, var(--colour-focus) 45%, var(--colour-border));
  color: var(--colour-focus);
}

.dock-button:disabled {
  cursor: wait;
  opacity: 0.45;
}

.dock-button svg {
  fill: none;
  height: 25px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 25px;
}

.dock-button-alerts .alert-fill {
  fill: #f4c34f;
  stroke: #9a6800;
}

.dock-button-alerts svg path:not(.alert-fill) {
  stroke: #513b0d;
}

.dock-button-badge {
  background: var(--colour-surface);
  border: 1px solid var(--colour-border-strong);
  border-radius: 999px;
  bottom: 1px;
  color: var(--colour-ink-strong);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 13px;
  padding: 0 4px;
  position: absolute;
  right: -1px;
}

.theme-icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-icon-sun {
  display: block;
}

.dock-collapse {
  align-items: center;
  background: var(--colour-surface);
  border: 1px solid var(--colour-border);
  border-left: 0;
  border-radius: 0 var(--radius-control) var(--radius-control) 0;
  color: var(--colour-ink-muted);
  cursor: pointer;
  display: flex;
  height: 48px;
  justify-content: center;
  left: var(--dock-width);
  padding: 0;
  position: absolute;
  top: calc(50% - 24px);
  width: 22px;
  z-index: 7;
}

.dock-collapse:hover {
  color: var(--colour-ink-strong);
}

.dock-collapse svg {
  fill: none;
  height: 16px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 16px;
}

.viewer-shell.dock-collapsed .dock-collapse {
  left: 0;
}

.viewer-shell.dock-collapsed .dock-collapse svg {
  transform: rotate(180deg);
}

.eyebrow {
  color: var(--colour-ink-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 15px;
  margin: 0 0 var(--space-2);
  text-transform: uppercase;
}

.status-row {
  align-items: center;
  color: var(--colour-ink-muted);
  display: flex;
  font-size: 13px;
  gap: var(--space-2);
  line-height: 17px;
}

.status-dot {
  background: var(--colour-warning);
  border-radius: 50%;
  height: 8px;
  width: 8px;
}

.status-row[data-state="ready"] .status-dot {
  background: var(--colour-focus);
}

.map-status-spinner { animation: map-loading-spin 0.8s linear infinite; border: 2px solid var(--colour-border); border-radius: 50%; border-top-color: var(--colour-focus); display: block; height: 12px; width: 12px; }
.status-row[data-state="ready"] .map-status-spinner { display: none; }
.status-row[data-state="error"] .map-status-spinner { animation: none; border-color: var(--colour-danger); }
.map-status-bar:has(.status-row[data-state="ready"]) { display: none; }

.status-row[data-state="error"] .status-dot {
  background: var(--colour-danger);
}

.map-status-bar {
  align-items: baseline;
  background: color-mix(in srgb, var(--colour-surface) 94%, transparent);
  border: 1px solid color-mix(in srgb, var(--colour-border-strong) 72%, transparent);
  border-radius: var(--radius-control);
  bottom: var(--space-6);
  box-shadow: 0 4px 16px rgb(41 42 46 / 9%);
  display: flex;
  flex-wrap: wrap;
  font-size: 11px;
  gap: var(--space-2);
  left: calc(var(--dock-width) + var(--space-4));
  line-height: 15px;
  padding: var(--space-2) var(--space-3);
  position: absolute;
  z-index: 4;
}

.viewer-shell.dock-collapsed .map-status-bar {
  left: var(--space-4);
}

.map-status-summary,
.project-acknowledgement {
  color: var(--colour-ink-muted);
}

.status-divider {
  align-self: stretch;
  border-left: 1px solid var(--colour-border);
}

.maplibregl-ctrl-group {
  background: var(--colour-surface);
  border: 1px solid var(--colour-border-strong);
  box-shadow: 0 4px 16px rgb(41 42 46 / 10%);
  overflow: hidden;
}

.maplibregl-ctrl-group button {
  background-color: var(--colour-surface);
  border-color: var(--colour-border);
  height: 44px;
  width: 44px;
}

.maplibregl-ctrl-group button:hover {
  background-color: var(--colour-surface-raised);
}

:root[data-theme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  filter: invert(1) brightness(1.35);
}

.maplibregl-ctrl-attrib {
  color: var(--colour-ink-muted);
  font-family: var(--font-ui);
  font-size: 11px;
}

.maplibregl-ctrl-top-right {
  bottom: 30px;
  top: auto;
}

:focus-visible {
  outline: 3px solid var(--colour-focus);
  outline-offset: 2px;
}

.noscript-message {
  background: var(--colour-surface);
  color: var(--colour-danger);
  inset: var(--space-4);
  margin: 0;
  padding: var(--space-4);
  position: fixed;
  z-index: 10;
}

@media (max-width: 700px), (max-width: 1000px) and (max-height: 500px) {
  .map {
    bottom: var(--dock-height-mobile);
    left: 0;
  }

  .app-dock {
    border-right: 0;
    border-top: 1px solid var(--colour-border);
    flex-direction: row;
    height: var(--dock-height-mobile);
    justify-content: space-around;
    padding: 0 var(--space-1);
    top: auto;
    width: 100%;
  }

  .app-identity {
    height: 52px;
    width: 44px;
  }

  .app-mark {
    height: 30px;
    width: 30px;
  }

  .dock-primary,
  .dock-secondary {
    flex-direction: row;
    gap: var(--space-1);
    margin: 0;
    padding: 0;
    width: auto;
  }

  .dock-primary {
    border-top: 0;
  }

  .dock-button {
    height: 48px;
    width: 48px;
  }

  .dock-collapse {
    display: none;
  }

  .map-status-bar,
  .viewer-shell.dock-collapsed .map-status-bar {
    bottom: calc(var(--dock-height-mobile) + var(--space-2));
    left: var(--space-2);
    max-width: calc(100vw - var(--space-4));
  }

  .map-loading-overlay {
    bottom: calc(var(--dock-height-mobile) + var(--space-4));
    max-width: calc(100vw - var(--space-4));
    right: var(--space-2);
  }

  .map-loading-backdrop { bottom: var(--dock-height-mobile); left: 0; }

  .map-status-summary,
  .status-divider-wide,
  .project-acknowledgement {
    display: none;
  }

  .maplibregl-ctrl-top-right {
    bottom: calc(var(--dock-height-mobile) + 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Labels share the existing dock; compact screens retain five direct actions. */
.dock-button { flex-direction: column; gap: 3px; flex-shrink: 0; }
.dock-label { font-size: 10px; font-weight: 600; line-height: 12px; }
.dock-button svg { height: 23px; width: 23px; }
.dock-button-badge { bottom: auto; top: -3px; right: -3px; }
.dock-button:focus-visible, .tool-panel-close:focus-visible,
.selection-panel-close:focus-visible { outline: 2px solid var(--colour-focus); outline-offset: -2px; }
@media (max-width: 700px), (max-width: 1000px) and (max-height: 500px) {
  .viewer-shell { height: 100dvh; }
  .app-dock, .viewer-shell.dock-collapsed .app-dock {
    display: flex; padding: 4px max(8px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }
  .app-identity, #dock-step-free, #dock-map-style, #dock-theme { display: none; }
  .dock-primary { flex: 4; justify-content: space-around; min-width: 0; }
  .dock-secondary { flex: 1; justify-content: center; min-width: 0; }
  .dock-button { height: 56px; width: 56px; }
  .viewer-shell.dock-collapsed .map { bottom: var(--dock-height-mobile); }
}

@media (max-width: 700px), (max-width: 1000px) and (max-height: 500px) {
  .maplibregl-ctrl-top-right { top: 12px; bottom: auto; }
  .maplibregl-ctrl-group button { width: 44px; height: 44px; }
  .map-loading-overlay:not(.is-error) .map-loading-note { display: none; }
}

/* Browser-native surfaces belong to the same quiet ink/signal system. */
::selection { background: var(--signal-tint, #fff0e9); color: var(--colour-ink-strong); }
input, textarea { caret-color: var(--colour-focus); }
.tool-panel, .selection-panel { scrollbar-color: var(--colour-border-strong) var(--colour-surface); scrollbar-width: thin; }
:is(button, summary, select, input[type="checkbox"], input[type="radio"]) { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
