/* ─────────────────────────────────────────────────────────────
   Design tokens + chrome ที่ทุกหน้าใช้ร่วมกัน (index.html, about.html)

   Anuphan — Cadson Demak, SIL Open Font License 1.1
   สัญญาอนุญาตฉบับเต็มที่ fonts/OFL.txt
   เก็บไฟล์ไว้ในโปรเจกต์เอง ไม่ดึงจาก CDN เพราะระบบอาจถูกติดตั้ง
   ในเครือข่ายที่ไม่มีอินเทอร์เน็ต — ถ้าพึ่ง CDN ฟอนต์จะหายทันที
   เป็น variable font ช่วง 100-700 ไฟล์เดียวจึงครอบทุกน้ำหนักที่ใช้
   (path ใน @font-face อ้างอิงจากตำแหน่งของไฟล์ CSS นี้)

   สีทุกค่าผ่านการตรวจ contrast แล้ว:
   accent ที่ใช้เป็น "ตัวอักษร" บนพื้นสว่างใช้ step 550 (#1c5cab, 6.46:1)
   ไม่ใช่ #2a78d6 (4.30:1) ซึ่งไม่ผ่าน WCAG AA สำหรับข้อความขนาดปกติ
   สีสถานะเป็นค่าคงที่ ไม่เปลี่ยนตามโหมด และใช้เป็นจุด/พื้นอ่อนเท่านั้น
   ไม่เคยใช้เป็นสีตัวอักษร (ข้อความอยู่ในโทเคน ink เสมอ)
   ───────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Anuphan';
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url(fonts/anuphan-thai.woff2) format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: 'Anuphan';
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url(fonts/anuphan-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --plane:      #f9f9f7;
  --surface:    #fcfcfb;
  --raised:     #ffffff;
  --ink:        #0b0b0b;
  --ink-2:      #52514e;
  --ink-3:      #898781;
  --hairline:   #e1e0d9;
  --rule:       #c3c2b7;
  --ring:       rgba(11,11,11,.10);

  --accent:      #2a78d6;   /* เติม meter / เส้น — ต้องการ 3:1 */
  --accent-text: #1c5cab;   /* ตัวอักษร / ปุ่ม — 6.46:1 */

  --good:     #0ca30c;
  --warning:  #fab219;
  --critical: #d03b3b;

  --shadow: 0 1px 2px rgba(11,11,11,.05), 0 4px 12px rgba(11,11,11,.04);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane:    #0d0d0d;
    --surface:  #1a1a19;
    --raised:   #1f1f1e;
    --ink:      #ffffff;
    --ink-2:    #c3c2b7;
    --ink-3:    #898781;
    --hairline: #2c2c2a;
    --rule:     #383835;
    --ring:     rgba(255,255,255,.10);
    --accent:      #3987e5;
    --accent-text: #3987e5;  /* 4.79:1 บนพื้นมืด — ผ่าน AA */
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:    #0d0d0d;
  --surface:  #1a1a19;
  --raised:   #1f1f1e;
  --ink:      #ffffff;
  --ink-2:    #c3c2b7;
  --ink-3:    #898781;
  --hairline: #2c2c2a;
  --rule:     #383835;
  --ring:     rgba(255,255,255,.10);
  --accent:      #3987e5;
  --accent-text: #3987e5;
  --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Anuphan", system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", sans-serif;
  background: var(--plane);
  color: var(--ink);
  line-height: 1.6;
  font-size: 15px;
}
a { color: var(--accent-text); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* ── แถบหัว ───────────────────────────────────────────────── */
.topbar {
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.topbar .wrap {
  display: flex; align-items: center; gap: 16px;
  min-height: 60px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto;
         text-decoration: none; color: inherit; }
.brand svg { width: 26px; height: 26px; color: var(--accent-text); flex: none; }
.brand b { font-size: 1rem; font-weight: 650; letter-spacing: -.01em; }
.brand span { color: var(--ink-2); font-size: .82rem; }

.navlink {
  font-size: .85rem; font-weight: 600; text-decoration: none;
  color: var(--ink-2); padding: 6px 4px;
}
.navlink:hover { color: var(--accent-text); }
.navlink[aria-current="page"] { color: var(--ink); }

.tbtn {
  font: inherit; font-size: .82rem;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--raised); color: var(--ink);
  cursor: pointer;
}
.tbtn:hover { border-color: var(--ink-3); }
.tbtn svg { width: 15px; height: 15px; }

:where(a, button):focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ── กล่องคำเตือนทางการแพทย์ — ต้องเห็นตลอด ─────────────────── */
.notice {
  display: flex; gap: 12px; align-items: flex-start;
  margin: 24px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--warning);
  border-radius: 10px;
  background: var(--surface);
}
.notice svg { width: 19px; height: 19px; flex: none; margin-top: 2px; color: var(--warning); }
.notice p { margin: 0; font-size: .875rem; color: var(--ink-2); text-wrap: pretty; }
.notice strong { color: var(--ink); font-weight: 650; }

/* จุดสถานะ — ใช้คู่กับข้อความเสมอ ไม่ใช้สีสื่อความหมายลำพัง */
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-3); }

footer {
  margin-top: 44px; padding: 22px 0 40px;
  border-top: 1px solid var(--hairline);
  color: var(--ink-2); font-size: .8rem;
}
footer p { margin: 0 0 5px; text-wrap: pretty; }
footer code { font-size: .95em; color: var(--ink); }

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
}
