/* Navigation chart, Glass HUD (design/design_handoff_bridge_glass README,
   "Pane C — chart"). One glass instrument: a 48 px grid, world dots over mono
   labels, the dashed 180 px ring round the current position, the dashed
   route with a 44 px destination ring and, under way, the ship triangle. The
   level controls are .gl-seg buttons in the pane head; the text index lives
   in the Helm detail. glass.css loads after this file, so rules that must
   outrank a single-class primitive carry an extra class. */

/* ── The instrument in Pane C ─────────────────────────────────────────── */
.gl-pane-c > .nav-chart {
  position: relative; display: flex; flex-direction: column; flex: 1 1 auto;
  min-width: 0; min-height: 252px; height: auto; max-height: none;
  margin: 0; padding: 0; overflow: visible; border: 0; background: none;
}
.nav-chart .nav-glass {
  /* README min-height 250 px inside its 1 px border (content-box in the prototype). */
  position: relative; flex: 1 1 auto; box-sizing: border-box; width: 100%; min-height: 252px;
  overflow: hidden; border: 1px solid var(--line); border-radius: 0; box-shadow: none;
  background-color: rgba(255, 255, 255, .03);
  background-image: repeating-linear-gradient(90deg, var(--line-soft) 0 1px, transparent 1px 48px),
    repeating-linear-gradient(0deg, var(--line-soft) 0 1px, transparent 1px 48px);
}
.nav-chart .nav-glass > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.nav-chart .nav-bearing {
  position: absolute; left: 12px; top: 10px; z-index: 1; margin: 0;
  font: 400 11px/1 var(--font-mono); letter-spacing: .06em; color: var(--ink-muted);
  white-space: nowrap; pointer-events: none;
}
.nav-chart .nav-status { position: absolute; left: 12px; right: 12px; top: 50%; margin: 0; transform: translateY(-50%); text-align: center; font: 400 13px/1.45 var(--font-ui); color: var(--ink-muted); }
.nav-chart .nav-retry { position: absolute; left: 50%; top: calc(50% + 28px); transform: translateX(-50%); }

/* Drawing (SVG in a 0–100 box; strokes stay 1 screen px). */
.nav-course { fill: none; stroke: var(--accent-60); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.nav-range { fill: none; stroke: var(--accent-40); stroke-width: 1; vector-effect: non-scaling-stroke; }
.nav-range.full, .nav-range.paused { stroke-dasharray: 4 4; }
.nav-sector-tile { fill: var(--accent); stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.nav-frontier { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
#nav-frontier path { stroke: var(--muted-40); stroke-width: .15; }
.nav-port-dot { fill: var(--ink-muted); opacity: .45; }
/* Leaders tie a moved marker or name to its world: solid and faint, so they
   never read as the dashed course. */
.nav-pin-leader, .nav-label-leader { stroke: var(--ink-muted); stroke-width: 1; opacity: .45; vector-effect: non-scaling-stroke; }

/* The dashed ring round the current position (README: 180 px, accent 60%).
   NavChart.fitRing narrows it through --nav-ring only where 180 px would run
   past the glass, so it stays whole and centred on the port (56 px at least). */
.nav-chart .nav-local-ring {
  position: absolute; z-index: 0; box-sizing: border-box; width: var(--nav-ring, 180px); height: var(--nav-ring, 180px);
  transform: translate(-50%, -50%); border: 1px dashed var(--accent-60); border-radius: 50%; pointer-events: none;
}
/* Its port's name keeps the README place under the dot. Where a fitted ring
   crosses that name, NavChart.layoutLabels knocks the ring out behind it: a
   hole the name's size and 3 px round it (edges --knock-l/t/r/b, in the
   ring's box), so the dashes stop short of the text. The outer edge runs
   8 px outside the box, so the rest of the ring is drawn as before. */
.nav-chart .nav-local-ring.nav-ring-knock {
  clip-path: polygon(evenodd, -8px -8px, calc(100% + 8px) -8px, calc(100% + 8px) calc(100% + 8px), -8px calc(100% + 8px), -8px -8px,
    var(--knock-l) var(--knock-t), var(--knock-r) var(--knock-t), var(--knock-r) var(--knock-b), var(--knock-l) var(--knock-b), var(--knock-l) var(--knock-t));
}

/* Markers: a 20 px target round each world's dot for a fine pointer, so
   the chart stays geographic (the chart index is the full-size alternative);
   44 px on touch and narrow screens, below. Galaxy tiles carry text: 44 px. */
.nav-chart .nav-pin, .nav-chart .nav-tile {
  -webkit-appearance: none; appearance: none; box-sizing: border-box;
  position: absolute; z-index: 2; transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; min-width: 20px; min-height: 20px; margin: 0; padding: 0;
  border: 0; border-radius: 50%; background: transparent; box-shadow: none; color: var(--ink);
  font: 400 11px/1 var(--font-mono); letter-spacing: 0; text-transform: none; cursor: pointer;
}
.nav-chart .nav-pin:hover { background: var(--accent-10); }
.nav-chart .nav-pin:focus, .nav-chart .nav-pin:hover { z-index: 4; }
.nav-chart .nav-dot {
  display: block; flex: none; box-sizing: content-box; width: 10px; height: 10px; border-radius: 50%;
  background: var(--good); box-shadow: 0 0 8px rgba(159, 212, 166, .5);
}
.nav-chart .nav-pin.current .nav-dot { width: 12px; height: 12px; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-20), 0 0 14px var(--accent); }
/* A course: the plotted port while docked, the destination under way. */
.nav-chart .nav-pin.course::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; transform: translate(-50%, -50%);
  border: 1px dashed var(--accent); border-radius: 50%; box-shadow: 0 0 12px var(--accent-40); pointer-events: none;
}
.nav-chart .nav-pin.selected:not(.course) .nav-dot { box-shadow: 0 0 0 3px var(--accent-40), 0 0 8px rgba(159, 212, 166, .5); }
.nav-chart .nav-pin.opportunity::after {
  content: ''; position: absolute; left: calc(50% + 7px); top: calc(50% - 13px); width: 5px; height: 5px;
  border: 1px solid var(--accent); transform: rotate(45deg); pointer-events: none;
}
.nav-chart .nav-pin-label { display: none !important; }
.nav-chart .nav-map-label {
  position: absolute; z-index: 3; margin: 0; padding: 0; background: none;
  font: 400 11px/1 var(--font-mono); letter-spacing: 0; color: var(--ink); white-space: nowrap; pointer-events: none;
}
/* Ports counted together (marker groups and phone groups). */
.nav-chart .nav-pin.nav-density, .nav-chart .nav-pin.nav-generated-group {
  border: 1px dashed var(--accent-60); background: var(--glass); color: var(--accent);
  font: 400 12px/1 var(--font-mono);
}
.nav-chart .nav-pin.nav-generated-group { border-style: solid; }
.nav-chart .nav-pin.nav-density, .nav-chart .nav-pin.nav-generated-group { width: 26px; height: 26px; min-width: 26px; min-height: 26px; }
@media (max-width: 640px), (pointer: coarse) {
  .nav-chart .nav-pin, .nav-chart .nav-pin.nav-density, .nav-chart .nav-pin.nav-generated-group { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
}
/* Galaxy: one tile per explored sector. */
.nav-chart .nav-tile { width: 44px; height: 44px; min-width: 44px; min-height: 44px; border-radius: 0; border: 1px solid var(--accent-60); background: var(--glass); color: var(--ink); flex-direction: column; gap: 2px; }
.nav-chart .nav-tile:hover { background: var(--accent-10); border-color: var(--accent); }
.nav-chart .nav-tile small { display: none; }

/* The ship under way: a 14 px accent triangle toward its destination. */
.nav-chart .nav-ship-marker { position: absolute; z-index: 3; width: 0; height: 0; pointer-events: none; }
.nav-chart .nav-ship-marker > i {
  position: absolute; left: -7px; top: -7px; width: 0; height: 0;
  border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 14px solid var(--accent);
  transform: rotate(var(--heading, 0deg)); transform-origin: 7px 7px; filter: drop-shadow(0 0 6px var(--accent));
}
.nav-chart .nav-ship-label {
  position: absolute; left: 0; top: 13px; transform: translateX(-50%);
  font: 400 11px/1 var(--font-mono); color: var(--accent); white-space: nowrap;
}

/* Funded notices: a small tag beside the port (folded to a corner when crowded). */
.nav-chart .nav-notice-tag {
  position: absolute; z-index: 4; box-sizing: border-box; display: flex; align-items: center;
  height: 18px; padding: 0 6px; border: 1px solid var(--accent); background: var(--glass); color: var(--accent);
  font: 400 10px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; pointer-events: none;
}
.nav-chart .nav-notice-tag.folded { width: 8px; height: 8px; padding: 0; border: 0; background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 100%); }
/* A port's own notice: the second line of its label, placed with the name. */
.nav-chart .nav-label-notice {
  display: block; width: max-content; margin-top: 3px; padding: 2px 5px; border: 1px solid var(--accent);
  background: var(--glass); color: var(--accent); font: 400 10px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase;
}
/* Legend keys for the marks the chart draws besides the dots. */
.nav-legend .nav-legend-tile { display: block; flex: none; box-sizing: border-box; width: 10px; height: 10px; border: 1px solid var(--accent-60); background: var(--glass); }
.nav-legend .nav-legend-hatch { background: repeating-linear-gradient(135deg, var(--muted-40) 0 1px, transparent 1px 3px); }
.nav-legend .nav-legend-opportunity { display: block; flex: none; box-sizing: border-box; width: 7px; height: 7px; margin: 0 1px; border: 1px solid var(--accent); transform: rotate(45deg); }
.nav-legend .nav-legend-notice { display: block; flex: none; box-sizing: border-box; width: 12px; height: 8px; border: 1px solid var(--accent); }
.nav-legend .nav-legend-group { display: block; flex: none; box-sizing: border-box; width: 10px; height: 10px; border: 1px solid var(--accent-60); border-radius: 50%; background: var(--glass); }
.nav-legend .nav-legend-group--dashed { border-style: dashed; }

/* A crowded group opens as a list over the chart. */
.nav-chart .nav-cluster-picker {
  position: absolute; z-index: 6; left: 8px; top: 8px; box-sizing: border-box;
  max-width: calc(100% - 16px); max-height: calc(100% - 16px); overflow: auto; padding: 10px 12px 12px;
  background: rgb(8 12 9 / .95); border: 1px solid var(--line); box-shadow: var(--hairline-top);
}
.nav-chart .nav-cluster-picker > .gl-head { align-items: center; margin-bottom: 8px; }
.nav-chart .nav-group-ports { display: grid; gap: 6px; }
.nav-chart .nav-group-ports .gl-btn { justify-content: flex-start; height: auto; min-height: 28px; padding-block: 6px; white-space: normal; text-align: left; }
.nav-group-preview {
  position: fixed; z-index: 40; top: 16px; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: min(480px, calc(100vw - 32px)); padding: 8px 12px;
  background: rgb(8 12 9 / .95); border: 1px solid var(--line); color: var(--ink);
  font: 400 12px/1.4 var(--font-mono); pointer-events: none;
}

/* ── The text index (Helm detail) ─────────────────────────────────────── */
.nav-index { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.nav-index .nav-caption { margin: 0; font: 400 13px/1.45 var(--font-ui); color: var(--ink-muted); }
.nav-index .nav-pan, .nav-index .nav-pages { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.nav-index .nav-pages { justify-content: space-between; }
.nav-index .nav-page { font: 400 11px/1 var(--font-mono); color: var(--ink-muted); }
.nav-index .nav-routes > summary {
  display: flex; align-items: center; gap: 8px; min-height: 28px; cursor: pointer; list-style: none;
  font: 500 11px/1 var(--font-ui); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-muted);
}
.nav-index .nav-routes > summary::-webkit-details-marker { display: none; }
.nav-index .nav-routes > summary::before { content: '\25B8'; font: 400 11px/1 var(--font-ui); }
.nav-index .nav-routes[open] > summary::before { content: '\25BE'; }
/* The list scrolls inside a 360 px box; its rows keep their content height
   (flex: none), and a 4 px inner margin keeps the 2 px focus ring, drawn
   2 px outside a row, inside the scrolling box. */
.nav-index [role="listbox"] {
  display: flex; flex-direction: column; max-height: 360px; overflow: auto;
  margin-top: 6px; padding: 4px; scroll-padding: 4px; border-top: 1px solid var(--accent-60);
}
.nav-index [role="listbox"] > .nav-route-row { flex: none; }
.nav-index .nav-route-row {
  -webkit-appearance: none; appearance: none; box-sizing: border-box;
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: 100%; min-height: 44px; margin: 0; padding: 8px 10px 8px 8px;
  border: 0; border-bottom: 1px solid var(--line-soft); border-left: 2px solid transparent; border-radius: 0;
  background: transparent; color: var(--ink); text-align: left; text-transform: none; letter-spacing: 0;
  font: 400 13px/1.4 var(--font-ui); cursor: pointer;
}
.nav-index .nav-sector-row { grid-template-columns: minmax(0, 1fr) auto; }
.nav-index .nav-route-row:hover { background: rgba(255, 255, 255, .04); }
.nav-index .nav-route-row[aria-selected="true"] { border-left-color: var(--accent); background: var(--accent-12); }
.nav-index .nav-route-name { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.nav-index .nav-route-name strong { font: 400 13px/1.3 var(--font-ui); color: inherit; }
.nav-index .nav-route-row[aria-selected="true"] .nav-route-name strong { color: var(--accent); }
.nav-index .nav-route-name small { display: flex; align-items: center; gap: 6px; font: 400 11px/1.35 var(--font-mono); color: var(--ink-muted); }
.nav-index .nav-route-cost { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font: 400 12px/1.2 var(--font-mono); color: var(--ink); white-space: nowrap; }
.nav-index .nav-route-cost small { font: 400 11px/1.2 var(--font-mono); color: var(--ink-muted); }
.nav-index .nav-route-cost i { display: block; width: var(--route-length); max-width: 70px; height: 2px; background: var(--accent); }
.nav-index .nav-route-cost i.blocked { background: var(--bad); }
.nav-globe { flex: none; color: var(--ink-muted); }
.nav-globe circle { fill: #3a423a; stroke: var(--accent-60); stroke-width: 1.3; }
.nav-globe path { fill: none; stroke: #0e120f; stroke-width: 1.4; }
.nav-globe-oceanic circle, .nav-globe-gas circle { fill: #4f6e6c; }
.nav-globe-ice circle { fill: #8fa3a2; }
.nav-globe-volcanic circle { fill: #8a5a3f; }
.nav-globe-temperate circle { fill: #5f7350; }
.nav-chart [hidden], .nav-index [hidden] { display: none !important; }
.nav-chart .sr-only, .nav-index .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ── Phones: a taller instrument for the 44 px targets ────────────────── */
@media (max-width: 760px), (max-width: 1279px) and (max-height: 500px) and (pointer: coarse) {
  .gl-pane-c > .nav-chart, .nav-chart .nav-glass { min-height: 300px; }
  .nav-index .nav-route-row { grid-template-columns: 24px minmax(0, 1fr); }
  .nav-index .nav-sector-row { grid-template-columns: minmax(0, 1fr); }
  .nav-index .nav-route-cost { grid-column: 2; align-items: flex-start; white-space: normal; }
  .nav-index .nav-routes > summary { min-height: 44px; }
}

/* ── Forced colours: the marks keep system colours ────────────────────── */
@media (forced-colors: active) {
  .nav-chart .nav-glass { forced-color-adjust: none; background: Canvas; border-color: CanvasText; }
  .nav-chart .nav-bearing, .nav-chart .nav-map-label, .nav-chart .nav-status { color: CanvasText; }
  .nav-chart .nav-dot { forced-color-adjust: none; background: CanvasText; box-shadow: none; }
  .nav-chart .nav-pin.current .nav-dot { background: Highlight; box-shadow: 0 0 0 3px Canvas, 0 0 0 4px Highlight; }
  .nav-chart .nav-pin.course::before, .nav-chart .nav-local-ring { border-color: CanvasText; box-shadow: none; }
  .nav-chart .nav-pin { forced-color-adjust: none; background: transparent; color: CanvasText; }
  .nav-chart .nav-pin:hover { background: transparent; outline: 1px solid Highlight; }
  .nav-chart .nav-ship-marker > i { border-bottom-color: Highlight; filter: none; }
  .nav-chart .nav-ship-label { color: Highlight; }
  .nav-course, .nav-range, .nav-frontier, .nav-pin-leader, .nav-label-leader { stroke: CanvasText; }
  .nav-sector-tile { fill: GrayText; stroke: CanvasText; }
  .nav-chart .nav-notice-tag, .nav-chart .nav-label-notice { border-color: CanvasText; background: Canvas; color: CanvasText; }
  .nav-legend :is(.nav-legend-tile, .nav-legend-opportunity, .nav-legend-notice, .nav-legend-group) { forced-color-adjust: none; border-color: CanvasText; background: Canvas; }
  .nav-chart .nav-notice-tag.folded { background: CanvasText; }
  .nav-index .nav-route-row[aria-selected="true"] { border-left-color: Highlight; }
}
