/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:      #0d47a1;
  --red:       #b71c1c;
  --indep:     #555;
  --bg:        #f4f6f9;
  --card-bg:   #ffffff;
  --border:    #dde1e8;
  --text:      #1a1a1a;
  --muted:     #666;
  --navy:      #0a2240;
  --header-h:  72px;
  --tabs-h:    50px;
  --radius:    10px;
  --shadow:    0 2px 10px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.18);
  --aligned-ring:  #16a34a;
  --leaning-ring:  #22c55e;
  --neutral-ring:  #9ca3af;
  --opposed-ring:  #f59e0b;
  --hostile-ring:  #ef4444;
}

html { font-size: 18px; scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; line-height: 1.5; }

/* ── Header ──────────────────────────────────────────────────────────────── */
#site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--navy); color: #fff;
  height: var(--header-h);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.header-inner {
  max-width: 1400px; margin: 0 auto; padding: 0 20px;
  height: 100%; display: flex; align-items: center; gap: 20px;
}
.header-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-logo { font-size: 1.5rem; color: #f0c040; }
.brand-title { font-size: 1.4rem; font-weight: 700; letter-spacing: .02em; }
.brand-sub { font-size: 0.9rem; opacity: .75; white-space: nowrap; }
.header-search { flex: 1; max-width: 480px; }
#search-input {
  width: 100%; padding: 10px 18px; font-size: 1.05rem; border: none; border-radius: 30px;
  background: rgba(255,255,255,.15); color: #fff; outline: none; transition: background .2s;
}
#search-input::placeholder { color: rgba(255,255,255,.6); }
#search-input:focus { background: rgba(255,255,255,.25); }
.member-count { font-size: 0.85rem; opacity: .7; white-space: nowrap; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
#borough-tabs {
  position: sticky; top: var(--header-h); z-index: 99;
  background: #fff; border-bottom: 2px solid var(--border);
  display: flex; padding: 0 16px; height: var(--tabs-h);
  align-items: flex-end; overflow-x: auto; scrollbar-width: none;
}
#borough-tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 8px 18px; font-size: 0.9rem; font-weight: 600;
  border: none; background: none; cursor: pointer; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  transition: color .15s, border-color .15s; white-space: nowrap; min-height: 44px; flex-shrink: 0;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--navy); border-bottom-color: var(--navy); }
.tab-spacer { flex: 1; min-width: 16px; }
.tier-tab.active[data-tier="Aligned"]  { color: #166534; border-bottom-color: var(--aligned-ring); }
.tier-tab.active[data-tier="Leaning"]  { color: #15803d; border-bottom-color: var(--leaning-ring); }
.tier-tab.active[data-tier="Neutral"]  { color: #374151; border-bottom-color: var(--neutral-ring); }
.tier-tab.active[data-tier="Opposed"]  { color: #b45309; border-bottom-color: var(--opposed-ring); }
.tier-tab.active[data-tier="Hostile"]  { color: #991b1b; border-bottom-color: var(--hostile-ring); }

/* ── Grid ────────────────────────────────────────────────────────────────── */
#grid-container { max-width: 1400px; margin: 0 auto; padding: 24px 20px 60px; }
#member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}

.member-card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  cursor: pointer; transition: transform .15s, box-shadow .15s;
  border: 2px solid transparent; display: flex; flex-direction: column;
}
.member-card:hover, .member-card:focus-visible {
  transform: translateY(-3px); box-shadow: var(--shadow-lg);
  border-color: var(--navy); outline: none;
}

/* Score stripe at top of card */
.card-score-stripe { height: 4px; width: 100%; }

.card-photo {
  width: 100%; aspect-ratio: 3/4; object-fit: cover; object-position: top;
  display: block; background: #e8edf3;
}
.card-photo-placeholder {
  width: 100%; aspect-ratio: 3/4;
  background: linear-gradient(135deg, #c8d6e8 0%, #e2e8f0 100%);
  display: flex; align-items: center; justify-content: center;
}
.card-photo-placeholder svg { width: 56px; height: 56px; color: #93a8c0; }

.card-body { padding: 12px 14px 14px; flex: 1; }
.card-name { font-size: 1rem; font-weight: 700; line-height: 1.25; margin-bottom: 6px; }
.card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.party-badge {
  width: 22px; height: 22px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 800; color: #fff; flex-shrink: 0;
}
.party-D, .party-Democratic { background: var(--blue); }
.party-R, .party-Republican  { background: var(--red); }
.party-none { background: var(--indep); }
.card-location { font-size: 0.82rem; color: var(--muted); }

.score-row { display: flex; align-items: center; gap: 8px; }
.score-tier-label { font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.score-bar-bg { flex: 1; height: 4px; background: #e8edf3; border-radius: 2px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 2px; }
.score-num { font-size: 0.75rem; font-weight: 800; font-family: monospace; width: 24px; text-align: right; flex-shrink: 0; }
.card-bills { margin-top: 6px; font-size: 0.78rem; font-weight: 600; color: #1565c0; }

.no-results { text-align: center; padding: 60px 20px; font-size: 1.2rem; color: var(--muted); }
.hidden { display: none !important; }

/* ── Profile View ────────────────────────────────────────────────────────── */
#profile-view { min-height: 100vh; background: var(--bg); }

#profile-topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--navy); padding: 0 24px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.back-btn {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  font-size: 1rem; font-weight: 700; padding: 10px 20px;
  border-radius: 8px; cursor: pointer; transition: background .15s; min-height: 44px;
}
.back-btn:hover { background: rgba(255,255,255,.28); }
.print-btn-top {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  font-size: 0.9rem; font-weight: 600; padding: 8px 18px;
  border-radius: 8px; cursor: pointer;
}
.nav-counter { font-size: 0.85rem; color: rgba(255,255,255,.7); font-weight: 600; white-space: nowrap; }

/* ── Nav Arrows ──────────────────────────────────────────────────────────── */
.nav-arrow {
  position: fixed; top: 50%; transform: translateY(-50%); z-index: 50;
  width: 54px; height: 100px; background: rgba(10,34,64,.75); color: #fff;
  border: none; border-radius: 6px; cursor: pointer; font-size: 3rem;
  line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: background .15s, opacity .15s; opacity: .7; user-select: none;
}
.nav-arrow:hover { background: rgba(10,34,64,.95); opacity: 1; }
.nav-arrow:disabled { opacity: .2; cursor: default; }
.nav-arrow-left  { left: 0; border-radius: 0 8px 8px 0; }
.nav-arrow-right { right: 0; border-radius: 8px 0 0 8px; }

/* ── Profile Content ─────────────────────────────────────────────────────── */
#profile-content {
  max-width: 900px; margin: 0 auto;
  padding: 32px 24px 80px; background: #fff;
  min-height: calc(100vh - 60px);
}

/* Profile header (party color bg) */
.prof-header {
  padding: 28px 28px 24px; border-radius: 10px;
  color: #fff; display: flex; gap: 24px; align-items: flex-start;
}
.prof-photo {
  width: 100px; height: 125px; object-fit: cover; object-position: top;
  border-radius: 6px; border: 3px solid rgba(255,255,255,.4); flex-shrink: 0;
}
.prof-photo-placeholder {
  width: 100px; height: 125px; border-radius: 6px;
  border: 3px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.prof-info { flex: 1; min-width: 0; }
.prof-name { font-size: 1.6rem; font-weight: 800; line-height: 1.2; margin-bottom: 6px; }
.prof-party-badge {
  display: inline-block; padding: 3px 12px; border-radius: 14px;
  background: rgba(255,255,255,.2); font-size: 0.85rem; font-weight: 700; margin-bottom: 8px;
}
.prof-title { font-size: 1rem; opacity: .9; margin-bottom: 4px; }

.prof-score-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.prof-score-num {
  font-size: 2rem; font-weight: 800; line-height: 1;
  background: rgba(255,255,255,.2); border-radius: 8px; padding: 6px 12px; flex-shrink: 0;
}
.prof-score-detail { flex: 1; }
.prof-score-tier { font-size: 0.85rem; font-weight: 700; opacity: .95; margin-bottom: 4px; }
.prof-score-bar-bg { height: 6px; background: rgba(255,255,255,.25); border-radius: 3px; overflow: hidden; }
.prof-score-bar-fill { height: 100%; background: rgba(255,255,255,.8); border-radius: 3px; }

.prof-social-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.prof-social-link {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px;
  border-radius: 20px; background: rgba(255,255,255,.2); color: #fff;
  text-decoration: none; font-size: 0.82rem; font-weight: 600; transition: background .15s;
}
.prof-social-link:hover { background: rgba(255,255,255,.35); }

/* ── Profile Bio ─────────────────────────────────────────────────────────── */
.prof-bio {
  padding: 16px 20px; background: #f8f9fb; border-left: 3px solid var(--navy);
  margin: 0 -20px; border-bottom: 1px solid var(--border);
}
.prof-bio-text { font-size: 0.9rem; color: #333; line-height: 1.65; }
.prof-wiki-link { font-size: 0.82rem; color: var(--blue); text-decoration: none; font-weight: 600; white-space: nowrap; }
.prof-wiki-link:hover { text-decoration: underline; }

/* ── Profile Sections ────────────────────────────────────────────────────── */
.prof-section { padding: 22px 0; border-bottom: 1px solid var(--border); }
.prof-section:last-child { border-bottom: none; }
.section-title {
  font-size: 1rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .06em; color: var(--navy); margin-bottom: 14px;
  padding-bottom: 6px; border-bottom: 2px solid var(--border);
}

/* ── Bill Grid (matching NORPAC) ─────────────────────────────────────────── */
.bill-grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.bill-grid { width: 100%; border-collapse: collapse; font-size: 0.8rem; min-width: 400px; }
table.bill-grid th, table.bill-grid td {
  border: 1px solid var(--border); text-align: center; padding: 7px 5px; vertical-align: middle;
}
table.bill-grid .group-header {
  font-weight: 700; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: .08em; color: #fff; padding: 5px 4px;
}
.group-buffer       { background: #1565c0; }
.group-antisemitism { background: #e65100; }
.bill-num   { font-weight: 700; font-size: 0.72rem; }
.bill-title { font-size: 0.62rem; color: var(--muted); margin-top: 2px; }
td.favorable   { background: #e8f5e9; }
td.unfavorable { background: #fff; }
.check  { color: #2e7d32; font-size: 1.1rem; font-weight: 900; }
.dash   { color: #bbb; font-size: 1.1rem; }

/* ── Bill Detail ─────────────────────────────────────────────────────────── */
.bill-detail-item { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.bill-detail-item:last-child { border-bottom: none; }
.bill-detail-header { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.bill-num-inline { font-weight: 700; font-size: 0.85rem; color: var(--navy); }
.bill-title-inline { font-size: 0.85rem; flex: 1; min-width: 0; }
.role-tag {
  font-size: 0.72rem; padding: 2px 8px; border-radius: 10px;
  background: #e8f5e9; color: #2e7d32; font-weight: 600; white-space: nowrap;
}
.prime-tag { background: #1565c0; color: #fff; }
.legistar-link { font-size: 0.72rem; color: #1565c0; text-decoration: none; margin-left: 4px; }
.legistar-link:hover { text-decoration: underline; }
.no-data { color: var(--muted); font-style: italic; font-size: 0.9rem; }

/* ── Committees ──────────────────────────────────────────────────────────── */
.committees-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.committee-tag {
  font-size: 0.8rem; padding: 5px 12px; border-radius: 20px;
  background: #e8edf3; color: #333; border: 1px solid var(--border);
}
.committee-tag.chair { background: #e8f0ff; color: #1565c0; font-weight: 700; border-color: #b0c8ff; }

/* ── Score Breakdown ─────────────────────────────────────────────────────── */
.score-breakdown { display: flex; flex-direction: column; gap: 6px; }
.score-item { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; }
.score-delta { font-weight: 800; font-size: 0.85rem; font-family: monospace; width: 40px; text-align: right; flex-shrink: 0; }
.score-delta.pos { color: #2e7d32; }
.score-delta.neg { color: #c62828; }

/* ── Statements (matching NORPAC style) ─────────────────────────────────── */
.statements-stack { display: flex; flex-direction: column; gap: 16px; }
.statement-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-header {
  padding: 10px 16px; font-weight: 700; font-size: 0.82rem;
  text-transform: uppercase; letter-spacing: .06em; background: var(--navy); color: #fff;
}
.statement-item { padding: 12px 16px; border-top: 1px solid var(--border); }
.stmt-meta {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  font-size: 0.75rem; color: var(--muted); margin-bottom: 5px;
}
.stmt-sentiment {
  font-size: 0.68rem; font-weight: 700; padding: 2px 7px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: .05em;
}
.sent-pro    { background: #e8f5e9; color: #2e7d32; }
.sent-anti   { background: #ffebee; color: #c62828; }
.sent-neutral{ background: #f5f5f5; color: #555; }
.sent-bad    { background: #b71c1c; color: #fff; }
.stmt-text { font-size: 0.88rem; line-height: 1.55; font-style: italic; }
.stmt-link { font-size: 0.75rem; color: #1565c0; text-decoration: none; display: block; margin-top: 5px; }
.stmt-link:hover { text-decoration: underline; }
.no-statements { padding: 14px 16px; color: var(--muted); font-style: italic; font-size: 0.88rem; }

/* ── UJA Asks ────────────────────────────────────────────────────────────── */
.uja-asks { font-size: 0.95rem; color: #333; display: flex; flex-direction: column; gap: 12px; }
.uja-item { padding: 12px 16px; background: #f8f9fb; border-radius: 8px; border-left: 4px solid var(--navy); }
.uja-heading { font-weight: 800; color: var(--navy); margin-bottom: 4px; font-size: 0.95rem; }
.uja-text { line-height: 1.5; }

/* ── Print ───────────────────────────────────────────────────────────────── */
@media print {
  #site-header, #borough-tabs, .back-btn, .print-btn-top, .nav-arrow { display: none; }
  #grid-view { display: none; }
  #profile-view { display: block !important; }
  #profile-content { max-width: 100%; padding: 16px; min-height: unset; }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  html { font-size: 16px; }
  .brand-sub { display: none; }
  #member-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .prof-header { padding: 16px 14px; gap: 14px; }
  .prof-name { font-size: 1.25rem; }
  .nav-arrow { width: 38px; height: 72px; font-size: 2rem; }
}
