/* Reading progress bar */
.article-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  z-index: 1000;
  background: transparent;
}
.article-progress__bar {
  height: 100%;
  width: 0%;
  background: var(--color-primary);
  transition: width 0.1s linear;
}

/* Article layout */
.article { max-width: 100%; }
.article__header {
  max-width: 720px;
  margin: 0 auto var(--space-xl);
  text-align: center;
}
.article__title {
  font-size: 2.4rem;
  line-height: 1.15;
  margin-bottom: var(--space-md);
}
.article__subtitle {
  font-size: 1.25rem;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-lg);
  line-height: 1.4;
}
.article__meta {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: var(--space-md);
}
.article__authors { font-weight: 600; }

/* Social share */
.article__share {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}
.article__share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.article__share-btn:hover {
  background: var(--color-primary);
  color: var(--color-bg);
  border-color: var(--color-primary);
}

/* Two-column layout: content + TOC */
.article__layout {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 860px;
  margin: 0 auto;
  gap: var(--space-xl);
}
@media (min-width: 1024px) {
  .article__layout {
    grid-template-columns: 1fr 220px;
    max-width: 1100px;
  }
}

/* Table of contents */
.article__toc {
  position: sticky;
  top: calc(var(--space-xl) + 4px); /* below progress bar */
  align-self: start;
  opacity: 0;
  transform: translateX(20px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  order: 2;
  z-index: 50;
}
.article__toc--visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.article__toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.article__toc-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
}
.article__toc-toggle svg {
  transition: transform 0.2s ease;
}
.article__toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid var(--color-border);
  max-height: 60vh;
  overflow-y: auto;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}
.article__toc-list--collapsed {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}
.article__toc-item a {
  display: block;
  padding: var(--space-xs) var(--space-md);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.article__toc-item a:hover { color: var(--color-text); }
.article__toc-item--sub a { padding-left: calc(var(--space-md) + var(--space-sm)); font-size: 0.8rem; }
a.article__toc-active {
  color: var(--color-primary);
  border-left-color: var(--color-primary);
  font-weight: 600;
}

/* Article content */
.article__content {
  order: 1;
  min-width: 0;
}

/* Metrics table styles */
.metrics-table__scroll { overflow-x: auto; }
.metrics-table__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.metrics-table__table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--color-border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  font-weight: 600;
  color: var(--color-text-muted);
  position: relative;
}
.metrics-table__table th:hover { color: var(--color-text); }
.metrics-table__table th[aria-sort="ascending"] .sort-indicator::after { content: " \25B2"; font-size: 0.7em; }
.metrics-table__table th[aria-sort="descending"] .sort-indicator::after { content: " \25BC"; font-size: 0.7em; }
.metrics-table__table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
}
.metrics-table__table tbody tr:hover { background: rgba(0,0,0,0.02); }
.metrics-table__bar-cell {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 120px;
}
.metrics-table__bar {
  height: 8px;
  background: var(--color-primary);
  border-radius: 4px;
  opacity: 0.5;
  flex-shrink: 0;
}
.metrics-table__bar-label { white-space: nowrap; }

/* City map styles */
.city-map__container {
  position: relative;
  cursor: grab;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
  background: #f0ebe0;
}
.city-map__svg { display: block; width: 100%; height: auto; }
.city-map__state {
  fill: #e8dfc4;
  stroke: #bbb5a0;
  stroke-width: 0.8;
  stroke-linejoin: round;
}
.city-map__metro { cursor: pointer; transition: filter 0.15s, stroke-width 0.1s; }
.city-map__metro:hover { filter: drop-shadow(0 0 4px rgba(0,0,0,0.5)); }

/* Map tooltip */
.city-map__tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(30, 30, 30, 0.92);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.45;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 10;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.city-map__tooltip--visible { opacity: 1; }
.city-map__tooltip strong { font-weight: 700; }

/* Color scale legend (outside SVG) */
.city-map__legend {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.city-map__legend-label {
  font-weight: 600;
  white-space: nowrap;
}
.city-map__legend-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 260px;
}
.city-map__legend-gradient {
  flex: 1;
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(to right, #d4eac7, #f4a261, #c1292e);
}
.city-map__legend-min,
.city-map__legend-max {
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Hide TOC on mobile — show as collapsible overlay instead */
@media (max-width: 1023px) {
  .article__toc {
    position: fixed;
    right: var(--space-md);
    bottom: var(--space-md);
    top: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    padding: var(--space-md);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    max-width: 260px;
    z-index: 100;
  }
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
