/* ==========================================================================
   Muuttokartta – map figure, filters, legend, tooltip and top-15 bar list.
   Loaded after style.css and uses its tokens; style.css itself is untouched.
   ========================================================================== */

.map {
  margin: 0;
}

/* --- Filters ------------------------------------------------------------- */

.map__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.75rem;
  margin: 0 0 1.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius);
  background: var(--color-gray-100);
}

.map__group {
  min-width: 0;
}

.map__grouplabel {
  max-width: none;
  margin: 0 0 0.4rem;
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

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

/* Active state is a filled pill – never an underline indicator. */
.map__btn {
  min-height: 2.75rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--color-petrooli);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-petrooli);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
}

.map__btn:hover {
  background: var(--color-bg-light);
  color: var(--color-tumma-petrooli);
}

.map__btn[aria-pressed="true"] {
  border-color: var(--color-keltaoranssi);
  background: var(--color-keltaoranssi);
  color: var(--color-laivasto);
}

/* --- Layout -------------------------------------------------------------- */

.map__body {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 1.5rem;
  align-items: start;
}

.map__canvas {
  position: relative;
  min-width: 0;
}

.map__svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 78vh;
}

.map__area {
  stroke-width: 0.4;
  vector-effect: non-scaling-stroke;
}

.map__area:hover {
  stroke: var(--color-laivasto);
  stroke-width: 1.4;
}

.is-near .map__area {
  stroke-width: 0.8;
}

.map__error {
  padding: 1rem;
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius);
  background: var(--color-gray-100);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

/* --- Tooltip ------------------------------------------------------------- */

.map__tooltip {
  position: absolute;
  z-index: 5;
  max-width: 15rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--color-laivasto);
  border-radius: var(--radius);
  background: var(--color-bg);
  box-shadow: 0 2px 10px rgba(0, 33, 54, 0.18);
  font-size: var(--text-xs);
  line-height: 1.45;
  pointer-events: none;
}

.map__tipname {
  max-width: none;
  margin: 0 0 0.25rem;
  color: var(--color-laivasto);
  font-weight: 750;
}

.map__tiprow {
  max-width: none;
  margin: 0;
  color: var(--color-text-secondary);
}

.map__tiprow--net {
  margin-top: 0.25rem;
  color: var(--color-laivasto);
  font-weight: 700;
}

/* --- Legend -------------------------------------------------------------- */

.map__legend {
  margin: 0.9rem 0 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius);
  background: var(--color-bg);
}

.map__legendtitle {
  max-width: none;
  margin: 0 0 0.5rem;
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-weight: 700;
}

.map__legenditems {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.map__legenditem {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  margin: 0;
}

.map__swatch {
  display: inline-block;
  width: 1.1rem;
  height: 0.85rem;
  border: 1px solid var(--color-gray-400);
  border-radius: var(--radius);
}

.map__swatch--empty {
  border-color: var(--color-gray-300);
}

.map__swatch--home {
  border-color: var(--color-keltaoranssi);
}

.map__legendlabel {
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

/* --- Top-15 bar list ----------------------------------------------------- */

.map__side {
  min-width: 0;
}

.map__sidetitle {
  max-width: none;
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  background: var(--color-petrooli);
  color: var(--color-text-white);
  font-size: var(--text-base);
  line-height: 1.35;
}

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

.maplist__row {
  display: grid;
  grid-template-columns: minmax(6rem, 8rem) minmax(0, 1fr) minmax(3.5rem, auto);
  gap: 0.6rem;
  align-items: center;
  padding: 0.3rem 0;
  font-size: var(--text-sm);
}

.maplist__name {
  color: var(--color-laivasto);
  overflow-wrap: anywhere;
}

.maplist__track {
  display: block;
  height: 0.9rem;
  border-radius: var(--radius);
  background: var(--color-gray-100);
}

.maplist__fill {
  display: block;
  height: 100%;
  border-radius: var(--radius);
  background: var(--color-petrooli);
}

/* The centre line makes the sign readable in the nettomuutto view. */
.maplist.is-diverging .maplist__track {
  background: linear-gradient(
    to right,
    var(--color-gray-100) calc(50% - 1px),
    var(--color-gray-400) calc(50% - 1px),
    var(--color-gray-400) calc(50% + 1px),
    var(--color-gray-100) calc(50% + 1px)
  );
}

.maplist__value {
  color: var(--color-text-secondary);
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.map__sidenote {
  max-width: none;
  margin: 0.75rem 0 0;
}

/* --- Explainer ----------------------------------------------------------- */

.map-explainer {
  margin: 1.25rem 0 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius);
  background: var(--color-bg);
}

.map-explainer > summary {
  color: var(--color-petrooli);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
}

.map-explainer[open] > summary {
  margin-bottom: 0.6rem;
}

.map-explainer p:last-child {
  margin-bottom: 0;
}

/* --- Narrow screens ------------------------------------------------------ */

@media (max-width: 800px) {
  .map__body {
    grid-template-columns: minmax(0, 1fr);
  }

  .map__svg {
    max-height: 68vh;
  }

  .map__controls {
    gap: 0.9rem 1.25rem;
  }

  .maplist__row {
    grid-template-columns: minmax(5rem, 7rem) minmax(0, 1fr) minmax(3rem, auto);
    font-size: var(--text-xs);
  }
}
