/* ========================================
   AEI State Housing Supply Legislative Tracker
   Editorial Styling v2.0
   ======================================== */

/* Reset and Base Styles */
* {
  box-sizing: border-box;
}

/* Hide Quarto-generated title (we have our own header) */
header.title-block-header,
h1.title {
  display: none !important;
}

html {
  color: #1a1a1a;
  background-color: #f0f4f8;
}

body {
  margin: 0;
  padding: 0;
  padding-right: 420px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  max-width: 1920px;
  margin-left: auto;
  margin-right: auto;
}

/* Links */
a {
  color: #0070C0;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:visited {
  color: #0070C0;
}

/* Lists */
ul, ol {
  padding-left: 1.7em;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

li {
  margin-bottom: 0.5em;
}

/* Paragraphs */
p {
  margin: 1em 0;
}

/* ========================================
   Hero Header - Clean Editorial Style
   ======================================== */
.hero-compact {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: linear-gradient(135deg, #0070C0 0%, #004080 100%);
  color: white;
  position: relative;
  gap: 24px;
}

.hero-compact::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #FFD700, #FFA500, #FFD700);
}

.hero-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}

.hero-logo {
  height: 36px;
  width: auto;
  background: white;
  padding: 5px 8px;
  border-radius: 4px;
}

.hero-title {
  font-size: 22px;
  font-weight: 700;
  color: white;
  line-height: 1.2;
  max-width: 220px;
  letter-spacing: -0.3px;
}

.hero-center {
  flex: 1;
  text-align: center;
  padding: 0 16px;
}

.hero-right {
  text-align: right;
  font-size: 12px;
  flex: 0 0 auto;
  line-height: 1.5;
}

.hero-number {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: -2px;
  color: white;
  line-height: 1;
}

.hero-label {
  font-size: 13px;
  color: rgba(255,255,255,0.95);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 500;
}

.hero-tagline {
  margin-top: 6px;
  font-size: 16px;
  font-style: italic;
  color: #FFD700;
  font-weight: 600;
}

.hero-stat {
  margin-bottom: 3px;
  color: rgba(255,255,255,0.95);
}

.stat-num {
  font-weight: 700;
  font-size: 16px;
  color: white;
}

.highlight-gold {
  color: #FFD700;
  font-weight: 600;
}

.hero-date {
  margin-top: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
}

/* ========================================
   Alignment Key Bar
   ======================================== */
.alignment-key {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  font-size: 12px;
  flex-wrap: wrap;
}

.alignment-key-title {
  font-weight: 600;
  color: #666;
}

.alignment-key .alignment-badge {
  margin-right: 4px;
}

/* ========================================
   Filter Bar
   ======================================== */
.filter-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  padding: 12px 20px;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.filter-label {
  font-size: 13px;
  font-weight: 600;
  color: #666;
}

.filter-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.filter-btn {
  padding: 10px 18px;
  border: 2px solid #e0e0e0;
  border-radius: 25px;
  background: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  border-color: #0070C0;
  color: #0070C0;
  transform: translateY(-1px);
}

.filter-btn.active {
  background: linear-gradient(135deg, #0070C0, #004080);
  color: white;
  border-color: #0070C0;
  box-shadow: 0 2px 8px rgba(0,112,192,0.3);
}

/* ========================================
   Main Content Area
   ======================================== */
main, .content {
  background: #f8f9fa;
}

/* ========================================
   Tables
   ======================================== */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  font-size: 9pt;
}

thead tr,
thead tr.header,
table thead tr {
  background-color: #1F4E79 !important;
}

thead th,
thead tr.header th {
  background-color: #1F4E79 !important;
  color: white !important;
  font-weight: bold;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  border: 1px solid #1F4E79;
}

thead th a,
thead tr.header th a {
  color: white !important;
}

tbody td,
td {
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
  border: 1px solid #ccc;
}

tbody tr.odd {
  background-color: #ffffff;
}

tbody tr.even {
  background-color: #f5f5f5;
}

/* ========================================
   Alignment Rating Colors
   ======================================== */
.complete { color: #00B050; }
.substantial { color: #0070C0; }
.moderate { color: #C65911; }
.weak { color: #C00000; }
.partial { color: #ED7D31; }

/* ========================================
   Detail Panel (Right Sidebar)
   ======================================== */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  overflow-y: auto;
  z-index: 1000;
  border-left: 3px solid #0070C0;
}

.detail-panel-content {
  display: none;
  padding: 20px;
}

.detail-panel-content.active {
  display: block;
}

.detail-panel h3 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #0070C0;
}

/* ========================================
   State Grid (All States in Sidebar)
   ======================================== */
.state-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.state-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.state-card:hover {
  background: #e9ecef;
  transform: translateX(4px);
  border-color: #0070C0;
}

.state-card.kudos {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 2px solid #FFD700;
}

.state-card.kudos:hover {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.state-rank {
  width: 28px;
  height: 28px;
  background: #0070C0;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 12px;
  flex-shrink: 0;
}

.state-card.kudos .state-rank {
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: #1a1a1a;
}

.state-info {
  flex: 1;
  min-width: 0;
}

.state-name {
  font-weight: 600;
  font-size: 15px;
  color: #1a1a1a;
}

.playbook-link {
  font-size: 11px;
  color: #0070C0;
  display: block;
  margin-top: 2px;
}

.playbook-link:hover {
  text-decoration: underline;
}

.state-stats {
  text-align: right;
  flex-shrink: 0;
}

.state-homes {
  font-size: 18px;
  font-weight: bold;
  color: #0070C0;
}

.state-label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
}

.state-increase {
  font-size: 14px;
  font-weight: 700;
  color: #00B050;
  margin-top: 2px;
}

.kudos-badge {
  font-size: 9px;
  background: #FFD700;
  color: #1a1a1a;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 2px;
  display: inline-block;
}

.leaderboard-subtitle {
  font-size: 13px;
  color: #666;
  margin: -10px 0 15px 0;
  font-style: italic;
}

/* Legacy kudos styles (for compatibility) */
.kudos-grid { display: flex; flex-direction: column; gap: 12px; }
.kudos-card { display: flex; align-items: center; gap: 12px; padding: 12px; background: #f8f9fa; border-radius: 8px; cursor: pointer; transition: background 0.2s; }
.kudos-card:hover { background: #e9ecef; }
.kudos-rank { width: 28px; height: 28px; background: #FFD700; color: #1a1a1a; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 14px; }
.kudos-state { flex: 1; font-weight: 600; font-size: 15px; }
.kudos-homes { font-size: 18px; font-weight: bold; color: #0070C0; }
.kudos-label { font-size: 11px; color: #666; }

/* ========================================
   State Panel Header
   ======================================== */
.panel-header {
  position: relative;
  padding-bottom: 15px;
  border-bottom: 2px solid #0070C0;
  margin-bottom: 15px;
}

.panel-header h3 {
  font-size: 22px;
  text-transform: none;
  letter-spacing: 0;
  color: #1a1a1a;
  margin-bottom: 5px;
  border-bottom: none;
  padding-bottom: 0;
}

.close-btn {
  position: absolute;
  top: -5px;
  right: 0;
  background: #f0f0f0;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #666;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.close-btn:hover {
  background: #0070C0;
  color: white;
}

.panel-stats {
  display: flex;
  gap: 15px;
  margin-top: 8px;
  align-items: baseline;
}

.stat-homes {
  font-size: 24px;
  font-weight: bold;
  color: #0070C0;
}

.stat-bills {
  color: #666;
  font-size: 14px;
}

.stat-increase {
  font-size: 16px;
  font-weight: 700;
  color: #00B050;
}

.playbook-link-header {
  display: block;
  margin-top: 12px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #0070C0, #004080);
  color: white !important;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(0,112,192,0.3);
  transition: all 0.2s ease;
}

.playbook-link-header:hover {
  background: linear-gradient(135deg, #005a9e, #003060);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,112,192,0.4);
}

/* ========================================
   Panel Filter Bar (inside state panels)
   ======================================== */
.panel-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 15px;
}

.panel-filter-bar .filter-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.panel-filter-bar .filter-btn {
  padding: 6px 12px;
  font-size: 11px;
  border-width: 1px;
}

.alignment-key-mini {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid #e0e0e0;
  align-items: center;
}

.alignment-key-mini .alignment-label {
  font-size: 10px;
  font-weight: 600;
  color: #666;
  margin-right: 4px;
}

.alignment-key-mini .alignment-badge {
  font-size: 9px;
  padding: 3px 8px;
}

/* Panel disclaimer */
.panel-disclaimer {
  margin-top: 20px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 6px;
  font-size: 11px;
  color: #666;
  line-height: 1.5;
  border-left: 3px solid #0070C0;
}

.panel-disclaimer a {
  color: #0070C0;
  font-weight: 500;
}

/* ========================================
   Bill Cards
   ======================================== */
.bills-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bill-card {
  padding: 15px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  background: white;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.bill-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-color: #0070C0;
}

.bill-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.bill-number {
  font-weight: 700;
  color: #0070C0;
  font-size: 15px;
}

.alignment-badge {
  padding: 4px 10px;
  border-radius: 15px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.alignment-badge.complete { background: #dcfce7; color: #166534; }
.alignment-badge.substantial { background: #dbeafe; color: #1e40af; }
.alignment-badge.moderate { background: #fef3c7; color: #92400e; }
.alignment-badge.weak { background: #fce7f3; color: #9d174d; }
.alignment-badge.no-alignment { background: #fee2e2; color: #991b1b; }
.alignment-badge.narrow { background: #e5e7eb; color: #374151; }
.alignment-badge.partial { background: #ffedd5; color: #9a3412; }
.alignment-badge.kiss { background: #f3e8ff; color: #7c3aed; }

.bill-homes {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 8px;
}

.bill-homes-note {
  font-size: 12px;
  color: #888;
  font-style: italic;
  margin-bottom: 8px;
}

.bill-alignment {
  font-size: 12px;
  color: #0070C0;
  margin-bottom: 10px;
  font-weight: 500;
}

.bill-summary {
  font-size: 14px;
  line-height: 1.6;
  color: #444;
}

.methodology-details {
  margin-top: 12px;
  font-size: 12px;
  border-top: 1px solid #eee;
  padding-top: 10px;
}

.methodology-details summary {
  cursor: pointer;
  color: #0070C0;
  font-weight: 600;
}

.methodology-details p {
  margin-top: 10px;
  color: #666;
  line-height: 1.6;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 3px solid #0070C0;
}

/* ========================================
   Bills Table Section
   ======================================== */
.bills-table-section {
  padding: 28px 20px 12px;
  background: white;
  margin-top: 20px;
}

.bills-table-section h3 {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 6px 0;
}

.bills-table-section .table-subtitle {
  color: #888;
  font-size: 12px;
  margin: 0;
}

/* Reactable styling overrides */
.reactable {
  font-size: 12px !important;
  margin: 0 20px 20px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.rt-thead {
  background: #0070C0 !important;
}

.rt-th {
  color: white !important;
  font-weight: 600 !important;
  padding: 10px 10px !important;
  font-size: 11px !important;
}

.rt-td {
  padding: 8px 10px !important;
  vertical-align: middle !important;
  border-bottom: 1px solid #f0f0f0 !important;
}

.rt-tr:hover .rt-td {
  background: #e8f4fd !important;
}

/* Clean filter inputs */
.rt-tr-filters .rt-td {
  padding: 6px 8px !important;
  background: #f8fafc !important;
  border-bottom: 1px solid #e0e0e0 !important;
}

.rt-filter {
  width: 100% !important;
  padding: 5px 8px !important;
  border: 1px solid #ddd !important;
  border-radius: 4px !important;
  font-size: 11px !important;
  background: white !important;
  color: #333 !important;
}

.rt-filter:focus {
  outline: none !important;
  border-color: #0070C0 !important;
  box-shadow: 0 0 0 2px rgba(0,112,192,0.15) !important;
}

.rt-filter::placeholder {
  color: #aaa !important;
  font-size: 10px !important;
}

/* Search input */
.rt-search {
  margin-bottom: 12px;
}

.rt-search-input {
  padding: 10px 14px !important;
  border: 1px solid #ddd !important;
  border-radius: 6px !important;
  font-size: 13px !important;
  width: 100% !important;
  max-width: 300px !important;
  background: white !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
}

.rt-search-input:focus {
  outline: none !important;
  border-color: #0070C0 !important;
  box-shadow: 0 0 0 3px rgba(0,112,192,0.12) !important;
}

/* Pagination */
.rt-pagination {
  padding: 12px 10px !important;
  border-top: 1px solid #e0e0e0 !important;
  background: #fafafa !important;
}

.rt-page-button {
  padding: 6px 10px !important;
  border-radius: 4px !important;
  font-size: 12px !important;
}

.rt-page-button-current {
  background: #0070C0 !important;
  color: white !important;
}

/* Table alignment badges (smaller for table) */
.reactable .alignment-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* ========================================
   Playbook Explainer
   ======================================== */
.explainer {
  padding: 25px 20px;
  background: white;
  border-top: 3px solid #0070C0;
  margin-top: 20px;
}

.explainer summary {
  cursor: pointer;
  font-weight: 700;
  color: #0070C0;
  font-size: 16px;
}

.explainer-content {
  margin-top: 20px;
  font-size: 14px;
  line-height: 1.7;
}

.explainer-content h4 {
  color: #0070C0;
  margin-top: 20px;
  margin-bottom: 10px;
}

.explainer-content ul {
  background: #f8f9fa;
  padding: 15px 15px 15px 35px;
  border-radius: 8px;
}

.explainer-content li {
  margin-bottom: 10px;
}

.explainer-content .disclaimer {
  margin-top: 20px;
  padding: 12px 12px 12px 16px;
  background: #fff3cd;
  border-radius: 6px;
  font-size: 13px;
  color: #856404;
  border-left: 3px solid #ffc107;
  list-style: none;
  display: block;
}

.explainer-content .disclaimer::before {
  content: none;
}

/* ========================================
   Footer
   ======================================== */
.footer {
  padding: 40px 20px;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  color: #aaa;
  font-size: 13px;
  text-align: center;
}

.footer p {
  margin: 8px 0;
}

.footer a {
  color: #4da6ff;
}

.footer a:hover {
  color: #FFD700;
}

.footer .acknowledgments {
  font-size: 11px;
  color: #888;
  margin-top: 16px;
  font-style: italic;
}

/* ========================================
   Mobile Responsive
   ======================================== */
@media (max-width: 1200px) {
  body {
    padding-right: 385px;
  }

  .detail-panel {
    width: 385px;
  }
}

@media (max-width: 900px) {
  body {
    padding-right: 0;
    max-width: 100%;
  }

  .hero-compact {
    flex-direction: column;
    text-align: center;
    padding: 20px;
  }

  .hero-left, .hero-right {
    text-align: center;
  }

  .hero-number {
    font-size: 48px;
    letter-spacing: -2px;
  }

  .hero-label {
    font-size: 14px;
  }

  .hero-tagline {
    font-size: 16px;
  }

  .alignment-key {
    justify-content: center;
  }

  .detail-panel {
    position: relative;
    width: 100%;
    height: auto;
    box-shadow: none;
    border-left: none;
    border-top: 3px solid #0070C0;
  }

  .filter-bar {
    flex-direction: column;
    gap: 8px;
    align-items: center;
  }
}

@media (max-width: 600px) {
  .hero-compact {
    padding: 15px;
  }

  .hero-number {
    font-size: 36px;
  }

  .hero-label {
    font-size: 12px;
    letter-spacing: 1px;
  }

  .hero-tagline {
    font-size: 14px;
  }

  .alignment-key {
    font-size: 10px;
    padding: 8px 10px;
  }

  .filter-btn {
    padding: 6px 10px;
    font-size: 10px;
  }

  .state-card {
    padding: 10px;
  }

  .state-homes {
    font-size: 14px;
  }
}

/* ========================================
   Changelog Page
   ======================================== */
.changelog-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
  background: white;
  min-height: 100vh;
}

.changelog-page .back-link {
  display: inline-block;
  margin-bottom: 30px;
  color: #0070C0;
  font-weight: 500;
  font-size: 14px;
}

.changelog-page h1 {
  font-size: 28px;
  color: #1a1a1a;
  margin-bottom: 10px;
  border-bottom: 3px solid #0070C0;
  padding-bottom: 10px;
}

.changelog-page h2 {
  font-size: 18px;
  color: #0070C0;
  margin-top: 30px;
  margin-bottom: 15px;
}

.changelog-page p {
  color: #444;
  line-height: 1.6;
}

.changelog-page strong {
  color: #1a1a1a;
}

.changelog-page ul {
  margin: 10px 0;
  padding-left: 25px;
}

.changelog-page li {
  margin-bottom: 6px;
  color: #444;
  line-height: 1.5;
}

.changelog-page code {
  background: #f4f4f4;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
}

.changelog-page hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 25px 0;
}
