/* Blog articles — loaded after site.css on article pages only.
   Everything is scoped under .article so it never affects the rest of the site.
   Covers both article templates: newer (.page / .post-header / .toc / .post-content)
   and older (.container / .blog-header / article / .terminal / .note …). */

.article {
  --a-text: #2a2a2a;
  --a-code-bg: #141414;
  --a-code-text: #e4e4e4;
  --a-inline-bg: #f4f4f4;
  --blue: #2f6fd6;
  --blue-tint: #f2f7ff;
  --green: #2f9e44;
  --green-tint: #f1faf3;
  --yellow: #b7791f;
  --yellow-tint: #fffaeb;
  padding-bottom: 32px;
}

/* ── Layout ───────────────────────────────────────────── */
.article .page,
.article .container,
.article .crumbs,
.article .article-end {
  max-width: 780px; margin: 0 auto; padding-left: 24px; padding-right: 24px; width: auto;
}
.article .container { padding-top: 0; padding-bottom: 0; }
.article .crumbs { padding-top: 36px; font: 13px var(--mono); color: var(--muted); }
.article .crumbs a { color: var(--red); }
.article .crumbs a:hover { text-decoration: underline; }
.article .page > *, .article .container > * { max-width: 100%; }

/* ── Article header (both templates) ──────────────────── */
.article .post-header,
.article .blog-header {
  background: none; color: var(--ink); padding: 28px 0 32px; margin-bottom: 36px; border-bottom: 1px solid var(--line);
}
.article .post-header h1,
.article .blog-header h1,
.article .blog-title {
  font-size: clamp(32px, 4.4vw, 46px); line-height: 1.1; letter-spacing: -.035em; font-weight: 800; color: var(--ink); margin: 18px 0 18px;
}
.article .post-header .lead,
.article .post-intro,
.article .blog-header .subtitle { font-size: 19px; line-height: 1.65; color: var(--muted); opacity: 1; max-width: none; }
.article .post-meta, .article .blog-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font: 13px/1.5 var(--mono); color: var(--muted); margin-bottom: 4px;
}
.article .post-date { font: 13px var(--mono); color: var(--muted); }
.article .tag, .article .badge {
  display: inline-block; font: 600 12px/1.4 var(--mono); letter-spacing: 0; text-transform: none;
  color: var(--red); background: #fff; border: 1px solid var(--line); padding: 3px 9px; border-radius: 4px;
}
.article .banner-image { width: 100%; height: 360px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); margin: 24px 0 0; }

/* ── Table of contents ────────────────────────────────── */
.article .toc { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 22px 26px; margin: 0 0 40px; }
.article .toc h3 { font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; }
.article .toc ol, .article .toc ul { padding-left: 20px; margin: 0; }
.article .toc li { font-size: 15px; margin-bottom: 6px; color: var(--ink); }
.article .toc a { color: var(--ink); }
.article .toc a:hover { color: var(--red); }

/* ── Typography ───────────────────────────────────────── */
.article .post-content, .article article { color: var(--a-text); font-size: 17px; line-height: 1.75; }
.article h2 {
  font-size: 28px; line-height: 1.25; letter-spacing: -.025em; font-weight: 800; color: var(--ink);
  margin: 56px 0 16px; padding-top: 28px; border-top: 1px solid var(--line);
}
.article .post-content > h2:first-child, .article article > h2:first-child { margin-top: 8px; padding-top: 0; border-top: 0; }
.article h3 { font-size: 21px; line-height: 1.3; letter-spacing: -.015em; font-weight: 700; color: var(--ink); margin: 36px 0 10px; }
.article h4 { font: 600 13px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 8px; }
.article p { margin: 0 0 18px; }
.article ul, .article ol { padding-left: 24px; margin: 0 0 18px; }
.article li { margin-bottom: 6px; }
.article li::marker { color: var(--red); }
.article strong, .article b { color: var(--ink); font-weight: 700; }
.article em { color: inherit; }
.article a { color: var(--red); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.article a:hover { color: var(--red-dark); }
.article hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
.article img { max-width: 100%; height: auto; }
.article .post-content img, .article article img, .article .blog-image { width: 100%; border-radius: 8px; border: 1px solid var(--line); margin: 24px 0; }
.article .image-caption { text-align: center; font: 13px var(--mono); color: var(--muted); margin: -12px 0 24px; }
.article .image-placeholder { margin: 24px 0; }

/* ── Code ─────────────────────────────────────────────── */
.article code { font: .86em var(--mono); background: var(--a-inline-bg); color: var(--red-dark); padding: 2px 6px; border-radius: 4px; border: 1px solid #ececec; }
.article pre, .article .terminal, .article .command {
  background: var(--a-code-bg); color: var(--a-code-text); border: 0; border-radius: 10px;
  padding: 20px 22px; margin: 24px 0; overflow-x: auto; font: 14px/1.7 var(--mono);
}
.article .terminal, .article .command { white-space: pre-wrap; word-break: break-word; }
.article pre code, .article .terminal code { background: none; color: inherit; padding: 0; border: 0; font-size: inherit; }
.article pre a, .article .terminal a { color: #ff8a96; }
.article .hl-key { color: #c678dd; }
.article .hl-val, .article .hl-str { color: #98c379; }
.article .hl-com { color: #7f848e; font-style: italic; }
.article .hl-url, .article .hl-fn { color: #61afef; }
.article .hl-num { color: #d19a66; }

/* ── Callouts ─────────────────────────────────────────── */
.article .callout, .article .note, .article .warning, .article .tip, .article .danger, .article .info-box {
  border-radius: 8px; padding: 16px 20px; margin: 28px 0; font-size: 16px; border: 1px solid var(--line); color: var(--a-text);
}
.article .callout > :last-child, .article .note > :last-child, .article .warning > :last-child,
.article .tip > :last-child, .article .danger > :last-child, .article .info-box > :last-child { margin-bottom: 0; }
.article .callout > strong:first-child { display: block; margin-bottom: 4px; font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.article .callout-red, .article .danger { background: var(--red-tint); }
.article .callout-blue, .article .note, .article .info-box { background: var(--blue-tint); }
.article .callout-yellow, .article .warning { background: var(--yellow-tint); }
.article .callout-green, .article .tip { background: var(--green-tint); }
.article .callout-red strong, .article .danger strong { color: var(--red); }
.article .callout-blue strong, .article .note strong, .article .info-box strong { color: var(--blue); }
.article .callout-yellow strong, .article .warning strong { color: var(--yellow); }
.article .callout-green strong, .article .tip strong { color: var(--green); }

/* ── Cards & blocks used in specific posts ────────────── */
.article .attack { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin: 32px 0; overflow: hidden; }
.article .attack-header { background: var(--soft); padding: 14px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.article .attack-number { font: 600 12px var(--mono); color: #fff; background: var(--red); padding: 2px 8px; border-radius: 4px; }
.article .attack-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.article .attack-body { padding: 20px 22px; }
.article .attack-body > :last-child { margin-bottom: 0; }

.article .section, .article .content-section { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 28px; margin: 0 0 24px; }

.article .steps { display: block; counter-reset: step; list-style: none; padding: 0; margin: 16px 0 20px; border: 0; background: none; }
/* Numbered steps. Items stay normal text (no flex), so a step mixing words, code and links wraps like a paragraph */
.article .steps ol, .article .steps ul { list-style: none; padding: 0; margin: 0; }
.article .steps li { counter-increment: step; position: relative; display: block; margin-bottom: 12px; padding: 0 0 0 38px; border: 0; min-height: 28px; }
.article .steps li::before {
  content: counter(step); position: absolute; left: 0; top: 1px; width: 26px; height: 26px; border-radius: 50%; background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center; font: 600 12px var(--mono);
}
.article .roadmap { padding-left: 0; list-style: none; counter-reset: roadmap; }
.article .roadmap-step { counter-increment: roadmap; position: relative; padding: 18px 20px 18px 60px; margin-bottom: 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.article .roadmap-step::before {
  content: counter(roadmap); position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%; background: var(--red); color: #fff; font: 700 12px var(--mono);
  display: flex; align-items: center; justify-content: center;
}

.article .fix-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 12px; margin: 20px 0; }
.article .fix-item { min-width: 0; background: #fff; border: 1px solid var(--line); padding: 16px 18px; border-radius: 8px; }
.article .fix-item h4 { color: var(--ink); margin: 0 0 6px; }
.article .fix-item > strong:first-child { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.article .fix-item p { font-size: 15px; color: var(--muted); margin: 0; }

.article .network-diagram, .article .diagram {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px;
  margin: 28px 0; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 24px;
}
.article .diagram { display: block; }
.article .diagram-title { font: 600 13px var(--mono); color: var(--muted); margin-bottom: 12px; }
.article .network-node { text-align: center; padding: 14px 18px; background: #fff; border: 1px solid var(--line); border-radius: 8px; min-width: 100px; font-size: 15px; }
.article .network-node .node-label { font-size: 13px; color: var(--muted); }
.article .network-arrow { font-size: 22px; color: var(--muted); padding: 0 6px; }
.article .mitm-node { border: 2px solid var(--red) !important; background: var(--red-tint) !important; }
.article .mitm-node .node-label { color: var(--red) !important; }

.article td small { font: 12px var(--mono); color: var(--muted); }

/* SVG network diagrams (.nn): Tier-1 red, content provider blue, IXP black, regional/access grey */
.article .diagram-scroll { overflow-x: auto; }
.article .nn { display: block; width: 100%; height: auto; max-width: 720px; margin: 0 auto; font-family: var(--font); }
.article .nn text { text-anchor: middle; }
.article .nn .nn-left { text-anchor: start; }
.article .nn-lbl { font-size: 15px; font-weight: 700; fill: var(--ink); }
.article .nn-sub { font-size: 12px; fill: var(--muted); }
.article .nn-tiny { font-size: 11px; fill: var(--muted); font-family: var(--mono); text-anchor: start !important; }
.article .nn-cap { font-size: 13px; font-weight: 600; fill: var(--ink); font-family: var(--mono); }
.article .nn .nn-w { fill: #fff; }
.article .nn .nn-sub.nn-w { fill: rgba(255, 255, 255, .8); }
.article .nn .nn-dark { fill: var(--ink); font-weight: 600; }
.article .nn-t1 { fill: var(--red); }
.article .nn-cp { fill: var(--blue); }
.article .nn-ixp { fill: var(--black); }
.article .nn-reg { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.article .nn-acc, .article .nn-dc { fill: #fff; stroke: #b9b9b9; stroke-width: 1.5; }
.article .nn-dc { stroke: var(--blue); }
.article .nn-dev { fill: var(--soft); stroke: #d4d4d4; }
.article .nn-link line, .article .nn-mesh line { stroke: #8a8a8a; stroke-width: 2; }
.article .nn-peer line { stroke: var(--red); stroke-dasharray: 6 5; }
.article .nn-priv line { stroke: var(--blue); stroke-width: 3; }
.article .nn-ok line { stroke: var(--red); }
.article .nn-dot circle { fill: #fff; stroke: var(--ink); stroke-width: 2; }
.article .nn-mesh line { stroke: #c4c4c4; }
.article .nn-ok line { stroke: var(--red); stroke-width: 2; }
.article .diagram-hint { display: none; font: 12px var(--mono); color: var(--muted); margin-top: -16px; }

/* Shapes used by the beginner diagrams */
.article .nn-soft { fill: var(--soft); stroke: #d4d4d4; stroke-width: 1.5; }
.article .nn-box { fill: #fff; stroke: #cfcfcf; stroke-width: 1.5; }
.article .nn-red { fill: var(--red); }
.article .nn-black { fill: var(--black); }
.article .nn-redt { fill: var(--red-tint); stroke: var(--red); stroke-width: 1.5; }
.article .nn-bluet { fill: var(--blue-tint); stroke: var(--blue); stroke-width: 1.5; }
.article .nn-cloud { fill: none; stroke: #b9b9b9; stroke-width: 2; stroke-dasharray: 6 5; }
.article .nn-empty { fill: #fff; stroke: #c9c9c9; stroke-dasharray: 4 3; }
.article .nn-ua { fill: var(--red); } .article .nn-ub { fill: var(--blue); } .article .nn-uc { fill: var(--black); } .article .nn-ud { fill: #8a8a8a; }
.article .nn-ua, .article .nn-ub, .article .nn-uc, .article .nn-ud { stroke: #fff; stroke-width: 2; }
.article .nn-slot text { font: 600 14px var(--mono); fill: #9a9a9a; }
.article .nn-slot-w text, .article .nn-slot .nn-on { fill: #fff; }
.article .nn-arrow line { stroke: var(--ink); stroke-width: 2; }
.article .nn-dim line { stroke: #c4c4c4; }
.article .nn-hl line { stroke: var(--red); stroke-width: 3; }
.article .nn-head { fill: var(--ink); } .article .nn-dim .nn-head { fill: #c4c4c4; }
.article .nn-head-red { fill: var(--red); }
.article .nn .nn-w-tiny { fill: #fff; font-weight: 600; }

/* Speed comparison bars */
.article .speed-bars { display: grid; gap: 10px; }
.article .speed-row { display: grid; grid-template-columns: 170px 1fr 84px; gap: 12px; align-items: center; font-size: 14px; }
.article .speed-row b { font: 600 13px var(--mono); text-align: right; }
.article .speed-bar { height: 14px; background: #ececec; border-radius: 7px; overflow: hidden; }
.article .speed-bar i { display: block; height: 100%; min-width: 10px; background: #9a9a9a; border-radius: 7px; }
.article .speed-bar i.max { background: var(--red); }

/* Delay breakdown bar */
.article .delay-bar { display: flex; height: 34px; border-radius: 6px; overflow: hidden; }
.article .delay-bar span { display: block; }
.article .d-check { background: var(--black); }
.article .d-wait { background: #8a8a8a; }
.article .d-push { background: var(--blue); }
.article .d-travel { background: var(--red); }
.article .delay-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; font: 12px var(--mono); color: var(--muted); }
.article .delay-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* Encapsulation diagram: headers stacking up as the packet goes down the layers */
.article .encap { display: grid; gap: 10px; }
.article .encap-row { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; }
.article .encap-row > span:first-child { font: 600 12px var(--mono); color: var(--muted); }
.article .encap-pkt { display: flex; flex-wrap: wrap; }
.article .encap-pkt b { font: 600 12px var(--mono); padding: 6px 10px; border: 1px solid rgba(0, 0, 0, .12); margin-left: -1px; }
.article .encap-pkt b:first-child { margin-left: 0; border-radius: 4px 0 0 4px; }
.article .encap-pkt b:last-child { border-radius: 0 4px 4px 0; }
.article .encap-pkt b:only-child { border-radius: 4px; }
.article .encap-pkt .m { background: #fff; color: var(--ink); }
.article .encap-pkt .t { background: var(--blue-tint); color: var(--blue); }
.article .encap-pkt .n { background: var(--yellow-tint); color: var(--yellow); }
.article .encap-pkt .l { background: var(--red-tint); color: var(--red); }

.article .workflow { margin: 20px 0; display: grid; gap: 8px; }
.article .workflow-step, .article .flow-step { position: relative; padding: 10px 14px 10px 40px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.article .workflow-step::before, .article .flow-step::before { content: "→"; position: absolute; left: 14px; top: 10px; color: var(--red); font-family: var(--mono); font-weight: 700; }
.article .flow-step { margin: 8px 0; }

.article .tooltip { position: relative; cursor: help; border-bottom: 1px dotted var(--muted); }
.article .tooltip .tooltiptext {
  visibility: hidden; opacity: 0; position: absolute; z-index: 10; bottom: 130%; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 280px; background: var(--black); color: #fff; font-size: 13px; line-height: 1.5;
  padding: 8px 12px; border-radius: 6px; transition: opacity .15s; pointer-events: none;
}
.article .tooltip:hover .tooltiptext, .article .tooltip:focus .tooltiptext { visibility: visible; opacity: 1; }
.article .tooltip[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: var(--black); color: #fff; font-size: 13px; padding: 6px 10px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 10;
}
.article .tooltip[data-tip]:hover::after { opacity: 1; }

/* ── Tables ───────────────────────────────────────────── */
.article table { width: 100%; border-collapse: collapse; margin: 24px 0; font-size: 15px; background: #fff; border: 1px solid var(--line); }
.article thead { background: var(--soft); }
.article th { padding: 10px 14px; text-align: left; font: 600 13px var(--mono); color: var(--ink); border-bottom: 1px solid var(--line); }
.article td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.article tbody tr:last-child td { border-bottom: 0; }
.article tbody tr:nth-child(even) { background: #fcfcfc; }

/* ── End of article ───────────────────────────────────── */
.article .article-end { margin-top: 56px; }
.article .article-end .box { padding: 32px; display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.article .article-end h2 { font-size: 24px; margin: 8px 0 6px; padding: 0; border: 0; }
.article .article-end p { color: var(--muted); margin: 0; font-size: 16px; }
.article .article-end .btn { color: #fff; text-decoration: none; flex-shrink: 0; }
.article .article-end .back { display: inline-block; margin-top: 18px; font: 13px var(--mono); }

/* ── Phones ───────────────────────────────────────────── */
@media (max-width: 760px) {
  .article .page, .article .container, .article .crumbs, .article .article-end { padding-left: 20px; padding-right: 20px; }
  /* bigger tap areas for the small text links */
  .article .crumbs { padding-top: 24px; }
  .article .crumbs a { display: inline-block; padding: 10px 0; }
  .article .article-end .back { padding: 10px 0; margin-top: 8px; }
  .article .post-date { text-wrap: pretty; }
  .article .crumbs { padding-top: 24px; }
  .article h2 { font-size: 24px; margin-top: 44px; }
  .article .post-content, .article article { font-size: 16px; }
  .article .page, .article .container { overflow-wrap: anywhere; }
  .article code { word-break: break-all; }
  .article pre code { word-break: normal; }
  .article pre, .article .terminal, .article .command { font-size: 13px; padding: 16px; border-radius: 8px; margin-left: -4px; margin-right: -4px; }
  .article table { display: block; overflow-x: auto; font-size: 14px; }
  .article th, .article td { overflow-wrap: normal; word-break: normal; } /* words stay whole; a wide table scrolls inside its box */
  .article th:first-child, .article td:first-child { white-space: nowrap; }
  .article .banner-image { height: 200px; }
  .article .fix-grid { grid-template-columns: 1fr !important; } /* beats a fixed inline column width in one post */
  .article .fix-grid.compact { grid-template-columns: 1fr 1fr !important; gap: 8px; }
  .article .fix-grid.compact .fix-item { padding: 12px; }
  .article .fix-grid.compact .fix-item p { font-size: 14px; }
  .article .network-diagram { flex-direction: column; }
  .article .network-arrow { transform: rotate(90deg); }
  .article .encap-row { grid-template-columns: 1fr; gap: 4px; }
  .article .diagram-scroll { padding: 16px; }
  .article .diagram-scroll .nn { min-width: 560px; }
  .article .diagram-scroll .nn-big { min-width: 620px; }
  .article .diagram-hint { display: block; }
  .article .speed-row { grid-template-columns: 1fr 64px; gap: 4px 10px; }
  .article .speed-row span { grid-column: 1 / -1; }
  .article .article-end .box { flex-direction: column; align-items: flex-start; padding: 24px; }
}
