/* Shared by /blog/ and every article. Tokens and nav mirror the inline styles in /index.html. */
:root {
  --ink:#1b1f24; --muted:#5b6570; --brand:#0b7a5b; --bg:#f7f8f6; --card:#fff; --line:#e4e7e3;
  --brand-soft:#dff3ea;
  --shadow: 0 1px 2px rgba(27,31,36,.06), 0 8px 24px rgba(27,31,36,.08);
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin:0; font-family: "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  color:var(--ink); line-height:1.8;
  background: radial-gradient(900px 520px at 85% -8%, #e3f2ec, rgba(227,242,236,0) 70%) no-repeat, var(--bg);
}
:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; border-radius: 4px; }
a { color: var(--brand); }
[id] { scroll-margin-top: 76px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Nav (same as /index.html) */
.navbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(247,248,246,.82); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid rgba(228,231,227,.8);
}
.nav { max-width: 1040px; margin: 0 auto; padding: 8px 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; min-width: 44px; color: var(--ink); font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.brand b { color: var(--brand); }
.dd-logo { width: 36px; height: 36px; display: block; border-radius: 9px; box-shadow: 0 4px 12px rgba(11,122,91,.28); }
.nav ul { display: flex; flex-wrap: wrap; gap: 2px; margin: 0; padding: 0; list-style: none; }
.nav ul a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: .95rem; text-decoration: none; white-space: nowrap; }
.nav ul a:hover, .nav ul a[aria-current] { color: var(--brand); background: var(--brand-soft); }
@media (max-width: 439px) {
  .brand span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .nav ul a { padding: 0 10px; }
}
@media (max-width: 359px) { .nav { padding: 8px 12px; gap: 6px; } .nav ul a { padding: 0 8px; } }
@media (max-width: 419px) { .nav-about { display: none; } } /* 4 links don't fit; same rule as /index.html */

main, footer { max-width: 760px; margin: 0 auto; padding: 0 20px; }
footer { color: var(--muted); font-size: .9rem; padding-top: 24px; padding-bottom: 32px; }
footer ul { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 8px; padding: 0; list-style: none; }
footer ul a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); }

/* Article */
.post { padding-top: 28px; }
.crumb { margin: 0 0 8px; font-size: .9rem; color: var(--muted); }
.crumb a { color: var(--muted); }
h1 { font-size: clamp(1.7rem, 4.6vw, 2.4rem); line-height: 1.35; margin: 0 0 12px; }
h1 span, h2 span { display: inline-block; } /* Thai has no spaces: keep each phrase on one line */
h1, h2 { overflow-wrap: anywhere; } /* long English words at 200% text on small phones */
article > p, article > ul, article > ol, .lead { max-width: 40em; } /* ~60–70 Thai chars a line */
.lead { font-size: 1.12rem; color: var(--muted); margin: 0 0 28px; }
h2 { font-size: 1.35rem; line-height: 1.4; margin: 40px 0 10px; }
h3 { font-size: 1.1rem; margin: 28px 0 6px; }
article p, article li { overflow-wrap: anywhere; }
article p, .lead { text-wrap: pretty; }
::selection { background: var(--brand-soft); color: var(--ink); }
.skip { position: absolute; left: 12px; top: -80px; z-index: 20; padding: 10px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 600; }
.skip:focus { top: 12px; }
/* "ในบทนี้": collapsed table of contents right after the lead */
.toc { margin: -12px 0 24px; max-width: 40em; }
.toc summary { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-weight: 600; cursor: pointer; }
.toc summary { list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: ""; width: 7px; height: 7px; margin: 0 2px 4px 12px; border-right: 2px solid var(--brand); border-bottom: 2px solid var(--brand); rotate: 45deg; }
.toc details[open] summary::after { rotate: 225deg; margin-bottom: -4px; }
.toc ol { margin: 10px 0 0; padding-left: 1.6em; }
.toc li + li { margin-top: 0; }
.toc a { display: block; padding: 10px 0; line-height: 1.5; }
pre:focus-visible { outline-offset: 2px; }
.author { display: flex; gap: 14px; align-items: center; margin: 40px 0 0; padding: 16px 18px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.author img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: none; }
.author p { margin: 0; color: var(--muted); font-size: .95rem; }
.author b { color: var(--ink); }
article li + li { margin-top: 4px; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .92em; background: var(--line); padding: .1em .35em; border-radius: 5px; }
pre { background: var(--ink); color: var(--bg); padding: 16px 18px; border-radius: 12px; overflow-x: auto; line-height: 1.55; font-size: .9rem; }
pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.note { background: var(--brand-soft); border-radius: 12px; padding: 14px 18px; margin: 20px 0; }
.note p { margin: 0; }
table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: .95rem; }
th, td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
th { background: var(--brand-soft); }
.books li { margin-bottom: 6px; }
.checklist li::marker { color: var(--brand); }

.trail { margin: 32px 0 0; padding: 12px 18px; border-radius: 12px; background: var(--brand-soft); }
.trail p { margin: 0; font-size: .93rem; }
.trail a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
.pager { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 12px; margin: 24px 0 8px; }
.pager a { display: block; min-height: 44px; padding: 12px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); font-weight: 600; }
.pager a:hover { border-color: var(--brand); }
.pager small { display: block; color: var(--muted); font-weight: 400; }
.pager .next { text-align: right; }

/* 3D teaching animation (CSS only).
   Stage coordinates: x right, y toward the viewer, z up. 1 unit = 1px on the floor.
   An element's base style is the still picture shown with reduced motion or before the first frame,
   so it must make sense on its own. Animate translate/rotate/scale/opacity/background, never `transform`
   (it holds the 3D placement). Per-article keyframes go in that page's own <style>.
   Colour meaning, same in every scene: #0b7a5b ok / done / result · #c23a43 fails / lost / too costly ·
   #2563eb in flight / being changed · #5b6570 idle / not yet · #1b1f24 actor (CPU, client, LLM).
   Never rely on colour alone: pair a red/green change with a tag, label or shape change.
   Markup: <figure class="anim"><figcaption>…</figcaption><div class="viewport" aria-hidden="true">…</div>
   <ol class="steps">…</ol><label class="anim-pause">…</label></figure>. Keep each step lit ≥ 3s. */
.anim { margin: 28px 0; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.anim .viewport { position: relative; height: var(--vh, 260px); perspective: 1000px; overflow: hidden; border-radius: 8px; background: var(--bg); }
.anim .stage { position: absolute; left: 50%; top: var(--sy, 56%); width: 0; height: 0; transform-style: preserve-3d; transform: rotateX(60deg) rotateZ(-22deg) scale(var(--s, 1)); }
.anim .stage * { transform-style: preserve-3d; }
.anim .floor { position: absolute; left: var(--x, -120px); top: var(--y, -120px); width: var(--w, 240px); height: var(--d, 240px); background: rgba(11,122,91,.07); border: 1px dashed rgba(11,122,91,.35); border-radius: 6px; }
/* .blk: a cuboid. Top face = the element at height --h; ::before = front (+y) face, ::after = right (+x) face. */
.anim .blk { position: absolute; left: var(--x, 0); top: var(--y, 0); width: var(--w, 40px); height: var(--d, 40px); transform: translateZ(var(--h, 20px)); background: var(--c, var(--brand)); color: #fff; font-weight: 700; font-size: .8125rem; line-height: 1.2; display: grid; place-items: center; text-align: center; }
.anim .blk::before, .anim .blk::after { content: ""; position: absolute; background: inherit; filter: brightness(.72); }
.anim .blk::before { left: 0; top: 100%; width: 100%; height: var(--h, 20px); transform-origin: top; transform: rotateX(-90deg); }
.anim .blk::after { left: 100%; top: 0; width: var(--h, 20px); height: 100%; transform-origin: left; transform: rotateY(90deg); filter: brightness(.86); }
/* .lbl: plain caption standing at floor level, facing the viewer (text lying flat gets squashed to half height
   by the 60deg tilt, so nothing is laid flat). .tag: the same, raised by --z on a dark pill.
   Text in the scene is rem-sized so it grows with the reader's text-size setting. Put the numbers the steps
   talk about on .lbl/.tag, not on a .blk top face (that face is foreshortened).
   Layout: an upright .lbl hangs toward the viewer from its anchor, so keep it ~40 units in front of the nearest
   block face; tags in one column need ~70 units of y between them to clear each other at 390px.
   Hide or show a .blk with scale, never opacity (an opacity animation flattens the cube in Chrome).
   Long labels sit ~20 units further forward: cancelling the stage's 22deg turn pushes their left end back.
   Each article sizes its scene for phones and wide screens in its own <style> (stage --s/scale, --vh, --sy);
   check 320px in a real browser, headless Chrome screenshots clamp the window to 500px. */
.anim .lbl { position: absolute; left: var(--x, 0); top: var(--y, 0); transform: translateZ(1px) rotateZ(22deg) rotateX(-60deg) translate(-50%, -50%); font-weight: 700; font-size: .875rem; line-height: 1.2; color: var(--ink); white-space: nowrap; }
.anim .tag { position: absolute; left: var(--x, 0); top: var(--y, 0); transform: translateZ(var(--z, 40px)) rotateZ(22deg) rotateX(-60deg) translate(-50%, -100%); padding: 2px 8px; border-radius: 6px; background: var(--ink); color: #fff; font-weight: 600; font-size: .8125rem; line-height: 1.4; white-space: nowrap; }
.anim .steps { margin: 12px 0 0; padding-left: 1.4em; font-size: .95rem; }
.anim .steps li { border-radius: 8px; padding: 4px 10px; }
.anim figcaption { margin: 0 0 10px; font-weight: 600; font-size: .95rem; }
.anim-pause { margin-top: 8px; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; font-size: .9rem; cursor: pointer; }
.anim-pause input { width: 18px; height: 18px; accent-color: var(--brand); }
.anim:has(.anim-pause input:checked) *, .anim:has(.anim-pause input:checked) *::before, .anim:has(.anim-pause input:checked) *::after { animation-play-state: paused !important; }
@media (max-width: 379px) { .anim .stage { scale: .84; } } /* scenes are laid out for ≥ 390px phones */
@media (prefers-reduced-motion: reduce) {
  .anim *, .anim *::before, .anim *::after { animation: none !important; transition: none !important; }
  .anim-pause { display: none; }
}

/* Blog index */
.tiers { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; padding: 0; list-style: none; }
.tiers a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: .9rem; text-decoration: none; }
.tiers a:hover { text-decoration: underline; text-underline-offset: 3px; }
.path a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font-weight: 600; font-size: .93rem; text-decoration: none; }
.path a:hover { border-color: var(--brand); color: var(--brand); }
.paths { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.paths > li > b { display: block; margin-bottom: 8px; }
.path { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.path li { counter-increment: step; }
.path a::before { content: counter(step); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: .8rem; }
.tier { margin-top: 36px; }
.tier > p { color: var(--muted); margin: 0 0 12px; }
.posts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.posts a { display: block; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); }
.posts a:hover { border-color: var(--brand); }
.posts b { display: block; }
.posts span { display: block; color: var(--muted); font-size: .93rem; line-height: 1.6; }
