/* ── Map-as-page layout ─────────────────────────────────── */

body.split-view {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: 'Inter', -apple-system, sans-serif;
}

body.split-view #map {
  position: fixed;
  top: 44px;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: calc(100vh - 44px);
  height: calc(100dvh - 44px);
  z-index: 0;
}

/* ── Top bar ───────────────────────────────────────────── */

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.top-logo {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--brand, #6D3FE3);
  text-decoration: none;
  white-space: nowrap;
}

.top-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 1;
  min-width: 0;
}

.top-nav::-webkit-scrollbar { display: none; }

.top-nav-item {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.top-nav-item:hover { background: var(--bg-region); color: var(--text); }
.top-nav-item.active { background: var(--brand, #6D3FE3); color: #fff; }

.top-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-controls .shell-select { font-size: 12px; padding: 4px 8px; }
.top-controls .shell-icon { font-size: 14px; }
.top-controls .shell-btn { font-size: 11px; padding: 4px 10px; }

/* ── Floating summary card ─────────────────────────────── */

.float-summary {
  position: fixed;
  top: 56px;
  left: 16px;
  z-index: 500;
  width: 320px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  background: rgba(from var(--bg-panel) r g b / 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  font-size: 13px;
  transition: opacity 0.2s, transform 0.2s;
}

@supports not (background: rgba(from white r g b / 0.9)) {
  .float-summary {
    background: var(--bg-panel);
  }
}

.float-summary.hidden {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

.float-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  margin: 0;
}

.float-summary .summary-name {
  font-size: 18px;
  margin-bottom: 2px;
}

.float-summary .summary-headline {
  font-size: 13px;
  margin-bottom: 12px;
}

.float-summary .summary-stats {
  gap: 16px;
  font-size: 11px;
}

.float-summary .stat-val {
  font-size: 16px;
}

.float-summary .theme-pills {
  gap: 6px;
  margin-bottom: 12px;
}

.float-summary .theme-pill {
  padding: 6px 12px;
  min-width: 0;
}

.float-top-cities {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.float-city-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 12px;
}

.float-city-row:hover {
  background: var(--bg-region);
  border-radius: 6px;
  transform: translateY(-1px);
}

.float-city-rank {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 16px;
}

.float-city-name { font-weight: 500; flex: 1; color: var(--text); }
.float-city-glyphs { font-size: 14px; opacity: 0.6; }

.float-coaching {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-style: italic;
}

/* ── Right-side filter rail ────────────────────────────── */

.filter-rail {
  position: fixed;
  top: 56px;
  right: 8px;
  z-index: 500;
}

.filter-rail-toggle {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.filter-rail-toggle:hover { color: var(--text); }

.filter-rail-body {
  margin-top: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  width: 180px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.filter-group {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.filter-group:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.filter-group label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.filter-group input[type="range"] { width: 100%; }
.filter-group input[type="checkbox"] { width: auto; margin: 0; }

.filter-group .orb-val {
  font-weight: 600;
  color: var(--accent, var(--brand));
  font-size: 12px;
}

.filter-btn {
  width: 100%;
  padding: 6px;
  font-size: 11px;
  background: var(--bg-region);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  margin: 8px 0 0;
}

.filter-btn:hover { color: var(--text); }

/* ── Bottom sheet ──────────────────────────────────────── */

.sheet-backdrop {
  position: fixed;
  top: 44px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 800;
  background: rgba(0,0,0,0.2);
  display: none;
  transition: opacity 0.3s;
}

.sheet-backdrop.visible { display: block; }

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  max-height: 60vh;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
  transform: translateY(100%);
  transition: transform 0.3s ease-out;
  display: flex;
  flex-direction: column;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
  cursor: grab;
  flex-shrink: 0;
}

.sheet-handle-bar {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.sheet-content {
  overflow-y: auto;
  padding: 0 24px 24px;
  flex: 1;
}

/* Override insights.css section styles inside sheet */
.bottom-sheet .ins-section {
  padding: 8px 0 16px;
  border-top: none;
}

.bottom-sheet .section-head {
  margin-bottom: 12px;
}

.bottom-sheet .section-title {
  font-size: 20px;
}

.bottom-sheet .power-layout {
  grid-template-columns: 280px 1fr;
  gap: 20px;
}

.bottom-sheet .section-desc { display: none; }

/* ── Map overlays ──────────────────────────────────────── */

.map-query-overlay {
  position: fixed;
  bottom: 16px;
  left: 16px;
  max-width: 320px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  z-index: 400;
  font-size: 12px;
  display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.map-query-overlay.visible { display: block; }

.map-status {
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 11px;
  color: var(--text-muted);
  z-index: 400;
  display: none;
}

/* ── Theme filter chips ─────────────────────────────────── */

.theme-filter-row {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.theme-filter {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-muted);
  cursor: pointer;
  margin: 0;
  width: auto;
  transition: background 0.15s, color 0.15s;
}

.theme-filter:hover { color: var(--text); background: var(--bg-region); }
.theme-filter.active { background: var(--brand, #6D3FE3); color: #fff; border-color: var(--brand, #6D3FE3); }

/* ── Loading skeleton ──────────────────────────────────── */

.skeleton {
  background: linear-gradient(90deg, var(--bg-region) 25%, var(--border) 50%, var(--bg-region) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}

.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-line-short { width: 60%; }
.skeleton-line-med { width: 80%; }
.skeleton-block { height: 60px; margin-bottom: 12px; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Export button ─────────────────────────────────────── */

.export-btn {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s;
}

.export-btn:hover { color: var(--text); }

/* ── Map line labels ───────────────────────────────────── */

.line-label {
  font-size: 11px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
  text-shadow: 0 0 4px var(--bg-body), 0 0 8px var(--bg-body);
  pointer-events: none;
}

/* ── City pin labels ───────────────────────────────────── */

.city-pin-label {
  background: var(--bg-panel) !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
  padding: 2px 6px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  color: var(--text) !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1) !important;
}

.city-pin-label::before { display: none !important; }

/* ── Jargon tooltips ───────────────────────────────────── */

abbr.jargon {
  text-decoration: underline dotted var(--text-muted);
  text-underline-offset: 2px;
  cursor: help;
  position: relative;
}

abbr.jargon:hover::after,
abbr.jargon:focus::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
  white-space: normal;
  width: 220px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  pointer-events: none;
  font-style: normal;
  text-decoration: none;
}

/* ── Hide standalone-mode elements ─────────────────────── */

body.split-view .app-shell { display: none; }
body.split-view .section-nav { display: none; }
body.split-view #insights-app { max-width: none; }

/* ── Responsive ────────────────────────────────────────── */

.mobile-menu-btn {
  display: none;
}

@media (max-width: 768px) {
  .top-bar { padding: 0 10px; gap: 8px; }
  .top-logo { font-size: 14px; }
  .top-controls .shell-select { display: none; }
  .top-controls .shell-btn { padding: 4px 8px; font-size: 10px; }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-region);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    margin: 0;
    padding: 0;
  }

  .top-nav {
    display: none;
    position: absolute;
    top: 44px;
    left: 0;
    right: 0;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 8px 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 1100;
  }

  .top-nav.mobile-open {
    display: flex;
  }

  .top-nav-item {
    padding: 12px 20px;
    font-size: 14px;
    border-radius: 0;
  }

  .top-nav-item:hover { background: var(--bg-region); }
  .top-nav-item.active { border-radius: 0; }

  .float-summary {
    top: auto;
    bottom: 16px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 45vh;
    padding: 12px;
    border-radius: 12px;
  }

  .float-summary .summary-name { font-size: 16px; }
  .float-summary .summary-headline { font-size: 12px; margin-bottom: 8px; }
  .float-summary .theme-pills { gap: 4px; margin-bottom: 8px; }
  .float-summary .theme-pill { padding: 4px 8px; min-width: 0; }
  .float-summary .theme-pill-desc { display: none; }

  .bottom-sheet { max-height: 75vh; }
  .filter-rail { top: 52px; right: 4px; }
  .bottom-sheet .power-layout { grid-template-columns: 1fr; }
}
