/* Interactive Sichuan-Yunnan map. Panel beside the map from 900px, stacked
   below it on narrower screens. Spacing, type and radius come from the site
   scale in site-chrome.css. */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; overflow-x: hidden; }
body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: var(--bg); color: var(--text-primary); line-height: var(--lh-body); }
::selection { background: var(--selection-bg); color: var(--text-primary); }
a { color: var(--accent-heading); text-decoration: none; }
a:hover { text-decoration: underline; }

.smap { display: grid; grid-template-columns: 1fr; }
/* Grid items default to min-width: auto, which let the 720px phone chart widen the page. */
.smap > * { min-width: 0; }
.smap-stage { position: relative; height: min(70vh, 640px); min-height: 420px; border-top: 1px solid var(--border-light); border-bottom: 1px solid var(--border-light); }
.smap-map { position: absolute; inset: 0; }
.smap-panel { order: 2; padding: var(--space-6) var(--gutter) var(--space-7); }

@media (min-width: 900px) {
  .smap { grid-template-columns: 360px 1fr; height: calc(100dvh - var(--nav-h, 64px)); }
  .smap-panel { order: 0; overflow-y: auto; padding: var(--space-5) var(--space-5) var(--space-6) var(--gutter); border-right: 1px solid var(--border-light); }
  .smap-stage { height: auto; min-height: 0; border: 0; }
}

.smap-back { display: inline-block; font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-4); }
.smap-kicker, .smap-label { font-size: var(--text-xs); font-weight: 700; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--text-tertiary); }
.smap-title { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -0.02em; line-height: var(--lh-tight); margin-top: var(--space-2); }
.smap-lede { margin-top: var(--space-3); font-size: var(--text-sm); color: var(--text-secondary); }

.smap-group { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border-light); }
.smap-group > .smap-label { margin-bottom: var(--space-3); }

/* Pill segmented control and route buttons: one pressed state, the accent wash. */
.smap-seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-control); padding: 2px; background: var(--bg-card); }
.smap-seg button, .smap-route, .smap-chip, .smap-close {
  font: inherit; color: inherit; background: none; border: 0; cursor: pointer;
}
.smap-seg button { min-height: 36px; padding: 0 var(--space-4); border-radius: var(--radius-control); font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.smap-seg button[aria-pressed="true"] { background: var(--accent-muted-strong); color: var(--accent-heading); }

.smap-routes { display: grid; gap: var(--space-2); }
.smap-route { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: var(--space-2); text-align: left; min-height: 44px; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-field); background: var(--bg-card); }
.smap-route strong { font-size: var(--text-sm); font-weight: 700; }
.smap-route span { font-size: var(--text-xs); color: var(--text-tertiary); }
.smap-route:hover { border-color: var(--accent-border); }
.smap-route[aria-pressed="true"] { border-color: var(--accent-border); background: var(--accent-muted-strong); }
.smap-route[aria-pressed="true"] strong { color: var(--accent-heading); }

.smap-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.smap-chip { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 36px; padding: 0 var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--bg-card); font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.smap-chip svg { width: 14px; height: 14px; flex: none; }
.smap-chip[aria-pressed="false"] { opacity: 0.55; }
.smap-chip[aria-pressed="false"] span { text-decoration: line-through; }
.smap-chip:hover { border-color: var(--accent-border); }

.smap-check { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-4); font-size: var(--text-sm); font-weight: 600; cursor: pointer; }
.smap-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.smap-check + .smap-check { margin-top: var(--space-2); }
.smap-check-note { font-weight: 400; color: var(--text-tertiary); font-size: var(--text-xs); }
/* Line keys match the map's network layers (THEMES in map.js). */
.smap-key { width: 28px; height: 8px; flex: none; fill: none; stroke-width: 2.5; }
.smap-key-road { stroke: #59523f; }
.smap-key-rail { stroke: #2a78d6; stroke-width: 1.5; stroke-dasharray: 3 3; }
.smap-key-trail { stroke: #59523f; stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 0.1 4.5; }
.smap-key-air { stroke: #8d877a; stroke-width: 1.2; stroke-dasharray: 6 4; }
.smap-key-boat { stroke: #2a78d6; stroke-width: 1.6; stroke-dasharray: 3 3; }
.smap-key-road.is-dashed { stroke-dasharray: 5 3.5; }
[data-theme="dark"] .smap-key-road { stroke: #a89f88; }
[data-theme="dark"] .smap-key-rail { stroke: #3987e5; }
[data-theme="dark"] .smap-key-trail { stroke: #a89f88; }
[data-theme="dark"] .smap-key-air { stroke: #6b6457; }
[data-theme="dark"] .smap-key-boat { stroke: #6da7ec; }
.smap-bands { list-style: none; display: grid; gap: var(--space-1); margin-top: var(--space-3); font-size: var(--text-xs); color: var(--text-secondary); }
.smap-bands li { display: flex; align-items: center; gap: var(--space-2); }
.smap-bands i { width: 14px; height: 14px; border-radius: var(--radius-chip); flex: none; }
.smap-bands.is-off { opacity: 0.45; }

.smap-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.smap-table th { text-align: left; font-size: var(--text-xs); font-weight: 700; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--text-tertiary); padding: 0 0 var(--space-2); }
.smap-table td { padding: var(--space-1) 0; border-top: 1px solid var(--border-light); vertical-align: top; }
.smap-table th:not(:first-child), .smap-table td:not(:first-child) { text-align: right; padding-left: var(--space-3); white-space: nowrap; }
.smap-table td small { display: block; color: var(--text-tertiary); font-size: var(--text-xs); }
.smap-table button { font: inherit; color: var(--accent-heading); background: none; border: 0; cursor: pointer; text-align: left; padding: 0; }
.smap-table button:hover { text-decoration: underline; }
.smap-warn { color: var(--pc-warn); font-weight: 700; }
.smap-note, .smap-foot p { margin-top: var(--space-3); font-size: var(--text-xs); line-height: var(--lh-body); color: var(--text-tertiary); }
.smap-foot p:first-child { margin-top: 0; }

/* Profile drawer over the bottom of the map. */
/* Lifted clear of the site's fixed "Ask" button in the bottom-right corner. */
.smap-profile { position: absolute; left: var(--space-3); right: var(--space-3); bottom: 72px; padding: var(--space-3) var(--space-4) var(--space-2); background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-field); }
.smap-profile[hidden] { display: none; }
.smap-profile-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.smap-profile-title { font-size: var(--text-sm); font-weight: 700; line-height: var(--lh-tight); }
.smap-close { width: 36px; height: 36px; border-radius: var(--radius-control); font-size: var(--text-xl); line-height: 1; color: var(--text-secondary); }
.smap-close:hover { background: var(--accent-muted-strong); }
.smap-help { font-size: var(--text-xs); color: var(--text-tertiary); }
@media (max-width: 899px) {
  .smap-profile { position: static; margin: 0; border-radius: 0; border-width: 1px 0 0; }
  .smap-stage:has(.smap-profile:not([hidden])) { height: auto; }
  .smap-stage:has(.smap-profile:not([hidden])) .smap-map { position: relative; height: min(60vh, 520px); min-height: 360px; }
  .smap-help { display: none; }
}

.smap-fallback { position: absolute; inset: 0; display: grid; place-content: center; gap: var(--space-3); text-align: center; padding: var(--gutter); color: var(--text-secondary); }
.smap-fallback[hidden] { display: none; }

/* Hover marker that follows the profile chart. */
.smap-follow { width: 14px; height: 14px; border-radius: 50%; background: var(--text-primary); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--text-primary); }

/* MapLibre chrome, in the site's surfaces. */
.maplibregl-popup-content { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); border-radius: var(--radius-field); padding: var(--space-3) var(--space-4); box-shadow: none; font-family: inherit; }
.maplibregl-popup-tip { display: none; }
.maplibregl-popup-close-button { color: var(--text-secondary); font-size: var(--text-lg); width: 32px; height: 32px; }
.smap-pop-name { font-size: var(--text-md); font-weight: 700; line-height: var(--lh-tight); padding-right: var(--space-5); }
.smap-pop-zh { font-size: var(--text-sm); color: var(--text-secondary); }
.smap-pop-alt { margin-top: var(--space-2); font-size: var(--text-xl); font-weight: 800; letter-spacing: -0.01em; }
.smap-pop-meta, .smap-pop-note { font-size: var(--text-xs); color: var(--text-tertiary); }
.smap-pop-note { margin-top: var(--space-2); max-width: 240px; }
.maplibregl-ctrl-attrib { background: var(--nav-bg) !important; color: var(--text-tertiary); font-size: var(--text-xs); }
.maplibregl-ctrl-attrib a { color: var(--text-secondary); }
.maplibregl-ctrl-group { background: var(--bg-card); border: 1px solid var(--border); box-shadow: none !important; }
.maplibregl-ctrl-group button + button { border-top-color: var(--border); }
[data-theme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
.maplibregl-ctrl-group .smap-home { color: var(--text-primary); }
.smap-home svg { display: block; margin: auto; }
