/* ===== Long-form posts (Distill-style) — loaded after style.css ===== */

.hero { border-bottom: 1px solid var(--rule); padding: 2.6rem 1.5rem 1.4rem; }
.hero-in { max-width: 1080px; margin: 0 auto; }
.kicker { color: var(--accent); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; margin-bottom: .5rem; }
.hero h1 { font-size: 2.3rem; line-height: 1.14; letter-spacing: -.03em; max-width: 860px; margin: 0 0 .7rem; }
.dek { font-size: 1.1rem; color: var(--muted); max-width: 720px; margin: 0; }
.meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin: 1.5rem 0 0; font-size: .86rem; }
.meta .k { color: var(--faint); text-transform: uppercase; font-size: .68rem; letter-spacing: .08em; margin-bottom: .15rem; }

.series { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1.4rem; }
.series a { font-size: .8rem; border: 1px solid var(--rule); border-radius: 999px; padding: .15rem .75rem; color: var(--muted); }
.series a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.series a.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.layout { max-width: 1080px; margin: 0 auto; padding: 2.2rem 1.5rem 4rem; display: grid; grid-template-columns: 200px minmax(0, 700px); gap: 2.6rem; }
.layout.notoc { grid-template-columns: minmax(0, 760px); }

.toc { position: sticky; top: 4.6rem; align-self: start; font-size: .82rem; max-height: calc(100vh - 6rem); overflow-y: auto; }
.toc-h { color: var(--faint); text-transform: uppercase; font-size: .68rem; letter-spacing: .08em; margin-bottom: .5rem; }
.toc a { display: block; color: var(--muted); padding: .22rem 0 .22rem .7rem; border-left: 2px solid var(--rule); line-height: 1.35; }
.toc a.l2 { color: var(--faint); margin-top: .5rem; }
.toc a:hover, .toc a.cur { color: var(--ink); border-color: var(--accent); text-decoration: none; }

/* article typography */
.article { min-width: 0; }
.article h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 2.6rem 0 .8rem; border: 0; padding: 0; }
.article h3 { font-size: 1.35rem; line-height: 1.3; letter-spacing: -.015em; margin: 2.4rem 0 .7rem; padding-top: 1.4rem; border-top: 1px solid var(--rule); }
.article h2 + h3 { border-top: 0; padding-top: 0; margin-top: 1rem; }
.article h4 { font-size: 1.06rem; margin: 1.8rem 0 .5rem; }
.article h5 { font-size: .95rem; margin: 1.4rem 0 .4rem; color: var(--muted); }
.article h2, .article h3, .article h4, .article h5 { scroll-margin-top: 4.6rem; }
.article ul, .article ol { padding-left: 1.3rem; margin: .4rem 0 1rem; }
.article li { margin: .25rem 0; }
.article li > ul, .article li > ol { margin: .2rem 0 .3rem; }
.article code { font-size: .86em; background: var(--accent-soft); border-radius: 4px; padding: .05em .3em; }
.article pre { background: var(--accent-soft); border-radius: 8px; padding: .9rem 1rem; overflow-x: auto; font-size: .85rem; }
.article pre code { background: none; padding: 0; }
.article img { max-width: 100%; height: auto; display: block; margin: 1rem auto; background: #fff; border-radius: 8px; padding: .5rem; }
.article blockquote { margin: 1rem 0; padding: .2rem 1rem; border-left: 3px solid var(--rule); color: var(--muted); }
.article table { border-collapse: collapse; width: 100%; font-size: .88rem; margin: 1rem 0 1.4rem; display: block; overflow-x: auto; }
.article th, .article td { padding: .4rem .6rem; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: top; }
.article th { font-weight: 600; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: .3rem 0; }

.primer { border-left: 3px solid #c08a00; background: color-mix(in srgb, #f5c400 12%, transparent); padding: .6rem .9rem; border-radius: 0 6px 6px 0; font-size: .9rem; }

.daycards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; margin: 0 0 2rem; }
.daycards a { border: 1px solid var(--rule); border-radius: 10px; padding: .8rem .9rem; color: var(--ink); transition: border-color .15s, transform .15s; }
.daycards a:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.daycards .dn { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: .3rem; }
.daycards .dt { font-size: .9rem; font-weight: 600; line-height: 1.35; }

.prevnext { display: flex; justify-content: space-between; gap: 1rem; margin: 3rem 0 1rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); font-weight: 600; }
.disclaimer { color: var(--faint); font-size: .8rem; }

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero h1 { font-size: 1.8rem; }
}
.article pre.mermaid { background: transparent; text-align: center; padding: .5rem 0; overflow-x: auto; }
.article { overflow-x: clip; }  /* hidden KaTeX MathML can widen the page on phones */
.article, .article .katex { position: relative; }  /* keep KaTeX MathML inside clipping ancestors */

/* standalone posts: facts card + embedded PDF */
.facts { display: grid; grid-template-columns: 8rem 1fr; gap: .35rem 1rem; border: 1px solid var(--rule); border-radius: 10px; padding: 1rem 1.2rem; font-size: .9rem; margin: 0 0 2rem; }
.facts .k { color: var(--faint); }
.pdfview { border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; height: min(88vh, 1100px); background: var(--rule); }
.pdfview iframe { width: 100%; height: 100%; border: 0; display: block; }
.pdf-fallback { color: var(--faint); font-size: .82rem; margin-top: .5rem; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; } .facts .k { margin-top: .4rem; } .pdfview { height: 70vh; } }

/* lead figure */
.cover { margin: -0.6rem 0 2rem; }
.cover img { width: 100%; height: auto; display: block; border: 1px solid var(--rule); border-radius: 10px; padding: 0; margin: 0; background: #fff; }
.cover figcaption { color: var(--faint); font-size: .82rem; margin-top: .5rem; line-height: 1.45; }
