/* Connect8 design tokens, shared by the public homepage and the console.
   Light is the default; dark follows the OS unless the visitor picked a theme
   (data-theme on <html>, set by /home/theme.js before first paint).
   --accent passes WCAG AA as text and as a button fill in both themes;
   --accent-2 is the brighter BE8 teal and is decorative only. */

/* Anuphan (SIL OFL 1.1, /home/fonts/OFL.txt) for headings and emphasis. */
@font-face { font-family: "Anuphan"; font-style: normal; font-weight: 100 700; font-display: swap; src: url(/home/fonts/anuphan-5.3.0-thai.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Anuphan"; font-style: normal; font-weight: 100 700; font-display: swap; src: url(/home/fonts/anuphan-5.3.0-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Anuphan"; font-style: normal; font-weight: 100 700; font-display: swap; src: url(/home/fonts/anuphan-5.3.0-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: light;

  /* surfaces */
  --bg: #f6f9fa;
  --bg-alt: #eef4f6;
  --surface: #ffffff;
  --surface-2: #f3f7f9;
  --surface-3: #e9f0f3;
  --line: #e0e8ed;
  --line-strong: #c8d5dd;

  /* text */
  --text: #0f1b2d;
  --muted: #4f5f73;
  --faint: #6b7a8c;

  /* brand */
  --accent: #0a7f9a;
  --accent-hover: #086c83;
  --accent-2: #19b3d1;
  --accent-soft: #e6f5f9;
  --accent-line: #bde5ef;
  --accent-ink: #ffffff;

  /* status */
  --ok: #0f7a4a;
  --ok-soft: #e2f4ea;
  --warn: #8c5a00;
  --warn-soft: #fcf0d9;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --info: #1d5fb8;
  --info-soft: #e5eefb;

  /* code */
  --code-bg: #0e1824;
  --code-text: #e3edf3;
  --code-comment: #8fa9ba;
  --code-inline: #edf2f5;

  /* shape */
  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 18px;
  --radius-pill: 999px;
  --shadow-s: 0 1px 2px rgba(15, 27, 45, .05);
  --shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 8px 24px rgba(15, 27, 45, .06);
  --shadow-l: 0 24px 64px rgba(15, 27, 45, .18);
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent-2) 35%, transparent);

  /* spacing (4px grid) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px; --s16: 64px;

  /* type: Thai needs generous line height for stacked vowels and tones */
  --font: system-ui, -apple-system, "Segoe UI", "Leelawadee UI", "Noto Sans Thai", "Sarabun", sans-serif;
  --font-head: "Anuphan", var(--font);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --lh: 1.65;
  --lh-head: 1.3;

  /* motion: short and purposeful; zeroed under prefers-reduced-motion */
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 320ms;
  --dur-4: 600ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a1016; --bg-alt: #0d151c; --surface: #121c25; --surface-2: #17232e; --surface-3: #1d2b37;
    --line: #22313d; --line-strong: #33475a;
    --text: #e8f0f5; --muted: #a6b5c3; --faint: #8394a6;
    --accent: #4fcbe4; --accent-hover: #7ad9ec; --accent-2: #2fbfdc; --accent-soft: #0f2a34; --accent-line: #1f4a5a; --accent-ink: #061218;
    --ok: #5fd4a0; --ok-soft: #10281e; --warn: #f1bb5c; --warn-soft: #2b2112; --bad: #ff8a80; --bad-soft: #2d1717; --info: #7fb2ff; --info-soft: #132339;
    --code-bg: #070c11; --code-inline: #1a2632;
    --shadow-s: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .28);
    --shadow-l: 0 30px 80px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1016; --bg-alt: #0d151c; --surface: #121c25; --surface-2: #17232e; --surface-3: #1d2b37;
  --line: #22313d; --line-strong: #33475a;
  --text: #e8f0f5; --muted: #a6b5c3; --faint: #8394a6;
  --accent: #4fcbe4; --accent-hover: #7ad9ec; --accent-2: #2fbfdc; --accent-soft: #0f2a34; --accent-line: #1f4a5a; --accent-ink: #061218;
  --ok: #5fd4a0; --ok-soft: #10281e; --warn: #f1bb5c; --warn-soft: #2b2112; --bad: #ff8a80; --bad-soft: #2d1717; --info: #7fb2ff; --info-soft: #132339;
  --code-bg: #070c11; --code-inline: #1a2632;
  --shadow-s: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .28);
  --shadow-l: 0 30px 80px rgba(0, 0, 0, .55);
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur-1: 0.01ms; --dur-2: 0.01ms; --dur-3: 0.01ms; --dur-4: 0.01ms; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* shared primitives */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.brand-mark { flex: none; color: var(--accent-2); }
.brand-8 { color: var(--accent-2); }

.theme-toggle { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; transition: color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out); }
.theme-toggle:hover { color: var(--accent); border-color: var(--accent-line); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur-3) var(--ease-spring); }
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}
.theme-toggle:active svg { transform: rotate(-30deg) scale(.9); }

/* Language switch: both codes are shown, the current one is highlighted. */
.lang-toggle { display: inline-flex; align-items: center; gap: 2px; height: 38px; padding: 3px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .04em; cursor: pointer; transition: border-color var(--dur-2) var(--ease-out); }
.lang-toggle:hover { border-color: var(--accent-line); }
.lang-toggle span { display: inline-grid; place-items: center; min-width: 30px; height: 100%; padding: 0 6px; border-radius: var(--radius-pill); transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out); }
:root[lang="th"] .lang-toggle [data-l="th"], :root[lang="en"] .lang-toggle [data-l="en"] { background: var(--accent); color: var(--accent-ink); }
/* English is chosen but the Thai markup is not translated yet (see i18n.js). */
:root.i18n-pending body { visibility: hidden; }
