/* styles.css - Chicago Ward Demographics Portal */

/* ============================================================================
   CSS VARIABLES - Consistent color palette
   Breakpoints: sm=576px, md=768px, lg=1024px
   ============================================================================ */

:root {
  --primary-color: #2c3e50;
  --primary-light: #34495e;
  --accent-color: #3498db;
  --accent-hover: #2980b9;
  --accent-subtle: #f0f7ff;
  --success-color: #27ae60;
  --bg-light: #f8f9fa;
  --bg-card: #ffffff;
  --border-color: #e9ecef;
  --text-primary: #2c3e50;
  --text-secondary: #6c757d;
  --text-muted: #95a5a6;
  --text-muted-dark: #7f8c8d;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --max-width: 900px;
  /* Semantic comparison tokens */
  --color-higher: #2c7bb6;
  --color-lower:  #7f8fa6;
  --color-ward-map: #C00000;
}

/* Focus ring — accessible, branded */
:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 3px;
}

/* ============================================================================
   GLOBAL LAYOUT - Prevent horizontal scroll
   ============================================================================ */

html, body {
  max-width: 100vw;
  scroll-padding-top: 100px;
}

body {
  color: var(--text-primary);
  line-height: 1.6;
  font-family: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Sticky TOC sidebar */
#quarto-margin-sidebar #TOC {
  position: sticky !important;
  top: 5rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  padding-bottom: 2rem;
}

#TOC .nav-link {
  color: var(--text-secondary) !important;
  font-weight: 400 !important;
  border: none !important;
  background: none !important;
}

#TOC .nav-link.active {
  color: var(--accent-color) !important;
  font-weight: 600 !important;
}

#TOC .nav-link:hover {
  color: var(--accent-color) !important;
  text-decoration: underline !important;
}


/* Import Lato font (used by Flatly theme) */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap');

/* ============================================================================
   SITE HEADER / NAVBAR
   ============================================================================ */

.site-header {
  background: var(--primary-color);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  margin-left: -1rem;
  margin-right: -1rem;
  margin-top: -1rem;
}

.site-header-content {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.site-header .site-title {
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  margin: 0;
  padding: 0;
  border: none;
}

.site-header .site-title:hover {
  color: rgba(255,255,255,0.9);
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.site-nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.site-nav a:hover {
  color: white;
  background: rgba(255,255,255,0.1);
  text-decoration: none;
}

.site-nav a.active {
  color: white;
  background: rgba(255,255,255,0.15);
}

/* Let Quarto handle page layout for proper TOC sidebar positioning */
/* Note: Removed centering constraints that conflicted with grid layout */

main.content {
  max-width: var(--max-width);
  padding-left: 1rem;
  padding-right: 1rem;
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */

h1, h2, h3, h4 {
  color: var(--primary-color);
  font-weight: 600;
  word-wrap: break-word;
  overflow-wrap: break-word;
  scroll-margin-top: 120px;
}

h1, .title {
  font-size: 1.75rem !important;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

/* Major Category Sections (h1) — shelf treatment */
h1:not(.unlisted):not(.title) {
  border-left: 5px solid var(--primary-color);
  border-top: none;
  padding: 1rem 1.25rem;
  margin-top: 4rem !important;
  margin-bottom: 1.75rem !important;
  margin-left: -1.25rem;
  font-size: 1.8rem !important;
  letter-spacing: 0.25px;
  background: var(--bg-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

h2 {
  font-size: 1.4rem;
  margin-top: 2.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  color: var(--primary-light);
}

h3 {
  font-size: 1.1rem;
  margin-top: 1.25rem;
  color: var(--primary-light);
}

/* ============================================================================
   STAT CARDS - Key metrics display
   ============================================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 1rem 0 1.5rem 0;
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 576px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease, background 0.2s ease;
  min-width: 0; /* Prevent overflow */
}

.stat-card:hover {
  background: var(--accent-subtle);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
  min-height: 2.5em;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1.2;
  white-space: nowrap;
}

.stat-value.currency {
  color: var(--success-color);
}

/* ── Stat card comparison view (Option 3A — side-by-side) ─────────────────── */

.stat-comp-view .stat-compare-row {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.15rem;
  align-items: flex-start;
}

.stat-comp-view .stat-col {
  flex: 1;
  min-width: 0;
}

.stat-comp-view .stat-col-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-comp-view .stat-col.ward .stat-col-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1.2;
  white-space: nowrap;
}

.stat-comp-view .stat-col.ward .stat-col-value.currency {
  color: var(--success-color);
}

.stat-comp-view .stat-col.city .stat-col-value {
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.2;
  white-space: nowrap;
}

.stat-comp-view .stat-divider {
  width: 1px;
  background: var(--border-color);
  align-self: stretch;
  flex-shrink: 0;
  margin: 0.15rem 0;
}

/* Prevent numbers from wrapping in tables */
td, .gt_row {
  white-space: nowrap;
}

/* ============================================================================
   WARD GRID - Homepage ward selection
   ============================================================================ */

.ward-grid {
  margin: 1rem 0 2rem 0;
  width: 100%;
  box-sizing: border-box;
}

.ward-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

@media (min-width: 768px) {
  .ward-row {
    grid-template-columns: repeat(10, 1fr);
  }
}

.ward-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.ward-card:hover {
  background: var(--accent-color);
  border-color: var(--accent-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.ward-card:hover .ward-number,
.ward-card:hover .ward-pop {
  color: white;
}

.ward-number {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--primary-color);
}

.ward-pop {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ============================================================================
   WARD NAVIGATION - Prev/Next links on ward pages
   ============================================================================ */

.ward-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  background: var(--bg-light);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.ward-nav .nav-link {
  padding: 0.4rem 0.75rem;
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.ward-nav .nav-link:hover {
  background: var(--accent-color);
  color: white;
  text-decoration: none;
}

.ward-nav .nav-divider {
  color: var(--border-color);
  font-weight: 300;
}

/* ============================================================================
   TABLES
   ============================================================================ */

/* GT table styling */
.gt_table {
  margin: 1rem 0 !important;
  border-radius: var(--radius-md) !important;
  overflow: hidden;
  box-shadow: var(--shadow-sm) !important;
  width: 100% !important;
  max-width: 100% !important;
  font-size: 0.9rem !important;
}

.gt_table thead th {
  background: var(--primary-light) !important;
  color: white !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  font-size: 0.75rem !important;
  letter-spacing: 0.5px !important;
  padding: 0.6rem 0.75rem !important;
}

.gt_table tbody td {
  padding: 0.5rem 0.75rem !important;
}

.gt_table tbody tr:hover {
  background: var(--bg-light) !important;
}

/* Standard markdown tables */
table {
  width: 100%;
  max-width: 100%;
  margin: 1rem 0;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 0.9rem;
}

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
}

th {
  font-weight: 600;
  background: var(--primary-color);
  color: white;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

td {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--bg-light);
}

/* ============================================================================
   CALLOUTS - Remove default styling
   ============================================================================ */

.callout {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
}

.callout-note {
  border: none !important;
  background: transparent !important;
}

.callout-header {
  display: none !important;
}

.callout-body {
  padding: 0 !important;
}

/* ============================================================================
   ABOUT SECTION
   ============================================================================ */

.about-section {
  background: var(--bg-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 2rem;
}

.about-section h2 {
  border-bottom: none;
  margin-top: 0;
  font-size: 1.2rem;
}

.about-section h3 {
  margin-top: 1.25rem;
  font-size: 1rem;
}

.about-section p {
  font-size: 0.9rem;
}

.data-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.25rem;
  list-style: none;
  padding: 0;
  margin: 0.75rem 0;
  font-size: 0.85rem;
}

@media (min-width: 500px) {
  .data-list {
    grid-template-columns: repeat(4, 1fr);
  }
}

.data-list li {
  padding: 0.35rem 0;
  padding-left: 1rem;
  position: relative;
}

.data-list li::before {
  content: "•";
  color: var(--accent-color);
  font-weight: bold;
  position: absolute;
  left: 0;
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 576px) {
  h1, .title {
    font-size: 1.5rem !important;
  }

  h2 {
    font-size: 1.2rem;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  .ward-nav {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .ward-nav .nav-divider {
    display: none;
  }

  .about-section {
    padding: 1rem;
  }
}

/* ============================================================================
   PAGE FOOTER
   ============================================================================ */

footer, .page-footer {
  margin-top: 2rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ============================================================================
   WARD SELECTOR DROPDOWN
   ============================================================================ */

.ward-selector-container {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0;
}

.ward-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.ward-selector label {
  font-weight: 600;
  color: var(--primary-color);
  font-size: 0.95rem;
  margin: 0;
}

.ward-selector select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.95rem;
  font-family: "Lato", sans-serif;
  color: var(--text-primary);
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 180px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232c3e50' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

.ward-selector select:hover {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.ward-selector select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

@media (max-width: 576px) {
  .ward-selector {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 1rem;
  }

  .ward-selector label {
    text-align: center;
  }

  .ward-selector select {
    width: 100%;
    min-width: 0;
  }
}

/* ============================================================================
   WARD MAP STYLING (Leaflet)
   ============================================================================ */

.leaflet-container {
  height: 600px;
  width: 100%;
  max-width: var(--max-width);
  margin: 2rem auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* Map tooltip styling */
.leaflet-tooltip {
  font-family: "Lato", sans-serif;
  font-size: 14px;
  font-weight: 600;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

/* Map popup styling */
.leaflet-popup-content {
  font-family: "Lato", sans-serif;
}

.leaflet-popup-content a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 600;
}

.leaflet-popup-content a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Responsive: shorter on mobile */
@media (max-width: 768px) {
  .leaflet-container {
    height: 400px;
  }
}

/* ============================================================================
   PAGE LAYOUT ADJUSTMENTS
   ============================================================================ */

.page-columns .page-full {
  grid-column: page !important;
}

/* ============================================================================
   ALDERPERSON CARD
   ============================================================================ */

.alder-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 1rem 0 2rem 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  font-family: "Lato", sans-serif;
}

.alder-main-row {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  align-items: start;
}

.alder-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1rem;
  margin-top: 0;
}

.alder-image {
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--border-color);
}

.alder-card .alder-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 0 0 0.2rem 0;
  border: none;
}

.alder-title {
  font-size: 1.1rem;
  color: var(--text-muted-dark);
  font-weight: 600;
}

.alder-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1rem 0;
}

.alder-divider-dashed {
  border: none;
  border-top: 1px dashed var(--border-color);
  margin: 1.25rem 0;
}

.alder-buttons-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.alder-card .alder-link-btn {
  padding: 0.4rem 1rem;
  border: 1px solid var(--accent-color);
  color: var(--accent-color);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  background-color: var(--bg-card);
  transition: all 0.2s ease;
  cursor: pointer;
  display: inline-block;
  line-height: 1.2;
}

.alder-card .alder-link-btn:hover {
  background-color: var(--accent-color);
  color: white;
}

.alder-map-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 0;
}

.alder-map-container {
  width: 100%;
  height: 220px;
  background-color: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.alder-map-container > .html-widget {
  height: 100% !important;
}

.alder-map-container .leaflet-container {
  height: 100% !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.map-caption {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted-dark);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.alder-more-info-content {
  width: 100%;
}

.alder-card .alder-more-info-btn {
  padding: 0.4rem 1rem;
  border: 1px solid var(--accent-color);
  color: var(--accent-color);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  background-color: var(--accent-subtle);
  transition: all 0.2s ease;
  cursor: pointer;
  display: inline-block;
  line-height: 1.2;
}

.alder-card .alder-more-info-btn:hover {
  background-color: var(--accent-color);
  color: white;
}

.alder-revealed-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.contact-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.contact-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.contact-label i {
  color: var(--accent-color);
  font-size: 0.9rem;
}

.contact-value {
  font-size: 0.95rem;
  color: var(--text-primary);
}

.contact-value a {
  color: var(--accent-color);
  text-decoration: none;
}

.alder-committees {
  margin-top: 1rem;
  padding: 1.25rem;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-light);
}

.alder-committees > strong {
  font-size: 0.85rem;
  color: var(--text-muted-dark);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
  display: block;
}

.committee-list li strong {
  color: var(--primary-color);
  font-weight: bold;
  text-transform: none;
  font-size: inherit;
  display: inline;
}

.committee-list {
  margin: 0;
  padding-left: 1.25rem;
  columns: 2;
  font-size: 0.85rem;
  color: var(--text-secondary);
  list-style-type: disc;
}

@media (max-width: 1024px) {
  .alder-revealed-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .alder-main-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  .alder-revealed-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   INTERACTIVE TABLE SYSTEM (from table-display-exploration)
   ============================================================================ */

/* Global controls - sticky toggle bar */
.global-controls-sticky {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.95);
  padding: 0.75rem 0;
  border-bottom: 2px solid var(--border-color);
  z-index: 990;
  margin-bottom: 2rem;
  backdrop-filter: blur(5px);
}

.segmented-control {
  display: flex;
  background: #f0f2f5;
  padding: 4px;
  border-radius: 10px;
  gap: 2px;
}

.control-btn {
  border: none;
  background: none;
  padding: 8px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted-dark);
  transition: all 0.2s ease;
}

.control-btn:hover { color: var(--primary-color); }

.control-btn.active {
  background: white;
  color: var(--primary-color);
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Profile card - wraps each table section */
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Hide TOC title */
#toc-title { display: none !important; }

/* Master hidden class */
.val-hidden { display: none !important; }

/* Dual-value cell spans */
.mode-pct, .mode-count {
  font-variant-numeric: tabular-nums;
  text-align: right;
  display: inline-block;
  width: 100%;
}

/* Tab navigation */
.profile-card .nav-tabs {
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-left: 0;
  list-style: none;
  display: flex;
}

.profile-card .nav-item { list-style: none; }

.profile-card .nav-link {
  cursor: pointer;
  color: var(--text-secondary);
  border: none;
  text-decoration: none;
  padding: 0.5rem 1rem;
  display: inline-block;
  transition: color 0.15s ease;
}

.profile-card .nav-link.active {
  color: var(--primary-color);
  font-weight: bold;
  border-bottom: 2px solid var(--primary-color);
}

/* Comparison difference indicators — color + icon */
.diff-higher {
  color: var(--color-higher);
  font-weight: bold;
}

.diff-lower {
  color: var(--color-lower);
  font-weight: bold;
}

/* Rank display — neutral, no color */
.rank-display { }

/* Parenthetical denominator note inside a table row label */
.label-note {
  font-size: 0.82em;
  color: #888;
  font-weight: normal;
}

/* Table note (shown in table pane) */
.table-note {
  font-size: 0.72rem;
  color: #333;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

/* Descriptive note mirrored below chart (bottom-right corner) */
.chart-table-note {
  font-size: 0.72rem;
  color: #888;
  font-style: italic;
  text-align: right;
  line-height: 1.4;
  padding: 5px 6px 0;
  margin-bottom: 0;
}

.gt_sourcenote {
  font-size: 0.72rem !important;
}

/* Chart.js canvas container — height set dynamically by JS based on row count */
.chart-canvas-wrapper {
  position: relative;
  width: 100%;
  min-height: 160px;
}

/* Chart annotation: stat card displayed above chart for summary stats on a different scale */
.chart-meta-note {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 7px 12px;
  margin-bottom: 12px;
  background: #f0f7ff;
  border-radius: 6px;
  border: 1px solid #d0e8f8;
}
.chart-meta-note .cmn-label {
  font-size: 11px;
  color: #7a9ab5;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chart-meta-note .cmn-value {
  font-size: 18px;
  font-weight: 700;
  color: #3f8bc9;
  line-height: 1.3;
}


/* Chart download button */
.viz-download-container {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
}

.btn-download {
  font-size: 0.8rem;
  color: var(--success-color);
  font-weight: bold;
  text-decoration: none;
}

.btn-download:hover { text-decoration: underline; }

/* Table alignment within profile cards */
.profile-card td { text-align: right !important; }
.profile-card td:first-child { text-align: left !important; }
.profile-card .gt_table { margin: 0 !important; }

/* Section headings inside profile cards */
.profile-card h3 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  border-bottom: none;
}

/* ============================================================================
   MOBILE TOC - Hide sidebar on mobile / tablet
   ============================================================================ */

@media (max-width: 1024px) {
  #quarto-margin-sidebar {
    display: none !important;
  }
}

/* ============================================================================
   GT TABLE NOTES - Source/universe notes extracted outside the overflow-x:auto
   table container so they wrap at viewport width on mobile.
   JS in ward-template.qmd moves .gt_sourcenote content into .gt-notes-mobile
   and hides the original <tfoot> rows.
   ============================================================================ */

.gt-notes-mobile {
  font-size: 0.72rem;
  color: #333;
  padding: 4px 5px 2px;
}

.gt-notes-mobile p {
  margin: 2px 0;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ============================================================================
   GT TABLE MOBILE - Wrap category labels (first column) on narrow screens
   so the table is narrower and requires less horizontal scrolling.
   The header and row label cells get a max-width and text wrapping.
   ============================================================================ */

@media (max-width: 576px) {
  .viz-download-container {
    display: none;
  }
}

@media (max-width: 576px) {
  .gt_table td.gt_row.gt_left:first-child,
  .gt_table th.gt_col_heading.gt_columns_bottom_border.gt_left:first-child {
    white-space: normal !important;
    max-width: 150px;
    min-width: 100px;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
}
