/* ============================================
   Engineering Blog - matches example blog theme
   WSJ-inspired, single-column article layout
   ============================================ */

:root {
  --wsj-tan: #f5f1eb;
  --wsj-cream: #faf8f5;
  --wsj-dark: #1a1a1a;
  --wsj-nav: #352a21;
  --wsj-brown: #6b5b4f;
  --wsj-gold: #c4a35a;
  --wsj-blue: #0274b6;
  --wsj-border: #d4c8b8;

  --bg: var(--wsj-tan);
  --bg-elevated: var(--wsj-cream);
  --bg-code: #fefcf9;
  --text: var(--wsj-dark);
  --text-dim: var(--wsj-brown);
  --muted: var(--wsj-brown);
  --accent: var(--wsj-blue);
  --border: var(--wsj-border);

  --font-serif: "Libre Baskerville", Georgia, serif;
  --font-sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, Segoe UI,
    Roboto, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-serif);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.025;
  z-index: 1000;
}

/* ============================================
   Navigation
   ============================================ */
.main-nav {
  background: var(--wsj-nav);
  border-bottom: 1px solid #453931;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 0;
}

.nav-brand-link {
  text-decoration: none;
}

.nav-brand {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: white;
  padding: 14px 0;
  margin-right: 32px;
  white-space: nowrap;
}

.nav-sections {
  display: flex;
  align-items: center;
  flex: 1;
}

.nav-section {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-section-dropdown {
  position: relative;
}

.nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  color: rgba(255, 255, 255, 0.7);
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
  border-bottom: 2px solid transparent;
}

.nav-dropdown-trigger:hover {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}

.nav-dropdown-trigger.open {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

.nav-dropdown-trigger svg {
  transition: transform 200ms ease;
  opacity: 0.6;
}

.nav-dropdown-trigger.open svg {
  transform: rotate(180deg);
}

.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 280px;
  background: white;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  z-index: 200;
}

.nav-dropdown.open {
  display: block;
}

.nav-dropdown-item {
  display: block;
  padding: 14px 18px;
  text-decoration: none;
  border-bottom: 1px solid #f0ece6;
  transition: background 100ms ease;
}

.nav-dropdown-item:last-child {
  border-bottom: none;
}

.nav-dropdown-item:hover {
  background: var(--wsj-cream);
}

.nav-dropdown-item.active {
  background: var(--wsj-cream);
  border-left: 3px solid var(--accent);
  padding-left: 15px;
}

.nav-dropdown-item-title {
  display: block;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.nav-dropdown-item-desc {
  display: block;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.nav-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 20px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 14px 16px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 150ms ease;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.nav-link:hover {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: white;
  background: rgba(255, 255, 255, 0.08);
  border-bottom-color: var(--wsj-gold);
}

@media (max-width: 768px) {
  .nav-container {
    flex-direction: column;
    padding: 12px 16px;
    gap: 8px;
  }

  .nav-brand {
    margin-right: 0;
    padding: 0;
  }

  .nav-sections {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .nav-section {
    flex-direction: column;
    width: 100%;
    gap: 4px;
  }

  .nav-dropdown-trigger {
    width: 100%;
    justify-content: center;
  }

  .nav-divider {
    width: 100%;
    height: 1px;
    margin: 4px 0;
  }

  .nav-link {
    padding: 10px 14px;
    font-size: 11px;
  }
}

/* ============================================
   Article container
   ============================================ */
.content {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 24px 80px;
}

/* ============================================
   Article header (real intro)
   ============================================ */
.article-header {
  text-align: center;
  padding-top: 48px;
  padding-bottom: 32px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.article-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--wsj-brown);
  margin-bottom: 16px;
}

.article-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(32px, 6vw, 44px);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin-bottom: 20px;
}

.article-subtitle {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--wsj-brown);
  line-height: 1.6;
  max-width: 600px;
  margin: 0 auto;
}

/* ============================================
   Body typography
   ============================================ */
.content p {
  margin: 0 0 20px;
}

.knobs-list {
  margin: 0 0 24px 0;
  padding-left: 24px;
  counter-reset: knob;
  list-style: none;
}

.knobs-list li {
  position: relative;
  padding-left: 28px;
  margin-bottom: 14px;
  line-height: 1.7;
  counter-increment: knob;
}

.knobs-list li::before {
  content: counter(knob);
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  width: 20px;
  text-align: right;
}

.compression-conditions {
  margin: 0 0 20px 0;
  padding-left: 28px;
}

.compression-conditions li {
  margin: 0 0 8px 0;
  padding-left: 4px;
  line-height: 1.7;
}

.compression-conditions li:last-child {
  margin-bottom: 0;
}

.content h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  margin: 48px 0 20px;
  letter-spacing: -0.01em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.content h3 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  margin: 32px 0 12px;
  color: var(--text);
}

.content h4 {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  margin: 24px 0 8px;
  color: var(--text);
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 2px;
}

/* ============================================
   Code block (real intro format)
   ============================================ */
.code-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  margin: 24px 0;
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--wsj-tan);
}

.code-content {
  padding: 16px 20px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
}

.code-content pre {
  margin: 0;
  padding: 0;
  background: transparent;
  overflow-x: auto;
}

.code-content code {
  display: block;
  white-space: pre;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 13px;
}

/* ============================================
   Inline example block (no code-header)
   ============================================ */
.inline-example {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 16px 20px;
  margin: 24px 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.inline-example code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 13px;
  font-family: inherit;
}

.example-card {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  margin: 24px 0;
  overflow: hidden;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.7;
}

.example-card-title {
  background: var(--wsj-tan);
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

.example-card-body {
  padding: 12px 16px;
  white-space: pre-wrap;
  overflow-x: auto;
}

.canonical-rules-card .example-card-body {
  font-family: var(--font-serif);
  font-size: 15px;
  white-space: normal;
  overflow-x: visible;
}

.canonical-rules-card ul {
  margin: 0;
  padding-left: 22px;
}

.canonical-rules-card li {
  margin: 0 0 8px;
  line-height: 1.65;
}

.canonical-rules-card li:last-child {
  margin-bottom: 0;
}

/* ============================================
   Inline links in body copy
   ============================================ */
.content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.content a:hover {
  text-decoration-thickness: 2px;
}

/* ============================================
   Chart figure (compression graph)
   ============================================ */
figure.chart {
  margin: 32px 0;
  padding: 20px 20px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

figure.chart svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 700px;
  margin: 0 auto;
}

figure.chart figcaption {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ============================================
   Page excerpt (full-text source block)
   ============================================ */
.page-excerpt {
  margin: 32px 0;
  padding: 24px 28px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}

.page-excerpt-header {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.page-excerpt-section {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
}

.page-excerpt-body p {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.75;
  margin: 0 0 14px 0;
  color: var(--text);
}

.page-excerpt-body p:last-child {
  margin-bottom: 0;
}

/* ============================================
   Fade-in (keeps parity with example JS/CSS)
   ============================================ */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.6s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   Outline placeholder divider
   ============================================ */
.outline-divider {
  border: none;
  border-top: 2px dashed var(--border);
  margin: 64px 0 24px;
}

.outline-note {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-dim);
  background: var(--wsj-cream);
  border: 1px solid var(--border);
  border-left: 3px solid var(--wsj-brown);
  padding: 12px 16px;
  margin-bottom: 32px;
}

/* ============================================
   Placeholder outline cards (NOT final format)
   These exist only so the outline survives while
   we replace sections one at a time.
   ============================================ */
.section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--wsj-brown);
  padding: 20px 22px;
  margin: 20px 0;
}

.section h2 {
  font-size: 20px;
  margin: 4px 0 12px;
  padding: 0;
  border: none;
  font-weight: 700;
}

.section h3 {
  font-size: 16px;
  margin: 20px 0 10px;
}

.section p {
  margin: 0 0 12px;
}

.section-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.bullets {
  margin: 8px 0 4px 20px;
  padding: 0;
}

.bullets li {
  margin: 4px 0;
}

.subsection {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

/* Stats grid (placeholder) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--border);
  margin: 16px 0;
  border: 1px solid var(--border);
}

.stat-card {
  background: var(--bg-elevated);
  padding: 14px 12px;
  text-align: center;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Metric callout (placeholder) */
.metric-callout {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 14px 16px;
  margin: 16px 0;
}

.metric-title {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

/* Comparison table (placeholder) */
.comparison-table {
  border: 1px solid var(--border);
  margin: 14px 0;
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg-elevated);
}

.comparison-row {
  display: grid;
  grid-template-columns: 1.3fr 0.75fr 1.6fr;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.comparison-table .comparison-row:first-child {
  border-top: none;
}

.comparison-table.columns-4 .comparison-row {
  grid-template-columns: 1.1fr 0.8fr 0.8fr 0.8fr;
}

.comparison-table.columns-2 .comparison-row {
  grid-template-columns: 1fr 1.4fr;
}

.comparison-table.columns-5 .comparison-row {
  grid-template-columns: 1.15fr 1.45fr 0.65fr 0.65fr 0.9fr;
}

.comparison-table.sweep-range-table .comparison-row {
  grid-template-columns: 1.6fr 0.7fr 0.7fr;
}

.comparison-table.text-training-table .comparison-row {
  grid-template-columns: 1.35fr 1fr 0.9fr;
}

.comparison-table.text-training-table .comparison-row > div:last-child {
  text-align: right;
}

.heatmap-table {
  border: 1px solid var(--border);
  margin: 14px 0;
  font-family: var(--font-sans);
  font-size: 13px;
  background: var(--bg-elevated);
}

.heatmap-row {
  display: grid;
  grid-template-columns: 1.45fr repeat(5, 0.72fr);
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  align-items: stretch;
}

.level-heatmap .heatmap-row {
  grid-template-columns: 1.45fr repeat(3, 0.9fr);
}

.heatmap-row:first-child {
  border-top: none;
}

.heatmap-head {
  background: var(--wsj-tan);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.45px;
  text-transform: uppercase;
}

.heatmap-row > div:not(:first-child) {
  border-radius: 3px;
  padding: 6px 4px;
  text-align: center;
}

.heat-0 { background: #8f4f43; color: #fffaf1; }
.heat-20 { background: #b77766; color: #fffaf1; }
.heat-40 { background: #d9b8a6; color: var(--text); }
.heat-60 { background: #c7c6a0; color: var(--text); }
.heat-70 { background: #a3ad82; color: var(--text); }
.heat-80 { background: #728c67; color: #fffaf1; }
.heat-90,
.heat-100 { background: #4d6f51; color: #fffaf1; }
.heat-na { background: #f7f3ec; color: var(--text-muted); }
.heat-na-inline {
  color: var(--text-muted);
  font-family: var(--font-sans);
}

.question-examples {
  border: 1px solid var(--border);
  margin: 16px 0;
  background: var(--bg-elevated);
}

.question-example {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.question-example:first-child {
  border-top: none;
}

.question-example p {
  margin: 4px 0 0;
}

.adapter-answer-label {
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.45px;
  margin-top: 10px;
  text-transform: uppercase;
}

.adapter-answer {
  color: var(--text-dim);
  font-style: italic;
}

.assessment-line {
  margin-top: 6px;
}

.assessment-badge {
  border-radius: 999px;
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 3px 9px;
  text-transform: uppercase;
}

.assessment-correct {
  background: rgba(57, 171, 100, 0.16);
  color: #2f8f56;
}

.assessment-partial {
  background: rgba(199, 137, 45, 0.16);
  color: #a46722;
}

.assessment-mostly {
  background: rgba(79, 124, 196, 0.16);
  color: #3d6ca8;
}

.question-type-label {
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.45px;
  text-transform: uppercase;
}

.flow-diagram {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 18px 0;
  font-family: var(--font-sans);
  font-size: 12.5px;
}

.flow-diagram > div {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  padding: 12px 8px;
  background: var(--bg-elevated);
  text-align: center;
}

.flow-diagram > div:not(:last-child)::after {
  content: ">";
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.prompt-block {
  border-left: 3px solid var(--text-dim);
  margin: 18px 0;
  padding: 16px 18px;
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.6;
}

.prompt-block p {
  margin: 0 0 8px;
}

.prompt-block p:last-child {
  margin-bottom: 0;
}

.question-quote {
  border-left: 3px solid var(--text-dim);
  margin: 16px 0;
  padding: 10px 16px;
  background: var(--bg-elevated);
  color: var(--text);
  font-style: italic;
}

.comparison-head {
  background: var(--wsj-tan);
  font-weight: 600;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 640px) {
  .content {
    padding: 32px 16px 60px;
  }

  .content h2 {
    font-size: 22px;
    margin: 36px 0 16px;
  }

  .content h3 {
    font-size: 17px;
  }

  .comparison-row {
    grid-template-columns: 1fr;
  }

  .comparison-table.columns-4 .comparison-row {
    grid-template-columns: 1fr;
  }

  .comparison-table.sweep-range-table .comparison-row {
    grid-template-columns: 1fr;
  }
}
