/* 出行安全地图（#view=safety，quick 261122-eqk）。视觉沿用新闻栏：浅底圆角面板、
   胶囊筛选、白卡片。地图节点由 safetyMap.js 常驻管理，这里只给尺寸。 */

.safety-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 28px 28px;
  min-height: calc(100vh - var(--topbar-height, 64px));
  box-sizing: border-box;
}

/* One row: tabs · search (grows) · phone pill. */
.safety-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* 安全地图 | 新闻 — the section's own tabs as large words, not a pill: the row beside
   them holds the topic chips (news) or the search (map), which are the pills. The
   current one is ink with a short bar under it; the other is muted. */
.safety-tabs {
  display: inline-flex;
  align-items: baseline;
  gap: 18px;
  margin-right: 10px;
}

.safety-tabs button {
  position: relative;
  padding: 4px 0 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  cursor: pointer;
}

.safety-tabs button:hover {
  color: var(--ink-strong);
}

.safety-tabs button.is-active {
  color: var(--ink-strong);
}

/* News: the topic chips take the rest of the row and slide sideways when they don't
   fit, so the emergency numbers never drop to a second line. */
.safety-head .np-chips {
  flex: 1 1 0;
  flex-wrap: nowrap;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}

.safety-head .np-chips::-webkit-scrollbar {
  display: none;
}

.safety-head .np-chips button {
  flex: none;
}

/* A chip cut by the edge fades out instead of being sliced. */
.safety-head .np-chips {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  padding-right: 28px;
}

.safety-head .np-updated {
  padding: 0 6px;
  white-space: nowrap;
}

/* "更新于…" only where the row has room for it whole. */
@media (max-width: 1599px) {
  .safety-head .np-updated {
    display: none;
  }
}

/* currentColor, so Dark Reader's ink inversion carries the bar with the text. */
.safety-tabs button.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 22px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
}

/* News tab: its own layout, src/styles/newsPage.css. */

/* Both numbers in one pill, split by a hairline; each half dials on a phone. */
.safety-emergency {
  display: inline-flex;
  align-items: stretch;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}

.safety-emergency a {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.safety-emergency a + a {
  border-left: 1px solid var(--line);
}

.safety-emergency a:hover {
  background: var(--surface-muted, var(--surface-3));
}

.safety-emergency strong {
  color: var(--ink-strong);
  font-size: 14px;
  font-weight: 800;
}

.safety-emergency .lbl-short {
  display: none;
}

.safety-emergency a:first-child strong {
  color: #b91c1c;
}

.safety-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.safety-seg {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted, var(--surface-3));
}

.safety-seg button {
  min-height: 30px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.safety-seg button.is-active {
  background: var(--surface);
  color: var(--ink-strong);
  box-shadow: 0 1px 8px color-mix(in srgb, var(--brand) 12%, transparent);
}

.safety-types {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.safety-type-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-strong);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.safety-type-chip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.safety-type-chip span {
  color: var(--muted);
  font-weight: 700;
}

.safety-type-chip.is-active {
  background: var(--brand, #001b4b);
  border-color: var(--brand, #001b4b);
  color: #ffffff;
}

.safety-type-chip.is-active span {
  color: rgba(255, 255, 255, 0.75);
}

.safety-search {
  flex: 0 1 300px;
  min-width: 180px;
  margin-left: auto;
}

.safety-search + .safety-emergency {
  margin-left: 0;
}

.safety-search input {
  width: 100%;
  box-sizing: border-box;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-strong);
  font: inherit;
  font-size: 13px;
}

/* Cities without official suburb counts (Brisbane, Perth, Auckland) have no switch. */
.safety-stats-toggle[hidden] {
  display: none;
}

/* Sits on the map's top-left corner: it is a map layer switch. */
.safety-stats-toggle {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 500;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--ink-strong-bg) 12%, transparent);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 14px 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-strong);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

/* Track uses color + currentColor so the knob survives the dark-mode engine
   (see the skill-wall switch: it rewrites color but never resolves currentColor). */
.safety-switch {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: var(--line-strong, #c7ccd6);
  color: #ffffff;
  transition: background 0.15s ease;
}

.safety-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: currentColor;
  transition: transform 0.15s ease;
}

.safety-stats-toggle.is-on .safety-switch {
  background: #2e7668;
}

.safety-stats-toggle.is-on .safety-switch::after {
  transform: translateX(12px);
}

.safety-body {
  display: flex;
  gap: 14px;
  flex: 1 1 auto;
  min-height: 560px;
  /* page padding + header row + filter row + gaps ≈ 165px */
  height: calc(100vh - var(--topbar-height, 64px) - 165px);
}

.safety-map-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface-muted, var(--surface-3));
}

.safety-map-slot,
.safety-map {
  position: absolute;
  inset: 0;
}

.safety-map {
  font: inherit;
  background: #e9ecef;
}

.safety-map .leaflet-tile-pane {
  filter: grayscale(1) contrast(0.9) brightness(1.06);
}

.safety-map.is-dark {
  background: #1b1d1f;
}

.safety-map.is-dark .leaflet-tile-pane {
  filter: grayscale(1) invert(1) brightness(0.82) contrast(0.9);
}

/* The self-hosted vector basemap is drawn in its own grayscale / dark flavour —
   the CSS greying above is only for the OSM raster fallback. */
.safety-map.is-vector .leaflet-tile-pane,
.safety-map.is-vector.is-dark .leaflet-tile-pane {
  filter: none;
}

.safety-map.is-vector {
  background: #f0f0f0;
}

.safety-map.is-vector.is-dark {
  background: #1f1f1f;
}

.safety-legends {
  position: absolute;
  left: 12px;
  bottom: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 260px;
  pointer-events: none;
}

.safety-legend {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--ink-strong-bg) 10%, transparent);
  color: var(--ink-strong);
  font-size: 12px;
  font-weight: 700;
  pointer-events: auto;
}

.safety-legend-title {
  font-size: 12px;
  font-weight: 800;
}

.safety-legend-note {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.safety-legend ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
}

.safety-legend li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.safety-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink-strong-bg) 20%, transparent);
}

.safety-legend-precision {
  padding-top: 6px;
  border-top: 1px solid var(--line-soft, var(--line));
}

.safety-legend .dot.is-street {
  background: #64748b;
}

.safety-legend .dot.is-suburb {
  width: 14px;
  height: 14px;
  border: 1px dashed #64748b;
  background: color-mix(in srgb, #64748b 15%, transparent);
  box-shadow: none;
}

/* Hollow ring, as on the map: a person's own post, unverified. */
.safety-legend .dot.is-social {
  border: 2.5px solid #64748b;
  background: #ffffff;
  box-shadow: none;
}

/* 每千名居民 / 总数 — same pill-switch look as the time-range control, smaller. */
.safety-legend-mode {
  display: flex;
  gap: 2px;
  margin-top: 7px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted, var(--surface-3));
}

.safety-legend-mode button {
  flex: 1;
  min-height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.safety-legend-mode button.is-active {
  background: var(--surface);
  color: var(--ink-strong);
  box-shadow: 0 1px 6px color-mix(in srgb, var(--brand) 12%, transparent);
}

.safety-legend-nodata {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.safety-legend-nodata i {
  width: 18px;
  height: 10px;
  border: 1px dashed #8a8f98;
  border-radius: 3px;
  background: color-mix(in srgb, #b8bcc4 45%, transparent);
}

.safety-suburb-card li small {
  flex-basis: 100%;
  margin-top: -4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.safety-suburb-card li {
  flex-wrap: wrap;
}

/* Horizontal ramp: five classes, the four break values sit under the joins. */
.safety-legend-ramp {
  display: flex;
  margin-top: 8px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, #2e7668 25%, transparent);
}

.safety-legend-ramp i {
  flex: 1;
  height: 10px;
}

.safety-legend-ticks {
  display: flex;
  justify-content: space-around;
  padding: 0 10%;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.safety-suburb-card {
  flex: 0 0 auto;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, #2e7668 35%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, #2e7668 6%, var(--surface));
  color: var(--ink-strong);
}

.safety-suburb-card-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.safety-suburb-card-head strong {
  font-size: 15px;
  font-weight: 800;
}

.safety-suburb-card-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.safety-suburb-card ul {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.safety-suburb-card li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
}

.safety-suburb-card li span {
  flex: 1;
  color: var(--muted);
}

.safety-suburb-card li strong {
  font-size: 14px;
  font-weight: 800;
}

.safety-suburb-card li em {
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
}

.safety-suburb-card li em.is-up {
  color: #b45309;
}

.safety-suburb-card li em.is-down {
  color: #2e7668;
}

.safety-metric select {
  margin-top: 6px;
  width: 100%;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-strong);
  font: inherit;
  font-size: 12px;
}

.safety-list-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 0 380px;
  min-height: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-muted, var(--surface-3));
  box-sizing: border-box;
}

.safety-list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink-strong);
  font-size: 14px;
}

.safety-list-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.safety-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 2px 2px 4px;
}

.safety-empty {
  padding: 24px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.safety-card {
  position: relative;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--ink-strong-bg) 6%, transparent);
  overflow: hidden;
}

.safety-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--type-color);
}

.safety-card.is-selected {
  border-color: color-mix(in srgb, var(--type-color) 55%, var(--line));
  box-shadow: 0 10px 26px color-mix(in srgb, var(--ink-strong-bg) 14%, transparent);
}

.safety-card-hit {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 11px 13px 11px 16px;
  border: 0;
  background: transparent;
  color: var(--ink-strong);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.safety-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.safety-type-tag {
  color: var(--type-color);
  font-size: 12px;
  font-weight: 800;
}

.safety-status {
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-strong-bg) 7%, transparent);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.safety-status.is-charged,
.safety-status.is-arrested {
  background: color-mix(in srgb, #2e7668 14%, transparent);
  color: #2e7668;
}

.safety-status.is-appeal {
  background: color-mix(in srgb, #b45309 14%, transparent);
  color: #b45309;
}

.safety-basis {
  padding: 0 7px;
  border: 1px dashed color-mix(in srgb, var(--muted) 60%, transparent);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

/* 网友自述 · 未核实: the same dashed pill, in the warning colour of the safety tie. */
.safety-basis.is-social {
  border-color: color-mix(in srgb, #c2410c 55%, transparent);
  color: #9a3412;
}

.safety-card-when {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.safety-card-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.safety-card-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

/* Same 4:3 cover thumbnail as the news board (.news-item-thumb): explicit width,
   min-width released, or an <img> flex item sizes to its intrinsic pixels. */
.safety-card-thumb {
  flex: 0 0 auto;
  width: clamp(72px, 28%, 112px);
  min-width: 0;
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  object-fit: cover;
  background: color-mix(in srgb, var(--ink-strong-bg) 8%, transparent);
}

.safety-card-summary {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.safety-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.safety-card-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0;
  padding: 10px 13px 13px 16px;
  border-top: 1px solid var(--line-soft, var(--line));
  font-size: 13px;
}

.safety-card-details dt {
  color: var(--muted);
  font-weight: 700;
}

.safety-card-details dd {
  margin: 0;
  color: var(--ink-strong);
  font-weight: 600;
  line-height: 1.45;
}

.safety-precision {
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-strong-bg) 7%, transparent);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.safety-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.safety-sources a {
  color: var(--brand, #001b4b);
  font-weight: 800;
  text-decoration: none;
}

.safety-sources a:hover {
  text-decoration: underline;
}

.safety-foot {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}

/* Leaflet overlays */
/* Campus = a small square on the exact spot + its name to the right, so the
   label never sits on top of the point itself. */
.safety-campus {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transform: translate(-5px, -50%);
  color: #0f2a4a;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  text-shadow: 0 0 3px #ffffff, 0 0 3px #ffffff, 0 0 2px #ffffff;
  opacity: 0.85;
}

.safety-campus b {
  width: 9px;
  height: 9px;
  border: 1.5px solid #0f2a4a;
  border-radius: 2px;
  background: #ffffff;
  box-sizing: border-box;
}

.safety-campus.is-own b {
  background: #0f2a4a;
}

.safety-map.is-dark .safety-campus {
  color: #dbe4f0;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
}

.safety-map.is-dark .safety-campus b {
  border-color: #dbe4f0;
}

.safety-map .leaflet-tooltip {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.safety-tip-note {
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
}

/* 校园信息右栏新闻头上的入口 */
.news-safety-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-strong);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.news-safety-link i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c2410c;
}

@media (max-width: 900px) {
  .safety-page {
    padding: 16px;
  }

  /* Phone: tabs + phone pill on the first line, search full width under them. */
  .safety-search {
    order: 3;
    flex: 1 1 100%;
    margin-left: 0;
  }

  .safety-search + .safety-emergency {
    margin-left: auto;
  }

  .safety-tabs {
    gap: 14px;
  }

  .safety-tabs button {
    font-size: 19px;
  }

  /* News: the topic chips get their own scrolling line under tabs + numbers. */
  .safety-head .np-chips {
    order: 3;
    flex: 1 1 100%;
    margin: 0 -16px;
    padding: 0 16px;
  }

  .safety-head .np-updated {
    display: none;
  }

  .safety-emergency a {
    padding: 8px 10px;
  }

  /* Short label so tabs + numbers share the first line at phone width. */
  .safety-emergency .lbl-long {
    display: none;
  }

  .safety-emergency .lbl-short {
    display: inline;
  }

  .safety-body {
    flex-direction: column;
    height: auto;
    min-height: 0;
  }

  .safety-map-wrap {
    flex: 0 0 auto;
    height: 56vh;
    min-height: 340px;
  }

  .safety-list-pane {
    flex: 0 0 auto;
  }

  .safety-list {
    overflow: visible;
  }

  .safety-legends {
    left: 8px;
    bottom: 22px;
    max-width: 210px;
  }

  /* Type colours are already on the filter chips above the map; on a phone the
     legend keeps only what the chips can't say (precision, stats ramp). */
  .safety-legend ul:not(.safety-legend-precision) {
    display: none;
  }

  .safety-legend-precision {
    padding-top: 0;
    border-top: 0;
  }
}
