/* ══════════════════════════════════════════════════════════════════════════
   CU MARKETS EXPLORER — demographic panel (panel.js)
   Tokens only (var(--…)) so it reads in both light & dark themes.
   Mounts into <aside class="panel-wrap" id="panel"> from index.html.
   ══════════════════════════════════════════════════════════════════════════ */

.dp {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  font-family: var(--font-body);
  color: var(--text);
}

/* ── HEADER ── */
.dp-head {
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
}
.dp-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.dp-sub {
  margin: 7px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.dp-sub-radius { color: var(--teal); font-weight: 500; }
.dp-sub-dot { color: var(--text-faint); }

/* ── TABS ── */
.dp-tabs {
  display: flex;
  gap: 2px;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.dp-tabs::-webkit-scrollbar { display: none; }
.dp-tab {
  position: relative;
  flex: 0 0 auto;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-dim);
  background: transparent;
  border: none;
  padding: 9px 13px 12px;
  cursor: pointer;
  transition: color .15s;
  white-space: nowrap;
}
.dp-tab:hover { color: var(--text); }
.dp-tab.is-active { color: var(--text); }
.dp-tab.is-active::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--teal);
}
.dp-tab:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

/* ── BODY / PANES ── */
.dp-body { padding: 6px 22px 4px; }
.dp-pane { display: none; }
.dp-pane.is-active { display: block; animation: dp-fade .18s ease; }
@keyframes dp-fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ── CORE STAT ROWS ── */
.dp-stats { display: flex; flex-direction: column; }
.dp-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--border);
}
.dp-stat:last-child { border-bottom: none; }
.dp-stat-label {
  font-size: 13.5px;
  color: var(--text-dim);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.dp-est {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 6px;
  cursor: help;
}
.dp-stat-val {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── BAR ROWS (race / education / language / industry) ── */
.dp-bars { display: flex; flex-direction: column; gap: 13px; padding: 14px 0 6px; }
.dp-bar-row { display: flex; flex-direction: column; gap: 6px; }
.dp-bar-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.dp-bar-label { font-size: 13px; color: var(--text); }
.dp-bar-figs {
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.dp-bar-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}
.dp-bar-pct {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12.5px;
  color: var(--text);
  min-width: 44px;
  text-align: right;
}
.dp-bar-track {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}
.dp-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal-glow), var(--teal));
  transition: width .35s cubic-bezier(.4, 0, .2, 1);
}

.dp-nodata, .dp-branch-none {
  padding: 18px 2px;
  font-size: 13px;
  color: var(--text-dim);
}

/* ── BRANCH SUMMARY (differentiator) ── */
.dp-branches {
  margin: 14px 22px 0;
  padding: 14px 15px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.dp-branch-head { display: flex; flex-direction: column; gap: 8px; }
.dp-branch-badge {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  border: 1px solid var(--teal-glow);
}
.dp-branch-headline {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-dim);
}
.dp-branch-headline strong { color: var(--text); font-weight: 600; }

/* mode accents */
.dp-mode-branching .dp-branch-badge {
  background: var(--violet-soft); color: var(--violet); border-color: var(--violet-soft);
}
.dp-mode-fom .dp-branch-badge {
  background: var(--green-soft); color: var(--green); border-color: var(--green-soft);
}

/* nearest-branch list */
.dp-branch-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 184px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.dp-branch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 4px;
  border-top: 1px solid var(--border);
}
.dp-branch:first-child { border-top: none; }
.dp-branch-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dp-branch-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dp-branch-tag {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--teal-soft);
  color: var(--teal);
}
.dp-branch-site {
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dp-branch-site:hover { color: var(--teal); }
.dp-branch-dist {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.dp-branch.is-main .dp-branch-name { color: var(--teal); }

/* ── FOOTNOTE ── */
.dp-footnote {
  margin: auto 0 0;
  padding: 16px 22px 18px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-faint);
}

/* ══════════════════════════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════════════════════════ */
.dp-empty {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
  padding: 48px 32px;
  flex: 1;
}
.dp-empty-art {
  width: 64px; height: 64px;
  color: var(--teal);
  margin-bottom: 14px;
  opacity: 0.9;
}
.dp-empty-art svg { width: 100%; height: 100%; }
.dp-empty-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.dp-empty-text {
  margin: 0;
  max-width: 32ch;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-dim);
}

/* ══════════════════════════════════════════════════════════════════════════
   LOADING / SKELETON
   ══════════════════════════════════════════════════════════════════════════ */
.dp-loading { padding: 20px 22px; gap: 0; }
.dp-sk {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface), var(--border), var(--surface));
  background-size: 200% 100%;
  animation: dp-shimmer 1.3s ease-in-out infinite;
}
@keyframes dp-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.dp-sk-head { height: 20px; width: 62%; margin-bottom: 10px; }
.dp-sk-sub  { height: 11px; width: 38%; border-radius: 999px; margin-bottom: 18px; }
.dp-sk-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.dp-sk-tab  { height: 13px; width: 46px; border-radius: 999px; }
.dp-sk-list { display: flex; flex-direction: column; gap: 14px; }
.dp-sk-row  { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dp-sk-label { height: 12px; width: 46%; border-radius: 999px; }
.dp-sk-val   { height: 12px; width: 22%; border-radius: 999px; }
.dp-loading-note {
  margin: 22px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

@media (prefers-reduced-motion: reduce) {
  .dp-pane.is-active, .dp-bar-fill, .dp-sk { animation: none; transition: none; }
}
