/* Tokens, typography, layout primitives, header/footer, legal pages */
:root {
  --paper: #ffffff;
  --paper-2: #f3f6fa;
  --ink: #051c2c;
  --ink-2: #33475b;
  --ink-3: #5a6b7c;
  --line: #dbe2ea;
  --accent: #2251ff;
  --accent-2: #00a9f4;
  --accent-soft: #e8edff;
  --night: #051c2c;
  --night-2: #0c2a42;
  --night-ink: #ffffff;
  --night-ink-2: #a8b9ca;
  /* Type scale: body text uses only these sizes, two weights (400 / 600) */
  --fs-xs: 13px;
  --fs-sm: 15px;
  --fs-base: 17px;
  --fs-lg: 19px;
  --fs-h3: 24px;
  --fs-h3-lg: clamp(26px, 3vw, 32px);
  --w-regular: 400;
  --w-strong: 600;
  --font-display: var(--font-body);
  --font-body: "Be Vietnam Pro", system-ui, sans-serif;
  --wrap: 1200px;
  --section-pad: clamp(72px, 11vw, 140px);
  --gutter: clamp(16px, 4vw, 40px);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--w-regular) var(--fs-base)/1.65 var(--font-body);
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: var(--w-strong); line-height: 1.18; margin: 0; text-wrap: balance; letter-spacing: -.02em; }
h1 { font-size: clamp(2.3rem, 5vw, 3.75rem); }
h2 { font-size: clamp(1.75rem, 3.4vw, 2.6rem); }
h3 { font-size: var(--fs-h3); }
strong, b { font-weight: var(--w-strong); }
p { margin: 0 0 1em; text-wrap: pretty; }
a { color: inherit; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
em.mark { font-style: normal; color: var(--accent); }
.nw { white-space: nowrap; }
.accent-bar { display: block; width: 48px; height: 4px; background: var(--accent); }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.label {
  font: var(--w-strong) var(--fs-xs)/1.4 var(--font-body);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.label b { color: var(--accent); font-weight: inherit; }
.section { padding-block: var(--section-pad); }
/* Anchor jumps land the section heading just below the sticky header, not after the full top padding */
.section[id] { scroll-margin-top: calc(40px - var(--section-pad)); }
.section-head { display: grid; gap: 18px; max-width: 760px; margin-bottom: clamp(40px, 6vw, 72px); }
.lead { font-size: var(--fs-lg); color: var(--ink-2); max-width: 60ch; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 14px; z-index: 200; }
.skip:focus { left: 8px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 48px; padding: 12px 22px;
  border: 1.5px solid var(--ink); border-radius: 2px;
  font: var(--w-strong) var(--fs-sm)/1 var(--font-body); text-decoration: none;
  transition: transform .25s var(--ease), background .25s var(--ease), color .25s var(--ease);
}
.btn:active { transform: translateY(1px) scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn svg { width: 18px; height: 18px; transition: transform .25s var(--ease); }
.btn:hover svg { transform: translateX(3px); }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .9);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.nav { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: var(--w-strong) var(--fs-lg)/1 var(--font-body); letter-spacing: -.01em; }
.brand svg { width: 30px; height: 30px; }
.brand span { font-weight: var(--w-regular); color: var(--ink-3); }
.nav-links { display: none; gap: 30px; list-style: none; margin: 0; padding: 0; }
.nav-links a { text-decoration: none; font-size: var(--fs-sm); color: var(--ink-2); }
.nav-links a:hover { color: var(--accent); }
.nav .btn { min-height: 40px; padding: 10px 16px; }
@media (min-width: 860px) { .nav-links { display: flex; } }

/* Footer */
.site-footer { background: var(--night); color: var(--night-ink-2); padding-block: 56px 40px; font-size: var(--fs-sm); }
.site-footer a { color: var(--night-ink); }
.site-footer a:hover { color: var(--accent-soft); }
.footer-grid { display: grid; gap: 32px; }
.footer-grid .brand { color: var(--night-ink); }
.footer-grid .brand span { color: var(--night-ink-2); }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer-note { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--night-2); font-size: var(--fs-xs); }
@media (min-width: 760px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr; } }

/* Legal pages */
.legal { max-width: 760px; padding-block: 64px 96px; }
.legal h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 12px 0 8px; }
.legal h2 { font-size: var(--fs-h3); margin: 44px 0 12px; }
.legal ul { padding-left: 1.2em; }
.legal li { margin-bottom: .4em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Language dropdown: native <details>, works without JS; lang-menu.js closes it on outside click / Esc */
.nav { justify-content: flex-start; gap: 12px; }
.lang-menu { position: relative; margin-left: auto; }
@media (min-width: 860px) { .nav-links { margin-left: auto; } .nav .lang-menu { margin-left: 8px; } }
.lang-menu summary { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 10px; cursor: pointer; list-style: none; border: 1px solid var(--line); border-radius: 2px; font: var(--w-strong) var(--fs-xs)/1 var(--font-body); color: var(--ink-2); }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary::after { content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); transition: transform .2s var(--ease); }
.lang-menu[open] summary::after { transform: translateY(1px) rotate(-135deg); }
.lang-menu summary:hover { color: var(--accent); border-color: var(--accent); }
.lang-menu summary svg { width: 16px; height: 16px; }
.lang-menu ul { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 168px; margin: 0; padding: 6px; list-style: none; background: var(--paper); border: 1px solid var(--line); box-shadow: 0 12px 32px rgba(5, 28, 44, .12); }
.lang-menu a { display: block; padding: 10px 12px; font-size: var(--fs-sm); color: var(--ink-2); text-decoration: none; }
.lang-menu a:hover { background: var(--paper-2); color: var(--accent); }
.lang-menu a[aria-current="page"] { color: var(--ink); font-weight: var(--w-strong); box-shadow: inset 3px 0 0 var(--accent); }
@media (max-width: 400px) { .nav > .btn { display: none; } }

/* Thai: no letter-case, no tracking on combining marks, taller lines for stacked vowels/tones */
:lang(th) { --font-body: "Be Vietnam Pro", "Noto Sans Thai", system-ui, sans-serif; }
:lang(th) .label, :lang(th) h1, :lang(th) h2, :lang(th) h3, :lang(th) dt { letter-spacing: 0; }
:lang(th) h1, :lang(th) h2, :lang(th) h3 { line-height: 1.4; }
:lang(th) body { line-height: 1.8; }
