/**
 * ThaiPAC — assets/style.css
 *
 * Design direction: Editorial Legal Document (refined minimalism, v2)
 * Day 10 — Section page redesign (ported from _design-section-test.html)
 *
 * Layout: shell grid (desktop = 1fr 220px; mobile = stack)
 *   - main         : article body (max 680px measure)
 *   - aside.toc    : sticky sidebar TOC (≥1024px)
 *   - details.toc-mobile : collapsible TOC (≤1023px)
 *
 * Sections rendered:
 *   header.section-head  → breadcrumb pills + H1 + meta strip
 *   section[id=...]      → H2 anchors (tatbot/summary/components/refs/notes)
 *   .concept-grid        → แนวคิดที่เกี่ยวข้อง pill grid (from frontmatter)
 *   nav.section-nav      → prev/next cards
 *   .progress-bar        → fixed top reading progress
 */

/* ─── Design tokens ──────────────────────────────────────── */
:root {
  /* Color */
  --ink:           #2a3540;
  --ink-soft:      #4a5562;
  --ink-muted:     #7a8290;
  --paper:         #faf9f5;
  --paper-warm:    #f5f2e8;
  --paper-deeper:  #fdfcf6;
  --rule:          #e6e2d4;
  --rule-soft:     #efece2;
  --accent:        #1d4d8c;
  --accent-hover:  #252b76;  /* matches navy shield bg in /assets/thaipac-logo.png */
  --accent-soft:   #eaf0f9;
  --gold:          #b89248;
  --gold-soft:     #f3ecd9;
  --gold-deeper:   #9c7a39;

  /* Typography */
  --font-thai:     'Sarabun', 'IBM Plex Sans Thai', 'Noto Sans Thai',
                   -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Type scale */
  --text-xs:       12px;
  --text-sm:       14px;
  --text-base:     17px;
  --text-lg:       19px;
  --text-xl:       22px;
  --text-2xl:      28px;
  --text-3xl:      48px;

  /* Rhythm */
  --leading-thai:  1.85;
  --leading-tight: 1.25;
  --leading-snug:  1.45;

  /* Layout */
  --measure:       680px;
  --measure-wide:  1100px;
}

/* ─── Reset / base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  font-family: var(--font-thai);
  font-size: var(--text-base);
  line-height: var(--leading-thai);
  color: var(--ink);
  background: var(--paper);
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--gold-soft);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ─── Persistent top-left home link ──────────────────────── */
/* Appears on every page that wraps via renderLayout, except landing.
 * Position: fixed so it stays available as the user scrolls. */
.home-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 100px;
  color: var(--accent-hover);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(42, 53, 64, 0.06);
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease, color 120ms ease;
}

.home-link::before {
  content: '←';
  display: inline-block;
  margin-right: 6px;
  font-weight: 400;
  transition: transform 120ms ease;
}

.home-link:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.home-link:hover::before {
  transform: translateX(-2px);
}

.home-link:active {
  transform: translateY(1px);
}

/* ─── Reading progress bar ───────────────────────────────── */
.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  width: 0%;
  z-index: 100;
  transition: width 80ms linear;
}

/* ─── Shell / layout grid ────────────────────────────────── */
.shell {
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 0 24px;
}

@media (min-width: 1024px) {
  .shell {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 72px;
    padding: 0 32px;
  }
}

main {
  max-width: var(--measure);
  padding: 64px 0 96px;
}

/* ─── Section header (hero) ──────────────────────────────── */
.section-head {
  margin-bottom: 56px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 24px;
}

.breadcrumb .pill {
  display: inline-flex;
  align-items: center;
  background: var(--gold-soft);
  color: var(--gold-deeper);
  border: 1px solid var(--rule);
  padding: 4px 12px;
  border-radius: 100px;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.03em;
  line-height: 1.5;
}

.breadcrumb .pill.alt {
  background: var(--paper);
  color: var(--ink-muted);
  border-color: var(--rule-soft);
}

.section-head h1 {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
  margin: 0 0 12px;
  color: var(--accent-hover);
  padding-bottom: 0;
  border-bottom: none;
}

.section-head h1 .num {
  color: var(--gold-deeper);
  font-feature-settings: "tnum" 1;
}

.section-head .meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 20px;
  font-size: var(--text-sm);
  color: var(--ink-muted);
  border-top: 1px solid var(--rule-soft);
  padding-top: 16px;
}

.section-head .meta .dot {
  color: var(--rule);
}

/* ─── Typography ─────────────────────────────────────────── */
h1 {
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  margin: 0 0 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
  color: var(--accent-hover);
}

h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: var(--leading-tight);
  margin: 64px 0 20px;
  padding-left: 16px;
  border-left: 3px solid var(--gold);
  color: var(--accent-hover);
  scroll-margin-top: 24px;
}

h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: var(--leading-snug);
  margin: 32px 0 12px;
  color: var(--accent-hover);
}

h2 + p, h2 + ul, h2 + ol,
h2 + blockquote, h2 + .concept-grid {
  margin-top: 0;
}

p { margin: 16px 0; }

strong {
  font-weight: 600;
  color: var(--accent);
}

em { font-style: normal; font-weight: 500; color: var(--ink-soft); }

/* ─── Blockquote — ตัวบท "document card" ─────────────────── */
/* Parsedown emits <blockquote> for `> ...` lines — that's our law text. */
blockquote {
  position: relative;
  margin: 28px 0;
  padding: 36px 40px 32px;
  background:
    linear-gradient(to bottom, #EFF6FF 0%, #DBEAFE 100%);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--gold);
  border-radius: 3px;
  box-shadow:
    0 1px 0 var(--rule),
    0 12px 32px -20px rgba(58, 50, 30, 0.18);
  font-size: var(--text-base);
  line-height: 1.92;
  color: var(--ink);
}

blockquote p { margin: 12px 0; }
blockquote p:first-child { margin-top: 0; }
blockquote p:last-child  { margin-bottom: 0; }

/* ─── Lists ──────────────────────────────────────────────── */
ul, ol {
  margin: 16px 0;
  padding-left: 0;
  list-style: none;
}

ul > li, ol > li {
  position: relative;
  padding-left: 24px;
  margin: 10px 0;
}

ul > li::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0.85em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

ol { counter-reset: ol; }
ol > li { counter-increment: ol; }

ol > li::before {
  content: counter(ol) ".";
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  text-align: right;
  font-weight: 600;
  color: var(--gold-deeper);
  font-feature-settings: "tnum" 1;
}

li > ul, li > ol { margin: 6px 0 8px; }

li ul > li::before {
  background: transparent;
  border: 1.5px solid var(--gold);
}

/* ─── Wiki-links ─────────────────────────────────────────── */
a {
  color: var(--accent);
  text-decoration: none;
}

a.wiki-link, a.wiki-link-auto {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--accent-soft);
  padding: 1px 2px;
  margin: 0 -2px;
  border-radius: 2px;
  transition:
    background-color 150ms ease,
    border-bottom-color 150ms ease,
    color 150ms ease;
}

a.wiki-link:hover, a.wiki-link-auto:hover {
  background: var(--accent-soft);
  border-bottom-color: var(--accent);
  color: var(--accent-hover);
}

a.wiki-link:active, a.wiki-link-auto:active {
  background: var(--gold-soft);
}

/* ─── Concept pills (แนวคิดที่เกี่ยวข้อง) ──────────────────── */
.concept-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 8px;
}

.concept-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background: var(--accent-soft);
  border: 1px solid #d8e3f2;
  color: var(--accent-hover);
  border-radius: 100px;
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  line-height: 1.5;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

.concept-pill::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 8px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.55;
  transition: opacity 150ms ease, background-color 150ms ease;
}

.concept-pill:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
  transform: translateY(-1px);
}

.concept-pill:hover::before {
  background: var(--paper);
  opacity: 1;
}

.concept-pill:active {
  transform: translateY(0);
  background: var(--accent-hover);
}

/* ─── Mobile TOC (collapsible details) ───────────────────── */
.toc-mobile {
  display: none;
}

@media (max-width: 1023px) {
  .toc-mobile {
    display: block;
    margin: 0 0 32px;
    border: 1px solid var(--rule);
    border-radius: 6px;
    background: var(--paper-deeper);
    overflow: hidden;
  }

  .toc-mobile > summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 18px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }

  .toc-mobile > summary::-webkit-details-marker { display: none; }

  .toc-mobile > summary .label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }

  .toc-mobile > summary .label::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 14px;
    background: var(--gold);
    border-radius: 2px;
  }

  .toc-mobile > summary .chev {
    color: var(--gold-deeper);
    font-size: 12px;
    transition: transform 200ms ease;
  }

  .toc-mobile[open] > summary .chev {
    transform: rotate(180deg);
  }

  .toc-mobile ol {
    list-style: none;
    margin: 0;
    padding: 4px 0 8px;
    border-top: 1px solid var(--rule);
    background: var(--paper);
    counter-reset: none;
  }

  .toc-mobile li {
    margin: 0;
    padding: 0;
  }

  .toc-mobile li::before { content: none; }

  .toc-mobile a {
    display: block;
    padding: 10px 18px;
    font-size: var(--text-sm);
    color: var(--ink-soft);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background-color 150ms ease, color 150ms ease, border-left-color 150ms ease;
  }

  .toc-mobile a:hover,
  .toc-mobile a:active {
    background: var(--gold-soft);
    border-left-color: var(--gold);
    color: var(--accent-hover);
  }
}

/* ─── Desktop TOC sidebar (≥1024px only) ─────────────────── */
.toc {
  display: none;
}

@media (min-width: 1024px) {
  .toc {
    display: block;
    position: sticky;
    top: 40px;
    align-self: start;
    margin-top: 64px;
    padding: 24px 0 0;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }

  .toc-label {
    font-size: var(--text-sm);
    letter-spacing: 0.03em;
    color: var(--ink);
    margin: 0 0 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }

  .toc-label::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 14px;
    background: var(--gold);
    border-radius: 2px;
  }

  .toc ol {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: none;
  }

  .toc li {
    margin: 0;
    padding: 0;
  }

  .toc li::before { content: none; }

  .toc a {
    display: block;
    padding: 8px 0 8px 16px;
    margin-left: -1px;
    border-left: 2px solid var(--rule-soft);
    color: var(--ink-muted);
    text-decoration: none;
    font-size: var(--text-sm);
    line-height: var(--leading-snug);
    transition: color 150ms ease, border-color 150ms ease;
  }

  .toc a:hover {
    color: var(--accent);
    border-left-color: var(--rule);
  }

  .toc a.active {
    color: var(--accent);
    border-left-color: var(--gold);
    font-weight: 500;
  }
}

/* ─── Section nav (prev/next cards) ──────────────────────── */
.section-nav {
  margin-top: 96px;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.section-nav a {
  display: block;
  padding: 16px 20px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  text-decoration: none;
  color: var(--ink-soft);
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.section-nav a:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
  transform: translateY(-1px);
}

.section-nav .label {
  display: block;
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.section-nav .title {
  display: block;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--ink);
}

.section-nav .next { text-align: right; }

.section-nav .placeholder {
  background: transparent;
  border-color: var(--rule-soft);
  opacity: 0.5;
  pointer-events: none;
}

/* ─── Footer ─────────────────────────────────────────────── */
footer.site-footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 32px 24px;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--ink-muted);
  border-top: 1px solid var(--rule);
}

footer.site-footer a {
  color: var(--ink-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

footer.site-footer a:hover { color: var(--ink); }

/* ─── Tablet (641-1023) ──────────────────────────────────── */
@media (max-width: 1023px) {
  main { padding: 48px 0 80px; }
  .section-head h1 { font-size: 40px; }
}

/* ─── Mobile (≤ 640) ─────────────────────────────────────── */
@media (max-width: 640px) {
  body {
    font-size: 16px;
    line-height: 1.78;
  }

  .shell { padding: 0 16px; }

  main {
    padding: 32px 0 64px;
  }

  .section-head {
    margin-bottom: 36px;
  }

  .section-head h1 {
    font-size: 30px;
  }

  h2 {
    font-size: 18px;
    margin: 44px 0 14px;
    padding-left: 12px;
    border-left-width: 2px;
  }

  h3 { font-size: var(--text-base); }

  blockquote {
    padding: 24px 20px 22px;
    font-size: 15.5px;
    line-height: 1.85;
  }

  ul > li, ol > li { padding-left: 22px; }

  .section-nav {
    grid-template-columns: 1fr;
    margin-top: 64px;
  }

  .section-nav .next { text-align: left; }

  footer.site-footer {
    padding: 24px 16px;
    font-size: var(--text-xs);
  }
}

/* ─── Graph panel (Quartz-style local + global) ──────────── */
.graph {
  margin: 64px 0 32px;
  padding: 20px;
  background: var(--paper-deeper);
  border: 1px solid var(--rule-soft);
  border-radius: 8px;
}

.graph h3 {
  margin: 0 0 12px;
  padding: 0;
  border: none;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  text-transform: none;
}

.graph-outer {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  overflow: hidden;
}

.graph-container {
  width: 100%;
  height: 260px;
  display: block;
  position: relative;
}

.graph-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.graph-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

/* Icon button — top-right inside .graph-outer */
.global-graph-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 6px;
  background: var(--paper-deeper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.global-graph-icon:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.global-graph-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ─── Global graph overlay ──────────────────────────────── */
.global-graph-outer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(42, 53, 64, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.global-graph-outer.active {
  display: flex;
}

.global-graph-container {
  width: 100%;
  height: 100%;
  max-width: 1280px;
  max-height: 800px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  position: relative;
}

.global-graph-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

body.graph-overlay-open {
  overflow: hidden;
}

/* ─── PC layout (≥1024px): float .graph bottom-right ────── */
@media (min-width: 1024px) {
  .graph {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 280px;
    margin: 0;
    z-index: 50;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  }

  .graph-container {
    height: 240px;
  }
}

/* ─── Mobile / tablet (≤1023px): inline panel, full-width — ── */
@media (max-width: 1023px) {
  .graph {
    margin: 48px 0 32px;
  }

  .graph-container {
    height: 220px;
  }
}

/* ─── Landing page (path = '/') ──────────────────────────── */
/* Override .shell grid — landing is single-column, centered content. */
.shell-landing {
  display: block;
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 0 24px;
}

@media (min-width: 1024px) {
  .shell-landing {
    display: block;
    grid-template-columns: none;
    gap: 0;
    padding: 0 32px;
  }
}

.landing {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 0 96px;
}

/* Hero — FULL VIEWPORT-WIDTH band (lives OUTSIDE .shell-landing so the
 * three.js node-link layer behind it can extend edge-to-edge).
 *   - background: light-blue gradient (#f6faff → --accent-soft) — paired
 *     with the navy/gold particle network for a "sky" feel
 *   - children content gets centred via .landing-hero-inner (max-width 760px)
 *   - positioning context for the absolutely-placed canvas backdrop. */
.landing-hero {
  position: relative;
  overflow: hidden;
  text-align: center;
  margin: 0 0 80px;
  padding: 80px 24px 56px;
  background: linear-gradient(to bottom, #EFF6FF 0%, #DBEAFE 100%);
}

.landing-hero-inner {
  max-width: 760px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Three.js node-link canvas — absolute behind the hero content, spans the
 * full hero band (which is now viewport-wide). pointer-events: none so
 * clicks pass through to the search / logo. */
.landing-hero-graph {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.landing-hero-graph canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.landing-logo {
  display: block;
  width: 224px;
  height: 224px;
  margin: 0 auto 24px;
  object-fit: contain;
  /* PNG has built-in shield silhouette; no extra framing */
}

@media (max-width: 640px) {
  .landing-logo {
    width: 176px;
    height: 176px;
    margin-bottom: 18px;
  }
}

.landing-hero h1 {
  font-size: var(--text-3xl);
  color: var(--accent-hover);
  margin: 0 0 12px;
  border: none;
  padding: 0;
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
}

.landing-hero .tagline {
  font-size: var(--text-lg);
  color: var(--ink-soft);
  margin: 0 0 36px;
  line-height: var(--leading-snug);
}

/* Tagline line-break shims — PC + mobile break the text at different
 * positions to balance line length. Each <br> is classed and toggled
 * via display: none (a hidden <br> emits no line break). */
.brk-mobile { display: none; }
.brk-pc     { display: inline; }

@media (max-width: 767px) {
  .brk-mobile { display: inline; }
  .brk-pc     { display: none; }
}

/* Search form */
.landing-search {
  display: flex;
  gap: 8px;
  margin: 0 auto 24px;
  max-width: 520px;
}

.landing-search input[type="search"] {
  flex: 1;
  padding: 12px 18px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-family: inherit;
  font-size: var(--text-base);
  background: var(--paper-deeper);
  color: var(--ink);
  line-height: 1.4;
  -webkit-appearance: none;
}

.landing-search input[type="search"]:focus {
  border-color: var(--accent);
  outline: none;
  background: var(--paper);
}

.landing-search button {
  padding: 12px 24px;
  background: var(--accent);
  color: var(--paper);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}

.landing-search button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Stats strip */
.landing-stats {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.landing-stats strong {
  color: var(--accent);
  font-weight: 600;
}

.landing-stats .dot {
  color: var(--rule);
}

.landing-stats a {
  color: var(--gold-deeper);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease;
}

.landing-stats a:hover {
  border-bottom-color: var(--gold);
}

/* Landing main heading — sits above the 3 landing sections inside <main>.
 * Semantically <h2> (the only <h1> on page is the hero brand wordmark) but
 * sized larger than sibling section h2s to act as the functional title of
 * the database. Uses --text-3xl (48px) to clearly dominate. No gold left
 * rule so it doesn't read as "just another section" — centered with a
 * full gold underline instead. */
.landing-h1 {
  font-size: 36px;
  color: var(--accent-hover);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: var(--leading-tight);
  text-align: center;
  margin: 0 0 48px;
  padding: 0 0 20px;
  border-bottom: 2px solid var(--gold);
  border-left: none;
}

@media (max-width: 640px) {
  .landing-h1 {
    font-size: var(--text-2xl);
    margin-bottom: 32px;
    padding-bottom: 16px;
  }
}

/* Sections (chapters + concepts) */
.landing-section {
  margin-bottom: 56px;
}

/* Match section page h2 — gold rule left + accent-hover navy color */
.landing-section h2 {
  font-size: var(--text-xl);
  color: var(--accent-hover);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: var(--leading-tight);
  margin: 0 0 24px;
  padding: 0 0 0 16px;
  border-left: 3px solid var(--gold);
  border-bottom: none;
}

/* Chapter grid — card list */
.chapter-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

/* Override global `ul > li::before { content: '' (gold dot) }` */
.chapter-grid li {
  position: static;
  padding-left: 0;
  margin: 0;
}

.chapter-grid li::before {
  content: none;
}

@media (min-width: 720px) {
  .chapter-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Chapter CARD — header (chapter link) + section number grid (one-click access)
 * Restructured so users can either click the chapter (→ /chapter/{slug})
 * or any individual มาตรา number (→ /section/N) without leaving the card. */
.chapter-card {
  display: flex;
  flex-direction: column;
  background: var(--paper-deeper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 120ms ease;
}

.chapter-card:hover {
  border-color: var(--accent);
}

.chapter-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--rule-soft);
  transition: background-color 120ms ease;
}

.chapter-header:hover {
  background: var(--accent-soft);
}

.chapter-label {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--accent-hover);
  letter-spacing: -0.005em;
}

.chapter-range {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  letter-spacing: 0.03em;
}

/* Section number grid inside chapter card — flex-wrap so it grows
 * vertically as needed (e.g. หมวด 4 has 28 sections → ~4 rows). */
.chapter-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 14px 12px;
}

.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  font-feature-settings: "tnum" 1;
  line-height: 1;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.section-num:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

/* Concept grid in landing — reuse .concept-pill, just tighten gap */
.landing .concept-grid {
  margin: 0;
}

/* Embedded landing graph — larger than the section-page panel */
.landing-graph .graph-container {
  height: 460px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper-deeper);
  overflow: hidden;
}

@media (min-width: 1024px) {
  .landing-graph .graph-container {
    height: 520px;
  }
}

@media (max-width: 640px) {
  .landing-graph .graph-container {
    height: 360px;
  }
}

/* ─── Chapter index page (/chapter/{slug}) ───────────────── */
.chapter-page {
  max-width: var(--measure);
  padding: 64px 0 96px;
}

.chapter-head {
  margin-bottom: 48px;
}

.chapter-head .breadcrumb {
  margin: 0 0 20px;
}

.chapter-head .breadcrumb .pill {
  text-decoration: none;
}

.chapter-head h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: var(--leading-tight);
  margin: 0 0 12px;
  color: var(--accent-hover);
  border: none;
  padding: 0;
}

.chapter-head .meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: var(--text-sm);
  color: var(--ink-muted);
  padding-top: 12px;
  border-top: 1px solid var(--rule-soft);
}

.chapter-head .meta .dot {
  color: var(--rule);
}

/* Subdivision header (ส่วนที่ N ...) */
.subdivision-head {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
  margin: 40px 0 16px;
  padding: 0 0 8px;
  border: none;
  border-bottom: 1px solid var(--rule);
}

.subdivision-head:first-of-type {
  margin-top: 0;
}

/* Section card list — within chapter index */
.section-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 720px) {
  .section-list {
    grid-template-columns: 1fr 1fr;
  }
}

/* Override global `ul > li::before { gold dot }` */
.section-list li {
  position: static;
  padding-left: 0;
  margin: 0;
}

.section-list li::before {
  content: none;
}

.section-list a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  background: var(--paper-deeper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

.section-list a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.section-list a:active {
  transform: translateY(0);
}

.sec-num {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--accent-hover);
  font-feature-settings: "tnum" 1;
}

.sec-keywords {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  line-height: 1.5;
}

/* ─── Landing collection cards (ข้อหารือ / คำสั่ง entry points) ── */
.collection-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  background: var(--paper-deeper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

.collection-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.collection-card:active {
  transform: translateY(0);
}

.cc-count {
  flex: 0 0 auto;
  min-width: 64px;
  text-align: center;
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--gold);
  font-feature-settings: "tnum" 1;
  line-height: 1;
}

.cc-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
}

.cc-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--accent-hover);
  line-height: var(--leading-snug);
}

.cc-desc {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  line-height: 1.55;
}

.cc-arrow {
  flex: 0 0 auto;
  font-size: var(--text-xl);
  color: var(--ink-muted);
  transition: transform 120ms ease, color 120ms ease;
}

.collection-card:hover .cc-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

@media (max-width: 640px) {
  .collection-card {
    gap: 14px;
    padding: 16px 16px;
  }
  .cc-count {
    min-width: 48px;
    font-size: var(--text-2xl);
  }
}

/* ─── Collection index pages (/opinions, /orders) ───────────── */
/* Single-column document cards — content is text-heavy, reads better
 * full-width than in the 2-col grid used by the chapter section list. */
.doc-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doc-list li {
  position: static;
  padding-left: 0;
  margin: 0;
}

.doc-list li::before {
  content: none;
}

.doc-card {
  background: var(--paper-deeper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 120ms ease;
}

.doc-card:hover {
  border-color: var(--accent);
}

.doc-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 18px;
  text-decoration: none;
  color: var(--ink);
  transition: background-color 120ms ease;
}

.doc-main:hover {
  background: var(--accent-soft);
}

.doc-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.doc-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  background: var(--accent-soft);
  border: 1px solid #d8e3f2;
  border-radius: 100px;
  color: var(--accent-hover);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}

.doc-asker {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--accent-hover);
}

.doc-summary {
  font-size: var(--text-sm);
  color: var(--ink-soft);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-meta {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

/* Disposition badge (orders) — colour-coded by outcome class */
.dispo-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.dispo-enforce {   /* ตักเตือน / ให้ปฏิบัติตามกฎหมาย — substantive outcome */
  background: #fbe7e4;
  border: 1px solid #f0ccc4;
  color: #a8432c;
}

.dispo-resolved {  /* ยุติเรื่องร้องเรียน — closed on merits */
  background: var(--accent-soft);
  border: 1px solid #d8e3f2;
  color: var(--accent-hover);
}

.dispo-rejected {  /* ไม่รับเรื่องร้องเรียน — not accepted at intake */
  background: var(--paper-warm);
  border: 1px solid var(--rule);
  color: var(--ink-muted);
}

/* Section cross-link chips (มาตราที่ตีความ / ละเมิด) */
.doc-secs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 18px 12px;
}

.doc-secs-label {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-right: 2px;
}

.sec-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  background: var(--gold-soft);
  border: 1px solid var(--rule);
  border-radius: 100px;
  color: var(--gold-deeper);
  font-size: var(--text-xs);
  font-weight: 500;
  text-decoration: none;
  font-feature-settings: "tnum" 1;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.sec-chip:hover {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--paper);
}
