/* ─── legal.css: ชุดหน้ากฎหมาย (/legal, /legal/privacy, /legal/terms) ─── */
/* โหลดคู่กับ site.css เสมอ (ใช้ token/ตัวแปรร่วมจากที่นั่น เหมือน solutions.css) ไม่แก้ site.css/site.js
   ต่างจากชุดหน้าอื่นตรงที่ B4 ตัดสินแล้วว่าเลื่อนแบบปกติ ไม่ snap ทีละจอ (เอกสารกฎหมายยาวเกินหนึ่งจอเสมอ)
   ไฟล์นี้จึงมีสองงาน: (1) ปลดล็อก scroll-snap/ความสูง 100svh ที่ site.css ผูกกับ .chapter ไว้ (2) ให้คอมโพเนนต์เฉพาะของหน้ากฎหมาย
   ที่ site.css/solutions.css ไม่มี: แบนเนอร์ฉบับร่าง, breadcrumb, สารบัญหัวข้อ, ตัวอักษรเนื้อหายาว, การ์ดลิงก์เอกสาร */

/* ─── หมวด 1: ปลดล็อก scroll-snap ─────────────────────────────
   ความจำเพาะ (specificity) ของ body.page-legal .chapter สูงกว่า .chapter/.chapter.chapter ที่ site.css ประกาศไว้
   ในทุก media query อยู่แล้ว (มี type selector "body" เพิ่ม) จึงชนะโดยไม่ต้อง !important และไม่ขึ้นกับลำดับไฟล์ */
html[data-page=legal] { scroll-snap-type: none; }
body.page-legal .chapter:not(.ch-foot) {
  scroll-snap-align: none; scroll-snap-stop: normal;
  height: auto; min-height: 0; overflow: visible; padding-bottom: 0;
}

/* ─── หมวด 2: ป้ายฉบับร่าง (เหนือหัวเรื่อง, ยังเป็น .eyebrow เดิมของ site.css เพื่อให้แสงคู่จับตำแหน่งได้ผ่าน
   headerPartsMap['ch-1'] ของ site.js ที่รออ่าน '.hero-copy .eyebrow') เหลือ icon กับข้อความอยู่ในแถวเดียว
   ไม่มีเส้นขอบ พื้นหลัง หรือ padding (เจ้าของงาน 28 ต.ค. 2569: ระยะหน้า icon เหลือเยอะ ไม่เข้ากับหน้า) ─── */
.legal-draft-badge {
  display: inline-flex; align-items: center; gap: var(--cs-space-1);
  padding: 0; border: 0; background: none;
  color: var(--cs-status-warning-content);
  font-family: var(--cs-font-thai); font-size: var(--cs-size-thai-dense); font-weight: var(--cs-weight-medium);
  letter-spacing: normal; text-transform: none;
}
.legal-draft-badge .ic { width: var(--cs-icon-sm); height: var(--cs-icon-sm); flex: none; }

/* ─── หมวด 3: hero ของหน้ากฎหมาย (ใช้โครงเดียวกับ headerPartsMap ch-1 ของหน้าแรก: .hero-copy > .eyebrow + #hero-title + .hero-copy > .lede) ─── */
.legal-hero { display: grid; place-items: center; text-align: center; padding: calc(var(--nav-h) + var(--rhy-6)) 0 var(--rhy-6); }
.hero-copy.legal-hero-copy { max-width: 760px; margin: 0 auto; }
.legal-hero-copy .legal-draft-badge { margin-bottom: var(--rhy-4); }
.legal-hero-copy h1 { margin: 0 0 var(--rhy-4); }
.legal-hero-copy > .lede { max-width: 42em; margin: 0 auto; }
@media (max-width: 719.98px) { .legal-hero { padding-top: calc(var(--nav-h) + var(--cs-space-6)); } }

/* ─── หมวด 4: breadcrumb บนหน้าลูก (สูตรเดียวกับ .sol-breadcrumb ของ solutions.css คัดมาไว้ที่นี่เพราะหน้ากฎหมายไม่โหลดไฟล์นั้น) ─── */
.legal-breadcrumb {
  display: flex; align-items: center; gap: var(--cs-space-2); justify-content: center;
  margin: 0 0 var(--rhy-4);
  font-size: var(--cs-size-thai-dense); color: var(--cs-content-secondary);
}
.legal-breadcrumb a { color: var(--cs-content-secondary); text-decoration: none; }
.legal-breadcrumb a:hover, .legal-breadcrumb a:focus-visible { color: var(--cs-content-primary); text-decoration: underline; text-underline-offset: 3px; }
.legal-breadcrumb .ic { width: 14px; height: 14px; flex: none; color: var(--cs-content-tertiary); }
.legal-breadcrumb [aria-current="page"] { color: var(--cs-content-primary); font-weight: var(--cs-weight-medium); }

/* ─── หมวด 5: บทเนื้อหา ที่คร่อม .statement (headerPartsMap ch-2) ให้แสงคู่ที่สองมีจุดจับตำแหน่งจากคำนำสั้นๆ เหนือสารบัญ ─── */
.legal-body-chapter { padding: calc(var(--nav-h) + var(--rhy-6)) 0 var(--rhy-10); }
.legal-body-chapter .statement {
  text-align: center; font-size: var(--cs-size-reading); line-height: var(--cs-leading-relaxed);
  color: var(--cs-content-secondary); max-width: 42em; margin: 0 auto var(--rhy-8); text-wrap: balance;
}

/* ─── หมวด 6: layout สองคอลัมน์ (สารบัญซ้าย + เนื้อหา) ─────────────────
   จอ ≥720px: สารบัญเป็นคอลัมน์ sticky ซ้าย, จอเล็ก: สารบัญกลายเป็นแผงพับเปิดด้านบนเนื้อหา */
.legal-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: var(--cs-space-8); align-items: start; }

.legal-toc { position: sticky; top: calc(var(--nav-h) + var(--cs-space-4)); }
.legal-toc-toggle {
  display: none; width: 100%; align-items: center; justify-content: space-between; gap: var(--cs-space-3);
  min-height: 48px; padding: 0 var(--cs-space-4); margin-bottom: var(--cs-space-3);
  border: 1px solid var(--cs-border-subtle); border-radius: var(--cs-radius-lg);
  background: var(--cs-surface-glass); color: var(--cs-content-primary);
  font-family: var(--cs-font-thai); font-size: var(--cs-size-thai); font-weight: var(--cs-weight-semibold);
  cursor: pointer;
}
.legal-toc-toggle .ic { flex: none; transition: rotate var(--cs-duration-base) var(--cs-ease-standard); }
.legal-toc-list {
  list-style: none; margin: 0; padding: var(--cs-space-2) 0 var(--cs-space-2) var(--cs-space-4);
  border-left: 1px solid var(--cs-border-subtle);
  display: flex; flex-direction: column; gap: var(--cs-space-1);
  max-height: calc(100svh - var(--nav-h) - var(--cs-space-8));
  overflow-y: auto;
}
.legal-toc-list a {
  display: block; padding: var(--cs-space-2) var(--cs-space-3);
  border-radius: var(--cs-radius-sm); text-decoration: none;
  font-family: var(--cs-font-thai); font-size: var(--cs-size-thai-dense); color: var(--cs-content-primary);
  transition: color var(--cs-duration-base) var(--cs-ease-standard), font-style var(--cs-duration-base) var(--cs-ease-standard);
}
.legal-toc-list a:hover, .legal-toc-list a:focus-visible { color: var(--cs-content-brand); }
.legal-toc-list a:focus-visible { outline: none; box-shadow: var(--cs-focus-ring); }
.legal-toc-list a[aria-current="true"] {
  color: var(--cs-content-brand);
}

/* ─── หมวด 7: คอลัมน์เนื้อหา ─── ความกว้างอ่าน ≤68 ตัวอักษร, ตัวอักษร ≥17px desktop, บรรทัดสบายตา */
.legal-doc { max-width: 68ch; }
.legal-section { padding-bottom: var(--rhy-8); margin-bottom: var(--rhy-8); border-bottom: 1px solid var(--cs-border-subtle); scroll-margin-top: calc(var(--nav-h) + var(--cs-space-4)); }
.legal-anchor { display: block; height: 0; scroll-margin-top: calc(var(--nav-h) + var(--cs-space-4)); }
.legal-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.legal-section h2 {
  font-family: var(--cs-font-thai); font-weight: var(--cs-weight-semibold); font-size: clamp(20px, 1.4vw + 1svh, 28px);
  color: var(--cs-content-primary); margin: 0 0 var(--cs-space-4); scroll-margin-top: calc(var(--nav-h) + var(--cs-space-4));
}
.legal-section h2 .legal-section-no { color: var(--cs-content-tertiary); font-weight: var(--cs-weight-regular); margin-right: var(--cs-space-2); }
.legal-section p {
  font-size: 17px; line-height: var(--cs-leading-relaxed); color: var(--cs-content-secondary); margin: 0;
}
.legal-section p + p { margin-top: var(--cs-space-4); }
@media (max-width: 719.98px) { .legal-section p { font-size: 16px; } }

/* ─── หมวด 8: กล่องข้อมูลที่ยังไม่ตัดสิน (ต่อท้ายเอกสาร) ─── */
.legal-todo { margin-top: var(--rhy-10); padding: var(--rhy-5); border: 1px solid var(--cs-border-subtle); border-radius: var(--cs-radius-lg); background: var(--cs-surface-glass); }
.legal-todo h2 { font-family: var(--cs-font-thai); font-size: var(--cs-size-thai); font-weight: var(--cs-weight-semibold); color: var(--cs-content-primary); margin: 0 0 var(--cs-space-3); }
.legal-todo ul { margin: 0; padding-left: var(--cs-space-5); display: flex; flex-direction: column; gap: var(--cs-space-2); }
.legal-todo li { font-size: var(--cs-size-thai-dense); line-height: var(--cs-leading-relaxed); color: var(--cs-content-secondary); }

@media (max-width: 719.98px) {
  .legal-layout { display: block; }
  .legal-toc { position: static; margin-bottom: var(--rhy-6); }
  /* ไม่มี JS สารบัญเปิดอยู่เสมอและไม่มีปุ่มพับ (ปุ่มกับการพับเป็นของ JS) */
  .legal-toc-toggle { display: flex; }
  html:not(.js) .legal-toc-toggle { display: none; }
  .legal-toc-list {
    border-left: 0; padding: var(--cs-space-2); max-height: none; overflow: visible;
    border: 1px solid var(--cs-border-subtle); border-radius: var(--cs-radius-lg); background: var(--cs-surface-glass);
  }
  html.js .legal-toc-list { display: none; }
  .legal-toc[data-open] .legal-toc-list { display: flex; }
  .legal-toc[data-open] .legal-toc-toggle .ic { rotate: 180deg; }
}

/* ─── หมวด 9: /legal ดัชนี ─── คอลัมน์ซ้ายชิดซ้าย, รายการเอกสารใช้ .path-index ของ chapters.css ตรงๆ (ดัชนี editorial
   เดียวกับ hero ของ /solutions) ไม่มีการ์ดหรือกล่องทึบ เพราะเจ้าของงานปฏิเสธการ์ดในดัชนีแล้ว (cresive-web-page-design.md หัวข้อ 7) ─── */
body.page-legal .chapter.legal-index-chapter { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--nav-h) + var(--rhy-5)) 0 var(--rhy-6); }
/* จอ ≥720: ระยะบนเท่าล่าง (nav-h) ให้เนื้อหากลางจอจริงแบบเดียวกับบทอื่นของเว็บ */
@media (min-width: 720px) { body.page-legal .chapter.legal-index-chapter { padding-top: var(--nav-h); padding-bottom: var(--nav-h); } }
.legal-index-copy.lead-left { max-width: 640px; margin: 0; text-align: left; }
.legal-index-copy h1 { margin: 0 0 var(--rhy-4); }
.legal-index-copy > .lede { max-width: none; margin: 0; }
.legal-index-copy .path-index { margin-left: 0; margin-right: 0; }
/* จอกว้าง: สองคอลัมน์แบบ hero ของ /solutions (ข้อความซ้าย ดัชนีขวา) แทนการกองทุกอย่างในคอลัมน์แคบซ้ายแล้วปล่อยครึ่งขวาว่าง */
@media (min-width: 1024px) {
  .legal-index-copy.lead-left {
    max-width: none; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    column-gap: clamp(48px, 7vw, 120px); align-items: center;
  }
  .legal-index-copy > h1, .legal-index-copy > .lede, .legal-index-copy > .legal-index-note { grid-column: 1; }
  .legal-index-copy > .path-index { grid-column: 2; grid-row: 1 / span 3; margin-top: 0; margin-bottom: 0; }
  .legal-index-copy > .legal-index-note { margin-top: var(--rhy-5); }
}
.legal-index-note {
  display: flex; align-items: flex-start; gap: var(--cs-space-3); margin: 0;
  padding: var(--cs-space-4) var(--cs-space-5); border-radius: var(--cs-radius-lg); background: var(--cs-alpha-light-04);
}
.legal-index-note .ic { flex: none; width: var(--cs-icon-md); height: var(--cs-icon-md); color: var(--cs-content-brand); margin-top: 2px; }
.legal-index-note p { margin: 0; font-size: var(--cs-size-thai-dense); line-height: var(--cs-leading-relaxed); color: var(--cs-content-secondary); }

@media (max-width: 719.98px) {
  .legal-index-chapter { padding-top: calc(var(--nav-h) + var(--cs-space-4)); }
}

/* ─── หมวด 9: สารบัญแบบเส้นเวลา (เจ้าของงานสั่ง 2026-09-29: เอาแถบเลื่อนของสารบัญออก ใช้จุดแบบแถบจุดบทในรูปเส้นเวลา)
   จอ ≥720px เท่านั้น: เส้นแนวตั้งหนึ่งเส้น จุดต่อหัวข้อ หัวข้อปัจจุบันเป็นวงแหวน 14px แบบ .chapters ของ site.css
   legal.js แสดงหัวข้อแรกและสุดท้ายเสมอ และหัวข้อข้างเคียงก่อน/หลังหัวข้อปัจจุบันอย่างละ 2 รายการ ที่เหลือพับไว้
   ช่วงที่พับแสดงเป็นจุดเล็กสามจุดบนเส้น (วาดด้วย radial-gradient ไม่ใช้อักขระ) รายการจึงสั้นพอไม่ต้องมีแถบเลื่อน
   มือถือยังเป็นแผงพับเปิดรายการเต็มแบบเดิม ─── */
@media (min-width: 720px) {
  .legal-toc-list {
    position: relative; max-height: none; overflow: visible; border-left: 0;
    padding: var(--cs-space-2) 0; gap: 0;
  }
  .legal-toc-list::before {
    content: ""; position: absolute; left: 6px; top: var(--cs-space-4); bottom: var(--cs-space-4); width: 1px;
    background: linear-gradient(var(--cs-border-subtle), var(--cs-border-subtle));
  }
  .legal-toc-list li { position: relative; }
  .legal-toc-list li[data-far] { display: none; }
  .legal-toc-list a {
    position: relative; display: flex; align-items: center; gap: var(--cs-space-3);
    min-height: 40px; padding: var(--cs-space-1) var(--cs-space-2) var(--cs-space-1) 0;
    color: var(--cs-content-secondary);
  }
  .legal-toc-list a::before {
    content: ""; flex: none; box-sizing: border-box; width: 14px; height: 14px; border-radius: 50%;
    background: radial-gradient(circle, var(--cs-action-primary) 0 2.5px, transparent 3px);
    border: 1.5px solid transparent;
    transition: border-color var(--cs-duration-base) var(--cs-ease-standard);
  }
  .legal-toc-list a[aria-current="true"] { color: var(--cs-content-primary); font-weight: var(--cs-weight-semibold); }
  .legal-toc-list a[aria-current="true"]::before { border-color: var(--cs-action-primary); }
  .legal-toc-list a:hover, .legal-toc-list a:focus-visible { color: var(--cs-content-brand); }
  /* ช่วงที่ถูกพับ: สามจุดเล็กเรียงบนเส้นใต้รายการก่อนหน้า */
  .legal-toc-list li[data-gap-after]::after {
    content: ""; display: block; width: 14px; height: 20px;
    background: radial-gradient(circle, var(--cs-content-tertiary) 0 1.2px, transparent 1.6px) center / 14px 6px repeat-y;
  }
}

/* หน้าต่างเตี้ย (< 680px สูง): บทดัชนี /legal ต้องพอดีหนึ่งจอ ระยะบนพ้นแคปซูลนำทางพอ ระยะล่างเล็กลง (เจ้าของงาน 2026-09-30)
   หน้าเอกสาร /legal/privacy และ /legal/terms ยังเลื่อนตามปกติตาม B4 (เอกสารยาวเกินหนึ่งจอ) */
@media (min-width: 720px) and (max-height: 679.98px) {
  body.page-legal .chapter.legal-index-chapter { padding-top: calc(var(--nav-h) - 24px); padding-bottom: var(--cs-space-6); }
}
