/* New City Mastery — call-intelligence dashboard
   Self-contained styles. Palette follows the dataviz skill's validated
   reference instance (references/palette.md): fixed categorical order,
   single-hue sequential for magnitude, reserved status colors for state,
   never color-alone (every mark ships a text value beside it). */

:root {
  color-scheme: light;
  --surface-0: #f5f4f1;
  --surface-1: #fcfcfb;
  --surface-2: #ffffff;
  --border: #e2e0da;
  --border-strong: #cbc9c1;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #8a887f;

  --series-blue: #2a78d6;
  --series-blue-strong: #1c5cab;
  --series-blue-soft: #86b6ef;
  --bar-track: #eceae4;

  --status-good: #0ca30c;
  --status-good-bg: #e7f6e7;
  --status-warning: #b9740f;
  --status-warning-bg: #fdf1dd;
  --status-critical: #d03b3b;
  --status-critical-bg: #fbe4e4;

  --focus-ring: #1c5cab;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-0: #131312;
    --surface-1: #1a1a19;
    --surface-2: #201f1d;
    --border: #33322f;
    --border-strong: #46443f;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8b8a80;

    --series-blue: #3987e5;
    --series-blue-strong: #5598e7;
    --series-blue-soft: #184f95;
    --bar-track: #2a2926;
    --status-critical-bg: #3a1414;

    --status-good: #35c235;
    --status-good-bg: #10240f;
    --status-warning: #fab219;
    --status-warning-bg: #2c2210;
    --status-critical: #e66767;

    --focus-ring: #86b6ef;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  overflow-x: hidden; /* the page body must never scroll horizontally */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
}

a { color: var(--series-blue-strong); }
@media (prefers-color-scheme: dark) { a { color: var(--series-blue-soft); } }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

/* ---------- Header ---------- */

header.hero {
  padding: 1.5rem 0 1rem;
}

header.hero h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 700;
}

.hero-sub {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0 0 0.9rem;
}

.headline-figure {
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  font-weight: 700;
  font-variant-numeric: proportional-nums;
  margin: 0 0 0.15rem;
}

.headline-caption {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.banner {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  border: 1px solid var(--status-warning);
  background: var(--status-warning-bg);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  font-size: 0.88rem;
}

.banner .banner-icon {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--status-warning);
  letter-spacing: 0.02em;
}

.banner strong { color: var(--status-warning); }

/* ---------- Sections / cards ---------- */

section.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.1rem 1.25rem;
  margin: 1.1rem 0;
}

section.card h2 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
}

.section-note {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0 0 0.9rem;
}

.caveat {
  border-left: 3px solid var(--status-warning);
  background: var(--status-warning-bg);
  padding: 0.55rem 0.75rem;
  font-size: 0.83rem;
  color: var(--text-primary);
  border-radius: 0 6px 6px 0;
  margin: 0.6rem 0 1rem;
}

.caveat strong { color: var(--status-warning); }

/* ---------- Stat tiles ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
}

.stat-tile .stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: 0 0 0.25rem;
}

.stat-tile .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: proportional-nums;
}

.stat-tile .stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ---------- Legend ---------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 0.3rem 0 0.9rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.legend-tick {
  width: 2px;
  height: 12px;
  background: var(--text-secondary);
  flex: 0 0 auto;
}

/* ---------- Bar rows (horizontal bar list, one chart component) ---------- */

.bar-list { display: flex; flex-direction: column; gap: 0.85rem; }

.bar-row { }

.bar-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.88rem;
  margin-bottom: 0.28rem;
}

.bar-row-name { font-weight: 600; color: var(--text-primary); }

.bar-row-value {
  color: var(--text-secondary);
  font-variant-numeric: proportional-nums;
  white-space: nowrap;
  font-size: 0.83rem;
}

.bar-track {
  position: relative;
  background: var(--bar-track);
  border-radius: 5px;
  height: 20px;
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--series-blue);
  border-radius: 5px;
  min-width: 3px;
  transition: width 0.2s ease;
}

.bar-fill:focus-visible, .bar-track:focus-within .bar-fill {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.bar-row-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* low-N hatch: 45deg texture is the CVD/print/forced-colors channel, used
   here as a permanent flag (not decorative) for statistically unreliable rows */
.bar-fill.low-n {
  opacity: 0.55;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(0,0,0,0.16) 0, rgba(0,0,0,0.16) 3px,
    transparent 3px, transparent 7px
  );
}
@media (prefers-color-scheme: dark) {
  .bar-fill.low-n {
    background-image: repeating-linear-gradient(
      45deg,
      rgba(255,255,255,0.18) 0, rgba(255,255,255,0.18) 3px,
      transparent 3px, transparent 7px
    );
  }
}

.low-n-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--status-warning);
  border: 1px solid var(--status-warning);
  background: var(--status-warning-bg);
  border-radius: 4px;
  padding: 0.04rem 0.35rem;
  margin-left: 0.4rem;
  white-space: nowrap;
}

/* ---------- Verdict chips (marketing-vs-reality alignment) ----------
   Status color, reserved (never reused for series identity), always shipped
   with its own text label — never color alone. Four states: three reuse the
   existing good/warning/critical status tokens; "unaddressed" (no data
   either way, not a bad outcome) uses neutral ink rather than a status
   color, since it isn't a warning or a failure — it's an absence. */

.verdict-chip {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  white-space: nowrap;
  border: 1px solid;
  letter-spacing: 0.01em;
}

.verdict-chip.verdict-supported {
  color: var(--status-good);
  border-color: var(--status-good);
  background: var(--status-good-bg);
}

.verdict-chip.verdict-weak {
  color: var(--status-warning);
  border-color: var(--status-warning);
  background: var(--status-warning-bg);
}

.verdict-chip.verdict-unaddressed {
  color: var(--text-muted);
  border-color: var(--border-strong);
  background: var(--surface-1);
}

.verdict-chip.verdict-contradicted {
  color: var(--status-critical);
  border-color: var(--status-critical);
  background: var(--status-critical-bg);
}

.claim-quote {
  display: block;
  font-style: italic;
  color: var(--text-secondary);
  font-size: 0.82rem;
  margin-top: 0.15rem;
}

.claim-maps-to {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ---------- Contrast (bullet-style) rows ---------- */

.bullet-track {
  position: relative;
  background: var(--bar-track);
  border-radius: 5px;
  height: 20px;
  overflow: visible;
}

.bullet-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--series-blue);
  border-radius: 5px;
  min-width: 3px;
}

.bullet-baseline {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 2px;
  background: var(--text-primary);
}

/* ---------- Tooltip ---------- */

.viz-tooltip {
  position: fixed;
  z-index: 50;
  background: var(--text-primary);
  color: var(--surface-1);
  font-size: 0.78rem;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  pointer-events: none;
  max-width: 260px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.1s ease;
}
.viz-tooltip.visible { opacity: 1; }
.viz-tooltip .tt-value { font-weight: 700; }

/* ---------- Tables (scroll container, never body-scroll) ---------- */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

table.data-table th, table.data-table td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data-table td.wrap-cell { white-space: normal; }

table.data-table th {
  color: var(--text-secondary);
  font-weight: 600;
  background: var(--surface-1);
  position: sticky;
  top: 0;
}

table.data-table td { font-variant-numeric: tabular-nums; }

details.table-toggle {
  margin-top: 0.75rem;
}

details.table-toggle > summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--series-blue-strong);
  font-weight: 600;
  list-style: none;
}
@media (prefers-color-scheme: dark) {
  details.table-toggle > summary { color: var(--series-blue-soft); }
}
details.table-toggle > summary::-webkit-details-marker { display: none; }
details.table-toggle > summary::before { content: "▸ "; }
details.table-toggle[open] > summary::before { content: "▾ "; }
details.table-toggle > .table-scroll { margin-top: 0.5rem; }

/* ---------- Avatars section ---------- */

/* Unsegmented is not a competing category to the avatars - it is a residual
   ("matches no rule"), so it gets muted ink rather than a categorical color.
   Same bar-list component used everywhere else on this page; only the fill
   color changes. */
.bar-fill.unsegmented {
  background: var(--text-muted);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 0.75rem 0 1rem;
}

.avatar-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 0.9rem;
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.avatar-card h3 {
  margin: 0;
  font-size: 0.98rem;
}

.avatar-stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.avatar-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
}

.avatar-stat-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.avatar-stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: proportional-nums;
}

.avatar-rule, .avatar-distinguishing {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 0;
}

.avatar-rule strong { color: var(--text-primary); }

.avatar-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-top: 0.2rem;
}

.avatar-mini-grid h4 {
  margin: 0 0 0.25rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.avatar-mini-list {
  margin: 0;
  padding-left: 1.05rem;
  font-size: 0.8rem;
}

.avatar-mini-list li { margin-bottom: 0.2rem; }

.avatar-mini-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

/* ---------- Footer / method ---------- */

.method-list {
  font-size: 0.88rem;
  padding-left: 1.2rem;
}
.method-list li { margin-bottom: 0.5rem; }

footer.site-footer {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
  padding: 1.5rem 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  section.card { padding: 0.9rem 0.85rem 1rem; }
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--series-blue);
  color: #fff;
  padding: 0.5rem 0.8rem;
  border-radius: 0 0 6px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }
