:root {
  --bg: #02060d;
  --surface: rgba(12, 22, 36, 0.86);
  --surface-strong: rgba(16, 28, 46, 0.96);
  --border: rgba(120, 170, 220, 0.18);
  --text: #e6eef7;
  --text-muted: #8ea3b8;
  --accent: #4fc3f7;
  --live: #66bb6a;
  --warn: #ffb74d;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--font);
}

button,
input {
  font: inherit;
  color: inherit;
}

.globe {
  position: fixed;
  inset: 0;
}

.globe canvas {
  display: block;
  touch-action: none;
}

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand__mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #9fe3ff, var(--accent) 60%, #0a5f8a);
  box-shadow: 0 0 12px var(--accent);
}

.brand__logo {
  display: block;
  height: 48px;
  width: auto;
}

.search {
  position: relative;
  flex: 0 1 420px;
  margin: 0 auto;
}

/*
 * On a wide screen the search sits in the middle of the window, over the
 * globe's centre, whatever the widths of the logo and the buttons beside it.
 * --topbar-side is the room kept clear on each side for the buttons.
 */
@media (min-width: 1250px) {
  .topbar {
    --topbar-side: 480px;
  }

  .search {
    position: absolute;
    left: 50%;
    width: min(420px, calc(100% - 2 * var(--topbar-side)));
    margin: 0;
    transform: translateX(-50%);
  }

  /* Keeps the buttons on the right now that the search is out of the row. */
  .brand {
    margin-right: auto;
  }
}

.search__input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(8px);
  outline: none;
  box-shadow: var(--shadow);
}

.search__input:focus {
  border-color: var(--accent);
}

.search__results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 60vh;
  overflow-y: auto;
}

.search__result {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.search__result[aria-selected='true'],
.search__result:hover {
  background: rgba(79, 195, 247, 0.14);
}

.search__type {
  grid-row: span 2;
  align-self: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  width: 76px;
}

.search__sub {
  color: var(--text-muted);
  font-size: 12px;
}

.search__empty {
  padding: 8px 10px;
  color: var(--text-muted);
}

.toggle__short {
  display: none;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.toggle--link {
  color: var(--text);
  text-decoration: none;
}

.toggle--link:hover {
  border-color: var(--accent);
}

/* ---------- Info panel ---------- */
.panel {
  position: fixed;
  top: 76px;
  right: 16px;
  width: 340px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  padding: 16px;
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel__close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.panel__close:hover {
  color: var(--text);
}

.panel__eyebrow {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel__title {
  margin: 4px 24px 2px 0;
  font-size: 20px;
}

.panel__subtitle {
  margin: 0 0 12px;
  color: var(--text-muted);
}

.panel__section {
  margin-top: 16px;
}

.panel__section h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
}

.facts dt {
  color: var(--text-muted);
}

.facts dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(79, 195, 247, 0.16);
  color: var(--accent);
}

.pill--port {
  background: rgba(102, 187, 106, 0.16);
  color: var(--live);
}

.pill--approx {
  background: transparent;
  box-shadow: inset 0 0 0 1px currentColor;
}

.pill--unknown {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.list__gap {
  padding: 2px 0 2px 22px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list__item {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 2px 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 8px;
}

.list__item--link {
  cursor: pointer;
}

.list__item--link:hover {
  background: rgba(79, 195, 247, 0.1);
}

.list__item--completed {
  opacity: 0.5;
}

.list__item--current {
  background: rgba(102, 187, 106, 0.12);
}

.list__meta {
  grid-column: 2 / 4;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.marker {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
}

.list__item--current .marker {
  background: var(--live);
  border-color: var(--live);
}

.links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.links a {
  color: var(--accent);
  text-decoration: none;
}

.links a:hover {
  text-decoration: underline;
}

.note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Time bar ---------- */
.timebar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(860px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.timebar__slider {
  flex: 1;
  min-width: 80px;
  accent-color: var(--accent);
}

.timebar__date {
  color-scheme: dark;
  background: transparent;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 6px;
  font: inherit;
  font-size: 12px;
}

.timebar__speed {
  flex: none;
  font-size: 12px;
}

.timebar__label {
  min-width: 190px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.timebar__label small {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
}

.btn {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
}

.btn--live[aria-pressed='true'] {
  background: rgba(102, 187, 106, 0.2);
  border-color: var(--live);
  color: var(--live);
}

/* The dot is always there (grey when not live), so the button keeps its width and the ones beside it don't shift. */
.btn--live::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.6;
  vertical-align: middle;
}

.btn--live[aria-pressed='true']::before {
  background: var(--live);
  opacity: 1;
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* ---------- Labels, tooltip, status ---------- */
.label {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(2, 6, 13, 0.7);
  color: var(--text);
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-14px);
}

.label--ship {
  font-weight: 600;
}

/* The traveller on the road between two cruises (trip replay). */
.label--traveller {
  width: 14px;
  height: 14px;
  padding: 0;
  border: 3px solid #ffd54f;
  border-radius: 50%;
  background: rgba(2, 6, 13, 0.85);
  box-shadow: 0 0 0 1px rgba(2, 6, 13, 0.6);
  transform: none;
}

/* ?debug performance figures (DebugOverlay). */
.debug-overlay {
  position: fixed;
  right: 12px;
  bottom: 96px;
  z-index: 50;
  max-width: min(460px, calc(100vw - 24px));
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(2, 6, 13, 0.88);
  color: #d6e2f0;
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.debug-overlay strong {
  display: block;
  margin-bottom: 4px;
  color: #ffd54f;
}

.debug-overlay span {
  color: #8aa0b8;
}

.tooltip {
  position: fixed;
  z-index: 10;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  pointer-events: none;
  font-size: 12px;
  transform: translate(12px, 12px);
}

.tooltip small {
  display: block;
  color: var(--text-muted);
}

.status {
  position: fixed;
  left: 16px;
  bottom: 80px;
  color: var(--warn);
  font-size: 12px;
}

.disclaimer {
  position: fixed;
  left: 16px;
  bottom: 2px;
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  pointer-events: none;
}

/* ---------- Trip replay panel ---------- */
.trip-panel {
  right: auto;
  left: 16px;
  width: 330px;
}

.trip-panel__links {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0 24px 8px 0; /* clear of the close button */
}

.trip-panel__share {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.trip-panel__share:hover {
  text-decoration: underline;
}

.trip-panel__back {
  display: inline-block;
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
}

.trip-panel__back:hover {
  text-decoration: underline;
}

.trip-panel__title {
  margin: 4px 24px 2px 0;
  font-size: 18px;
}

.trip-progress {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  overflow: hidden;
}

.trip-progress__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: #ffd54f;
}

.trip-progress__tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(2, 6, 13, 0.7);
}

.trip-panel__days {
  margin: -8px 0 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.trip-panel .est {
  margin-right: 2px;
  color: var(--warn, #f5b942);
}

.trip-panel__clock {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* While a trip replays, its own timeline bar takes the time bar's place. */
.trip-mode #timebar,
.trip-mode #disclaimer {
  display: none;
}

/* "← Back to planner" in the trip panel replaces it: "Plan a cruise" reads like starting over. */
.trip-mode .plan-link {
  display: none;
}

.tripbar[hidden] {
  display: none;
}

.tripbar .trip-progress {
  flex: 1;
  min-width: 80px;
  margin: 0;
}

.trip-panel__ship {
  display: flex;
  align-items: center;
  gap: 6px;
}

.trip-panel__swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.trip-panel__status {
  margin-top: 2px;
  color: var(--text-muted);
}

/* Same width playing (❚❚) or paused (▶). */
.trip-panel__play {
  width: 44px;
  text-align: center;
}

.timebar__speed {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
}

.trip-panel__follow {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  cursor: pointer;
}

/* Show: other ships / other ports, to see the trip on its own. */
.trip-panel__others {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 10px;
  font-size: 13px;
}

.trip-panel__others-label {
  color: var(--text-muted);
}

.trip-panel__others label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.trip-panel__cruises {
  margin-top: 12px;
  font-size: 13px;
}

.trip-panel__cruises summary {
  color: var(--text-muted);
  cursor: pointer;
}

.trip-panel__cruises ol {
  max-height: 220px;
  margin: 6px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.trip-panel__cruises li {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 0 8px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.trip-panel__cruises li small {
  grid-column: 2;
  color: var(--text-muted);
}

.trip-panel__cruises li:hover,
.trip-panel__cruises li.is-current {
  background: rgba(255, 213, 79, 0.12);
}

@media (max-width: 720px) {
  .brand__name,
  .toggle__long {
    display: none;
  }

  /* Two rows: the brand and buttons (with short labels) on top, the search full width below it. */
  .topbar {
    top: 12px;
    left: 12px;
    right: 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* The logo gets its own row so the buttons stay together on the row below it. */
  .brand {
    flex: 1 0 100%;
  }

  .brand__logo {
    height: 32px;
  }

  .search {
    order: 1;
    flex: 1 0 100%;
    margin: 0;
  }

  .toggle {
    padding: 6px 10px;
    font-size: 13px;
  }

  .toggle__short {
    display: inline;
  }

  .panel {
    top: auto;
    bottom: 112px; /* clear of the two-row timebar */
    left: 16px;
    right: 16px;
    width: auto;
    max-height: 38vh;
  }

  /* Two rows on a phone: buttons, speed and time on top, the slider full width below.
     It sits a little higher, leaving a line for the data note beneath it. */
  .timebar {
    bottom: 24px;
    flex-wrap: wrap;
    gap: 4px 6px;
    border-radius: 22px;
  }

  /* The data note: one line under the timebar, cut short rather than wrapping into it. */
  .disclaimer {
    right: 16px;
    bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Messages ("Could not load data…") go above the two-row timebar, not inside it. */
  .status {
    right: 16px;
    bottom: 108px;
  }

  .timebar__slider,
  .tripbar .trip-progress {
    order: 1;
    flex-basis: 100%;
  }

  .timebar__speed {
    padding: 5px 6px;
  }

  /* The time takes whatever the buttons leave, so a longer date never moves them or wraps the row. */
  .timebar__label {
    flex: 1 1 0;
    min-width: 0;
    font-size: 12px;
  }

  .timebar__label,
  .timebar__label small {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .trip-panel {
    top: 112px; /* below the two-row top bar */
    bottom: auto;
    max-height: 42vh;
    padding: 12px;
  }

  .trip-panel .panel__subtitle,
  .trip-panel__days,
  .trip-panel__cruises {
    display: none;
  }

  /* While a trip plays, the trip panel is the one that matters on a small screen. */
  .trip-mode #info-panel {
    display: none;
  }

  #time-back,
  #time-forward,
  .timebar__date {
    display: none;
  }
}

/* Too narrow for the time beside the buttons: it takes a row of its own, so the panel sits higher. */
@media (max-width: 370px) {
  .panel:not(.trip-panel) {
    bottom: 144px;
  }

  .status {
    bottom: 144px;
  }

  /* No room beside the buttons: the time always gets its own row, rather than jumping there and back. */
  .timebar__label {
    flex-basis: 100%;
  }
}

/* ---------- Account (sign-in) ---------- */
/* At the end of a page's top bar: "Sign in", or Clerk's round avatar button once signed in. */
.account {
  display: flex;
  align-items: center;
  align-self: center;
}

.account[hidden] {
  display: none;
}

.account__sign-in {
  min-height: 36px;
}

/* Just the person, in a circle, where the words are hidden (below). */
@media (max-width: 720px) {
  .account__sign-in {
    padding: 8px 9px;
  }

  /*
   * On the globe, pinned to the right end of the logo's row, out of the
   * rows' layout: after the buttons it wraps onto a row of its own on a
   * phone and pushes the search further down over the globe, and in the
   * logo's row it would still wrap if Clerk's button were wider than planned.
   */
  .topbar .account {
    position: absolute;
    top: 0;
    right: 0;
    height: 32px; /* the logo's height here */
  }

  .topbar .brand {
    padding-right: 56px;
  }
}

/*
 * With the account button the globe's top bar only fits its long labels
 * ("All routes", "Approximate ships", "Sign in") on the widest screens, with
 * more room kept beside the centred search; below that it uses the short
 * ones, as on a phone.
 */
@media (min-width: 1500px) {
  .topbar:has(.account:not([hidden])) {
    --topbar-side: 580px;
  }
}

@media (max-width: 1499px) {
  .topbar:has(.account:not([hidden])) .toggle__long {
    display: none;
  }

  .topbar:has(.account:not([hidden])) .toggle__short {
    display: inline;
  }

  .topbar .account__sign-in {
    padding: 8px 9px;
  }
}

.sign-in-page,
html:has(.sign-in-page) {
  overflow: auto;
}

.sign-in-page {
  background: radial-gradient(1200px 600px at 20% -10%, #0c2238 0%, var(--bg) 60%) fixed, var(--bg);
}

.sign-in-page__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
}

.sign-in-page__main {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 48px;
}

.sign-in-page__message {
  color: var(--text-muted);
}

.sign-in-page__message[hidden] {
  display: none;
}

@media (max-width: 720px) {
  .sign-in-page__top .brand__logo {
    height: 32px;
  }
}

.sign-in-page__retry {
  margin-top: 4px;
}
