.map-train-track,
.map-lighthouse-beam {
  opacity: 0;
  pointer-events: none;
}

.map-train-track {
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 1;
}

.map-lighthouse-beam {
  fill: currentColor;
  transform-origin: 0 0;
}

.map-lighthouse-beam .beam-ray {
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
}

.map-lantern-fringe {
  pointer-events: none;
  transform-origin: 0 0;
}

@media (prefers-reduced-motion: no-preference) {
  /* The inner and middle sea contours catch the same crest in succession. */
  .map-stage[data-opening="playing"] .shore-rings path:nth-child(3) {
    animation: coastal-wave 820ms ease-in-out 900ms;
  }

  .map-stage[data-opening="playing"] .shore-rings path:nth-child(2) {
    animation: coastal-wave 900ms ease-in-out 1210ms;
  }

  .tag-train > use {
    transform-box: fill-box;
    transform-origin: center;
  }

  .map-stage[data-opening="waiting"] .tag-train > use {
    opacity: 0.48;
    transform: scale(0.42);
  }

  .map-stage[data-opening="playing"] .tag-train > use {
    animation: reveal-train 950ms cubic-bezier(0.2, 0.72, 0.2, 1) 2000ms backwards;
  }

  .map-stage[data-opening="playing"] .island-point[data-icon="hill-country-train"] .map-train-track {
    animation: map-track-draw 1050ms ease-out 2050ms;
  }

  .map-stage[data-opening="playing"] .tag-train .map-train-track {
    animation: map-track-draw 1320ms ease-out 2630ms;
  }

  .map-stage[data-idle-accent="lighthouse"] .island-set[aria-hidden="false"] .map-lighthouse-beam {
    animation: idle-lighthouse-sweep 1000ms ease-in-out;
  }

  .map-stage[data-idle-accent="lantern"] .island-set[aria-hidden="false"] .map-lantern-fringe {
    animation: idle-lantern-sway 1150ms ease-in-out;
  }

  .is-dwelling .map-train-track {
    animation: map-track-draw 700ms ease-out;
  }

  .is-dwelling .map-lighthouse-beam {
    animation: map-beam-sweep 740ms ease-in-out;
  }

  .is-dwelling .map-lantern-fringe {
    animation: map-fringe-sway 800ms ease-in-out;
  }
}

@keyframes coastal-wave {
  0%, 100% { stroke: var(--rings); stroke-width: 0.75; }
  46% { stroke: color-mix(in srgb, #479c8b 68%, var(--map)); stroke-width: 2.35; }
}

@keyframes reveal-train {
  from { opacity: 0.48; transform: scale(0.42); }
  to { opacity: 1; transform: none; }
}

@keyframes map-track-draw {
  0% { opacity: 0; stroke-dashoffset: 1; }
  18% { opacity: 0.95; }
  65% { opacity: 0.85; stroke-dashoffset: 0; }
  100% { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes map-beam-sweep {
  0% { opacity: 0; transform: rotate(-24deg); }
  28% { opacity: 0.56; }
  67% { opacity: 0.5; }
  100% { opacity: 0; transform: rotate(23deg); }
}

@keyframes idle-lighthouse-sweep {
  0% { opacity: 0; transform: rotate(-28deg); }
  38% { opacity: 0.42; }
  72% { opacity: 0.32; }
  100% { opacity: 0; transform: rotate(4deg); }
}

@keyframes idle-lantern-sway {
  0%, 100% { transform: skewX(0deg); }
  36% { transform: skewX(11deg); }
  73% { transform: skewX(-3deg); }
}

@keyframes map-fringe-sway {
  0%, 100% { transform: skewX(0deg); }
  32% { transform: skewX(14deg); }
  70% { transform: skewX(-5deg); }
}
