/* Color tokens and system font styling for What Nearly Hit Us */

:root {
  --font-system: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Light Theme */
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --surface: #ffffff;
  --surface-sunken: #f1f5f9;
  --surface-card: #ffffff;
  --border: #e2e8f0;
  --border-strong: #94a3b8;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --max-width: 1140px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #090d16;
    --bg-subtle: #0f172a;
    --surface: #1e293b;
    --surface-sunken: #0b1120;
    --surface-card: #141e33;
    --border: #334155;
    --border-strong: #64748b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --accent: #38bdf8;
    --accent-hover: #7dd3fc;
    --accent-light: #082f49;
    --danger: #f87171;
    --danger-light: #450a0a;
    --warning: #fbbf24;
    --warning-light: #451a03;
    --success: #4ade80;
    --success-light: #052e16;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.5);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-system);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  text-decoration: underline;
}

/* Header & Navigation */
.site-header {
  border-bottom: 1px solid var(--border);
  background-color: var(--bg-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.header-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-logo:hover {
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--text-muted);
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
  text-decoration: none;
}

/* Container & Layout */
.main-content {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

/* Cards & Surfaces */
.card {
  background-color: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

/* Count Strip Banner */
.count-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  background-color: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 2rem;
}

.count-item {
  display: flex;
  flex-direction: column;
}

.count-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}

.count-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Key Facts Block */
.key-facts-block {
  background-color: var(--accent-light);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

.key-facts-block h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.key-facts-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.key-facts-list li {
  position: relative;
  padding-left: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.key-facts-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 900;
  font-size: 1.2rem;
  line-height: 1;
}

/* Visual Graphics & SVG */
.graphic-container {
  background-color: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1.5rem 0;
  text-align: center;
}

.graphic-container svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.graphic-caption {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  text-align: center;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

table.data-table th {
  background-color: var(--surface-sunken);
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

table.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

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

table.data-table tr:hover td {
  background-color: var(--surface-sunken);
}

/* Citations */
.citation-block {
  background-color: var(--surface-sunken);
  border: 1px solid var(--border);
  margin-top: 2.5rem;
}

.citation-block pre {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  overflow-x: auto;
  margin-top: 0.5rem;
}

.citation-format {
  margin-top: 1rem;
}

/* Ad Slots with Reserved Height (Zero CLS) */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface-sunken);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  margin: 1.5rem auto;
  color: var(--text-dim);
  font-size: 0.8rem;
  overflow: hidden;
}

.ad-slot.slot-home-top {
  width: 100%;
  max-width: 970px;
  height: 90px;
  min-height: 90px;
}

.ad-slot.slot-page-inline-1,
.ad-slot.slot-page-inline-2 {
  width: 100%;
  max-width: 728px;
  height: 90px;
  min-height: 90px;
}

.ad-slot.slot-sidebar-1 {
  width: 300px;
  height: 250px;
  min-height: 250px;
}

/* Cookie Consent Banner */
.consent-banner {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  max-width: 500px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  z-index: 100;
  display: none;
}

.consent-banner.visible {
  display: block;
}

.consent-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-primary {
  background-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  text-decoration: none;
}

.btn-secondary {
  background-color: var(--surface-sunken);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background-color: var(--border);
  text-decoration: none;
}

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

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background-color: var(--bg-subtle);
  padding: 2.5rem 1.25rem 2rem;
  margin-top: auto;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}
