/*
 * legal.css — สไตล์เฉพาะหน้า terms.html / privacy.html
 * ใช้ร่วมกับ style.css + theme-cyan.css (อ้างตัวแปรสีจาก theme-cyan.css: --primary, --muted, --line, --panel ...)
 * ไฟล์นี้ไม่ถูกโหลดโดย index.html จึงไม่กระทบหน้าแรก
 */

/* ---------- แบรนด์ (เหมือน index.html) ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { width: 24px; height: 24px; object-fit: contain; border-radius: 8px; display: block; flex: none; }
.footer-brand { display: inline-flex; align-items: center; gap: 10px; }

/* ---------- Header ---------- */
.legal-header-actions { display: flex; align-items: center; gap: 10px; }
.legal-header-actions .button { padding: 7px 16px; font-size: 13px; white-space: nowrap; }
.legal-header-actions .button[aria-current="page"] { border-color: var(--primary); color: var(--primary); }
@media (max-width: 640px) {
  .legal-header-actions .button-switch { display: none; }
}

/* ---------- Hero ---------- */
.legal-hero { max-width: 1240px; margin: 0 auto; padding: 64px clamp(22px, 5vw, 64px) 8px; }
.legal-hero h1 { font-size: clamp(30px, 4.2vw, 48px); font-weight: 500; line-height: 1.25; margin: 0 0 14px; }
.legal-hero h1 .accent { color: var(--primary); text-shadow: 0 0 22px rgba(51, 255, 243, .35); }
.legal-lead { max-width: 780px; margin: 0; color: var(--muted); font-size: 15px; }
.legal-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.legal-meta span {
  font-size: 12px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(51, 255, 243, .07); color: #d5fffd;
}
.legal-meta b { font-weight: 500; color: var(--primary); }

/* ---------- Layout: สารบัญ + เนื้อหา ---------- */
.legal-layout {
  max-width: 1240px; margin: 0 auto; padding: 32px clamp(22px, 5vw, 64px) 72px;
  display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 36px; align-items: start;
}

.legal-toc {
  position: sticky; top: 94px; max-height: calc(100vh - 120px); overflow-y: auto;
  padding: 6px 8px 10px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel); box-shadow: 0 0 24px rgba(51, 255, 243, .08);
  scrollbar-width: thin; scrollbar-color: rgba(51, 255, 243, .35) transparent;
}
.legal-toc summary {
  cursor: pointer; list-style: none; padding: 12px 12px 8px;
  font-size: 13px; letter-spacing: 0; font-weight: 500; color: var(--primary-2);  /* ไม่ใช้ letter-spacing กับอักษรไทย: สระ/วรรณยุกต์จะแยกจากพยัญชนะ */
  display: flex; align-items: center; justify-content: space-between;
}
.legal-toc summary::-webkit-details-marker { display: none; }
.legal-toc summary::after { content: "▾"; font-size: 13px; letter-spacing: 0; transition: transform .2s; }
.legal-toc:not([open]) summary::after { transform: rotate(-90deg); }
.legal-toc ol { list-style: none; margin: 0; padding: 0; }
.legal-toc a {
  display: flex; gap: 8px; padding: 6px 10px; border-radius: 8px; border-left: 2px solid transparent;
  font-size: 13px; line-height: 1.5; color: var(--muted); transition: color .2s, background .2s, border-color .2s;
}
.legal-toc a .n { flex: none; width: 1.6em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; opacity: .7; padding-top: 1px; }
.legal-toc a:hover { color: #fff; background: rgba(51, 255, 243, .06); }
.legal-toc a.active { color: var(--primary); background: rgba(51, 255, 243, .09); border-left-color: var(--primary); }
.legal-toc a:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 2px; }

/* ---------- เนื้อหา ---------- */
.legal-content { min-width: 0; }
.legal-section {
  padding: 28px clamp(18px, 3vw, 34px); margin: 0 0 16px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel);
}
.legal-section h2 {
  display: flex; align-items: baseline; gap: 12px; margin: 0 0 14px;
  font-size: clamp(19px, 2.2vw, 24px); font-weight: 500; line-height: 1.4;
}
.legal-section h2 .num { flex: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .62em; letter-spacing: 1px; color: var(--primary); }
.legal-section h3 { margin: 22px 0 8px; font-size: 16px; font-weight: 500; color: var(--primary-2); }
.legal-section p, .legal-section li { font-size: 14.5px; line-height: 1.9; color: #cdeceb; }
.legal-section p { margin: 0 0 12px; }
.legal-section p:last-child { margin-bottom: 0; }
.legal-section ul, .legal-section ol { margin: 0 0 12px; padding-left: 22px; }
.legal-section li { margin-bottom: 4px; }
.legal-section li::marker { color: var(--primary); }
.legal-section strong { color: #fff; font-weight: 500; }
.legal-section a { color: var(--primary); text-decoration: underline; text-decoration-color: rgba(51, 255, 243, .4); text-underline-offset: 3px; transition: text-decoration-color .2s; }
.legal-section a:hover { text-decoration-color: var(--primary); }
.legal-section a:focus-visible, .legal-actions a:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 3px; border-radius: 4px; }
.legal-section code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; padding: 1px 6px; border-radius: 6px; background: rgba(51, 255, 243, .1); color: var(--primary-2); word-break: break-all; }

.legal-note {
  margin: 14px 0 0; padding: 12px 16px; border-left: 3px solid var(--primary); border-radius: 0 10px 10px 0;
  background: rgba(51, 255, 243, .06); font-size: 14px; line-height: 1.8; color: #d5fffd;
}
.legal-note.warn { border-left-color: #ffcc66; background: rgba(255, 204, 102, .07); color: #ffe9bd; }
.legal-note p, .legal-note li { font-size: inherit; color: inherit; }
.legal-note ul { margin: 6px 0 0; }

/* ตาราง — เลื่อนแนวนอนภายในกล่องของตัวเองบนจอแคบ */
.table-wrap { overflow-x: auto; margin: 12px 0 14px; border: 1px solid var(--line); border-radius: 12px; }
.legal-section table { width: 100%; min-width: 560px; border-collapse: collapse; }
.legal-section th, .legal-section td { padding: 10px 14px; text-align: left; vertical-align: top; font-size: 13.5px; line-height: 1.7; border-bottom: 1px solid rgba(51, 255, 243, .12); color: #cdeceb; }
.legal-section th { background: rgba(51, 255, 243, .07); color: var(--primary-2); font-weight: 500; white-space: nowrap; }
.legal-section tr:last-child td { border-bottom: 0; }

.contact-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.contact-list li { margin: 0; }
.contact-list a { display: inline-flex; align-items: center; gap: 8px; }

/* ปุ่มด้านล่าง */
.legal-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 28px; }

/* ---------- Footer ---------- */
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; }
.footer-links a { color: inherit; text-decoration: underline; text-decoration-color: rgba(51, 255, 243, .35); text-underline-offset: 3px; transition: color .2s; }
.footer-links a:hover, .footer-links a[aria-current="page"] { color: var(--primary); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .legal-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .legal-toc { position: static; max-height: none; }
}
@media (max-width: 640px) {
  .legal-hero { padding-top: 40px; }
  .legal-section { padding: 22px 16px; }
  .legal-section h2 { flex-direction: column; gap: 2px; }
  footer .footer-links { width: 100%; justify-content: center; }
}

/* ---------- พิมพ์ / บันทึกเป็น PDF ---------- */
@media print {
  body::before, body::after, .magic-bg, .site-header, .legal-toc, .legal-actions, footer { display: none !important; }
  body, .legal-section { background: #fff !important; color: #000 !important; box-shadow: none !important; }
  .legal-section { border-color: #bbb; break-inside: avoid-page; }
  .legal-section p, .legal-section li, .legal-section td, .legal-section th, .legal-section h2, .legal-section h3, .legal-section strong, .legal-note { color: #000 !important; }
  .legal-section a { color: #000; text-decoration: underline; }
  .legal-hero h1, .legal-hero h1 .accent, .legal-lead { color: #000; text-shadow: none; }
  .legal-layout { display: block; }
}
