/* ============================================================
   thClaws blog — long-form prose styles
   layered on top of /style.css
   ============================================================ */

body.blog {
  background:
    radial-gradient(1100px 600px at 80% -10%, rgba(109,242,255,.06), transparent 60%),
    radial-gradient(800px 700px at -10% 40%, rgba(46,184,156,.04), transparent 65%),
    var(--bg);
}

/* Thai language tweaks — IBM Plex Sans Thai Looped renders Thai script
   beautifully and falls through to JetBrains Mono for Latin chars. */
body.blog--th {
  font-family: 'IBM Plex Sans Thai Looped', 'JetBrains Mono', ui-monospace, monospace;
}
body.blog--th .post__body {
  font-family: 'IBM Plex Sans Thai Looped', 'JetBrains Mono', ui-monospace, monospace;
  line-height: 1.85;
}
body.blog--th .post__title,
body.blog--th .post__head h1 {
  font-family: 'IBM Plex Sans Thai Looped', 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: -.02em;
}

/* ============================================================
   post page — single post layout
   ============================================================ */

.post-page {
  padding: clamp(40px, 6vw, 80px) var(--gutter) clamp(60px, 8vw, 120px);
}

.post {
  max-width: 760px;
  margin: 0 auto;
}

.post__head {
  margin-bottom: clamp(36px, 5vw, 56px);
}
.post__back {
  display: inline-block;
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--fg-3);
  text-transform: lowercase;
  margin-bottom: 28px;
  transition: color .2s ease, transform .2s ease;
}
.post__back:hover { color: var(--cyan); transform: translateX(-3px); }

.post__title {
  font-size: clamp(36px, 5.6vw, 64px);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -.04em;
  margin: 0 0 22px;
  text-transform: lowercase;
}
.post__title-accent {
  background: linear-gradient(95deg, var(--cyan), var(--cyan-soft) 60%, var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.post__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--fg-3);
  letter-spacing: .03em;
}
.post__meta time { color: var(--fg-2); }
.post__meta .post__sep { color: var(--fg-4); }
.post__meta .post__author { color: var(--fg-2); }
.post__lang {
  color: var(--cyan);
  border-bottom: 1px dashed var(--cyan-deep);
  transition: color .2s ease;
}
.post__lang:hover { color: var(--cyan-soft); }

/* ============================================================
   prose body
   ============================================================ */

.post__body {
  font-size: 15px;
  line-height: 1.78;
  color: var(--fg);
}

.post__body > * + * { margin-top: 1.2em; }

.post__body p {
  color: var(--fg);
}
.post__body p strong { color: var(--fg); font-weight: 700; }
.post__body p em     { color: var(--fg); font-style: italic; }

.post__body h2,
.post__body h3,
.post__body h4 {
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--fg);
  text-transform: lowercase;
  margin-top: 2.6em;
  margin-bottom: 0.6em;
  scroll-margin-top: 80px;
}
.post__body h2 {
  font-size: clamp(22px, 3.2vw, 30px);
  padding-top: 0.4em;
  border-top: 1px solid var(--border);
  padding-top: 1.4em;
  margin-top: 2.4em;
}
.post__body h3 { font-size: clamp(18px, 2vw, 22px); }

.post__body h2:first-child,
.post__body h3:first-child { margin-top: 0; border-top: none; padding-top: 0; }

.post__body a {
  color: var(--cyan);
  border-bottom: 1px solid rgba(109,242,255,.35);
  transition: color .15s ease, border-color .15s ease;
}
.post__body a:hover {
  color: var(--cyan-soft);
  border-bottom-color: var(--cyan);
}

.post__body ul,
.post__body ol {
  padding-left: 1.5em;
  list-style: revert;
}
.post__body li {
  margin: 0.5em 0;
  color: var(--fg);
}
.post__body li::marker { color: var(--fg-3); }

.post__body blockquote {
  margin: 1.6em 0;
  padding: 18px 22px;
  border-left: 3px solid var(--cyan);
  background: var(--bg-1);
  font-size: 15px;
  color: var(--fg);
  font-style: normal;
}
.post__body blockquote p { margin: 0; }
.post__body blockquote p + p { margin-top: 0.8em; }
.post__body blockquote em,
.post__body blockquote strong { color: var(--fg); }

.post__body code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: var(--bg-2);
  border: 1px solid var(--border-bright);
  padding: 1px 6px;
  font-size: 0.92em;
  border-radius: 3px;
  color: var(--cyan-soft);
}
.post__body pre {
  margin: 1.4em 0;
  padding: 18px 20px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}
.post__body pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--fg);
  font-size: 13px;
  border-radius: 0;
}

.post__body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.4em 0;
}

.post__body img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.8em 0 0.4em;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,.7);
}
.post__body img + em,
.post__body img + p > em:only-child {
  display: block;
  text-align: center;
  font-size: 12.5px;
  color: var(--fg-3);
  margin-top: 0.4em;
  font-style: normal;
  letter-spacing: .02em;
}
/* PNGs that already include their own native shadow (e.g. macOS captures)
   shouldn't double-shadow. Detect by file extension via attribute selector. */
.post__body img[src$=".png"],
.post__body img[src$=".webp"] {
  box-shadow: none;
  border-radius: 0;
}

/* hero image — first image right after the H1 gets a flat, edge-to-edge feel */
.post__body > p:first-child > img:first-child,
.post__body > img:first-child {
  margin-top: 0;
  border-radius: 8px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.7);
}

/* ============================================================
   post footer
   ============================================================ */

.post__foot {
  margin-top: clamp(50px, 7vw, 90px);
  padding-top: 30px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12.5px;
  letter-spacing: .03em;
}
.post__foot .post__back { margin: 0; }
.post__cta {
  color: var(--cyan);
  border-bottom: 1px dashed var(--cyan-deep);
  text-transform: lowercase;
}
.post__cta:hover { color: var(--cyan-soft); }

/* ============================================================
   chapter navigation (manual)
   ============================================================ */

.chapter-nav {
  margin-top: clamp(50px, 7vw, 90px);
  padding-top: 28px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
}
.chapter-nav__prev,
.chapter-nav__next { min-width: 0; }
.chapter-nav__next { text-align: right; }

.chapter-nav a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  color: var(--fg-2);
  border-bottom: 1px solid var(--border);
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.chapter-nav a:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--bg-2);
  border-bottom-color: var(--cyan);
}
.chapter-nav__dir {
  display: block;
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--cyan);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.chapter-nav__title {
  display: block;
  font-size: 13px;
  color: var(--fg);
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chapter-nav__index {
  align-self: center;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--fg-3);
  border: 1px solid var(--border-bright);
  padding: 8px 14px;
  white-space: nowrap;
}
.chapter-nav__index:hover {
  color: var(--cyan);
  border-color: var(--cyan);
}

@media (max-width: 640px) {
  .chapter-nav { grid-template-columns: 1fr; }
  .chapter-nav__index { text-align: center; }
  .chapter-nav__next { text-align: left; }
}

/* ============================================================
   blog index
   ============================================================ */

.post-index {
  max-width: 1000px;
  margin: 0 auto;
  padding: clamp(50px, 8vw, 100px) var(--gutter) clamp(70px, 10vw, 130px);
}
.post-index__head {
  margin-bottom: clamp(40px, 6vw, 70px);
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: clamp(16px, 3vw, 40px);
  align-items: start;
}
@media (max-width: 700px) {
  .post-index__head { grid-template-columns: 1fr; gap: 14px; }
}
.post-index__head .section-head__index {
  font-size: 12px;
  letter-spacing: .12em;
  color: var(--cyan);
  text-transform: uppercase;
  padding-top: 8px;
  border-top: 1px solid var(--cyan);
}
.post-index__head h1 {
  margin: 0;
  font-size: clamp(38px, 6vw, 76px);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 0.96;
  text-transform: lowercase;
}
.post-index__head p {
  grid-column: 2;
  margin: 24px 0 0;
  max-width: 56ch;
  color: var(--fg-2);
  font-size: 15px;
  line-height: 1.65;
}
@media (max-width: 700px) {
  .post-index__head p { grid-column: 1; }
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}
.post-list__item {
  background: var(--bg-1);
  position: relative;
  transition: background .25s ease;
}
.post-list__item:hover { background: var(--bg-2); }
.post-list__link {
  display: block;
  padding: clamp(24px, 3.5vw, 38px);
  border-bottom: none;
  color: var(--fg);
}
.post-list__link:hover { color: var(--fg); border-bottom: none; }
.post-list__date {
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--cyan);
  text-transform: uppercase;
}
.post-list__title {
  margin: 10px 0 10px;
  font-size: clamp(22px, 3.2vw, 30px);
  font-weight: 800;
  letter-spacing: -.025em;
  line-height: 1.1;
  text-transform: lowercase;
  transition: color .2s ease;
}
.post-list__item:hover .post-list__title { color: var(--cyan); }
.post-list__desc {
  margin: 0;
  color: var(--fg-2);
  font-size: 14px;
  line-height: 1.6;
  max-width: 70ch;
}
.post-list__alt {
  position: absolute;
  top: clamp(24px, 3.5vw, 38px);
  right: clamp(24px, 3.5vw, 38px);
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--fg-3);
  border: 1px solid var(--border-bright);
  padding: 4px 10px;
  transition: color .2s ease, border-color .2s ease;
}
.post-list__alt[lang="th"] {
  font-family: 'IBM Plex Sans Thai Looped', 'JetBrains Mono', monospace;
}
.post-list__alt:hover {
  color: var(--cyan);
  border-color: var(--cyan);
}
