/* Keep map controls readable while letting the geography use its own space. */
.map-shell {
  display: grid;
  grid-template-rows: minmax(280px, 1fr) auto auto auto;
  align-content: stretch;
  background: var(--paper);
  border-color: #ccd5c6;
  isolation: isolate;
}
.map-shell #map {
  position: relative;
  inset: auto;
  grid-row: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #e8edde;
}
.map-top {
  top: 12px;
  left: 12px;
  right: 68px;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}
.map-label {
  max-width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.45;
  background: #fffefa;
  color: var(--ink);
}
.map-label #map-place {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-action {
  min-height: 44px;
  padding: 9px 11px;
  font-size: 11px;
  line-height: 1.4;
  background: #fffefa;
  color: var(--green);
}
.map-actions {
  top: 12px;
  right: 12px;
  border-color: #bdcbb7;
  background: var(--paper);
}
.map-actions .icon-button {
  width: 44px;
  height: 44px;
  color: var(--green);
  font-size: 24px;
}
.map-actions .icon-button:focus-visible {
  outline-offset: -4px;
}
.map-legend {
  position: relative;
  inset: auto;
  grid-row: 2;
  z-index: auto;
  display: flex;
  flex-wrap: wrap;
  min-height: 34px;
  gap: 7px 16px;
  padding: 8px 14px;
  border-radius: 0;
  border-top: 1px solid var(--line);
  background: var(--paper);
  color: #53634f;
  font-size: 11px;
}
.map-history-card {
  position: relative;
  inset: auto;
  grid-row: 3;
  z-index: auto;
  width: calc(100% - 20px);
  margin: 0 10px 6px;
  padding: 10px 12px;
  gap: 13px;
  border-radius: 8px;
  box-shadow: none;
  background: #f5f6ee;
}
.map-history-card .history-card-year { font-size: 25px; }
.map-history-card .history-card-year span { font-size: 8px; }
.map-history-card strong { font-size: 12px; }
.map-history-card > span:nth-child(2) { min-width: 0; flex: 1; }
.map-history-card small { display: block; font-size: 10px; }
.map-history-card > span:last-child { display: inline-flex; }
.base-map-caption {
  position: relative;
  inset: auto;
  grid-row: 4;
  z-index: auto;
  justify-self: end;
  padding: 0 12px 6px;
  color: #687763;
  background: transparent;
  font-size: 9px;
}
.map-shell .leaflet-control-attribution {
  max-width: 100%;
  padding: 2px 5px;
  background: #fffefae8;
  color: #53634f;
  line-height: 1.4;
}
.map-shell .leaflet-control-attribution a { color: #335d45; }
.map-shell .marker-content {
  min-height: 44px;
  padding: 4px;
  filter: drop-shadow(0 2px 3px #1b352847);
}
.map-shell .marker-circle {
  width: 36px;
  height: 36px;
  border-width: 3px;
}
.map-shell .marker-circle b { font-size: 13px; font-weight: 750; }
.map-shell .marker-name {
  max-width: 190px;
  margin-left: 5px;
  padding: 5px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  color: #243e2e;
  border-color: #bdcbb7;
  background: #fffefa;
  box-shadow: 0 1px 4px #213c2a15;
}
.map-shell .shop-marker.selected .marker-circle {
  box-shadow: 0 0 0 4px #e2b452, 0 3px 10px #1b35284d;
}
.map-shell .shop-marker.selected .marker-name {
  display: block !important;
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}
.map-shell .shop-marker:focus-visible { outline: none; }
.map-shell .shop-marker:focus-visible .marker-circle {
  outline: 3px solid #8c481c;
  outline-offset: 4px;
}
.map-shell .road-label {
  color: #68785e;
  font-size: 10px;
  text-shadow: 0 0 3px #fffefa, 0 0 3px #fffefa;
}
.map-shell .attraction-label {
  color: #4b6c43;
  font-size: 11px;
  text-shadow: 0 0 4px #fffefa, 0 0 4px #fffefa;
}
#map.map-zoom-compact .road-label,
#map.map-zoom-compact .attraction-label,
#map:not(.map-zoom-detailed) .road-secondary { visibility: hidden; }
.map-shell .leaflet-baseRoads-pane path { stroke-opacity: 1; }
.map-shell .destination-marker span {
  box-shadow: 0 0 0 2px #a57929, 0 2px 8px #4c49274d;
}
.mobile-view > button { min-height: 44px; }
.mobile-view > button[aria-pressed="true"] {
  color: var(--green);
  font-weight: 750;
  box-shadow: inset 0 -2px var(--green), 0 1px 4px #263d2910;
}
@media (max-width: 700px) {
  .map-shell {
    display: none;
    height: auto;
    grid-template-rows: clamp(420px, 72vh, 620px) auto auto auto;
    grid-template-rows: clamp(420px, 72dvh, 620px) auto auto auto;
    scroll-margin-top: 12px;
  }
  .mobile-map .map-shell { display: grid; }
  .map-legend { gap: 7px 12px; padding: 8px 11px; font-size: 10px; }
  .map-history-card { padding: 10px; gap: 10px; }
  .map-history-card strong { font-size: 11px; line-height: 1.5; }
  .map-history-card small { font-size: 9px; }
  .map-history-card .history-card-year { font-size: 23px; }
  .map-history-card > span:last-child { flex-shrink: 0; }
  .map-shell .marker-name { max-width: 155px; }
}
@media (prefers-reduced-motion: reduce) {
  .map-shell *, .mobile-view > button { transition: none !important; }
}

/* Nearby restaurants share one target until the visitor expands the area. */
.map-shell .shop-cluster { border: 0; background: transparent; }
.map-shell .cluster-bubble {
  width: 44px;
  height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 3px solid #fffefa;
  border-radius: 50%;
  color: #fffefa;
  background: var(--green);
  box-shadow: 0 0 0 2px #73916b, 0 3px 9px #233f2a45;
  font-family: inherit;
  line-height: 1;
  transition: background 180ms ease-out, box-shadow 180ms ease-out;
}
.map-shell .cluster-count { font-size: 17px; font-weight: 800; }
.map-shell .cluster-label { font-size: 9px; font-weight: 550; }
.map-shell .shop-cluster:focus-visible { outline: none; }
.map-shell .shop-cluster:focus-visible .cluster-bubble {
  outline: 3px solid #8c481c;
  outline-offset: 4px;
}
.map-shell .restaurant-cluster-popup .leaflet-popup-content-wrapper {
  border: 1px solid #cbd5c4;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 8px 24px #243b3029;
}
.map-shell .restaurant-cluster-popup .leaflet-popup-content {
  width: min(268px, calc(100vw - 140px)) !important;
  margin: 15px 13px 12px;
  font-family: inherit;
  line-height: 1.5;
}
.map-shell .restaurant-cluster-popup .leaflet-popup-tip {
  background: var(--paper);
}
.map-shell .restaurant-cluster-popup .leaflet-popup-close-button {
  width: 44px;
  height: 44px;
  padding: 8px;
  font-size: 25px;
  line-height: 28px;
  color: #536b4b;
  border-radius: 8px;
}
.map-shell .cluster-popup-title {
  display: block;
  padding: 0 36px 10px 0;
  font-size: 13px;
  font-weight: 750;
  color: var(--green);
}
.map-shell .cluster-popup-list {
  max-height: min(260px, 38dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #b7c4af transparent;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.map-shell .cluster-shop {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 44px;
  padding: 9px 7px;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border-radius: 5px;
  line-height: 1.45;
}
.map-shell .cluster-shop + .cluster-shop { border-top: 1px solid #e8ebdf; }
.map-shell .cluster-shop-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  flex-shrink: 0;
  border-radius: 50%;
  color: var(--green);
  background: #e8eedf;
  font-size: 11px;
  font-weight: 750;
}
.map-shell .cluster-shop-name {
  min-width: 0;
  font-size: 13px;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.map-shell .cluster-zoom {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  padding: 9px 12px;
  border: 1px solid #bfd0b7;
  border-radius: 7px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 650;
}
.map-shell .cluster-shop:focus-visible,
.map-shell .cluster-zoom:focus-visible { outline-offset: -3px; }
@media (hover: hover) and (pointer: fine) {
  .map-shell .shop-cluster:hover .cluster-bubble {
    background: #315c48;
    box-shadow: 0 0 0 3px #aabd97, 0 4px 11px #233f2a45;
  }
  .map-shell .cluster-shop:hover { background: var(--green-soft); color: var(--green); }
  .map-shell .cluster-zoom:hover { background: #e1ead9; }
}
.map-shell .cluster-shop:active,
.map-shell .cluster-zoom:active { background: #dce7d4; }
@media (prefers-reduced-motion: reduce) {
  .map-shell .cluster-bubble { transition: none; }
}
@media (max-width: 700px) {
  .map-shell .cluster-popup-list { max-height: min(210px, 30dvh); }
}

/* Keep the existing header on one line even with Japanese labels at 320px. */
@media (max-width: 370px) {
  .header { padding-left: 12px; padding-right: 12px; gap: 6px; }
  .header .brand { min-width: 0; gap: 3px; }
  .header .brand-mark { width: 22px; flex: 0 0 22px; }
  body[data-lang="ja"] .header .brand { font-size: 15px; }
  .header .header-tools { flex-shrink: 0; gap: 5px; margin-left: auto; }
  .header .language-label { flex-shrink: 0; padding: 5px; }
  .header .language-label select { width: 58px; font-size: 10px; }
  .header .demo-button {
    flex-shrink: 0;
    min-width: 52px;
    min-height: 40px;
    justify-content: center;
    white-space: nowrap;
    padding: 6px;
  }
}

@media (max-width: 370px) { body[data-lang="ja"] h1, body[data-lang="ja"] h2, body[data-lang="ja"] h3 { word-break: normal; overflow-wrap: anywhere; } }
