/* Article page styles - shared across all article pages */

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

:root {
  --navy:       #06182A;
  --navy-mid:   #0F1C2E;
  --navy-light: #172840;
  --teal:       #2DD4BF;
  --teal-dim:   #1FA8A8;
  --teal-faint: rgba(45,212,191,0.08);
  --off-white:  #F0EDE6;
  --muted:      #8FA8BC;
  --border:     rgba(45,212,191,0.15);
  --font-serif: 'Spectral', Georgia, serif;
  --font-sans:  'IBM Plex Sans', system-ui, sans-serif;
  --font-mono:  'IBM Plex Mono', monospace;
  /* Syntax highlighting tokens */
  --code-comment: #64798C;
  --code-string:  #E3C588;
  --code-key:     #5EEAD4;
  --code-number:  #9CC0E8;
  --code-flag:    #8FA8BC;
  --code-prompt:  #64798C;
  --code-cmd:     #2DD4BF;
  --code-output:  #AFBFCC;
  --amber:        #E3C588;
  --toc-link:     #A9BECD;
  --measure:      44rem;   /* article prose column (~70ch) */
}

[data-theme="light"] {
  --navy:       #F5F7FA;
  --navy-mid:   #FFFFFF;
  --navy-light: #EBF0F5;
  --teal:       #0F7B6C;
  --teal-dim:   #0D6B5E;
  --teal-faint: rgba(15,123,108,0.08);
  --off-white:  #1A2B3C;
  --muted:      #4A6580;
  --border:     rgba(15,123,108,0.15);
  --code-comment: #8295A8;
  --code-string:  #9A6700;
  --code-key:     #0F7B6C;
  --code-number:  #1A5FA8;
  --code-flag:    #4A6580;
  --code-prompt:  #8295A8;
  --code-cmd:     #0D6B5E;
  --code-output:  #54677A;
  --amber:        #9A6700;
  --toc-link:     #5A7488;
}

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  background: var(--navy);
  color: var(--off-white);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

body > nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(1.5rem, 5vw, 4rem);
  height: 64px;
  background: rgba(6,24,42,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 0.5px solid var(--border);
}
[data-theme="light"] body > nav { background: rgba(245,247,250,0.85); }
.nav-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-logo-text { font-family: var(--font-serif); font-size: 17px; font-weight: 600; color: var(--off-white); letter-spacing: 0.01em; }
.nav-right { display: flex; align-items: center; gap: 2rem; }
.nav-links { display: flex; align-items: center; gap: 2rem; list-style: none; }
.nav-links a { font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none; letter-spacing: 0.03em; transition: color 0.2s; }
.nav-links a:hover { color: var(--off-white); }

.theme-toggle { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; background: transparent; border: 0.5px solid var(--border); border-radius: 4px; cursor: pointer; transition: border-color 0.15s; }
.theme-toggle:hover { border-color: rgba(45,212,191,0.4); }
[data-theme="light"] .theme-toggle:hover { border-color: rgba(15,123,108,0.4); }
.theme-toggle svg { width: 16px; height: 16px; color: var(--muted); transition: color 0.15s; }
.theme-toggle:hover svg { color: var(--off-white); }
.theme-icon-sun, .theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun, :root:not([data-theme]) .theme-icon-sun { display: block; }
[data-theme="light"] .theme-icon-moon { display: block; }

.article-wrapper { padding-top: 64px; }
.article-header { padding: clamp(3rem, 8vw, 6rem) clamp(1.5rem, 5vw, 4rem) clamp(2rem, 4vw, 3rem); max-width: var(--measure); margin: 0 auto; }
.article-meta { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.article-tag { font-family: var(--font-mono); font-size: 11px; color: var(--teal); background: var(--teal-faint); border: 0.5px solid rgba(45,212,191,0.2); padding: 4px 10px; border-radius: 3px; letter-spacing: 0.06em; text-transform: uppercase; }
.article-date { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.article-title { font-family: var(--font-serif); font-size: clamp(2rem, 5vw, 3rem); font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; color: var(--off-white); margin-bottom: 1.5rem; }
.article-excerpt { font-size: 1.125rem; color: var(--muted); line-height: 1.7; max-width: 640px; }

.article-content { padding: 0 clamp(1.5rem, 5vw, 4rem) clamp(4rem, 8vw, 6rem); max-width: var(--measure); margin: 0 auto; font-size: 1.0625rem; }
.article-content h2 { font-family: var(--font-serif); font-size: 1.9rem; font-weight: 600; letter-spacing: -0.02em; color: var(--off-white); margin: 3.5rem 0 1.25rem; line-height: 1.25; scroll-margin-top: 84px; }
.article-content h3 { font-family: var(--font-serif); font-size: 1.45rem; font-weight: 600; letter-spacing: -0.01em; color: var(--off-white); margin: 2.5rem 0 1rem; line-height: 1.3; scroll-margin-top: 84px; }
.article-content p { margin-bottom: 1.6rem; color: var(--off-white); line-height: 1.75; }
.article-content ul, .article-content ol { margin-bottom: 1.5rem; padding-left: 1.5rem; }
.article-content li { margin-bottom: 0.6rem; color: var(--off-white); line-height: 1.75; }
.article-content strong { font-weight: 500; color: var(--off-white); }
.article-content em { font-style: italic; }
.article-content a { color: var(--teal); text-decoration: none; border-bottom: 1px solid rgba(45,212,191,0.3); transition: border-color 0.2s; }
.article-content a:hover { border-color: var(--teal); }
.article-content hr { border: none; border-top: 0.5px solid var(--border); margin: 3rem 0; }

.article-content code { font-family: var(--font-mono); font-size: 0.9em; background: var(--navy-mid); padding: 0.2em 0.4em; border-radius: 3px; border: 0.5px solid var(--border); }
.article-content pre { background: var(--navy-mid); border: 0.5px solid var(--border); border-radius: 6px; padding: 1.25rem 1.5rem; overflow-x: auto; margin-bottom: 1.5rem; }
.article-content pre code { background: none; border: none; padding: 0; font-size: 0.875rem; line-height: 1.6; color: var(--off-white); }

/* Enhanced code blocks (built by /js/code.js) */
.article-content .code-block { margin: 0 0 1.75rem; border: 0.5px solid var(--border); border-radius: 6px; background: var(--navy-mid); overflow: hidden; }
.article-content .code-block pre { border: none; border-radius: 0; margin: 0; background: none; }
.code-block-header { display: flex; align-items: center; justify-content: space-between; padding: 0.45rem 1rem 0.45rem 1.5rem; border-bottom: 0.5px solid var(--border); }
.code-block-lang { font-family: var(--font-mono); font-size: 10px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.code-copy { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); background: transparent; border: none; padding: 4px 6px; border-radius: 3px; cursor: pointer; letter-spacing: 0.03em; transition: color 0.15s; }
.code-copy:hover { color: var(--off-white); }
.code-copy.copied { color: var(--teal); }
.code-copy svg { width: 13px; height: 13px; }

/* Syntax tokens */
.tok-c   { color: var(--code-comment); font-style: italic; }
.tok-s   { color: var(--code-string); }
.tok-k   { color: var(--code-key); }
.tok-n   { color: var(--code-number); }
.tok-f   { color: var(--code-flag); }
.tok-p   { color: var(--code-prompt); }
.tok-cmd { color: var(--code-cmd); }
.tok-out { color: var(--code-output); }

/* Callouts */
.callout { border: 0.5px solid var(--border); border-left: 2px solid var(--teal); border-radius: 4px; background: var(--teal-faint); padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
.callout-label { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--teal); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.5rem; }
.callout p { margin-bottom: 1rem; }
.callout p:last-child { margin-bottom: 0; }
.callout-warning { border-left-color: var(--amber); background: rgba(227,197,136,0.06); }
.callout-warning .callout-label { color: var(--amber); }
[data-theme="light"] .callout-warning { background: rgba(154,103,0,0.06); }

/* Tables */
.article-content table { width: 100%; border-collapse: collapse; margin: 0 0 1.75rem; font-size: 0.95rem; line-height: 1.6; }
.article-content th { text-align: left; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border-bottom: 0.5px solid var(--border); padding: 0.6rem 0.9rem; }
.article-content td { padding: 0.6rem 0.9rem; border-bottom: 0.5px solid var(--border); vertical-align: top; }

/* Reading-progress bar */
.reading-progress { position: fixed; top: 0; left: 0; height: 2px; background: var(--teal); z-index: 200; width: 0; transition: width 0.1s linear; }

/* Heading anchors */
.heading-anchor { margin-left: 0.4em; color: var(--muted); opacity: 0; text-decoration: none; border-bottom: none; transition: opacity 0.15s, color 0.15s; }
.article-content h2:hover .heading-anchor, .article-content h3:hover .heading-anchor { opacity: 1; }
.heading-anchor:hover { color: var(--teal); border-bottom: none; }

/* Sticky side table of contents.
   The prose column stays centred (max-width: var(--measure), margin auto).
   The TOC is fixed just to the right of that centred column, anchored to the
   viewport centre so it tracks the column at any width. Half the column is
   22rem; we add a 2rem gap → 24rem offset from centre. Shown only when there
   is room for column + gap + TOC without clipping (≥1280px). */
.article-toc { display: none; }
@media (min-width: 1280px) {
  .article-toc {
    display: block;
    position: fixed; top: 104px; left: calc(50% + 24rem); right: auto;
    width: 200px; height: auto; z-index: 90;
    max-height: calc(100vh - 140px); overflow-y: auto;
    padding: 0 0 0 1.25rem; border-left: 0.5px solid var(--border);
    border-bottom: none; background: none; backdrop-filter: none;
  }
  .article-toc-label { display: block; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 1rem; }
  .article-toc ul { list-style: none; margin: 0; padding: 0; }
  .article-toc li { margin: 0; }
  .article-toc a { display: block; font-family: var(--font-mono); font-size: 12px; line-height: 1.45; color: var(--toc-link); text-decoration: none; border-left: 2px solid transparent; margin-left: -1.25rem; padding: 0.35rem 0 0.35rem 1.25rem; transition: color 0.15s, border-color 0.15s; }
  .article-toc a:hover { color: var(--off-white); }
  .article-toc a.toc-h3 { padding-left: 2rem; font-size: 11.5px; }
  .article-toc a.active { color: var(--teal); border-left-color: var(--teal); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .article-toc a { transition: none; }
}

.back-link { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); text-decoration: none; letter-spacing: 0.03em; transition: color 0.2s; margin-bottom: 2rem; }
.back-link:hover { color: var(--teal); }
.back-link svg { width: 14px; height: 14px; }

footer { border-top: 0.5px solid var(--border); padding: 2.5rem clamp(1.5rem, 5vw, 4rem); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.footer-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.footer-brand span { font-family: var(--font-serif); font-size: 15px; color: var(--muted); }
.footer-brand strong { color: var(--off-white); font-weight: 600; }
.footer-right { font-family: var(--font-mono); font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 1.5rem; }
.footer-right a { color: var(--muted); text-decoration: none; transition: color 0.2s; }
.footer-right a:hover { color: var(--teal); }

@media (max-width: 768px) {
  .nav-links { display: none; }

  .article-header { padding: clamp(2.5rem, 8vw, 3.5rem) 1.25rem 1.5rem; }
  .article-content { padding: 0 1.25rem clamp(3rem, 8vw, 4rem); font-size: 1rem; }
  .article-content p, .article-content li { line-height: 1.7; }
  .article-content h2 { font-size: 1.5rem; margin: 2.5rem 0 1rem; }
  .article-content h3 { font-size: 1.25rem; margin: 2rem 0 0.75rem; }

  .article-content pre { padding: 1rem; }
  .article-content pre code { font-size: 0.8rem; }
  .code-block-header { padding-left: 1rem; }

  .article-content table { display: block; overflow-x: auto; font-size: 0.875rem; }
  .article-content th, .article-content td { padding: 0.5rem 0.7rem; white-space: nowrap; }

  .heading-anchor { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ARTICLE VISUAL COMPONENTS
   On-brand blocks used inside .article-content (feature grid, comparison
   table, component-flow diagram). Theme-aware via the variables above.
   ═══════════════════════════════════════════════════════════════════════════ */
:root  { --rust: #E07A5F; --rust-faint: rgba(224,122,95,0.14); }
[data-theme="light"] { --rust: #C2552F; --rust-faint: rgba(194,85,47,0.12); }

/* Definition lead box */
.article-content .def-box { border: 0.5px solid var(--border); border-left: 2px solid var(--teal); border-radius: 6px; background: var(--teal-faint); padding: 1.25rem 1.5rem; margin: 0 0 1.75rem; }
.article-content .def-box p { margin: 0; font-size: 1.05rem; line-height: 1.6; }
.article-content .def-box strong { color: var(--teal); }

/* Feature grid (2×2) */
.feature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin: 0 0 1.75rem; }
.feature-card { border: 0.5px solid var(--border); border-radius: 8px; background: var(--navy-mid); padding: 1.2rem 1.3rem; }
.feature-card .fc-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.55rem; }
.feature-check { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--teal); color: var(--navy); }
.feature-check svg { width: 16px; height: 16px; }
.feature-card h4 { font-family: var(--font-sans); font-size: 1.02rem; font-weight: 600; color: var(--off-white); margin: 0; line-height: 1.3; }
.feature-card p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }

/* Comparison table — Ingress vs Gateway API */
.article-content table.gw-compare { table-layout: fixed; }
.gw-compare thead th { border: none; border-bottom: 0.5px solid var(--border); text-transform: none; padding: 0 0.5rem 0.85rem; vertical-align: bottom; }
.gw-compare thead th:first-child { padding-left: 0; }
.gw-compare .pill { display: block; text-align: center; font-family: var(--font-sans); font-weight: 600; font-size: 0.92rem; letter-spacing: 0; padding: 0.5rem 0.75rem; border-radius: 999px; }
.gw-compare .pill-x  { background: var(--rust); color: #fff; }
.gw-compare .pill-ok { background: var(--teal); color: var(--navy); }
.gw-compare tbody td { vertical-align: top; color: var(--muted); }
.gw-compare td.aspect { color: var(--off-white); font-weight: 600; }
.gw-compare .mark { font-weight: 700; margin-right: 0.45rem; }
.gw-compare .mark-x  { color: var(--rust); }
.gw-compare .mark-ok { color: var(--teal); }

/* Core components — role flow + detail cards */
.flow { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 1.5rem; }
.flow-node { flex: 1 1 0; min-width: 130px; border: 0.5px solid var(--border); border-radius: 8px; background: var(--navy-mid); padding: 0.85rem 0.9rem; text-align: center; }
.flow-node .fn-title { display: block; font-family: var(--font-sans); font-weight: 600; color: var(--off-white); font-size: 0.95rem; }
.flow-node .fn-role { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--teal); margin-top: 0.3rem; }
.flow-arrow { flex: none; color: var(--muted); display: inline-flex; }
.flow-arrow svg { width: 18px; height: 18px; }

.component-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 0 0 1.75rem; }
.component-card { border: 0.5px solid var(--border); border-radius: 8px; background: var(--navy-mid); padding: 1.2rem 1.3rem; }
.component-card h4 { font-family: var(--font-serif); font-size: 1.15rem; color: var(--teal); margin: 0 0 0.8rem; }
.component-card ul { margin: 0; padding-left: 1.1rem; }
.component-card li { font-size: 0.88rem; color: var(--muted); line-height: 1.5; margin-bottom: 0.5rem; }
.component-card .rt-label { font-size: 0.82rem; color: var(--muted); margin: 0 0 0.6rem; }
.route-types { list-style: none; padding: 0; margin: 0; }
.route-types li { font-family: var(--font-mono); font-size: 0.8rem; color: var(--off-white); background: var(--navy); border: 0.5px solid var(--border); border-radius: 5px; padding: 0.4rem 0.7rem; margin-bottom: 0.45rem; }

@media (max-width: 768px) {
  .feature-grid { grid-template-columns: 1fr; }
  .component-cards { grid-template-columns: 1fr; }
  .flow { flex-direction: column; align-items: stretch; }
  .flow-node { width: 100%; }
  .flow-arrow { align-self: center; transform: rotate(90deg); }
}
