/* ============================================================
   U.S. Factory Rankings - Consolidated Styles
   ============================================================

   This file contains ALL styles for the Quarto site.
   Organized into sections:

   1. CSS Variables (brand colors, grade colors)
   2. Grade Badges
   3. Main Rankings Table (reactable)
   4. Quadrant Chart
   5. Factory Detail Panel
   6. Lightbox
   7. Utility Classes
   8. Responsive Breakpoints

   ============================================================ */

/* ============================================================
   1. CSS VARIABLES
   ============================================================ */

:root {
  /* Brand colors */
  --brand-blue: #008ccc;
  --brand-dark: #1a1a2e;

  /* Grade colors - SINGLE SOURCE OF TRUTH */
  --grade-a: #28a745;
  --grade-b: #17a2b8;
  --grade-c: #ffc107;
  --grade-d: #fd7e14;
  --grade-f: #dc3545;

  /* Grade background colors (lighter versions) */
  --grade-a-bg: #d4edda;
  --grade-b-bg: #cce5ff;
  --grade-c-bg: #fff3cd;
  --grade-d-bg: #f8d7da;
  --grade-f-bg: #f5c6cb;

  /* Neutral colors */
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-500: #6c757d;
  --gray-700: #495057;
  --gray-900: #1a1a2e;
}

/* ============================================================
   2. GRADE BADGES
   ============================================================ */

.grade-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: bold;
  color: white;
  min-width: 2rem;
  text-align: center;
  font-size: 0.8rem;
}

.grade-badge.grade-sm {
  font-size: 0.75rem;
  padding: 0.2rem 0.4rem;
  min-width: 1.5rem;
}

.grade-badge.grade-lg {
  font-size: 1rem;
  padding: 0.4rem 0.8rem;
}

.grade-A {
  background-color: var(--grade-a);
}
.grade-B {
  background-color: var(--grade-b);
}
.grade-C {
  background-color: var(--grade-c);
  color: #333;
}
.grade-D {
  background-color: var(--grade-d);
}
.grade-F {
  background-color: var(--grade-f);
}

/* ============================================================
   3. MAIN RANKINGS TABLE (Reactable)
   ============================================================ */

#factory-table {
  font-family:
    Inter,
    system-ui,
    -apple-system,
    sans-serif;
}

#factory-table .rt-table {
  border: none;
}

#factory-table .rt-thead {
  background: var(--gray-100);
}

#factory-table .rt-th {
  padding: 8px 8px;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

#factory-table .rt-tbody .rt-tr {
  cursor: pointer;
  transition: background-color 0.15s ease;
  border-bottom: 1px solid #f0f0f0;
}

#factory-table .rt-tbody .rt-tr:hover {
  background-color: var(--gray-100);
}

#factory-table .rt-tbody .rt-tr.selected-row {
  background-color: #bbdefb !important;
}

#factory-table .rt-td {
  padding: 6px 8px;
  vertical-align: middle;
}

#factory-table .rt-search {
  max-width: 300px;
  margin-bottom: 1rem;
}

/* Pagination */
#factory-table .rt-pagination {
  border-top: 1px solid var(--gray-300);
  padding-top: 1rem;
  margin-top: 0.5rem;
}

#factory-table .rt-page-button {
  border-radius: 4px;
  padding: 6px 12px;
}

#factory-table .rt-page-button:hover {
  background-color: var(--gray-200);
}

#factory-table .rt-page-button-current {
  background-color: var(--brand-blue);
  color: white;
}

/* ============================================================
   4. QUADRANT CHART
   ============================================================ */

#quadrant-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto 1.5rem auto;
}

#quadrant-chart {
  width: 100%;
  height: auto;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  background: white;
}

.quadrant-label {
  font-size: 12px;
  font-weight: bold;
  text-anchor: middle;
}

.quadrant-sublabel {
  font-size: 9px;
  text-anchor: middle;
  opacity: 0.8;
}

.axis-label {
  font-size: 12px;
  font-weight: 600;
  fill: #333;
  text-anchor: middle;
}

.axis-tick {
  font-size: 10px;
  fill: #666;
  text-anchor: middle;
}

.axis-tick-y {
  font-size: 10px;
  fill: #666;
  text-anchor: start;
}

.quadrant-dot {
  cursor: pointer;
  transition:
    r 0.15s ease,
    stroke-width 0.15s ease;
}

.quadrant-dot:hover {
  r: 12;
  stroke-width: 3;
}

.quadrant-dot.dot-selected {
  r: 12;
  stroke: var(--gray-900);
  stroke-width: 4;
}

.quadrant-tooltip {
  display: none;
  position: absolute;
  background: rgba(26, 26, 46, 0.95);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ============================================================
   5. FACTORY DETAIL PANEL (Modal Overlay)
   ============================================================ */

/* Modal backdrop */
.factory-detail {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  overflow-y: auto;
  padding: 2rem;
  box-sizing: border-box;
}

/* Modal content container */
.factory-detail-inner {
  background: white;
  border-radius: 12px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
}

/* Modal top bar with nav and close button */
.modal-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: -1.5rem; /* Offset the modal padding */
  background: white;
  padding: 0.75rem 0;
  margin: -1.5rem -1.5rem 1rem -1.5rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  z-index: 100;
}

/* Section navigation */
.section-nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.section-nav-link {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-500);
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.section-nav-link:hover {
  background: var(--gray-100);
  color: var(--gray-700);
  text-decoration: none;
}

.section-nav-link.active {
  background: var(--brand-blue);
  color: white;
}

.close-detail {
  position: fixed;
  top: 80px;
  right: 24px;
  background: white;
  color: var(--gray-600);
  border: 1px solid var(--gray-300);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.75rem;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1001;
}

.close-detail:hover {
  background: var(--gray-100);
  color: var(--gray-900);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Factory Header */
.factory-header {
  background: linear-gradient(135deg, var(--gray-900) 0%, #16213e 100%);
  color: white;
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.factory-header h2 {
  margin: 0 0 0.5rem 0;
  color: white;
  font-size: 1.5rem;
}

.factory-header h2 .report-card-subtitle {
  font-weight: 400;
  opacity: 0.7;
  font-size: 0.9em;
}

.factory-header .location {
  opacity: 0.9;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.factory-header .industry {
  opacity: 0.7;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.factory-grades {
  margin-bottom: 0.5rem;
}

.criteria-grid-header {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem 1.5rem;
  margin-top: 0.5rem;
  max-width: 400px;
}

.criteria-grid-header .criteria-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.criteria-grid-header .criteria-label {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  line-height: 1.2;
  white-space: nowrap;
}

/* Reader-first framing callout */
.framing-callout {
  background: var(--gray-100);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border-radius: 8px;
}

.framing-question {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
}

.framing-blurb {
  font-size: 0.9rem;
  color: var(--gray-700);
  line-height: 1.6;
}

.framing-good {
  color: var(--grade-a);
  font-weight: 600;
}
.framing-bad {
  color: var(--grade-f);
  font-weight: 600;
}

/* Summary line */
.summary-line {
  background: #e8f4f8;
  border-left: 4px solid var(--brand-blue);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 1rem;
  line-height: 1.6;
  color: #333;
}

.summary-grade {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.summary-interpretation {
  font-size: 1rem;
  line-height: 1.6;
}

/* Interpretation color coding */
.interp-good {
  color: var(--grade-a);
  font-weight: 600;
}
.interp-caution {
  color: var(--grade-c);
  font-weight: 600;
}
.interp-warning {
  color: var(--grade-d);
  font-weight: 600;
}
.interp-bad {
  color: var(--grade-f);
  font-weight: 600;
}

/* Section headings in factory detail */
.factory-detail h3 {
  color: var(--gray-900);
  border-bottom: 2px solid var(--brand-blue);
  padding-bottom: 0.5rem;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.factory-detail h4 {
  color: var(--gray-900);
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

/* Metrics cards */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.metric-card {
  background: var(--gray-100);
  padding: 0.75rem;
  border-radius: 6px;
  text-align: center;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--gray-900);
}

.metric-label {
  font-size: 0.7rem;
  color: #666;
  margin-top: 0.2rem;
}

/* Criteria table */
.criteria-table {
  background: var(--gray-100);
  padding: 1rem;
  border-radius: 8px;
}

.criteria-table table {
  width: 100%;
  border-collapse: collapse;
}

.criteria-table th {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 2px solid var(--gray-300);
}

.criteria-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--gray-300);
  vertical-align: top;
}

.criteria-table th.grade-col,
.criteria-table td.grade-col {
  width: 50px;
  text-align: center;
  vertical-align: top;
  padding-top: 0.75rem;
}

.criteria-table small {
  color: #666;
}

.criteria-detail {
  font-size: 0.85rem;
  color: #555;
  margin-top: 0.4rem;
  line-height: 1.5;
}

.criteria-data {
  font-size: 0.85rem;
  color: #333;
  margin-top: 0.5rem;
  line-height: 1.6;
}

.criteria-data strong {
  color: var(--gray-900);
}

.criteria-threshold {
  display: block;
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.3rem;
  font-style: italic;
}

.criteria-breakdown {
  display: block;
  font-size: 0.8rem;
  color: #555;
}

.criteria-method-link {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--brand-blue);
  text-decoration: none;
  font-weight: 500;
}

.criteria-method-link:hover {
  text-decoration: underline;
  color: #006da3;
}

.criteria-table tr:last-child td {
  border-bottom: none;
}

/* Playbook Panel - Growth Strategies */
.playbook-panel {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  margin-top: 1.5rem;
}

.playbook-header {
  background: linear-gradient(135deg, var(--gray-900) 0%, #16213e 100%);
  padding: 1.25rem 1.5rem;
  color: white;
}

.playbook-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.playbook-subtitle {
  font-size: 0.85rem;
  opacity: 0.85;
}

.playbook-subtitle strong {
  color: #7dd3fc;
}

.playbook-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}

.playbook-card {
  padding: 1.5rem 1rem;
  text-align: center;
  border-right: 1px solid var(--gray-200);
  transition: background-color 0.2s ease;
}

.playbook-card:last-child {
  border-right: none;
}

.playbook-card:hover {
  background-color: var(--gray-100);
}

.playbook-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.75rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.playbook-icon svg {
  width: 28px;
  height: 28px;
}

/* Greenfield - green theme */
.playbook-greenfield .playbook-icon {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #059669;
}

/* Infill/Expand Suburbs - blue theme */
.playbook-infill .playbook-icon {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #2563eb;
}

/* Mixed-Use/Grayfield - amber theme */
.playbook-mixed .playbook-icon {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #d97706;
}

.playbook-card-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.2;
}

.playbook-card-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-top: 0.25rem;
}

.playbook-card-desc {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 0.35rem;
  line-height: 1.4;
}

.playbook-footer {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--gray-200);
}

.playbook-total-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
}

.playbook-total-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand-blue);
}

.playbook-total-value span {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-500);
}

/* Summary table image */
.summary-table-iframe {
  margin: 1rem 0;
}

.summary-table-iframe iframe {
  width: 100%;
  border-radius: 8px;
}

.no-data {
  color: #999;
  font-style: italic;
}

/* Maps section */
.maps-intro {
  color: #666;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.map-toggle-buttons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.map-toggle-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  background: #fff;
  color: var(--gray-700);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.map-toggle-btn:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

.map-toggle-btn.active {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  color: #fff;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.map-grid-single {
  grid-template-columns: 1fr;
}

.map-item {
  text-align: center;
}

.map-item img {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--gray-300);
}

.map-label {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.4rem;
  font-weight: 500;
}

/* Zoomable images */
.zoomable {
  cursor: zoom-in !important;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    outline 0.2s ease !important;
  outline: 3px solid transparent;
}

.zoomable:hover {
  transform: scale(1.05) !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25) !important;
  outline: 3px solid var(--brand-blue) !important;
}

/* ============================================================
   6. LIGHTBOX
   ============================================================ */

.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  cursor: zoom-out;
}

.lightbox img {
  max-width: 90%;
  max-height: 85%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: white;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10000;
}

.lightbox-close:hover {
  color: #ccc;
}

.lightbox-caption {
  color: white;
  font-size: 1.1rem;
  margin-top: 1rem;
  text-align: center;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
}

/* ============================================================
   6.5 MAPGL TOOLTIP TRANSPARENCY
   ============================================================ */

/* Make mapgl tooltips semi-transparent so factories aren't hidden */
.maplibregl-popup-content,
.mapboxgl-popup-content {
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: blur(4px);
}

.maplibregl-popup-tip,
.mapboxgl-popup-tip {
  border-top-color: rgba(255, 255, 255, 0.92) !important;
}

/* ============================================================
   6.6 COLLAPSIBLE SECTIONS
   ============================================================ */

.collapsible-section {
  margin-bottom: 1rem;
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 0.5rem 0;
  border-bottom: 2px solid var(--gray-300);
  margin-bottom: 1rem;
  transition: border-color 0.2s ease;
}

.collapsible-header:hover {
  border-color: var(--brand-blue);
}

.collapsible-header h3 {
  margin: 0;
  padding: 0;
  border: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.collapsible-toggle {
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.collapsible-toggle:hover {
  background: var(--gray-200);
  border-color: var(--gray-500);
}

.collapsible-toggle .toggle-icon {
  transition: transform 0.3s ease;
  color: var(--gray-700);
}

/* Collapsed state */
.collapsible-section.collapsed .collapsible-toggle .toggle-icon {
  transform: rotate(-90deg);
}

.collapsible-section.collapsed .collapsible-header {
  margin-bottom: 0;
}

.collapsible-content {
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
  max-height: 2000px; /* Large enough to fit any content */
  opacity: 1;
}

.collapsible-section.collapsed .collapsible-content {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* WIP badge for sections */
.wip-badge {
  display: inline-block;
  background: #ffc107;
  color: #333;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================================
   6.7 STICKY PAGE NAVIGATION
   ============================================================ */

.page-nav {
  position: fixed;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 500;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.page-nav.hidden {
  opacity: 0;
  visibility: hidden;
}

.page-nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  color: var(--gray-500);
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.page-nav-link:hover {
  background: white;
  border-color: var(--brand-blue);
  color: var(--brand-blue);
  transform: scale(1.05);
  text-decoration: none;
}

.page-nav-link.active {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  color: white;
}

.page-nav-link svg {
  flex-shrink: 0;
}

/* ============================================================
   6.8 BACK TO TOP BUTTON
   ============================================================ */

.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--gray-300);
  border-radius: 50%;
  color: var(--gray-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 140, 204, 0.3);
}

.back-to-top svg {
  flex-shrink: 0;
}

/* ============================================================
   7. UTILITY CLASSES
   ============================================================ */

/* Loading state */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--gray-500);
}

.loading-spinner p {
  margin-top: 1rem;
  font-size: 0.9rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--brand-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Transition states */
.factory-detail.loading {
  opacity: 0.7;
}

.factory-detail.loaded {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0.7;
  }
  to {
    opacity: 1;
  }
}

/* Callouts */
.callout-note {
  border-left-color: var(--brand-blue) !important;
}

/* Download button (data.qmd) */
.download-btn {
  display: inline-block;
  background: var(--brand-blue);
  color: white !important;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  text-decoration: none !important;
  font-weight: 600;
  margin: 1rem 0;
  transition: background 0.2s ease;
}

.download-btn:hover {
  background: #006da3;
}

/* ============================================================
   8. RESPONSIVE BREAKPOINTS
   ============================================================ */

/* Tablet */
@media (max-width: 768px) {
  .factory-header h2 {
    font-size: 1.25rem;
  }

  .metrics-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .metric-card {
    padding: 0.5rem;
  }

  .metric-value {
    font-size: 1rem;
  }

  .map-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .playbook-cards {
    grid-template-columns: 1fr;
  }

  .playbook-card {
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
  }

  .playbook-card:last-child {
    border-bottom: none;
  }

  .playbook-footer {
    flex-direction: column;
    text-align: center;
    gap: 0.25rem;
  }

  .criteria-grid-header {
    max-width: 100%;
  }

  .criteria-table td,
  .criteria-table th {
    padding: 0.4rem;
    font-size: 0.85rem;
  }

  .summary-line {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  .framing-callout {
    padding: 0.75rem 1rem;
  }

  .framing-question {
    font-size: 1rem;
  }

  .framing-blurb {
    font-size: 0.85rem;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .factory-detail {
    padding: 0.5rem;
  }

  .factory-detail-inner {
    padding: 1rem;
    border-radius: 8px;
  }

  .modal-top-bar {
    top: -1rem;
    margin: -1rem -1rem 0.75rem -1rem;
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

  .section-nav {
    gap: 0.15rem;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .section-nav::-webkit-scrollbar {
    display: none;
  }

  .section-nav-link {
    padding: 0.3rem 0.5rem;
    font-size: 0.65rem;
  }

  .close-detail {
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
    top: 70px;
    right: 12px;
  }

  .factory-header {
    padding: 1rem;
  }

  .factory-header h2 {
    font-size: 1.1rem;
  }

  .factory-header .location,
  .factory-header .industry {
    font-size: 0.8rem;
  }

  .criteria-grid-header {
    grid-template-columns: 1fr;
    gap: 0.3rem;
    max-width: 100%;
  }

  .criteria-grid-header .criteria-label {
    font-size: 0.55rem;
  }

  .grade-badge.grade-sm {
    font-size: 0.65rem;
    padding: 0.15rem 0.3rem;
  }

  .metrics-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .metric-value {
    font-size: 0.95rem;
  }

  .metric-label {
    font-size: 0.65rem;
  }

  .map-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .map-grid-single {
    grid-template-columns: 1fr;
  }

  .factory-detail h3 {
    font-size: 1rem;
    margin-top: 1.25rem;
  }

  .factory-detail h4 {
    font-size: 0.9rem;
  }

  .playbook-card-value {
    font-size: 1.35rem;
  }

  .playbook-card-label {
    font-size: 0.8rem;
  }

  .playbook-card-desc {
    font-size: 0.65rem;
  }

  .playbook-header {
    padding: 1rem;
  }

  .playbook-title {
    font-size: 1rem;
  }

  .playbook-card {
    padding: 1rem 0.75rem;
  }

  .playbook-icon {
    width: 40px;
    height: 40px;
  }

  .playbook-icon svg {
    width: 22px;
    height: 22px;
  }

  .playbook-total-value {
    font-size: 1.25rem;
  }

  .close-detail {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    top: 75px;
    right: 16px;
  }

  .collapsible-header h3 {
    font-size: 0.95rem;
  }

  .collapsible-toggle {
    width: 28px;
    height: 28px;
  }

  .collapsible-toggle .toggle-icon {
    width: 16px;
    height: 16px;
  }

  .wip-badge {
    font-size: 0.55rem;
    padding: 0.1rem 0.35rem;
  }

  /* Smaller page nav on mobile */
  .page-nav {
    right: 0.5rem;
    gap: 0.35rem;
  }

  .page-nav-link {
    width: 32px;
    height: 32px;
  }

  .page-nav-link svg {
    width: 14px;
    height: 14px;
  }

  /* Adjust back to top for mobile */
  .back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
  }
}

/* Quadrant chart legend */
.quadrant-legend {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.5rem 0 1.5rem 0;
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.quadrant-legend span {
  padding: 6px 14px;
  border-radius: 4px;
}

.legend-best {
  background: #d4edda;
  border: 1px solid #155724;
  color: #155724;
}

.legend-mixed-blue {
  background: #cce5ff;
  border: 1px solid #004085;
  color: #004085;
}

.legend-mixed-yellow {
  background: #fff3cd;
  border: 1px solid #856404;
  color: #856404;
}

.legend-worst {
  background: #f5c6cb;
  border: 1px solid #721c24;
  color: #721c24;
}
