/* =========================================================================
   base.css — Design tokens · Reset · Typography · Animations
   ========================================================================= */
:root {
  color-scheme: light;
  --bg: #e8e6e2; --surface: #ffffff; --surface-2: #f3f1ed;
  --text: #1d1d1f; --muted: #7a7a7a; --line: #c8c5bf; --border: #e3e1dc;
  --accent: #5b5bd6; --discord: #5865f2; --danger: #e5484d; --success: #2f9e5d;
  --ceo-bg: #1d1d1f; --ceo-fg: #ffffff;
  --badge-bg: #fdf1cc; --badge-fg: #8a5a00;
  --c: #6b7280;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / .04), 0 2px 10px rgb(0 0 0 / .05);
  --shadow-md: 0 10px 30px rgb(0 0 0 / .09);
  --shadow-lg: 0 24px 70px rgb(0 0 0 / .28);
  --r-sm: 8px; --r: 12px; --r-lg: 18px; --r-pill: 999px;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --t: .35s;

  --pad: clamp(12px, 3.2vw, 24px);
  --logo: 84px;
  --fs-sm: 13px;
  --fs-xl: clamp(21px, 1.1rem + 1vw, 26px);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121212; --surface: #1e1e1e; --surface-2: #262626;
  --text: #ececec; --muted: #9a9a9a; --line: #3b3b3b; --border: #2c2c2c;
  --accent: #a1a1f8; --ceo-bg: #f2f2f2; --ceo-fg: #111111;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .5);
  --shadow-md: 0 10px 30px rgb(0 0 0 / .5);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; scroll-padding-top: 80px; }
html:has(dialog[open]) { overflow: hidden; }
body {
  min-height: 100dvh; overflow-x: hidden;
  font-family: 'Sarabun', system-ui, sans-serif; font-size: 16px; line-height: 1.6;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
  transition: background-color .4s var(--ease), color .4s var(--ease);
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---------- Utilities ---------- */
.muted { color: var(--muted); font-size: var(--fs-sm); }
.empty { color: var(--muted); font-size: 14px; font-style: italic; text-align: center; padding: 14px; }
.nowrap { white-space: nowrap; }
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 999; padding: 8px 14px;
  background: var(--text); color: var(--surface); border-radius: var(--r-sm); transition: top .2s;
}
.skip-link:focus { top: calc(12px + var(--safe-t)); }

/* เปลี่ยนธีมแบบนุ่มนวล */
html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color .45s var(--ease), color .45s var(--ease), border-color .45s var(--ease), box-shadow .45s var(--ease) !important;
}

/* ---------- Keyframes ---------- */
@keyframes fadeIn   { from { opacity: 0; } }
@keyframes fadeOut  { to { opacity: 0; } }
@keyframes fadeUp   { from { opacity: 0; transform: translateY(16px); } }
@keyframes scaleIn  { from { opacity: 0; transform: translateY(10px) scale(.96); } }
@keyframes scaleOut { to { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes popIn    { 0% { opacity: 0; transform: scale(.5) rotate(-8deg); } 60% { opacity: 1; transform: scale(1.06) rotate(1deg); } 100% { transform: none; } }
@keyframes sheetIn  { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }
@keyframes growY    { from { transform: scaleY(0); } }
@keyframes kenburns { from { transform: scale(1.1); } to { transform: scale(1); } }
@keyframes progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes shimmer  { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgb(34 197 94 / .6); }
  70% { box-shadow: 0 0 0 7px rgb(34 197 94 / 0); }
  100% { box-shadow: 0 0 0 0 rgb(34 197 94 / 0); }
}

/* แอนิเมชันตอนเปิดหน้า (ไล่ลำดับด้วย --d) */
.enter { animation: fadeUp .8s var(--ease) backwards; animation-delay: calc(var(--d, 0) * 90ms + 80ms); }
.pop > * { animation: popIn .8s var(--spring) backwards; }

/* ผู้ใช้ที่ตั้งค่าลดการเคลื่อนไหว */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}