/* gpo-formatting-dictionary: this post's own components. Shared post styles are in /engineering_blog/blog.css. */

/* Header */

header {
  background: var(--wsj-cream);
  border-bottom: 3px double var(--wsj-border);
  padding: 48px 24px 40px;
}

.blog-header {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}

.blog-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;
}

.blog-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin-bottom: 16px;
}

.blog-subtitle {
  font-family: var(--font-serif);
  font-size: 18px;
  color: #555;
  line-height: 1.6;
}

/* Matching priority list */

ol.matching-priority {
  background: var(--wsj-cream);
  border: 1px solid var(--border);
  padding: 24px 24px 24px 48px;
  margin: 24px 0;
}

ol.matching-priority li {
  margin-bottom: 12px;
  padding-left: 8px;
  font-family: var(--font-sans);
  font-size: 15px;
}

ol.matching-priority li:last-child {
  margin-bottom: 0;
}

ol.matching-priority strong {
  color: var(--accent);
}

.content ol,
.content ul {
  margin: 20px 0 28px;
  padding-left: 1.5rem;
}

.content ol li,
.content ul li {
  margin: 0;
  padding-bottom: 24px;
  line-height: 1.7;
}

.content ol li p {
  margin: 0 0 1em;
}

.content ol li p:last-child {
  margin-bottom: 0;
}

.content ol li:last-child,
.content ul li:last-child {
  padding-bottom: 0;
}

/* Stats Bar */

.stats-bar {
  margin: 32px 0;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  overflow: hidden;
}

.stats-row--2x2 {
  grid-template-columns: repeat(2, 1fr);
}

.stats-caption {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
  margin-top: 12px;
}

.stat {
  background: var(--wsj-cream);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-family: var(--font-sans);
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  display: block;
}

.stat-label {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Code Blocks */

.code-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  margin: 24px 0;
  overflow: hidden;
}

.code-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  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-header-note {
  font-weight: 400;
  font-style: italic;
  font-size: 11px;
  line-height: 1.4;
}

.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;
  padding: 0;
  border: none;
}

/* Code syntax highlighting */

.code-comment {
  color: var(--wsj-brown);
  font-style: italic;
}

.code-new {
  color: var(--wsj-green);
  font-weight: 500;
}

.code-error {
  color: var(--wsj-red);
}

.code-keyword {
  color: var(--wsj-blue);
  font-weight: 500;
}

/* Page excerpt (full-text source block) — from doc_mem_1 */

.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;
}

.page-excerpt-body .excerpt-cut {
  background: rgba(46, 125, 50, 0.15);
  box-shadow: inset 3px 0 0 var(--success);
  padding: 2px 0 2px 6px;
}

.page-excerpt-body .excerpt-overlap {
  background: rgba(196, 163, 90, 0.25);
  padding: 1px 4px;
  border-radius: 2px;
}

.page-excerpt-key {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-dim);
}

.page-excerpt-key .key-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-excerpt-key .key-swatch {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 2px;
}

.page-excerpt-key .key-swatch.cut {
  background: rgba(46, 125, 50, 0.15);
  box-shadow: inset 3px 0 0 var(--success);
}

.page-excerpt-key .key-swatch.overlap {
  background: rgba(196, 163, 90, 0.25);
}

/* Interactive Demo */

.demo-container {
  background: var(--wsj-cream);
  border: 1px solid var(--border);
  margin: 32px 0;
  overflow: hidden;
}

.demo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--wsj-tan);
}

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

.demo-controls {
  display: flex;
  gap: 8px;
}

.demo-btn {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  background: var(--wsj-dark);
  border: none;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.demo-btn:hover {
  background: #333;
}

.demo-btn:active {
  background: #000;
}

.demo-body {
  padding: 20px;
}

.demo-line {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  padding: 12px 16px;
  padding-right: 150px;
  margin-bottom: 8px;
  background: var(--bg);
  border-left: 3px solid transparent;
  transition: all 0.3s ease;
  position: relative;
}

.demo-line.highlight-speaker {
  background: rgba(2, 116, 182, 0.1);
  border-left-color: var(--accent);
}

.demo-line.highlight-scan {
  background: var(--wsj-cream);
  border-left-color: var(--text-dim);
}

.demo-line.highlight-state {
  background: rgba(46, 125, 50, 0.1);
  border-left-color: var(--success);
}

.demo-line.highlight-error {
  background: rgba(183, 28, 28, 0.1);
  border-left-color: var(--error);
}

.demo-line .annotation {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  padding: 4px 8px;
  opacity: 0;
  transition: opacity 0.3s;
}

.demo-line.highlight-speaker .annotation {
  background: var(--accent);
  color: white;
  opacity: 1;
}

.demo-line.highlight-scan .annotation {
  background: var(--wsj-cream);
  color: var(--text-dim);
  opacity: 1;
}

.demo-line.highlight-state .annotation {
  background: var(--success);
  color: white;
  opacity: 1;
}

.demo-line.highlight-error .annotation {
  background: var(--error);
  color: white;
  opacity: 1;
}

.speaker-name {
  color: var(--accent);
  font-weight: 600;
}

.state-name {
  color: var(--success);
  font-weight: 600;
}

.error-text {
  color: var(--error);
}

/* Disambiguation Demo */

.disambig-line {
  background: var(--bg);
  padding: 16px;
  margin-bottom: 12px;
  border-left: 3px solid transparent;
  transition: all 0.3s ease;
}

.disambig-line.active {
  border-left-color: var(--accent);
  background: rgba(2, 116, 182, 0.08);
}

.disambig-line.matched {
  border-left-color: var(--success);
  background: rgba(46, 125, 50, 0.08);
}

.disambig-text {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}

.disambig-match {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.disambig-line.matched .disambig-match {
  opacity: 1;
}

.match-arrow {
  color: var(--success);
  font-weight: bold;
}

.match-result {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  color: var(--success);
  font-weight: 600;
}

/* Line Scan Demo */

.line-scan-body {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
}

.scan-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin: 4px 0;
  border-left: 3px solid transparent;
  transition: all 0.3s ease;
  opacity: 0.5;
}

.scan-line .line-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.scan-line .scan-result {
  margin-left: 16px;
  font-size: 12px;
  min-width: 100px;
  text-align: right;
}

.scan-line.scanning {
  opacity: 1;
  background: rgba(2, 116, 182, 0.1);
  border-left-color: var(--accent);
}

.scan-line.scanned {
  opacity: 1;
  background: rgba(2, 116, 182, 0.1);
  border-left-color: var(--accent);
}

.scan-line.speaker-found {
  opacity: 1;
  background: rgba(46, 125, 50, 0.1);
  border-left-color: var(--success);
}

.scan-line.speaker-found .scan-result {
  color: var(--success);
  font-weight: 600;
}

.scan-line.processed {
  opacity: 0.5;
  background: transparent;
  border-left-color: transparent;
}

.scan-line.processed .scan-result {
  color: var(--text-dim);
}

.scan-line:not(.speaker-found):not(.scanned):not(.processed) .scan-result {
  color: var(--text-dim);
}

.scan-output {
  border-top: 1px solid var(--border);
  margin-top: 16px;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.output-section {
  min-height: 100px;
}

.output-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: 8px;
}

.output-card {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 12px;
  min-height: 80px;
  transition: all 0.3s ease;
}

.output-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 116, 182, 0.1);
}

.output-card.saving {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

.output-speaker {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 8px;
}

.output-text {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
}

.saved-card {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 12px;
  margin-bottom: 8px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.saved-speaker {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
}

.saved-text {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  display: block;
  white-space: pre-wrap;
}

/* Nickname Demo */

.nickname-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
}

.nickname-step {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 16px 20px;
  width: 100%;
  max-width: 400px;
  opacity: 0.4;
  transition: all 0.3s ease;
}

.nickname-step.active {
  opacity: 1;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 116, 182, 0.1);
}

.nickname-step.active.skipped {
  border-color: var(--text-dim);
  box-shadow: none;
  opacity: 0.6;
}

.nickname-step.active.matched {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

.nickname-step .step-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: 8px;
}

.nickname-step .step-content {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
}

.nickname-arrow {
  font-size: 20px;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.nickname-arrow.visible {
  opacity: 1;
  color: var(--accent);
}

.lookup-key {
  color: var(--accent);
}

.lookup-result {
  margin-left: 16px;
  padding: 4px 8px;
  background: var(--bg);
}

.lookup-result.success {
  background: rgba(46, 125, 50, 0.15);
  color: var(--success);
}

.nickname-highlight {
  background: rgba(2, 116, 182, 0.2);
  padding: 2px 4px;
  color: var(--accent);
}

.step-content.matched {
  color: var(--success);
}

/* Animated Parser */

.parser-animation {
  background: var(--wsj-cream);
  border: 1px solid var(--border);
  padding: 24px;
  margin: 32px 0;
}

.parser-input {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  padding: 16px;
  background: var(--bg);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}

.parser-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background: var(--accent);
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.parser-output {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.parser-field {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 16px;
}

.parser-field-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: 8px;
}

.parser-field-value {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  color: var(--accent);
  min-height: 1.5em;
}

.parser-field-value.success {
  color: var(--success);
}

.parser-field-value.error {
  color: var(--error);
}

/* File Chain Animation */

.file-chain {
  background: var(--wsj-cream);
  border: 1px solid var(--border);
  padding: 24px;
  margin: 32px 0;
}

.file-chain-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

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

.file-boxes {
  display: flex;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  padding-bottom: 8px;
}

.file-box {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 16px;
  min-width: 150px;
  flex-shrink: 0;
  transition: all 0.3s;
}

.file-box.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 116, 182, 0.1);
}

.file-name {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.file-speaker {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.file-speaker.inherited {
  color: var(--warning);
}

.file-speaker.detected {
  color: var(--success);
}

.file-arrow {
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.file-chain-legend {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  font-family: var(--font-sans);
  font-size: 13px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 10px;
  height: 10px;
}

.legend-dot.detected {
  background: var(--success);
}

.legend-dot.inherited {
  background: var(--warning);
}

/* Progress bar for parsing animation */

.parse-progress {
  height: 4px;
  background: var(--border);
  margin-top: 16px;
  overflow: hidden;
}

.parse-progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}

/* Responsive */

@media (max-width: 640px) {
  .stats-row {
    grid-template-columns: 1fr;
  }

  .parser-output {
    grid-template-columns: 1fr;
  }

  .scan-output {
    grid-template-columns: 1fr;
  }

  header {
    padding: 32px 16px;
  }
}

/* Formerly inline in the page head. */
/* Dictionary entry layout */
      .entry {
        border-top: 3px solid var(--wsj-gold);
        padding-top: 22px;
        margin: 46px 0 0 0;
      }
      .entry-head {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 14px;
        margin-bottom: 4px;
      }
      .entry-id {
        font-family: var(--font-sans);
        font-size: 13px;
        font-weight: 700;
        letter-spacing: 0.1em;
        color: var(--wsj-gold);
        text-transform: uppercase;
      }
      .entry-kind {
        font-family: var(--font-sans);
        font-size: 12.5px;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--text-dim);
        border: 1px solid var(--border);
        border-radius: 2px;
        padding: 2px 9px;
      }
      .entry h3 {
        margin: 0 0 14px 0;
      }
      .field {
        margin: 16px 0;
        font-family: var(--font-sans);
        font-size: 16.5px;
        line-height: 1.65;
      }
      .field > .label {
        display: block;
        font-size: 12.5px;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--text-dim);
        margin-bottom: 5px;
      }
      .field > p {
        margin: 0;
      }
      .field > p + p {
        margin-top: 1em;
      }
      .field > ul {
        margin: 8px 0 0 1.25em;
        padding: 0;
      }
      .field > ul > li {
        margin: 0;
      }
      /* The defective characters themselves, marked inside a source excerpt. */
      .defect {
        background: rgba(183, 28, 28, 0.16);
        box-shadow: inset 0 -2px 0 var(--danger, #b71c1c);
        padding: 1px 2px;
        border-radius: 2px;
        font-weight: 600;
      }
      .correct {
        background: rgba(46, 125, 50, 0.16);
        box-shadow: inset 0 -2px 0 var(--success, #2e7d32);
        padding: 1px 2px;
        border-radius: 2px;
        font-weight: 600;
      }
      .part-head {
        border-top: 4px double var(--wsj-gold);
        margin: 64px 0 0 0;
        padding-top: 26px;
      }
      .part-head .part-label {
        font-family: var(--font-sans);
        font-size: 12.5px;
        font-weight: 700;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: var(--wsj-gold);
      }
      .part-head h2 {
        margin: 6px 0 10px 0;
      }
      .part-head p {
        font-family: var(--font-sans);
        font-size: 16.5px;
        line-height: 1.65;
        margin: 0;
      }
      .part-head p + p {
        margin-top: 1em;
      }
      /* Groups entries by the part of the page they concern. */
      .group-head {
        font-family: var(--font-sans);
        font-size: 13px;
        font-weight: 700;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: var(--text-dim);
        border-bottom: 1px solid var(--border);
        margin: 54px 0 -18px 0;
        padding-bottom: 8px;
      }
      /* One-line context sentence introducing an individual source excerpt. */
      .example-lead {
        font-family: var(--font-sans);
        font-size: 15.5px;
        line-height: 1.6;
        color: var(--text);
        margin: 20px 0 -10px 0;
      }

/* Comparison table (same style as the other engineering posts) */
.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-2 .comparison-row {
  grid-template-columns: 1fr 1.4fr;
}

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

@media (max-width: 640px) {
  .comparison-row {
    grid-template-columns: 1fr;
  }
}
