/* ============================================================
   legal.css — reusable legal-document foundation.
   Membership Terms · Privacy Notice · Cookie Policy share this file.
   MONOCHROME legal DOCUMENT (One's ruling): the legal document itself is
   black + white — emphasis is carried by size, weight, border and
   whitespace, never by hue. NO gold, NO orange.
   ★ SCOPE: monochrome applies to the DOCUMENT ONLY. The shared site
   chrome (header, FIQH logo, Beta badge, navigation, search, auth
   controls, footer and its red FIQH wordmark) keeps its normal Index
   branding — this file must never redefine shared/global brand
   variables, and must never repaint #header-placeholder /
   #footer-placeholder. The accent override below is therefore scoped to
   the legal-document containers, not to :root.
   Base tokens resolve via css/tokens.css. Fonts (Rule 24): Sarabun body ·
   IBM Plex Sans Thai headings · D-DIN labels · Amiri Arabic.
   Components: hero (.legal-*), comparison (.mt-compare),
   critical summary (.mt-summary), sticky-TOC layout (.legal-doc),
   restrained notice (.legal-callout), related docs (.legal-related),
   mobile สารบัญ (.legal-toc-mobile), print rules.
   ============================================================ */
:root {
  --bg-primary: var(--ink);
  --bg-secondary: var(--ink-2);
  --bg-tertiary: var(--ink-3);
  --text-primary: var(--heading);
  --text-secondary: var(--text);
  --text-tertiary: var(--muted);
  --border-primary: var(--line);
  --border-secondary: var(--line-strong);
  --theme-transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ── MONOCHROME accent — SCOPED TO THE LEGAL DOCUMENT ONLY ────────────
   Custom properties inherit, so redefining the accent on the document
   containers turns every legal component black without touching anything
   outside them. The shared header/footer live outside these containers
   and therefore keep the global brand red from tokens.css.
   ★ Never move these to :root — that is exactly what leaked the
   monochrome into shared site chrome. */
.legal-wrap,
.legal-doc {
  --accent: #1a1a1a;
  --accent-deep: #000000;
}
#themeToggleBtn { display: none !important; }
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--thai, 'Sarabun', system-ui, sans-serif);
  color: var(--text-secondary);
  background: var(--bg-primary);
  font-size: 16px; line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: var(--theme-transition);
}
a { text-decoration: none; color: inherit; transition: color 0.2s ease; }

.legal-wrap { max-width: 820px; margin: 0 auto 96px; padding: clamp(92px, 12vw, 124px) 24px 0; }
.legal-eyebrow {
  font-family: var(--ui); font-size: 11px; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase; color: var(--accent-deep); margin-bottom: 14px;
}
.legal-title {
  font-family: var(--serif, 'IBM Plex Sans Thai', system-ui, sans-serif);
  font-size: clamp(30px, 5vw, 50px); font-weight: 700; line-height: 1.12;
  letter-spacing: -.02em; color: var(--text-primary);
}
.legal-title em { font-style: normal; color: var(--accent); }
.legal-intro { max-width: 66ch; margin: 22px 0 6px; font-size: 16px; line-height: 1.95; color: var(--text-tertiary); }
.legal-intro strong { color: var(--text-secondary); font-weight: 600; }
.legal-meta { margin: 12px 0 0; font-family: var(--ui); font-size: 13px; letter-spacing: .01em; color: var(--text-tertiary); }

/* table of contents */
.legal-toc {
  margin: 40px 0 8px; padding: 22px 26px;
  border: 1px solid var(--border-primary); border-radius: 14px; background: var(--bg-secondary);
}
.legal-toc ol { margin: 0; padding-left: 22px; columns: 2; column-gap: 32px; }
.legal-toc li { margin: 5px 0; font-size: 14.5px; break-inside: avoid; }
.legal-toc a { color: var(--text-secondary); }
.legal-toc a:hover { color: var(--accent); }

.legal-section { margin-top: 44px; scroll-margin-top: 90px; }
.legal-section h2 {
  display: flex; align-items: baseline; gap: 12px;
  font-family: var(--serif, 'IBM Plex Sans Thai', system-ui, sans-serif);
  font-size: clamp(20px, 2.6vw, 25px); font-weight: 700; color: var(--text-primary);
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border-primary);
}
.legal-num {
  flex: 0 0 auto; display: inline-grid; place-items: center;
  min-width: 30px; height: 30px; padding: 0 8px;
  font-family: var(--ui); font-size: 14px; font-weight: 700;
  color: var(--accent); border: 1px solid var(--border-secondary); border-radius: 8px;
}
.legal-section h3 {
  font-family: var(--serif, 'IBM Plex Sans Thai', system-ui, sans-serif);
  font-size: 17px; font-weight: 600; color: var(--text-primary); margin: 24px 0 10px;
}
.legal-section p { margin: 12px 0; max-width: 72ch; }
.legal-section strong { color: var(--text-primary); font-weight: 600; }
.legal-list { margin: 12px 0 12px; padding-left: 22px; max-width: 74ch; }
.legal-list li { margin: 8px 0; padding-left: 4px; }
.legal-list li::marker { color: var(--accent-deep); }
.legal-section a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.legal-section a:hover { color: var(--accent-deep); }
code {
  font-family: 'Inter', ui-monospace, monospace; font-size: .88em;
  background: var(--bg-tertiary); border: 1px solid var(--border-primary);
  border-radius: 5px; padding: 1px 6px; color: var(--text-secondary); overflow-wrap: anywhere;
}

/* callout note */
.legal-note {
  margin-top: 16px; padding: 16px 20px;
  border: 1px solid var(--border-primary); border-left: 3px solid var(--accent-deep);
  border-radius: 10px; background: var(--bg-secondary);
  font-size: 15px; color: var(--text-tertiary);
}

/* third-party processor cards */
.legal-card {
  border: 1px solid var(--border-primary); border-radius: 14px;
  padding: 20px 24px; margin: 14px 0; background: var(--bg-secondary);
}
.legal-card h3 { margin: 0 0 8px; font-family: var(--serif, 'IBM Plex Sans Thai', system-ui, sans-serif); font-size: 17px; font-weight: 600; color: var(--text-primary); }
.legal-card p { margin: 6px 0; font-size: 15px; }
.legal-card-link a { font-family: var(--ui); font-size: 14px; }

/* tables (purpose/legal-basis · cookie table) */
.legal-table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--border-primary); border-radius: 12px; }
.legal-table { width: 100%; border-collapse: collapse; min-width: 560px; font-size: 14.5px; }
.legal-table th, .legal-table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border-primary); vertical-align: top; }
.legal-table thead th {
  font-family: var(--serif, 'IBM Plex Sans Thai', system-ui, sans-serif); font-weight: 600;
  color: var(--text-primary); background: var(--bg-tertiary); white-space: nowrap;
}
.legal-table tbody tr:last-child td { border-bottom: 0; }
.legal-table td code { white-space: nowrap; }

@media (max-width: 640px) {
  .legal-toc ol { columns: 1; }
  .legal-wrap { padding-left: 18px; padding-right: 18px; }
}

/* ============================================================
   Membership-Terms components (reusable legal foundation).
   White/black/red · restrained glass · no gold · no marketing.
   ============================================================ */

/* — restrained legal hero support — */
.legal-hero-meta {
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
  margin-top: 18px; font-family: var(--ui); font-size: 13px; color: var(--text-tertiary);
}
.legal-hero-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--border-secondary); }
.legal-hero-contact a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* — sticky-TOC document layout (desktop: contents left, document right) — */
.legal-doc { max-width: 1180px; margin: 0 auto 96px; padding: 0 24px;
  display: grid; grid-template-columns: 1fr; gap: 0; }
.legal-doc-body { min-width: 0; max-width: 78ch; }
.legal-doc-nav { display: none; }
@media (min-width: 1000px) {
  .legal-doc { grid-template-columns: 248px minmax(0, 1fr); gap: 56px; align-items: start; }
  .legal-doc-nav { display: block; position: sticky; top: 96px; align-self: start; }
}
.legal-doc-nav .toc-head {
  font-family: var(--ui); font-size: 11px; font-weight: 600; letter-spacing: .18em;
  text-transform: uppercase; color: var(--text-tertiary); margin: 0 0 12px;
}
.legal-doc-nav ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border-primary); }
.legal-doc-nav li { margin: 0; }
.legal-doc-nav a {
  display: block; padding: 7px 0 7px 16px; margin-left: -1px;
  border-left: 2px solid transparent; color: var(--text-tertiary);
  font-size: 14px; line-height: 1.4;
}
.legal-doc-nav a:hover { color: var(--text-primary); }
.legal-doc-nav a.is-active {
  color: var(--accent); border-left-color: var(--accent); font-weight: 600;
}

/* — mobile สารบัญ (compact, native <details>) — */
.legal-toc-mobile { margin: 26px 0 8px; border: 1px solid var(--border-primary); border-radius: 12px;
  background: var(--bg-secondary); }
@media (min-width: 1000px) { .legal-toc-mobile { display: none; } }
.legal-toc-mobile > summary {
  list-style: none; cursor: pointer; padding: 14px 18px; min-height: 44px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-family: var(--serif, 'IBM Plex Sans Thai', system-ui, sans-serif);
  font-weight: 600; color: var(--text-primary);
}
.legal-toc-mobile > summary::-webkit-details-marker { display: none; }
.legal-toc-mobile > summary::after { content: "＋"; color: var(--text-tertiary); font-size: 18px; }
.legal-toc-mobile[open] > summary::after { content: "－"; }
.legal-toc-mobile ol { list-style: none; margin: 0; padding: 4px 8px 12px; }
.legal-toc-mobile li { margin: 0; }
.legal-toc-mobile a { display: block; padding: 10px 12px; min-height: 44px;
  color: var(--text-secondary); font-size: 15px; border-radius: 8px; }
.legal-toc-mobile a:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* major section wrapper inside the document */
.legal-major { margin-top: 56px; scroll-margin-top: 88px; }
.legal-major:first-of-type { margin-top: 8px; }
.legal-major > .major-head {
  font-family: var(--serif, 'IBM Plex Sans Thai', system-ui, sans-serif);
  font-size: clamp(19px, 2.4vw, 23px); font-weight: 700; color: var(--text-primary);
  letter-spacing: -.01em; margin: 0 0 4px; padding-bottom: 10px;
  border-bottom: 2px solid var(--border-secondary);
}
.legal-major > .major-sub { margin: 0 0 8px; font-family: var(--ui); font-size: 12.5px;
  letter-spacing: .04em; color: var(--text-tertiary); }

/* — membership comparison — */
.mt-compare { margin: 8px 0 4px; }
.mt-compare-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 720px) { .mt-compare-grid { grid-template-columns: 1fr 1fr; } }
.mt-card {
  border: 1px solid var(--border-primary); border-radius: 16px;
  background: var(--bg-secondary); padding: 22px 22px 8px; display: flex; flex-direction: column;
}
.mt-card.is-founding { border-color: var(--accent); }
.mt-card-tag {
  align-self: flex-start; font-family: var(--ui); font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-tertiary);
  border: 1px solid var(--border-secondary); border-radius: 999px; padding: 3px 10px; margin-bottom: 12px;
}
.mt-card.is-founding .mt-card-tag { color: var(--accent); border-color: var(--accent); }
.mt-card-name { font-family: var(--serif, 'IBM Plex Sans Thai', system-ui, sans-serif);
  font-size: 22px; font-weight: 700; color: var(--text-primary); margin: 0; }
.mt-card-en { font-family: var(--ui); font-size: 12px; letter-spacing: .06em; color: var(--text-tertiary); margin: 2px 0 0; }
.mt-card-price { margin: 12px 0 2px; display: flex; align-items: baseline; gap: 6px; }
.mt-card-price b { font-family: var(--serif, 'IBM Plex Sans Thai', system-ui, sans-serif);
  font-size: 30px; font-weight: 700; color: var(--text-primary); }
.mt-card-price span { font-size: 14px; color: var(--text-tertiary); }
.mt-card ul { list-style: none; margin: 14px 0 6px; padding: 14px 0 0; border-top: 1px solid var(--border-primary); }
.mt-card li { position: relative; padding: 7px 0 7px 26px; font-size: 14.5px; line-height: 1.6; }
.mt-card li::before { content: ""; position: absolute; left: 2px; top: 15px;
  width: 9px; height: 9px; border-radius: 2px; border: 1.5px solid var(--accent-deep); }
.mt-card li.no::before { border-color: var(--border-secondary); background: transparent; }
.mt-card li.no { color: var(--text-tertiary); }
.mt-card li b { color: var(--text-primary); font-weight: 600; }
/* full comparison table (semantic, screen-reader friendly) */
.mt-table-wrap { overflow-x: auto; margin: 20px 0 4px; border: 1px solid var(--border-primary); border-radius: 12px; }
.mt-table { width: 100%; border-collapse: collapse; min-width: 560px; font-size: 14.5px; }
.mt-table caption { text-align: left; padding: 12px 16px 0; color: var(--text-tertiary); font-size: 13px; }
.mt-table th, .mt-table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border-primary); vertical-align: top; }
.mt-table thead th { font-family: var(--serif, 'IBM Plex Sans Thai', system-ui, sans-serif);
  font-weight: 600; color: var(--text-primary); background: var(--bg-tertiary); }
.mt-table th[scope="row"] { font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.mt-table td.founding-col { border-left: 1px solid var(--border-primary); }
.mt-table tbody tr:last-child td, .mt-table tbody tr:last-child th { border-bottom: 0; }
/* compact bulleted list inside a comparison-table cell (FIQH Beta chronology benefits) */
.mt-table td .mt-cell-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mt-table td .mt-cell-list li { position: relative; padding-left: 16px; }
.mt-table td .mt-cell-list li::before { content: "•"; position: absolute; left: 0; color: var(--text-tertiary); }

/* — critical-terms summary (สิ่งสำคัญที่ควรทราบก่อนสมัคร) — */
.mt-summary { margin: 8px 0 4px; }
.mt-summary ol { list-style: none; counter-reset: mt; margin: 14px 0 0; padding: 0;
  display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) { .mt-summary ol { grid-template-columns: 1fr 1fr; } }
.mt-summary li { counter-increment: mt; position: relative; padding: 14px 16px 14px 52px;
  border: 1px solid var(--border-primary); border-radius: 12px; background: var(--bg-secondary);
  font-size: 14.5px; line-height: 1.6; }
.mt-summary li::before { content: counter(mt); position: absolute; left: 14px; top: 14px;
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px;
  font-family: var(--ui); font-size: 13px; font-weight: 700; color: var(--accent);
  border: 1px solid var(--border-secondary); }
.mt-summary li a { display: inline-block; margin-top: 4px; font-family: var(--ui);
  font-size: 12.5px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* — restrained legal callout (termination / grace) — no danger colours — */
.legal-callout { margin: 18px 0; padding: 16px 20px; border: 1px solid var(--border-primary);
  border-left: 3px solid var(--accent); border-radius: 10px; background: var(--bg-secondary); }
.legal-callout .callout-head { font-family: var(--serif, 'IBM Plex Sans Thai', system-ui, sans-serif);
  font-weight: 600; color: var(--text-primary); margin: 0 0 6px; }
.legal-callout p { margin: 6px 0; font-size: 15px; color: var(--text-secondary); }

/* — related documents / cross-doc nav — */
.legal-related { margin: 64px 0 0; padding-top: 28px; border-top: 1px solid var(--border-primary); }
.legal-related h2 { font-family: var(--serif, 'IBM Plex Sans Thai', system-ui, sans-serif);
  font-size: 18px; font-weight: 700; color: var(--text-primary); margin: 0 0 14px; }
.legal-related-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .legal-related-grid { grid-template-columns: 1fr 1fr; } }
.legal-related a.rel {
  display: block; padding: 16px 18px; min-height: 44px; border: 1px solid var(--border-primary);
  border-radius: 12px; background: var(--bg-secondary); color: var(--text-primary); font-weight: 600;
}
.legal-related a.rel:hover { border-color: var(--accent); color: var(--accent); }
.legal-related a.rel span { display: block; font-family: var(--ui); font-weight: 400; font-size: 12.5px;
  color: var(--text-tertiary); margin-top: 3px; }
.legal-related .rel-contact { margin: 18px 0 0; font-size: 14.5px; color: var(--text-tertiary); }
.legal-related .rel-contact a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* ============================================================
   MONOCHROME EDITORIAL LAYER (One's ruling)
   Calm, serious, confident legal typography: hierarchy is carried by
   SIZE, WEIGHT and WHITESPACE — never by hue. Black on white only.
   Scoped: legal.css is linked exclusively by the three legal pages.
   ============================================================ */

/* — hero: bigger, calmer, more air — */
.legal-title {
  font-size: clamp(34px, 5.6vw, 58px);
  letter-spacing: -.025em;
  line-height: 1.08;
}
.legal-title em { font-style: normal; color: var(--text-primary); }
.legal-intro { font-size: 17px; line-height: 2; max-width: 62ch; }

/* — major sections: confident heads, generous vertical rhythm — */
.legal-major { margin-top: 88px; }
.legal-major:first-of-type { margin-top: 16px; }
.legal-major > .major-head {
  font-size: clamp(24px, 3.2vw, 34px);
  letter-spacing: -.02em; line-height: 1.2;
  margin: 0 0 6px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border-secondary);
}
.legal-major > .major-sub { margin: 0 0 10px; font-size: 13px; }
/* prose sitting directly under a major head (overview blocks) — the base
   reset zeroes <p>, so restore rhythm and measure here too */
.legal-major > p { margin: 14px 0; max-width: 72ch; line-height: 1.95; }

/* — clauses: quieter numbers, more breathing room — */
.legal-section { margin-top: 40px; }
.legal-section h2 { font-size: clamp(18px, 2.2vw, 21px); letter-spacing: -.01em; }
.legal-section h3 { margin-top: 28px; }
.legal-section p { line-height: 1.95; }

/* — links: black, underlined (no hue) — */
.legal-section a, .legal-hero-contact a, .legal-related .rel-contact a, .mt-summary li a {
  color: var(--text-primary);
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.legal-section a:hover, .legal-hero-contact a:hover,
.legal-related .rel-contact a:hover, .mt-summary li a:hover {
  color: #000; text-decoration-thickness: 2px;
}
.legal-toc a:hover, .legal-doc-nav a:hover { color: var(--text-primary); }
.legal-doc-nav a.is-active { color: var(--text-primary); border-left-color: #000; }

/* — notices: structure, not colour. The callout stays unmistakable via a
     heavy rule, bold head and generous padding (Founding-termination). — */
.legal-callout {
  border-left-width: 4px; border-left-color: #000;
  padding: 20px 24px; background: var(--bg-secondary);
}
.legal-callout .callout-head { font-weight: 700; letter-spacing: -.01em; }
.legal-note { border-left-width: 3px; border-left-color: var(--text-primary); }
.mt-card.is-founding { border-color: var(--text-primary); border-width: 2px; }
.mt-card.is-founding .mt-card-tag { color: var(--text-primary); border-color: var(--text-primary); }

/* NOTE: shared site chrome (#header-placeholder / #footer-placeholder,
   the FIQH logo, Beta badge, navigation, search, auth controls, footer
   wordmarks and #backToTopBtn / #readingProgress) is deliberately NOT
   styled here. It inherits the global Index branding from tokens.css and
   the components' own styles — one source of truth. */

@media (max-width: 640px) {
  .legal-major { margin-top: 64px; }
}

/* — print: clean black-on-white legal document — */
@media print {
  #header-placeholder, #footer-placeholder, .legal-doc-nav, .legal-toc-mobile,
  #backToTopBtn, #readingProgress { display: none !important; }
  html, body { background: #fff !important; color: #000 !important; }
  .legal-doc { display: block; max-width: 100%; padding: 0; }
  .legal-doc-body { max-width: 100%; }
  .legal-major, .legal-section, .mt-card, .mt-summary li, .legal-callout { break-inside: avoid; }
  .legal-major > .major-head, .legal-section h2, .legal-major, h1, h2, h3 { break-after: avoid; }
  .mt-compare-grid, .mt-summary ol { grid-template-columns: 1fr 1fr; }
  a { color: #000 !important; text-decoration: underline; }
  .mt-card, .mt-summary li, .legal-callout, .legal-related a.rel, .legal-toc { background: #fff !important; }
}
