/* Global (not scoped to .mm-map) so other elements outside the map
   container - e.g. mm.modal.css's UI - can also resolve these
   tokens. Prefixed to avoid colliding with a host page's own custom
   properties. */
:root {
  --mm-land: #d4b043;
  --mm-land-stroke: #3a2f22;
  --mm-land-hover: #ffe100;
  --mm-land-selected: #ffffff;
  --mm-land-selected-stroke: #6e2c14;
  --mm-panel-bg: #fffdf8;
  --mm-panel-border: #000000;
  --mm-panel-ink: #2a2117;
  --mm-panel-ink-soft: #6b6050;
  --mm-panel-shadow: 0 8px 24px rgba(42, 33, 23, 0.18);
  /* "Noto Sans" has no Japanese glyphs - Noto Sans JP is the CJK member of
     the same type family Google Fonts serves it under, loaded via the
     <link> tags in index.html's <head>. */
  --mm-font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
}

/* Block: mm-map */

.mm-map {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.mm-map__stage {
  /* Always exactly fills .mm-map, at every zoom level - panning/clicking
     must work everywhere in the container, not just in some smaller
     sub-region sized to fit the map's own aspect ratio. Fitting the
     (square) map content into this (possibly non-square) box without
     distortion, and shrinking any letterbox margin as the zoom level
     increases, is instead handled by the non-square viewBox math in
     renderedViewBox() in mm.map.js. */
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.mm-map__stage--dragging {
  cursor: grabbing;
}

.mm-map__stage svg {
  width: 100%;
  height: 100%;
  display: block;
}

.mm-map__pref path {
  fill: var(--mm-pref-color, var(--mm-land));
  stroke: var(--mm-land-stroke);
  /* Set on .mm-map by applyView() in mm.map.js, so the border thickens as
     the zoom level increases (still non-scaling-stroke, i.e. a screen-px
     width, not the raw SVG-unit stroke that zooming would otherwise
     scale on its own). */
  stroke-width: var(--mm-pref-stroke-width, 1px);
  vector-effect: non-scaling-stroke;
  transition: fill 120ms ease;
}

.mm-map__pref {
  cursor: pointer;
}

.mm-map__pref:hover path {
  /* Deliberately its own color, not --mm-land-hover - that token is
     shared with the toolbar/modal buttons' hover state and shouldn't
     change together with the map region's. */
  fill: #ffaaaa;
}

.mm-map__pref--selected path {
  fill: var(--mm-land-selected);
  stroke: var(--mm-land-selected-stroke);
}

.mm-map__dividers polyline {
  stroke-width: var(--mm-pref-stroke-width, 1px);
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

/* Block: mm-widget - the embeddable unit combining the zoom/reset toolbar
   with the map itself (see index.html for the markup this styles). Meant
   to be dropped into a host page as-is, together with mm-map's own
   markup/JS above. */

.mm-widget {
  position: relative;
  width: 100%;
  height: 600px;
  border: 1px solid #e4dac4;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.mm-widget__toolbar {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  background: var(--mm-panel-bg);
}

.mm-widget__zoom-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 2px;
  border-bottom: 1px solid #e4dac4;
}

.mm-widget__zoom-btn,
.mm-widget__reset-btn {
  width: 28px;
  padding: 6px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #000000;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.mm-widget__zoom-btn:hover:not(:disabled),
.mm-widget__reset-btn:hover {
  background: var(--mm-land-hover);
}

.mm-widget__zoom-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.mm-widget__icon {
  width: 16px;
  height: 16px;
  display: block;
}

.mm-widget__zoom-slider {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  writing-mode: vertical-lr;
  direction: rtl;
  width: 6px;
  height: 110px;
  margin: 2px 0;
  background: var(--mm-land);
}

.mm-widget__zoom-slider::-webkit-slider-thumb {
  cursor: pointer;
  appearance: none;
  width: 18px;
  height: 8px;
  border-radius: 0;
  background: #000000;
}

.mm-widget__zoom-slider::-moz-range-thumb {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 8px;
  border-radius: 0;
  background: #000000;
}

.mm-widget__zoom-label {
  font-size: 13px;
  color: #6b6050;
  min-width: 3.5ch;
  text-align: center;
}

.mm-widget__legend {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1;
  padding: 14px 12px;
  background: var(--mm-panel-bg);
}

.mm-widget__legend-title {
  font-size: 12px;
  color: var(--mm-panel-ink-soft);
  margin-bottom: 8px;
}

.mm-widget__legend-bar {
  display: flex;
  width: 140px;
  height: 14px;
  border: 1px solid var(--mm-land-stroke);
}

.mm-widget__legend-swatch {
  flex: 1 1 0;
}

.mm-widget__legend-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 12px;
  color: var(--mm-panel-ink);
}

/* Below this width the legend/toolbar switch from floating over the map
   (which crowds a narrow screen) to a header row stacked above it, so
   nothing ever overlaps the map itself. */
@media (max-width: 768px) {
  .mm-widget {
    display: flex;
    flex-direction: column;
    /* The map below gets its height from its own width via aspect-ratio,
       not from filling a fixed-height box - a fixed height here would just
       fight that, so let the widget's total height be whatever the header
       plus the square map add up to. */
    height: auto;
  }

  .mm-widget__header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    background: #ffffff;
  }

  .mm-widget__legend,
  .mm-widget__toolbar {
    position: static;
    padding: 8px;
  }

  /* Narrower than the desktop bar so it still fits next to the toolbar on
     a phone-width screen. */
  .mm-widget__legend-bar {
    width: 90px;
  }

  .mm-widget__toolbar {
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }

  .mm-widget__zoom-group {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    border-bottom: none;
    border-right: 1px solid #e4dac4;
    padding-bottom: 0;
    padding-right: 6px;
    margin-bottom: 0;
    margin-right: 0;
  }

  /* DOM order (+, slider, -, label) reads top-to-bottom on the desktop's
     vertical layout (+ above, - below), but flattened left-to-right as-is
     it puts + before the slider's low end and - after its high end -
     backwards from the usual "- [low...high] +" reading. Reorder visually
     only, without touching the DOM/tab order or any JS. */
  .mm-widget__zoom-btn--out {
    order: 1;
  }

  .mm-widget__zoom-slider {
    order: 2;
    writing-mode: horizontal-tb;
    direction: ltr;
    width: 50px;
    height: 6px;
    margin: 0;
  }

  .mm-widget__zoom-btn--in {
    order: 3;
  }

  .mm-widget__zoom-slider::-webkit-slider-thumb {
    width: 8px;
    height: 18px;
  }

  .mm-widget__zoom-slider::-moz-range-thumb {
    width: 8px;
    height: 18px;
  }

  .mm-widget__zoom-label {
    order: 4;
    font-size: 11px;
    min-width: 2.8ch;
  }

  /* .mm-map is added by mm.map.js at runtime to whatever element was
     passed to MessageMap.init() - targeted by class, not #map's id, so
     this still applies regardless of what a host page names that element. */
  .mm-widget > .mm-map {
    flex: none;
    width: 100%;
    aspect-ratio: 1;
  }
}
