/* Essay pages. Loaded after home.css, which supplies tokens, header, buttons and footer. */

.post-head { position: relative; padding: 72px 0 40px; overflow: hidden; }
.post-head::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 60% 70% at 30% 30%, #000 25%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 60% 70% at 30% 30%, #000 25%, transparent 75%);
}
.post-head .wrap { position: relative; }
.back { display: inline-block; color: var(--soft); font-size: 0.9rem; margin-bottom: 28px; }
.back:hover { color: var(--text); }
.post-head h1 {
  margin: 0; max-width: 22ch;
  font-size: clamp(2.1rem, 4.6vw, 3.4rem); line-height: 1.06;
  letter-spacing: -0.04em; font-weight: 600;
}
.post-head .dek { margin: 18px 0 0; max-width: 36em; color: var(--soft); font-size: 1.15rem; line-height: 1.55; }
.post-head .date { margin-top: 18px; color: var(--faint); font-size: 0.9rem; }

.post-figure { margin: 8px 0 0; }
.post-figure .flow { max-width: 820px; }
.post-figure figcaption { margin-top: 10px; color: var(--faint); font-size: 0.85rem; max-width: 820px; }

.prose { max-width: 680px; padding: 48px 0 24px; font-size: 1.0938rem; line-height: 1.75; }
.prose p { margin: 0 0 1.25em; color: color-mix(in srgb, var(--text) 88%, var(--soft)); }
.prose h2 { margin: 2.2em 0 0.7em; font-size: 1.5rem; letter-spacing: -0.025em; line-height: 1.25; font-weight: 600; }
.prose h3 { margin: 1.8em 0 0.5em; font-size: 1.15rem; letter-spacing: -0.015em; font-weight: 600; }
.prose strong { color: var(--text); font-weight: 600; }
.prose em { font-style: italic; }
.prose a { color: var(--blue); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--blue) 40%, transparent); text-underline-offset: 0.2em; }
.prose ul, .prose ol { margin: 0 0 1.25em; padding-left: 1.3em; }
.prose li { margin: 0.4em 0; color: color-mix(in srgb, var(--text) 88%, var(--soft)); }
.prose li::marker { color: var(--faint); }
.prose code { font: 0.88em var(--mono); background: var(--panel-solid); border: 1px solid var(--edge); border-radius: 6px; padding: 1px 6px; }
.prose hr { border: 0; border-top: 1px solid var(--edge); margin: 3em 0 2em; }

.author {
  max-width: 680px; margin: 0 0 96px;
  border: 1px solid var(--edge); border-radius: 16px; padding: 24px 26px;
  background: var(--panel-solid);
}
.author p { margin: 0; color: var(--soft); }
.author strong { color: var(--text); font-weight: 600; }
.author .cta { margin-top: 18px; }

/* Generic step diagram used on essay pages */
.steps .node rect { fill: var(--bg); stroke: var(--edge-strong); stroke-width: 1; transition: stroke 300ms, fill 300ms; }
.steps .node text { fill: var(--text); font: 600 12.5px var(--sans); }
.steps .node text.sub { fill: var(--faint); font: 400 10.5px var(--sans); }
.steps .node.hit rect { stroke: var(--blue); }
.steps .node.hit.ok rect { stroke: var(--green); fill: color-mix(in srgb, var(--green) 9%, var(--bg)); }
.steps .node.hit.wait rect { stroke: var(--amber); fill: color-mix(in srgb, var(--amber) 9%, var(--bg)); }
.steps .route { fill: none; stroke: var(--edge-strong); stroke-width: 1.25; stroke-dasharray: 3 5; }
.steps .packet { fill: var(--blue); filter: drop-shadow(0 0 6px var(--blue)); }

/* Writing index */
.list-head { padding: 72px 0 32px; }
.list-head h1 { margin: 0; font-size: clamp(2.1rem, 4.6vw, 3.2rem); letter-spacing: -0.04em; font-weight: 600; }
.list-head p { margin: 14px 0 0; color: var(--soft); max-width: 36em; font-size: 1.1rem; }
.list-body { padding-bottom: 96px; }

/* Two-column reading layout: prose plus a sticky outline */
.post-figure .flow { max-width: none; }
.post-figure figcaption { max-width: none; }
.post-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.prose { max-width: 720px; font-size: 1.125rem; }
.author { max-width: 720px; }
.toc { display: none; }
@media (min-width: 1080px) {
  .post-body { grid-template-columns: minmax(0, 720px) 240px; justify-content: space-between; gap: 64px; }
  .toc {
    display: block; position: sticky; top: 92px; align-self: start;
    margin-top: 52px; padding-left: 20px; border-left: 1px solid var(--edge);
  }
  .toc-title { margin: 0 0 12px; font-size: 0.85rem; color: var(--faint); }
  .toc nav { display: grid; gap: 2px; }
  .toc nav a {
    display: block; padding: 6px 0; font-size: 0.9rem; line-height: 1.35; color: var(--soft);
    position: relative; transition: color 150ms;
  }
  .toc nav a:hover { color: var(--text); }
  .toc nav a.on { color: var(--text); }
  .toc nav a.on::before {
    content: ""; position: absolute; left: -21px; top: 6px; bottom: 6px; width: 2px;
    background: var(--blue); border-radius: 2px;
  }
  .toc-meta { margin: 18px 0 0; font-size: 0.85rem; color: var(--faint); }
}
.prose h2 { scroll-margin-top: 84px; }
.post-figure { margin-left: 0; margin-right: 0; }
@media (max-width: 700px) { .post-figure svg.steps { min-width: 640px; } }
