.case-map-toggle {
  width: 44px;
  padding: 0;
  text-decoration: none;
}

.case-map-icon {
  width: 22px;
  height: 22px;
  color: var(--ink);
}

html:has(.case-map-view:not([hidden])) { overflow: hidden; }

body:has(.case-map-view:not([hidden])) {
  --map-height: 100lvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100lvh;
  overflow: hidden;
}

@supports (height: 100lvh) and (-webkit-touch-callout: none) {
  @media (pointer: coarse) and (display-mode: browser) {
    body:has(.case-map-view:not([hidden])) {
      /* Mobile Safari can expose part of the screen below its largest layout viewport. */
      --map-height: clamp(100lvh, var(--map-screen-height, 100lvh), 100lvh + 120px);
      height: var(--map-height);
    }
  }
}

.case-map-view {
  --map-top: 12px;
  --map-left: max(12px, env(safe-area-inset-left, 0px));
  --map-right: max(12px, env(safe-area-inset-right, 0px));
  --map-bottom: env(safe-area-inset-bottom, 0px);
  --map-bottom: max(env(safe-area-inset-bottom, 0px), var(--map-height) - 100dvh);
  position: relative;
  overflow: hidden;
  background: #efe9de;
  color: var(--ink);
}

.case-map-layout, .case-map-frame, #case-map-canvas {
  position: absolute;
  inset: 0;
}

.case-map-status {
  display: grid;
  position: absolute;
  inset: 0;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.case-map-controls {
  position: absolute;
  z-index: 2;
  inset: var(--map-top) var(--map-right) auto var(--map-left);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.case-map-controls > button { pointer-events: auto; }

.case-map-frame .maplibregl-ctrl-top-right {
  top: calc(var(--map-top) + 44px);
  right: calc(var(--map-right) - 10px);
}

.case-map-frame .maplibregl-ctrl-bottom-right {
  right: env(safe-area-inset-right, 0px);
  bottom: var(--map-bottom);
}

.case-map-frame .maplibregl-ctrl-group:not(:empty) {
  margin-top: 0;
  background: transparent;
  box-shadow: none;
}

:is(.case-map-icon-button, .case-map-frame .maplibregl-ctrl-group button) {
  display: grid;
  flex: none;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}

.case-map-controls > button { margin-inline-start: auto; }

:is(.case-map-icon-button, .case-map-frame .maplibregl-ctrl-group button)
  > :is(.case-map-control-face, .maplibregl-ctrl-icon) {
  position: relative;
  width: 32px;
  height: 32px;
  border: 1px solid rgb(255 255 255 / .76);
  border-radius: 50%;
  background-color: rgb(255 253 248 / .68);
  background-size: 0;
  -webkit-backdrop-filter: blur(10px) saturate(145%);
  backdrop-filter: blur(10px) saturate(145%);
  box-shadow:
    inset 0 1px 1px rgb(255 255 255 / .8),
    inset 0 -1px 2px rgb(91 70 47 / .09),
    0 0 0 1px rgb(70 54 39 / .07),
    0 2px 6px rgb(70 54 39 / .12);
}

:is(.case-map-icon-button, .case-map-frame .maplibregl-ctrl-group button)
  > :is(.case-map-control-face, .maplibregl-ctrl-icon)::before,
:is(.case-map-icon-button, .case-map-frame .maplibregl-ctrl-group button)
  > :is(.case-map-control-face, .maplibregl-ctrl-icon)::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 11px;
  border-top: 2px solid;
  border-radius: 1px;
  translate: -50% -50%;
}

.case-map-control-face::before { rotate: 45deg; }
.case-map-control-face::after { rotate: -45deg; }
.case-map-frame .maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon::after { rotate: 90deg; }
.case-map-frame .maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon::after { content: none; }

.case-map-frame .maplibregl-ctrl-group button:disabled .maplibregl-ctrl-icon {
  color: rgb(75 60 45 / .42);
  opacity: 1;
}

:is(.case-map-icon-button, .case-map-frame .maplibregl-ctrl-group button):focus:focus-visible {
  outline: none;
  box-shadow: none;
}

:is(.case-map-icon-button, .case-map-frame .maplibregl-ctrl-group button):focus-visible
  > :is(.case-map-control-face, .maplibregl-ctrl-icon) {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  :is(.case-map-icon-button, .case-map-frame .maplibregl-ctrl-group button):not(:disabled):hover
    > :is(.case-map-control-face, .maplibregl-ctrl-icon) {
    background-color: rgb(255 253 248 / .95);
  }
}

.case-map-unavailable {
  display: grid;
  place-content: center;
  position: absolute;
  inset: 0;
  padding: 60px 24px 46dvh;
  color: var(--muted);
  text-align: center;
}

.case-map-marker {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.case-map-marker span {
  display: grid;
  min-width: 27px;
  min-height: 27px;
  place-items: center;
  padding-inline: 5px;
  border: 1px solid #fff9ef;
  border-radius: 50%;
  background: #9f2436;
  color: #fff;
  box-shadow: 0 1px 4px rgb(83 19 26 / .28);
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.case-map-marker[aria-pressed="true"] span { background: #35221e; }

.case-map-panel {
  position: absolute;
  z-index: 1;
  inset-inline-start: var(--map-left);
  inset-block-end: calc(var(--map-bottom) + 42px);
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100% - var(--map-left) - var(--map-right)));
  max-height: min(52dvh, 430px);
  min-width: 0;
  padding: 14px;
  border: 1px solid rgb(255 255 255 / .78);
  border-radius: 24px;
  background: #faf7ef;
  box-shadow:
    inset 0 1px 1px rgb(255 255 255 / .8),
    0 0 0 1px rgb(78 59 41 / .09),
    0 8px 28px rgb(57 41 28 / .17);
  color: var(--ink);
}

@supports (backdrop-filter: blur(6px)) or (-webkit-backdrop-filter: blur(6px)) {
  .case-map-panel {
    background: linear-gradient(150deg, rgb(255 253 249 / .7), rgb(255 252 247 / .52));
    -webkit-backdrop-filter: blur(6px) saturate(135%);
    backdrop-filter: blur(6px) saturate(135%);
  }
}

.case-map-panel-heading {
  display: flex;
  flex: none;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.case-map-panel-title {
  min-width: 0;
  padding: 3px 0 1px 6px;
  overflow-wrap: anywhere;
}

.case-map-panel h2 { font-size: 24px; line-height: 1.18; letter-spacing: -.035em; }
.case-map-panel p { color: var(--muted); font-size: 13px; }
.case-map-panel-title p { margin-top: 3px; }

.case-map-city-list, .case-map-articles {
  min-height: 0;
  margin: 10px 0 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}
.case-map-city-list li + li, .case-map-articles li + li { border-top: 1px solid rgb(78 59 41 / .13); }
.case-map-city-list button, .case-map-article {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 6px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: start;
  text-decoration: none;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.case-map-city-list button span { color: #9f2436; font-variant-numeric: tabular-nums; }

.case-map-article:focus-visible, .case-map-city-list button:focus-visible {
  outline-offset: -2px;
  border-radius: 8px;
}

.case-map-article-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.case-map-article-title {
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.case-map-article-meta {
  color: #585249;
  font-size: 11px;
  font-weight: 550;
}

.case-map-link-arrow { color: var(--muted); flex: none; font-size: 16px; line-height: 1; }

.case-map-feed {
  display: flex;
  flex: none;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 10px;
  padding: 0 11px;
  border: 1px solid rgb(78 59 41 / .13);
  border-radius: 12px;
  background: rgb(255 253 248 / .59);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-align: start;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .case-map-city-list button:hover, .case-map-article:hover { color: #9f2436; }
  .case-map-feed:hover { background: rgb(255 253 248 / .85); }
}

@media (prefers-reduced-motion: no-preference) {
  .case-map-markers-pending .case-map-marker { visibility: hidden; }
  .case-map-view:not([hidden]) { animation: case-map-in 160ms ease-out; }
  .case-map-panel[data-animate-open]:not([hidden]) {
    animation: case-map-panel-in 360ms cubic-bezier(.22, .7, .22, 1);
  }
  @keyframes case-map-in { from { opacity: 0; } }
  @keyframes case-map-panel-in { from { opacity: 0; transform: translateY(16px); } }
}
