/* ═══════════════════════════════════════════════════════════════
   Social Physics of the New Disorder — Design System
   Aesthetic: Steampunk control panel meets editorial journalism
   Palette derived from hero image: brass, copper, danger-red,
   amber glow, steam, deep warm shadows
   ═══════════════════════════════════════════════════════════════ */

/* --- Tokens --- */
:root {
  --bg-void: #050403;
  --bg-primary: #0d0b08;
  --bg-secondary: #161310;
  --bg-panel: #1c1914;
  --bg-elevated: #252019;

  --text-primary: #e8dcc8;
  --text-secondary: #c4b89a;
  --text-muted: #8a7d6a;
  --text-bright: #f5edd8;

  --brass: #c4a44a;
  --brass-light: #dcc060;
  --brass-dim: #8a7430;
  --copper: #cd7f32;
  --copper-dim: #8b5a2b;
  --danger: #cc3333;
  --danger-glow: #e84444;
  --amber: #e89830;
  --steam: rgba(200, 190, 170, 0.08);

  --border-brass: rgba(196, 164, 74, 0.25);
  --border-copper: rgba(205, 127, 50, 0.2);
  --border-hard: rgba(196, 164, 74, 0.5);

  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-data: 'Source Code Pro', 'SF Mono', Menlo, Consolas, monospace;

  --content-width: 720px;
  --wide-width: 900px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.78;
  font-weight: 400;
  /* subtle noise grain */
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(196, 164, 74, 0.03) 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

::selection {
  background: rgba(196, 164, 74, 0.3);
  color: var(--text-bright);
}

a {
  color: var(--copper);
  text-decoration: none;
  border-bottom: 1px solid rgba(205, 127, 50, 0.3);
  transition: color 0.2s, border-color 0.2s;
}
a:hover {
  color: var(--brass-light);
  border-color: var(--brass);
}

/* --- Top Navigation --- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: rgba(13, 11, 8, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-brass);
  font-size: 14px;
}
.nav-back {
  color: var(--text-muted);
  border-bottom: none;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.nav-back:hover { color: var(--brass); }
.nav-article {
  color: var(--brass-dim);
  font-family: var(--font-data);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* --- Hero --- */
.hero {
  position: relative;
  width: 100%;
  max-height: 520px;
  overflow: hidden;
  background: var(--bg-void);
}
.hero img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  max-height: 520px;
}
/* When hero has no img child, collapse completely */
.hero:not(:has(img)) {
  max-height: 0;
  padding: 0;
  margin: 0;
}
/* Reduce hero-content top padding when no image precedes it */
.hero:not(:has(img)) + .hero-content {
  padding-top: 20px;
}
.hero-gradient {
  position: relative;
  width: 100%;
  height: 420px;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(196, 164, 74, 0.06) 0%, transparent 50%),
    linear-gradient(180deg,
      var(--bg-void) 0%,
      rgba(22, 18, 10, 0.95) 30%,
      rgba(28, 24, 16, 0.9) 60%,
      var(--bg-primary) 100%
    );
}
.hero-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 80px 24px 40px;
  background: linear-gradient(
    transparent 0%,
    rgba(5, 4, 3, 0.4) 20%,
    rgba(5, 4, 3, 0.85) 50%,
    rgba(5, 4, 3, 0.97) 75%,
    rgba(13, 11, 8, 1) 100%
  );
  text-align: center;
}
.hero-content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 60px 24px 20px;
  text-align: center;
}

.series-tag {
  font-family: var(--font-data);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--brass);
  margin-bottom: 16px;
}
.article-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 54px);
  font-weight: 900;
  line-height: 1.15;
  color: var(--text-bright);
  margin-bottom: 16px;
}
.article-dateline {
  font-family: var(--font-data);
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 12px;
}

.article-subtitle {
  font-size: 20px;
  color: var(--text-secondary);
  font-weight: 300;
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.5;
}

/* --- Article Body --- */
.article-body {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.article-body h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-bright);
  margin: 56px 0 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-brass);
}
.article-body h2:first-child { margin-top: 0; }

.article-body h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-bright);
  margin: 40px 0 16px;
}

.article-body p {
  margin-bottom: 20px;
  color: var(--text-primary);
}
.article-body p:last-child { margin-bottom: 0; }

.article-body em {
  color: var(--text-secondary);
  font-style: italic;
}
.article-body strong {
  color: var(--text-bright);
  font-weight: 600;
}

/* --- Receipt Section --- */
.receipt { margin-bottom: 48px; }
.receipt-intro {
  font-size: 20px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* --- Gauge Data Table --- */
.gauge-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0 32px;
  font-size: 15px;
  border: 1px solid var(--border-hard);
}
.gauge-table thead {
  background: var(--bg-elevated);
}
.gauge-table th {
  font-family: var(--font-data);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brass);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 2px solid var(--border-hard);
}
.gauge-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-brass);
  vertical-align: top;
}
.gauge-table tbody tr:hover {
  background: rgba(196, 164, 74, 0.04);
}
.gauge-label {
  font-weight: 600;
  color: var(--text-bright);
  white-space: nowrap;
}
.gauge-reading {
  font-family: var(--font-data);
  font-weight: 600;
  white-space: nowrap;
}
.gauge-reading.danger {
  color: var(--danger);
  text-shadow: 0 0 8px rgba(204, 51, 51, 0.3);
}
.gauge-reading.warning {
  color: var(--amber);
  text-shadow: 0 0 8px rgba(232, 152, 48, 0.2);
}

/* --- FRED Series Reference Table --- */
.fred-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 32px;
  font-size: 14px;
  border: 1px solid var(--border-brass);
}
.fred-table th {
  font-family: var(--font-data);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brass);
  padding: 10px 14px;
  text-align: left;
  background: var(--bg-elevated);
  border-bottom: 2px solid var(--border-hard);
}
.fred-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(196, 164, 74, 0.12);
  font-family: var(--font-data);
  font-size: 13px;
}
.fred-table td:first-child {
  color: var(--brass);
  font-weight: 600;
  white-space: nowrap;
}

/* --- Data Panel (Chart Annotations) --- */
.data-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-hard);
  border-left: 3px solid var(--brass);
  border-radius: 2px;
  padding: 16px 20px;
  margin: 28px 0;
  box-shadow:
    0 0 12px rgba(196, 164, 74, 0.06),
    inset 0 1px 0 rgba(196, 164, 74, 0.08);
}
.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.panel-icon {
  font-size: 16px;
  filter: saturate(0.7);
}
.panel-series {
  font-family: var(--font-data);
  font-size: 13px;
  font-weight: 600;
  color: var(--brass);
  letter-spacing: 0.04em;
}
.panel-desc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0;
}

/* --- Feedback Loop Callout --- */
blockquote.feedback-loop {
  background: linear-gradient(135deg, rgba(196, 164, 74, 0.06), rgba(205, 127, 50, 0.04));
  border-left: 3px solid var(--copper);
  padding: 24px 28px;
  margin: 32px 0;
  border-radius: 2px;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.7;
}
blockquote.feedback-loop p { margin-bottom: 0; }

/* --- Pattern Name --- */
.pattern-name {
  color: var(--brass-light);
  font-weight: 700;
  border-bottom: 2px solid var(--brass-dim);
}

/* --- Section Dividers --- */
.section-divider {
  border: none;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--border-hard) 20%,
    var(--border-hard) 80%,
    transparent
  );
  margin: 56px 0;
}

/* --- Sources --- */
.sources {
  margin-top: 64px;
  padding-top: 32px;
  border-top: 2px solid var(--border-hard);
}
.sources h2 {
  font-size: 22px;
  margin-bottom: 24px;
}
.sources details {
  margin-bottom: 8px;
  border: 1px solid rgba(196, 164, 74, 0.12);
  border-radius: 2px;
}
.sources details[open] {
  border-color: var(--border-brass);
  margin-bottom: 16px;
}
.sources summary {
  cursor: pointer;
  padding: 12px 16px;
  background: var(--bg-secondary);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sources summary::before {
  content: '▸';
  color: var(--brass-dim);
  transition: transform 0.2s;
  font-size: 12px;
}
.sources details[open] summary::before {
  transform: rotate(90deg);
}
.sources summary:hover {
  color: var(--text-bright);
  background: var(--bg-panel);
}
.sources summary h3 {
  font-size: 16px;
  margin: 0;
  display: inline;
  color: inherit;
}
.source-list {
  list-style: none;
  padding: 12px 16px 16px;
}
.source-list li {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-left: 16px;
  position: relative;
}
.source-list li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--brass-dim);
}
.source-list li a {
  font-size: 14px;
  border-bottom-color: rgba(205, 127, 50, 0.2);
}

/* --- Article Footer --- */
.article-footer {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 24px 80px;
}
.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 0;
  border-top: 1px solid var(--border-brass);
}
.nav-prev, .nav-next {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text-muted);
  border-bottom: none;
  transition: color 0.2s;
}
.nav-prev:hover, .nav-next:hover { color: var(--brass); }
.nav-next { text-align: right; margin-left: auto; }

.series-footer {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 32px;
  font-style: italic;
  line-height: 1.6;
}

/* ═══ INDEX PAGE ═══ */
.index-hero {
  position: relative;
  width: 100%;
  min-height: 80vh;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-void);
}
/* Collapse index hero when no image present */
.index-hero:not(:has(img)) {
  min-height: auto;
  align-items: center;
}
.index-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  opacity: 0.75;
}
.index-hero-overlay {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 60px 24px 48px;
  background: linear-gradient(transparent 0%, rgba(5, 4, 3, 0.7) 40%, rgba(5, 4, 3, 0.96) 75%);
  width: 100%;
}
.index-hero-overlay .series-tag { font-size: 14px; }
.index-hero-overlay h1 {
  font-family: var(--font-display);
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 900;
  color: var(--text-bright);
  line-height: 1.1;
  margin-bottom: 20px;
}
.index-hero-overlay .series-desc {
  max-width: 640px;
  margin: 0 auto;
  font-size: 18px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.index-body {
  max-width: var(--wide-width);
  margin: 0 auto;
  padding: 64px 24px 96px;
}

.article-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
}

.article-card {
  display: block;
  background: var(--bg-secondary);
  border: 1px solid var(--border-brass);
  padding: 28px 32px;
  text-decoration: none;
  border-bottom: none;
  transition: background 0.2s, border-color 0.2s;
  position: relative;
}
.article-card:hover {
  background: var(--bg-panel);
  border-color: var(--brass);
}
.article-card:last-child { border-bottom: 1px solid var(--border-brass); }

.card-number {
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--brass-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
}
.card-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 8px;
  line-height: 1.3;
}
.card-desc {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
}
.card-status {
  position: absolute;
  top: 28px;
  right: 32px;
  font-family: var(--font-data);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 3px 10px;
  border-radius: 2px;
}
.card-status.live {
  color: var(--brass);
  background: rgba(196, 164, 74, 0.1);
  border: 1px solid var(--border-brass);
}
.card-status.draft {
  color: var(--text-muted);
  background: rgba(138, 125, 106, 0.08);
  border: 1px solid rgba(138, 125, 106, 0.15);
}

/* --- Framework Box --- */
.framework-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-hard);
  border-radius: 2px;
  padding: 24px 28px;
  margin: 32px 0;
}
.framework-box h4 {
  font-family: var(--font-data);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brass);
  margin-bottom: 16px;
}
.framework-box ul {
  list-style: none;
  padding: 0;
}
.framework-box li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(196, 164, 74, 0.08);
  font-size: 16px;
}
.framework-box li:last-child { border-bottom: none; }
.framework-box li strong {
  color: var(--brass-light);
}

/* --- Article Figures --- */
.article-figure {
  margin: 32px 0;
  padding: 0;
}
.article-figure img {
  width: 100%;
  border-radius: 6px;
  display: block;
}
.article-figure figcaption {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 12px;
  line-height: 1.5;
}
.article-figure.wide {
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% + 280px);
}

/* --- Bayesian Sequence Cards --- */
.bayes-sequence {
  margin: 24px 0 32px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bayes-case {
  background: var(--bg-secondary);
  border: 1px solid var(--border-brass);
  border-radius: 2px;
  overflow: hidden;
}
.bayes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-brass);
}
.bayes-label {
  font-weight: 600;
  color: var(--text-bright);
  font-size: 16px;
}
.bayes-signal {
  font-family: var(--font-data);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 10px;
  border-radius: 2px;
}
.bayes-signal.warning {
  color: var(--amber);
  background: rgba(232, 152, 48, 0.1);
  border: 1px solid rgba(232, 152, 48, 0.25);
}
.bayes-signal.danger {
  color: var(--danger);
  background: rgba(204, 51, 51, 0.1);
  border: 1px solid rgba(204, 51, 51, 0.25);
}
.bayes-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--border-brass);
}
.bayes-col {
  padding: 14px 18px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-secondary);
}
.bayes-col-label {
  display: block;
  font-family: var(--font-data);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brass-dim);
  margin-bottom: 6px;
}

/* --- Source Attribution Box --- */
.source-attribution {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 24px;
}
.source-attribution-inner {
  background: var(--bg-panel);
  border: 1px solid var(--border-hard);
  border-left: 3px solid var(--brass);
  border-radius: 2px;
  padding: 20px 24px;
  margin-top: -20px;
  margin-bottom: 0;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.source-attribution-inner .source-icon {
  font-size: 22px;
  flex-shrink: 0;
  margin-top: 2px;
}
.source-attribution-inner .source-links {
  display: flex;
  gap: 20px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.source-attribution-inner .source-links a {
  font-family: var(--font-data);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 5px 14px;
  border: 1px solid var(--border-brass);
  border-radius: 2px;
  color: var(--brass);
  background: rgba(196, 164, 74, 0.05);
  transition: background 0.2s, color 0.2s;
}
.source-attribution-inner .source-links a:hover {
  background: rgba(196, 164, 74, 0.12);
  color: var(--brass-light);
  border-color: var(--brass);
}

/* --- Slide Figure Grid --- */
.slide-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin: 20px 0 28px;
}
.slide-figure {
  margin: 0;
  padding: 0;
}
.slide-figure img {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--border-brass);
  display: block;
  transition: border-color 0.2s;
}
.slide-figure img:hover {
  border-color: var(--brass);
}
.slide-figure figcaption {
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  letter-spacing: 0.03em;
}

/* Single slide inline */
.slide-inline {
  margin: 20px 0 28px;
}
.slide-inline img {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--border-brass);
  display: block;
}
.slide-inline figcaption {
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  body { font-size: 16px; }
  .article-body { padding: 32px 16px 60px; }
  .hero { max-height: 360px; }
  .article-title { font-size: 28px; }
  .gauge-table { font-size: 13px; }
  .gauge-table td, .gauge-table th { padding: 10px 10px; }
  .data-panel { padding: 14px 16px; }
  .article-nav { flex-direction: column; gap: 12px; }
  .nav-next { text-align: left; margin-left: 0; }
  .article-card { padding: 20px 20px; }
  .card-status { position: static; margin-bottom: 8px; display: inline-block; }
  .article-figure.wide {
    width: 100%;
    left: 0;
    transform: none;
    max-width: 100%;
  }
  .source-attribution-inner {
    flex-direction: column;
    gap: 8px;
  }
  .bayes-row {
    grid-template-columns: 1fr;
  }
}
