/* ============================================================
   APN — รายงานการพัฒนาเว็บไซต์
   ฟอนต์: Prompt · สีแบรนด์: #A43838
   ============================================================ */

:root {
  --brand: #a43838;
  --brand-dark: #7d2828;
  --brand-light: #c85a5a;
  --ink: #1d1d1b;
  --ink-soft: #4a4a47;
  --muted: #6f6f6a;
  --line: #e6e3df;
  --bg: #f7f5f2;
  --bg-card: #ffffff;
  --bg-soft: #faf8f5;

  --p0: #c0392b;
  --p0-bg: #fdecea;
  --p1: #d97706;
  --p1-bg: #fdf2e2;
  --p2: #b8932a;
  --p2-bg: #fbf6e4;
  --ok: #2f8f5b;
  --ok-bg: #e8f5ee;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 29, 27, .04), 0 8px 24px rgba(29, 29, 27, .06);
  --shadow-sm: 0 1px 3px rgba(29, 29, 27, .06);
  --maxw: 880px;
  --toc-w: 260px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 18px);
  overflow-x: clip; /* กัน spill ของ fixed element (สารบัญมือถือ) โดยไม่ทำลาย sticky/smooth-scroll */
}

body {
  margin: 0;
  font-family: 'Prompt', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  overflow-x: clip; /* กัน horizontal spill โดยไม่ทำลาย position:sticky ของสารบัญ */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

code {
  font-family: 'Prompt', ui-monospace, monospace;
  font-size: .88em;
  background: #efece7;
  color: var(--brand-dark);
  padding: .08em .42em;
  border-radius: 6px;
  font-weight: 500;
  word-break: break-word;
}

strong { font-weight: 600; }
em { font-style: normal; color: var(--brand-dark); font-weight: 500; }

/* ---------- scroll progress ---------- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--brand), var(--brand-light));
  z-index: 200;
  transition: width .08s linear;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 100;
}
.topbar-inner {
  max-width: calc(var(--maxw) + var(--toc-w) + 80px);
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand-mark {
  font-weight: 800;
  letter-spacing: .06em;
  color: #fff;
  background: var(--brand);
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 1rem;
}
.brand-text { font-weight: 600; font-size: .98rem; color: var(--ink); }
.topbar-link {
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: color .15s;
}
.topbar-link:hover { color: var(--brand); }
.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink);
}

/* ---------- layout ---------- */
.layout {
  max-width: calc(var(--maxw) + var(--toc-w) + 80px);
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: var(--toc-w) minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

/* ---------- TOC ---------- */
.toc {
  position: sticky;
  top: calc(var(--topbar-h) + 28px);
  padding: 8px 0;
  max-height: calc(100vh - var(--topbar-h) - 48px);
  overflow-y: auto;
}
.toc-title {
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}
.toc nav { display: flex; flex-direction: column; gap: 2px; border-left: 2px solid var(--line); }
.toc-link, .toc-sub {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: .92rem;
  padding: 6px 14px;
  margin-left: -2px;
  border-left: 2px solid transparent;
  transition: all .15s;
  font-weight: 500;
}
.toc-sub { font-size: .85rem; color: var(--muted); padding-left: 26px; font-weight: 400; }
.toc-link:hover, .toc-sub:hover { color: var(--brand); }
.toc-link.active, .toc-sub.active {
  color: var(--brand);
  border-left-color: var(--brand);
  font-weight: 600;
  background: linear-gradient(90deg, rgba(164, 56, 56, .06), transparent);
}

/* ---------- content & sections ---------- */
.content { min-width: 0; padding-bottom: 80px; }

.block { padding: 44px 0 8px; scroll-margin-top: calc(var(--topbar-h) + 18px); }

.section-h {
  font-size: clamp(1.4rem, 1.1rem + 1vw, 1.85rem);
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -.01em;
  position: relative;
  padding-bottom: 12px;
}
.section-h::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0;
  width: 52px; height: 3px;
  background: var(--brand);
  border-radius: 3px;
}
.section-lead { color: var(--muted); margin: 12px 0 24px; font-size: .96rem; }

/* ---------- HERO ---------- */
.hero {
  padding: 56px 0 36px;
  scroll-margin-top: calc(var(--topbar-h) + 18px);
}
.eyebrow {
  color: var(--brand);
  font-weight: 600;
  font-size: .85rem;
  letter-spacing: .04em;
  margin: 0 0 14px;
}
.hero h1 {
  font-size: clamp(2rem, 1.3rem + 3vw, 3.1rem);
  line-height: 1.18;
  font-weight: 700;
  margin: 0 0 18px;
  letter-spacing: -.02em;
}
.hero h1 .hl { color: var(--brand); }
.hero-sub {
  font-size: clamp(1rem, .95rem + .3vw, 1.15rem);
  color: var(--ink-soft);
  max-width: 60ch;
  margin: 0 0 32px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin: 0 0 26px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card.accent {
  background: linear-gradient(150deg, var(--brand), var(--brand-dark));
  border-color: var(--brand-dark);
}
.stat-card.accent .stat-num,
.stat-card.accent .stat-label { color: #fff; }
.stat-num {
  font-size: clamp(1.8rem, 1.4rem + 1.2vw, 2.4rem);
  font-weight: 700;
  color: var(--brand);
  line-height: 1.1;
  letter-spacing: -.02em;
}
.stat-label { font-size: .82rem; color: var(--muted); font-weight: 500; line-height: 1.35; }

.hero-foot {
  font-size: .85rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin: 0;
}

/* ---------- EXECUTIVE SUMMARY ---------- */
.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 30px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--brand);
}
.summary-card > p:first-child { margin-top: 0; font-size: 1.02rem; }
.key-points { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 16px; }
.key-points li { display: flex; gap: 14px; align-items: flex-start; }
.kp-ico {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1.15rem;
}
.key-points li div { font-size: .96rem; color: var(--ink-soft); }

/* ---------- TIMELINE ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 8px; position: relative; }
.tl-item { position: relative; padding: 0 0 26px 34px; border-left: 2px solid var(--line); }
.tl-item:last-child { border-left-color: transparent; padding-bottom: 4px; }
.tl-dot {
  position: absolute;
  left: -8px; top: 4px;
  width: 14px; height: 14px;
  background: #fff;
  border: 3px solid var(--brand-light);
  border-radius: 50%;
}
.tl-item.current .tl-dot {
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(164, 56, 56, .15);
}
.tl-body {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}
.tl-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 8px; }
.tl-hash { background: var(--ink); color: #fff; font-weight: 600; }
.tl-date { font-size: .82rem; color: var(--muted); font-weight: 500; }
.tl-diff {
  font-size: .76rem;
  color: var(--ok);
  background: var(--ok-bg);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
  margin-left: auto;
}
.tl-badge {
  font-size: .72rem;
  background: var(--brand);
  color: #fff;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.tl-body h3 { margin: 0 0 6px; font-size: 1.05rem; font-weight: 600; }
.tl-body p { margin: 0; font-size: .92rem; color: var(--ink-soft); }

/* ---------- THEME CARDS ---------- */
.theme-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  scroll-margin-top: calc(var(--topbar-h) + 18px);
}
.theme-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--ink);
  transition: background .15s;
}
.theme-head:hover { background: var(--bg-soft); }
.theme-ico {
  font-size: 1.3rem;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--bg-soft);
  border-radius: 10px;
  flex: 0 0 auto;
}
.theme-title { font-weight: 600; font-size: 1.06rem; margin-right: auto; }
.theme-chevron { color: var(--brand); font-size: 1.1rem; transition: transform .25s; flex: 0 0 auto; }
.theme-head[aria-expanded="false"] .theme-chevron { transform: rotate(-90deg); }

.theme-body {
  padding: 0 22px;
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease, padding .3s ease;
}
.theme-card.open .theme-body { padding: 4px 22px 24px; }

.theme-lead {
  color: var(--brand-dark);
  font-weight: 500;
  font-size: .95rem;
  margin: 4px 0 14px;
  padding-left: 12px;
  border-left: 3px solid var(--brand-light);
}
.detail-list { margin: 0; padding-left: 20px; display: grid; gap: 9px; }
.detail-list li { font-size: .95rem; color: var(--ink-soft); padding-left: 4px; }
.detail-list li::marker { color: var(--brand-light); }
.impact {
  margin: 18px 0 0;
  padding: 13px 16px;
  background: var(--ok-bg);
  border-radius: 10px;
  font-size: .92rem;
  color: #225f3d;
}
.impact strong { color: var(--ok); }
.note-inline {
  margin: 10px 0 0;
  font-size: .86rem;
  color: var(--muted);
  font-style: italic;
}

/* ---------- FILTER BAR ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.filter-btn {
  font-family: inherit;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  padding: 8px 16px;
  border-radius: 30px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all .15s;
}
.filter-btn:hover { border-color: var(--brand-light); color: var(--brand); }
.filter-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.filter-btn .cnt {
  background: rgba(0, 0, 0, .08);
  padding: 1px 8px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
}
.filter-btn.active .cnt { background: rgba(255, 255, 255, .25); }

/* ---------- FINDINGS ---------- */
.findings { display: grid; gap: 10px; }
.finding {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform .12s, box-shadow .12s;
}
.finding:hover { transform: translateX(2px); box-shadow: var(--shadow); }
.finding.hidden { display: none; }
.pri {
  font-weight: 700;
  font-size: .78rem;
  padding: 4px 10px;
  border-radius: 8px;
  flex: 0 0 auto;
  letter-spacing: .02em;
}
.pri-p0 { color: var(--p0); background: var(--p0-bg); }
.pri-p1 { color: var(--p1); background: var(--p1-bg); }
.pri-p2 { color: var(--p2); background: var(--p2-bg); }
.finding-main { min-width: 0; }
.finding-title { margin: 0; font-weight: 600; font-size: .96rem; }
.finding-fix { margin: 3px 0 0; font-size: .88rem; color: var(--muted); }
.tag-new {
  font-size: .68rem;
  background: var(--brand);
  color: #fff;
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 500;
  vertical-align: middle;
  margin-left: 4px;
}
.status {
  flex: 0 0 auto;
  font-size: .82rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
}
.status.done { color: var(--ok); background: var(--ok-bg); }
.status.done::before { content: "✓ "; }
.findings-empty { text-align: center; color: var(--muted); padding: 30px; }

/* ---------- NOTES ---------- */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.note-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--muted);
}
.note-card.ok { border-top-color: var(--ok); }
.note-card.warn { border-top-color: var(--p1); }
.note-card h3 { margin: 0 0 8px; font-size: 1rem; font-weight: 600; }
.note-card p { margin: 0; font-size: .9rem; color: var(--ink-soft); }
.source-note {
  margin: 24px 0 0;
  font-size: .85rem;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 14px 18px;
}

.page-foot {
  margin-top: 50px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
}

/* ---------- back to top ---------- */
.back-to-top {
  position: fixed;
  bottom: 26px; right: 26px;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all .25s;
  z-index: 90;
}
.back-to-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.back-to-top:hover { background: var(--brand-dark); }

/* ---------- responsive ---------- */
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; gap: 0; }
  .menu-toggle { display: inline-block; }
  .topbar-link { display: none; }
  .toc {
    position: fixed;
    top: var(--topbar-h);
    left: 0; right: 0;
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    max-height: 0;
    overflow: hidden;
    padding: 0 24px;
    z-index: 95;
    transition: max-height .3s ease, padding .3s ease;
  }
  .toc.open { max-height: 70vh; overflow-y: auto; padding: 18px 24px; }
  .toc nav { border-left: none; }
  .hero { padding: 36px 0 28px; }
  .finding { grid-template-columns: auto 1fr; }
  .finding .status { grid-column: 2; justify-self: start; }
  .summary-card { padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
