/* =====================================================================
   Vessel tracking — vessel-tracking.html.
   A framed console on the ink ground: our own chart on the left, the
   vessel board on the right, three notes underneath.

   Depends on the tokens in css/styles.css.
   ===================================================================== */

/* The footer is ink as well and brings its own top padding, so this only
   needs enough to end the notes. */
.track--live {
  background: var(--ink);
  color: var(--paper);
  padding-bottom: clamp(1rem, 3vw, 2.5rem);
}

/* One framed instrument: chart on the left, vessel board on the right. */
.console {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--ink-2);
}

@media (min-width: 1024px) {
  .console {
    grid-template-columns: minmax(0, 1fr) clamp(330px, 28vw, 410px);
    height: clamp(600px, calc(100svh - 120px), 880px);
  }
}

/* ---------- Chart ---------- */
/* minmax(0, ...) on the column, or the unwrapped row of area chips sets its
   minimum and the chart is laid out 490px wide on a 390px phone. */
.chart {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

.chart-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

/* Scrolls sideways on a phone rather than wrapping to a second row. */
.chips {
  display: flex;
  gap: 0.4rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: color var(--duration-fast) ease, background-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
}

.chip:hover {
  color: var(--paper);
}

.chip.is-active {
  color: var(--ink);
  background: var(--paper);
  box-shadow: none;
}

.chart-zoom {
  display: flex;
  flex: none;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  overflow: hidden;
}

.chart-zoom button {
  width: 38px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--fog);
  transition: color var(--duration-fast) ease, background-color var(--duration-fast) ease;
}

.chart-zoom button + button {
  box-shadow: inset 1px 0 0 var(--line-strong);
}

.chart-zoom button:hover {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.06);
}

.chart-zoom svg {
  width: 12px;
  height: 12px;
}

/* A square on a phone: the view is clamped to the coastline data, and a tall
   box would need more latitude than there is land to draw. */
.chart-view {
  position: relative;
  min-height: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: radial-gradient(90% 90% at 45% 45%, #0f0e2c 0%, var(--ink) 72%);
}

@media (min-width: 700px) {
  .chart-view {
    aspect-ratio: 16 / 10;
  }
}

@media (min-width: 1024px) {
  .chart-view {
    aspect-ratio: auto;
  }
}

/* pan-y: a vertical swipe still scrolls the page, a sideways one pans the
   chart, a pinch zooms it. Same trade the hero globe and the planner make. */
.chart-view canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
  cursor: grab;
}

.chart-view canvas.is-dragging {
  cursor: grabbing;
}

.chart-view canvas:focus-visible {
  outline-offset: -3px;
}

.chart-tag,
.chart-scale,
.chart-coords {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  color: var(--fog);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
}

.chart-tag {
  left: 0.75rem;
  top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.7rem;
  border-radius: 4px;
  background: rgba(7, 7, 26, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: inset 0 0 0 1px var(--line);
}

.status-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fog-2);
}

.is-live > .status-dot {
  background: #3fd47a;
  box-shadow: 0 0 0 3px rgba(63, 212, 122, 0.2);
}

.is-wait > .status-dot {
  background: #f0b429;
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.2);
}

.is-down > .status-dot {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(237, 30, 36, 0.2);
}

/* Backed like the tag: at some zooms there is coast underneath it. */
.chart-scale {
  left: 0.75rem;
  bottom: 0.6rem;
  display: grid;
  gap: 0.3rem;
  padding: 0.35rem 0.5rem 0.45rem;
  border-radius: 4px;
  background: rgba(7, 7, 26, 0.7);
}

.chart-scale i {
  display: block;
  height: 5px;
  border: 1px solid var(--fog);
  border-top: 0;
}

.chart-coords {
  right: 0.85rem;
  bottom: 0.7rem;
  font-variant-numeric: tabular-nums;
}

@media (hover: none) {
  .chart-coords {
    display: none;
  }
}

.chart-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 0.7rem 0.85rem;
  border-top: 1px solid var(--line);
  color: var(--fog-2);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--fog);
}

.legend svg {
  width: 10px;
  height: 12px;
}

.chart-hint .hint-touch {
  display: none;
}

@media (hover: none) {
  .chart-hint .hint-pointer {
    display: none;
  }
  .chart-hint .hint-touch {
    display: inline;
  }
}

/* ---------- Board ---------- */
.board {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  background: var(--ink);
  border-top: 1px solid var(--line);
}

@media (min-width: 1024px) {
  .board {
    border-top: 0;
    border-left: 1px solid var(--line);
  }
}

.board-browse,
.board-detail {
  display: grid;
  min-height: 0;
}

.board-browse {
  grid-template-rows: auto minmax(0, 1fr);
}

.board-browse[hidden],
.board-detail[hidden] {
  display: none;
}

.board-head {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.board-status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--fog);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
}

.board-status time,
.board-status .board-updated {
  margin-left: auto;
  color: var(--fog-2);
  font-variant-numeric: tabular-nums;
}

.board-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.board-tab {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  color: var(--fog);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: color var(--duration-fast) ease, background-color var(--duration-fast) ease;
}

.board-tab b {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fog-2);
}

.board-tab:hover {
  color: var(--paper);
}

.board-tab.is-active {
  color: var(--white);
  background: var(--navy);
  box-shadow: inset 0 0 0 1px rgba(154, 164, 255, 0.4);
}

.board-tab.is-active b {
  color: var(--white);
}

/* 16px floor: iOS Safari zooms the page on focus below that and stays zoomed. */
.board-search input {
  width: 100%;
  font: inherit;
  font-size: max(16px, 0.95rem);
  color: var(--paper);
  background: var(--ink-2);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.board-search input::placeholder {
  color: var(--fog-2);
}

.board-search input:focus {
  outline: none;
  border-color: var(--periwinkle);
  box-shadow: 0 0 0 3px rgba(154, 164, 255, 0.18);
}

/* Scrolls inside the console on a desktop; on a phone the console has no
   fixed height, so the list is simply as long as it is. */
.board-scroll {
  min-height: 0;
}

@media (min-width: 1024px) {
  .board-scroll {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
  }
}

.vessel-list {
  display: grid;
}

.vessel-row {
  display: grid;
  grid-template-columns: 1.1rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  transition: background-color var(--duration-base) ease;
}

.vessel-row:hover,
.vessel-row:focus-visible {
  background: rgba(237, 30, 36, 0.08);
}

.vessel-row:focus-visible {
  outline-offset: -2px;
}

/* Same dart the chart draws, turned to the vessel's course. */
.vessel-mark {
  display: grid;
  place-items: center;
  width: 1.1rem;
  height: 1.1rem;
}

.vessel-mark svg {
  width: 11px;
  height: 13px;
  fill: var(--periwinkle);
  stroke: none;
}

.vessel-mark i {
  display: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--periwinkle);
}

.vessel-row.is-still .vessel-mark svg {
  display: none;
}

.vessel-row.is-still .vessel-mark i {
  display: block;
}

.vessel-row.is-bound .vessel-mark svg {
  fill: var(--red);
}

.vessel-row.is-bound .vessel-mark i {
  background: var(--red);
}

.vessel-row.is-quiet .vessel-mark {
  opacity: 0.5;
}

.vessel-row.is-lost .vessel-mark svg {
  fill: none;
  stroke: var(--red);
  stroke-width: 1.3;
}

.vessel-row.is-lost .vessel-mark i {
  background: none;
  box-shadow: inset 0 0 0 1.5px var(--red);
}

.vessel-id {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.vessel-id strong {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vessel-id small {
  color: var(--fog-2);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vessel-num {
  display: grid;
  gap: 0.2rem;
  justify-items: end;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--fog-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.vessel-num b {
  font-weight: 500;
  color: var(--paper);
}

.vessel-row.is-lost .vessel-num b {
  color: var(--red);
}

.board-empty,
.board-more {
  padding: 1.25rem 1rem;
  color: var(--fog-2);
  font-size: 0.9rem;
  line-height: 1.55;
}

.board-more {
  font-size: 0.8rem;
}

/* ---------- Selected vessel ---------- */
.board-detail {
  align-content: start;
  gap: 1rem;
  padding: 1rem;
}

@media (min-width: 1024px) {
  .board-detail {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
  }
}

.detail-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--fog);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  padding: 0.25rem 0;
  transition: color var(--duration-fast) ease;
}

.detail-back:hover {
  color: var(--paper);
}

.detail-back svg {
  width: 12px;
  height: 12px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  color: var(--fog);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.pill--bound {
  color: var(--white);
  background: var(--red);
  box-shadow: none;
}

.pill--lost {
  color: #ff8f93;
  box-shadow: inset 0 0 0 1px rgba(237, 30, 36, 0.55);
}

.detail-name {
  font-family: var(--font-display);
  font-weight: 900;
  text-transform: uppercase;
  font-size: clamp(2.1rem, 3vw, 2.75rem);
  line-height: 0.9;
  letter-spacing: 0.005em;
  overflow-wrap: anywhere;
}

.detail-ids {
  color: var(--fog-2);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  margin-top: -0.4rem;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

/* space-between: "To Benghazi" wraps on a phone, and the three figures
   should still sit on one line. */
.detail-stats > div {
  display: grid;
  align-content: space-between;
  gap: 0.35rem;
  padding: 0.85rem 0.75rem;
}

.detail-stats > div:first-child {
  padding-left: 0;
}

.detail-stats > div + div {
  border-left: 1px solid var(--line);
}

.detail-stats .mono {
  color: var(--fog-2);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.detail-stats b {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2rem;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.detail-stats b small {
  margin-left: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--fog-2);
}

.detail-note {
  padding: 0.75rem 0.85rem;
  border-radius: 6px;
  background: rgba(237, 30, 36, 0.09);
  box-shadow: inset 0 0 0 1px rgba(237, 30, 36, 0.3);
  color: var(--paper);
  font-size: 0.85rem;
  line-height: 1.5;
}

.detail-note[hidden] {
  display: none;
}

.detail-list {
  margin: 0;
  display: grid;
}

.detail-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.detail-list dt {
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fog-2);
}

.detail-list dd {
  margin: 0;
  text-align: right;
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* ---------- Notes under the console ---------- */
.track-notes {
  display: grid;
  gap: 2rem;
  margin-top: clamp(2.5rem, 5vw, 4rem);
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.track-fact {
  display: grid;
  gap: 0.5rem;
  align-content: start;
}

.track-fact h3 {
  color: var(--fog-2);
}

.track-fact p {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--fog);
}

.track-fact a {
  color: var(--paper);
  font-weight: 700;
  border-bottom: 1px solid currentColor;
}

.track-fact a:hover {
  color: var(--red);
}

@media (min-width: 800px) {
  .track-notes {
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
  }
}

@media (pointer: coarse) {
  .chip,
  .board-tab {
    min-height: 44px;
  }
  .chip {
    display: inline-flex;
    align-items: center;
  }
  .board-tab {
    align-items: center;
  }
  .chart-zoom button {
    width: 44px;
    height: 44px;
  }
  .detail-back {
    min-height: 44px;
  }
}
