/* ============================================================
   EU Legislative Screener — Design-system compatibility shim
   ============================================================
   Loaded AFTER shell.css. Maps the legacy template class
   vocabulary (`card-section`, `section-title`, `stat-value`,
   `focus-badge`, `heat-*`, `pipeline-*`, `mep-header`, etc.)
   onto the new shell.css tokens, and reconciles Bootstrap's
   .card (which templates use heavily via .card-body/.card-header)
   with shell.css's standalone .card block.
   ============================================================ */

/* ---------- Legacy token aliases (old name → shell.css var) ---------- */
:root {
  --ceps-primary: var(--ceps);
  --ceps-primary-light: var(--ceps-light);
  --ceps-primary-dark: var(--ceps-dark);
  --ceps-accent: var(--accent);

  --surface-white: var(--bg-card);
  --surface-light: var(--bg);
  --surface-card: var(--bg-card);
  --surface-muted: var(--bg-tint);

  --border-light: var(--hair);
  --border-medium: var(--hair-strong);

  --text-primary: var(--ink);
  --text-secondary: var(--ink-2);
  --text-muted: var(--ink-3);

  --success: var(--positive);
  --warning: var(--warn);
  --danger:  var(--neg);

  --eu-blue: var(--ceps);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
}

/* ---------- Bootstrap .card reconciliation ----------
   shell.css defines a standalone `.card` block (padding 20/24, radius 14).
   v1-style templates use `.card` as a self-contained surface — keep shell's
   padding. Bootstrap-style templates (index.html) nest `.card-body` /
   `.card-header` directly inside `.card`; use :has() to strip padding only
   in that case so the nested header/body controls spacing. */
.card:has(> .card-body),
.card:has(> .card-header),
.card:has(> .card-footer) {
  padding: 0;
}
.card-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--hair);
  padding: 14px 18px;
}
.card-header h6,
.card-header h5 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  color: var(--ink);
  font-size: 15px;
  letter-spacing: -0.005em;
}
.card-body { padding: 16px 18px; }
.card-footer {
  background: var(--bg);
  border-top: 1px solid var(--hair);
}

/* ---------- Legacy workhorse: .card-section = shell.css .card ---------- */
.card-section {
  background: var(--bg-card);
  border: 1px solid var(--hair);
  border-radius: 14px;
  padding: 20px 24px;
  margin-bottom: 18px;
}
.card-section .section-title,
.section-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0 0 4px 0;
  line-height: 1.15;
}
.card-section .section-explainer,
.section-explainer {
  font-size: 11.5px;
  color: var(--ink-3);
  font-style: italic;
  line-height: 1.5;
  margin: 0 0 12px 0;
}

/* ---------- Stats ---------- */
.stat-box {
  text-align: center;
  padding: 10px 18px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-box .stat-value,
.stat-value {
  font-family: 'Inter', sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ceps);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-box .stat-label,
.stat-label {
  font-size: 10.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.stat-row {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--hair);
  border-radius: 14px;
  padding: 14px 12px;
  margin-bottom: 18px;
  gap: 18px;
  flex-wrap: wrap;
}
.stat-number {
  font-family: 'Inter', sans-serif;
  font-size: 24px; font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ceps);
  font-variant-numeric: tabular-nums;
}

/* ---------- Horizontal bars (.h-bar) ---------- */
.h-bar {
  height: 26px;
  border-radius: 4px;
  transition: width 0.3s ease;
  display: flex; align-items: center;
  padding-left: 10px;
  font-size: 0.78rem; font-weight: 600;
  color: #fff; min-width: 28px; white-space: nowrap;
}
.h-bar-track {
  background: var(--bg-tint);
  border-radius: 4px;
  overflow: hidden; flex: 1;
}

/* ---------- Pipeline segmented bar (homepage) ---------- */
.pipeline-bar {
  display: flex;
  width: 100%;
  height: 46px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--hair);
  background: var(--bg-tint);
}
.pipeline-seg {
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  color: #fff; font-size: 0.72rem; font-weight: 600;
  text-align: center; padding: 4px 6px;
  min-width: 32px;
  border-right: 1px solid rgba(255,255,255,0.25);
  text-decoration: none;
  transition: filter .15s ease;
  overflow: hidden;
}
.pipeline-seg:last-child { border-right: none; }
.pipeline-seg:hover { filter: brightness(1.1); color: #fff; text-decoration: none; }
.pipeline-seg .seg-count { font-size: 0.82rem; font-weight: 700; line-height: 1.1; }
.pipeline-seg .seg-name  {
  font-size: 0.66rem; opacity: 0.9; line-height: 1.1;
  text-overflow: ellipsis; overflow: hidden; max-width: 100%;
}

/* ---------- Pill bar (party/topic selectors) ---------- */
.pill-bar {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.pill-bar a {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--hair-strong);
  background: var(--bg-card);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition: all .15s ease;
}
.pill-bar a:hover { border-color: var(--ceps); color: var(--ceps); }
.pill-bar a.active {
  background: var(--ceps);
  color: #fff;
  border-color: var(--ceps);
}

/* ---------- MEP header ---------- */
.mep-header {
  background: var(--bg);
  border: 1px solid var(--hair);
  border-radius: 14px;
  margin-bottom: 18px;
}
.mep-header .mep-name {
  font-family: 'Source Serif 4', serif;
  font-size: 1.5rem; font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  margin: 0 0 4px 0;
}
.mep-header .mep-meta {
  font-size: 0.85rem; color: var(--ink-2);
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.mep-photo-lg {
  width: 120px; height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--ceps);
}

/* ---------- Focus badges (MEP thematic focus) ---------- */
.focus-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: center;
}
.focus-badge.high { background: var(--ceps); color: #fff; }
.focus-badge.mid  { background: var(--bg-tint); color: var(--ink-2); }
.focus-badge.low  { background: #fbeaea; color: #8b3a28; }

/* ---------- Alignment heatmap ---------- */
.align-heatmap td {
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  text-align: center;
  padding: 4px 6px;
  border: 1px solid var(--hair);
  font-variant-numeric: tabular-nums;
}
.heat-low  { background: #f5d9d4; color: #8B3A28; }
.heat-mid  { background: #e8b9a6; color: #6b2d17; }
.heat-high { background: #c6e4c9; color: #1f5226; }
.heat-top  { background: #2e7d32; color: #fff; }

/* ---------- Procedure reference + title ---------- */
.procedure-ref {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.9rem;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  font-weight: 500;
}
.procedure-title {
  font-family: 'Source Serif 4', serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  margin: 4px 0 10px 0;
}

/* ---------- Committee abbreviation badge ---------- */
.committee-badge {
  display: inline-block;
  padding: 3px 10px;
  background: var(--ceps);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

/* ---------- Bootstrap overrides ---------- */
.btn-primary,
.btn-outline-primary {
  --bs-btn-bg: var(--ceps);
  --bs-btn-border-color: var(--ceps);
  --bs-btn-hover-bg: var(--ceps-dark);
  --bs-btn-hover-border-color: var(--ceps-dark);
  --bs-btn-active-bg: var(--ceps-dark);
}
.btn-outline-primary {
  color: var(--ceps);
  border-color: var(--ceps);
}
.btn-outline-primary:hover {
  background: var(--ceps);
  border-color: var(--ceps);
  color: #fff;
}
.badge.bg-primary { background-color: var(--ceps) !important; }
.badge.bg-secondary { background-color: var(--ink-3) !important; }

/* Table polish */
.table { --bs-table-striped-bg: var(--bg); }
.table thead th {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  font-weight: 600;
  border-bottom: 1px solid var(--hair-strong);
}
.table td { font-size: 13px; }

/* Breadcrumbs */
.breadcrumb {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.breadcrumb a { color: var(--ink-3); }
.breadcrumb a:hover { color: var(--ceps); }
.breadcrumb-item.active { color: var(--ink-2); }

/* Forms */
.form-control:focus,
.form-select:focus {
  border-color: var(--ceps);
  box-shadow: 0 0 0 0.15rem rgba(0,102,94,0.15);
}

/* ---------- Utilities ---------- */
.text-ceps       { color: var(--ceps) !important; }
.bg-surface      { background: var(--bg) !important; }
.border-light-ds { border-color: var(--hair) !important; }
.muted-italic    { color: var(--ink-3); font-style: italic; }

.tabular, table td.num, table th.num, .data-number {
  font-variant-numeric: tabular-nums;
}
