/* Archive viz panel (#96) — coverage heatmap + category bars */

.archive-viz-panel {
  margin: 1.5rem 0 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.archive-viz-three-up {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .archive-viz-three-up {
    grid-template-columns: repeat(3, 1fr);
    align-items: start;
  }
}

@media (max-width: 899px) {
  .archive-viz-three-up {
    grid-template-areas:
      'heatmap'
      'map'
      'categories';
  }

  .archive-viz-heatmap-host {
    grid-area: heatmap;
  }

  .archive-viz-three-up .viz-dept-map-host {
    grid-area: map;
  }

  .archive-viz-categories-host {
    grid-area: categories;
  }
}

.archive-viz-year-hist-host {
  width: 100%;
}

.viz-year-hist {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.viz-year-hist-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: baseline;
  justify-content: space-between;
}

.viz-year-hist-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.viz-year-hist-caption {
  font-size: 0.85rem;
  color: #555;
  margin: 0;
}

.viz-year-hist-track {
  position: relative;
  height: 3.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #faf8f5;
  touch-action: none;
  cursor: crosshair;
}

.viz-year-hist-brush {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(0, 42, 159, 0.12);
  border: 1px solid var(--haiti-blue, #002a9f);
  border-radius: 2px;
  pointer-events: none;
}

.viz-year-bar {
  position: absolute;
  bottom: 0;
  width: 6px;
  max-width: 8px;
  margin-left: -3px;
  border: none;
  border-radius: 2px 2px 0 0;
  background: #c41e3a;
  opacity: 0.75;
  cursor: pointer;
  padding: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.viz-year-bar:hover,
.viz-year-bar:focus-visible {
  opacity: 1;
  outline: 2px solid var(--haiti-blue, #002a9f);
  outline-offset: 1px;
}

.viz-year-bar.is-selected {
  background: var(--haiti-blue, #002a9f);
  opacity: 1;
}

.viz-year-hist-axis {
  position: relative;
  height: 1.75rem;
  margin-top: 0.15rem;
  font-size: 0.7rem;
  color: #555;
}

.viz-year-hist-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 0;
}

.viz-year-hist-tick.is-edge:first-child {
  transform: translateX(0);
  align-items: flex-start;
}

.viz-year-hist-tick.is-edge:last-child {
  transform: translateX(-100%);
  align-items: flex-end;
}

.viz-year-hist-tick-mark {
  display: block;
  width: 1px;
  height: 0.45rem;
  background: #999;
}

.viz-year-hist-tick-label {
  line-height: 1;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .viz-year-hist-tick-label {
    font-size: 0.62rem;
  }
}

.viz-year-hist-hint {
  font-size: 0.8rem;
  color: #666;
  margin: 0;
  text-align: center;
}

.viz-year-hist-empty {
  font-size: 0.9rem;
  color: #555;
  margin: 0;
  text-align: center;
}

.viz-cat-row {
  cursor: pointer;
}

.viz-cat-row.is-active .viz-cat-label {
  font-weight: 700;
}

.viz-dept-path.is-selected {
  stroke-width: 2;
  stroke: var(--haiti-blue, #002a9f);
}

.viz-section-heading {
  font-size: 1.25rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 1rem;
  text-align: center;
}

.viz-charts-grid {
  display: grid;
  gap: 2rem;
}

@media (min-width: 900px) {
  .viz-charts-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

/* Department choropleth (#131) */
.viz-dept-map {
  max-width: 520px;
  margin: 0 auto;
}

.viz-dept-disclaimer {
  font-size: 0.85rem;
  color: #555;
  background: #f5f5f5;
  border-left: 3px solid #ccc;
  padding: 0.45rem 0.65rem;
  margin: 0 0 0.5rem;
  line-height: 1.45;
}

.viz-dept-map-wrap {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
}

.viz-dept-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  transform: translate(-50%, calc(-100% - 10px));
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  color: #fff;
  background: var(--haiti-blue, #002a9f);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  max-width: min(280px, 90vw);
  text-align: center;
}

.viz-dept-tooltip[hidden] {
  display: none;
}

.viz-dept-hint {
  font-size: 0.82rem;
  color: #666;
  margin: 0.35rem 0 0;
  text-align: center;
}

.viz-dept-path.is-hovered {
  stroke-width: 1.4;
  stroke: var(--haiti-blue, #002a9f);
  filter: brightness(0.95);
}

.viz-dept-scope {
  font-size: 0.85rem;
  color: #444;
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.viz-dept-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
}

.viz-dept-legend-none::before {
  background: #f4f0e8;
}

.viz-dept-legend-low::before {
  background: #f4c4ce;
}

.viz-dept-legend-mid::before {
  background: #e85d75;
}

.viz-dept-legend-high::before {
  background: #d21034;
}

.viz-dept-svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.viz-dept-path {
  transition: fill 0.15s ease;
}

.viz-dept-path:hover,
.viz-dept-path:focus {
  stroke-width: 1.2;
  stroke: var(--haiti-blue, #002a9f);
}

.viz-dept-stats {
  font-size: 0.82rem;
  color: #555;
  margin: 0.5rem 0 0;
  line-height: 1.4;
}

.viz-chart {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  background: #fafafa;
}

.viz-chart-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.viz-chart-caption {
  font-size: 0.9rem;
  color: #444;
  margin: 0 0 0.75rem;
  line-height: 1.4;
}

.viz-source {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.75rem;
}

.viz-loading,
.viz-error {
  text-align: center;
  color: #555;
  padding: 1rem;
}

.viz-error {
  color: #d21034;
}

/* Heatmap */
.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
}

.viz-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.viz-legend-item::before {
  content: '';
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.viz-heat-has-highlight::before,
.viz-heat-cell.viz-heat-has-highlight {
  background: var(--haiti-red, #d21034);
}

.viz-heat-has-events::before,
.viz-heat-cell.viz-heat-has-events {
  background: #f4c4ce;
}

.viz-heat-events-low::before,
.viz-heat-cell.viz-heat-events-low {
  background: #f4c4ce;
}

.viz-heat-events-mid::before,
.viz-heat-cell.viz-heat-events-mid {
  background: #e86882;
}

.viz-heat-events-high::before,
.viz-heat-cell.viz-heat-events-high {
  background: var(--haiti-red, #d21034);
}

.viz-heat-empty::before,
.viz-heat-cell.viz-heat-empty {
  background: #e8e8e8;
}

.viz-heat-grid {
  display: grid;
  gap: 0.75rem;
}

.viz-heat-month-label {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0 0 0.25rem;
  border: none;
  background: none;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #333;
  text-align: left;
  cursor: pointer;
}

.viz-heat-month-trigger:hover,
.viz-heat-month-trigger:focus-visible {
  color: var(--haiti-blue, #002a9f);
  text-decoration: underline;
}

.viz-heat-month.is-active .viz-heat-month-trigger {
  color: var(--haiti-red, #ce1126);
}

.viz-heat-month.is-active .viz-heat-row {
  outline: 1px solid rgba(206, 17, 38, 0.35);
  outline-offset: 2px;
  border-radius: 2px;
}

.viz-heat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.viz-heat-cell {
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 2px;
  cursor: pointer;
  font: inherit;
}

.viz-heat-cell:focus-visible {
  outline: 2px solid var(--haiti-blue, #002a9f);
  outline-offset: 1px;
}

.viz-sr-day {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Category bars */
.viz-cat-svg {
  max-width: 100%;
  height: auto;
}

.viz-cat-label {
  font-size: 11px;
  fill: #333;
}

.viz-cat-count {
  font-size: 11px;
  fill: #555;
}

/* Accessible data tables */
.viz-table-details {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.viz-table-details summary {
  cursor: pointer;
  color: var(--haiti-blue, #002a9f);
  font-weight: 600;
  padding: 0.25rem 0;
  background: transparent;
  list-style: disclosure-closed;
}

.viz-data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

.viz-data-table caption {
  text-align: left;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.viz-data-table th,
.viz-data-table td {
  border: 1px solid #ddd;
  padding: 0.25rem 0.4rem;
  text-align: left;
}

.viz-data-table th {
  background: #f0f0f0;
}

@media (prefers-reduced-motion: reduce) {
  .viz-heat-cell {
    transition: none;
  }

  .viz-dept-path {
    transition: none;
  }
}

/* External macro context (#196) — stories (macro-context), not archive browse */
.viz-external-context {
  border: 1px solid #e4e4e4;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  background: #fafafa;
}

.viz-external-context .viz-chart-title {
  font-size: 1rem;
  margin: 0 0 0.35rem;
}

.viz-external-context .viz-chart-caption {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: #444;
}

.viz-external-focus {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.viz-external-sparkline {
  display: block;
  max-width: 100%;
  height: auto;
}

.viz-external-line {
  stroke: var(--haiti-blue, #002a9f);
  stroke-width: 2;
}

.viz-external-marker {
  fill: var(--haiti-red, #d21034);
}

.viz-external-marker-line {
  stroke: var(--haiti-red, #d21034);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.7;
}
