/* The stage map: sea, land, the two test zones, the planned route, the wake and
   the ship. Strokes do not scale with the camera's zoom; labels and the ship are
   scaled by the script (src/play-map.mjs) so they keep one size on screen. */
.view {
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--seam);
  border-radius: 6px;
  background: var(--sea);
}

.chart {
  margin: 0;
}

.map {
  display: block;
  width: 100%;
  height: 100%;
}

.map .sea {
  fill: var(--sea);
}

.map .land {
  fill: var(--land);
  stroke: var(--coast);
  stroke-width: 0.8;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.map .veil {
  fill: #03060b;
  opacity: 0;
  transition: opacity 0.6s var(--ease-out);
  pointer-events: none;
}

.map.is-night .veil {
  opacity: 0.5;
}

.map .zone {
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  transition:
    fill-opacity 0.4s var(--ease-out),
    stroke-opacity 0.4s var(--ease-out);
  fill-opacity: 0.22;
}

.map .zone.jwc {
  fill: var(--jwc);
  stroke: var(--jwc);
}

.map .zone.ibf {
  fill: var(--ibf);
  stroke: var(--ibf);
}

.map .zone.wait {
  fill-opacity: 0.1;
  stroke-opacity: 0.55;
}

/* The zone the ship is in now. */
.map .zone.lit {
  fill-opacity: 0.42;
}

.map .plan,
.map .wake {
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.map .plan {
  stroke: var(--edge);
  stroke-width: 1.25;
  stroke-opacity: 0.7;
}

.map .wake {
  stroke: var(--accent-text);
  stroke-width: 2.5;
}

.map text {
  font: 500 12px/1 "Barlow", system-ui, sans-serif;
  fill: var(--muted);
  paint-order: stroke;
  stroke: var(--sea);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.map .place circle {
  fill: var(--muted);
}

.place.right text {
  transform: translate(7px, 4px);
}

.place.left text {
  text-anchor: end;
  transform: translate(-7px, 4px);
}

.place.below text {
  text-anchor: middle;
  transform: translateY(17px);
}

.map .zone-tag text {
  font-weight: 600;
  transform: translate(0, -9px);
}

.map .zone-tag.jwc text {
  fill: var(--jwc-text);
}

.map .zone-tag.ibf text {
  fill: var(--ibf-text);
}

.ship circle {
  fill: var(--accent-text);
}

.ship .halo {
  fill: var(--accent);
  opacity: 0.28;
  transform-box: fill-box;
  transform-origin: center;
}

.is-playing .ship .halo {
  animation: halo 2.4s var(--ease-out) infinite;
}

@keyframes halo {
  from {
    opacity: 0.45;
    transform: scale(0.5);
  }

  to {
    opacity: 0;
    transform: scale(1.6);
  }
}

/* The moment the page starts playing: the planned route comes up, then the
   zones. A fade, not a dash draw-on: Chrome measures dashes on a non-scaling
   stroke in screen pixels and ignores pathLength, so a dash would leave the
   route dotted. The wake draws the route as the ship moves. */
.is-playing .plan {
  animation: route-up 0.9s var(--ease-out) both;
}

.is-playing .zone {
  animation: zones-up 0.6s var(--ease-out) 0.5s both;
}

@keyframes route-up {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes zones-up {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.map-note {
  position: absolute;
  top: 10px;
  right: 12px;
  max-width: 34ch;
  font-size: 12px;
  line-height: 16px;
  color: var(--faint);
  text-align: right;
}

/* The caption sits under the map, so it never hides the ship, a zone or a port. */
.view {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.chart {
  position: relative;
  inset: auto;
  min-height: 0;
}

.view .caption {
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 12px 20px 14px;
  border-top: 1px solid var(--seam);
  background: var(--pane);
}

@media (max-width: 900px) {
  .map-note {
    display: none;
  }

  .view .caption {
    padding: 8px 12px 10px;
  }
}
