/* ============================================================
   kit/css/base.css — reset, ฟอนต์ Sarabun, typography, พื้นหลัง
   ============================================================ */

/* ---------- ฟอนต์ Sarabun (thai/latin แยก unicode-range) ---------- */
@font-face {
  font-family: "Sarabun";
  src: url("../fonts/sarabun-400-thai.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Sarabun";
  src: url("../fonts/sarabun-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2122;
}
@font-face {
  font-family: "Sarabun";
  src: url("../fonts/sarabun-600-thai.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Sarabun";
  src: url("../fonts/sarabun-600-latin.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2122;
}
@font-face {
  font-family: "Sarabun";
  src: url("../fonts/sarabun-700-thai.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Sarabun";
  src: url("../fonts/sarabun-700-latin.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2122;
}
@font-face {
  font-family: "Sarabun";
  src: url("../fonts/sarabun-800-thai.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Sarabun";
  src: url("../fonts/sarabun-800-latin.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2122;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--c-bg);
  background-image: radial-gradient(var(--c-bg-dot) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--c-ink);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--sp-2);
  font-weight: 800;
  line-height: var(--lh-tight);
  color: var(--c-ink);
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3, .k-h3 { font-size: var(--fs-xl); } /* G7: .k-h3 = หัวข้อระดับ h2 ที่ต้องการขนาดเท่า h3 (ไม่ข้ามระดับหัวข้อ) */
h4 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--sp-3); }
ul, ol { margin: 0 0 var(--sp-3); padding-left: var(--sp-5); }
a { color: var(--c-primary-ink); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
a:hover { color: color-mix(in srgb, var(--c-primary-ink) 78%, var(--c-ink)); }
img, svg, canvas, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; }
label { font-weight: 600; }
hr { border: none; border-top: 1px solid var(--c-border); margin: var(--sp-4) 0; }
code, kbd, pre, .k-num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* ---------- focus-visible ring ---------- */
:focus { outline: none; }
:focus-visible {
  outline: none;
  box-shadow: var(--sh-focus);
  border-radius: var(--r-sm);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  box-shadow: var(--sh-focus);
}
/* G7 (a11y): สถานะ "เลือก/กดอยู่" ของแท็บ ชิป ปุ่มสลับ และการ์ดแถบ variant ตั้ง box-shadow เป็นความสูงนุ่มของตัวเอง
   (specificity 0,2,0) แล้วทับวงโฟกัสจนผู้ใช้คีย์บอร์ดมองไม่เห็นว่าอยู่ตรงไหน — :root นำหน้าให้วงโฟกัสชนะเสมอ */
:root [aria-pressed="true"]:focus-visible,
:root [aria-selected="true"]:focus-visible,
:root [aria-checked="true"]:focus-visible,
:root [aria-current]:focus-visible,
:root .is-active:focus-visible,
:root .k-chip--on:focus-visible,
:root .k-card--hover:focus-visible {
  box-shadow: var(--sh-focus);
}

/* ---------- scrollbar นุ่ม ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--c-border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--c-border-strong);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--c-ink-3); background-clip: padding-box; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- โครงหน้าพื้นฐาน ---------- */
.k-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.k-app__main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5);
}
@media (max-width: 640px) {
  .k-app__main { padding: var(--sp-4) var(--sp-3); }
}

.k-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ป้องกันบั๊ก CSS ที่พบบ่อย (คำขอจาก F1a ใน docs/v3/kit-requests/f1a.md): element ที่มีทั้ง attribute
   [hidden] และคลาสที่ตั้ง display เอง (เช่น .k-btn, .k-badge, .k-seg ตั้ง display:flex/inline-flex) จะไม่ถูก
   ซ่อนจริง เพราะกฎของผู้เขียน (author stylesheet) ชนะกฎ [hidden] ของ UA stylesheet เสมอไม่ว่า specificity
   จะเท่ากันแค่ไหน — ย้ายมาจาก kit/css/sim-shell.css ให้ใช้ร่วมกันทุกหน้า (styleguide/gallery/lab-shell ด้วย) */
[hidden] { display: none !important; }
