/* PosePitch — Design system tokens */

:root {
  /* Brand palette */
  --bg: #0B1020;
  --bg-deep: #070A18;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #F5F7FF;
  --text-dim: rgba(245, 247, 255, 0.66);
  --text-faint: rgba(245, 247, 255, 0.42);

  --violet: #7C5CFF;
  --violet-soft: #A48BFF;
  --cyan: #22D3EE;
  --cyan-soft: #67E8F9;
  --pink: #FF6B9A;
  --green: #34D399;
  --amber: #F5B544;
  --red: #FF6B6B;

  --grad-primary: linear-gradient(135deg, #7C5CFF 0%, #22D3EE 100%);
  --grad-warm: linear-gradient(135deg, #FF6B9A 0%, #7C5CFF 100%);
  --grad-bg: radial-gradient(1200px 800px at 12% -10%, rgba(124,92,255,0.22), transparent 60%),
             radial-gradient(900px 700px at 95% 10%, rgba(34,211,238,0.16), transparent 55%),
             radial-gradient(900px 700px at 60% 110%, rgba(255,107,154,0.12), transparent 55%);

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Consistent spacing scale (4px base) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;
  /* Type scale */
  --fs-xs: 11px; --fs-sm: 13px; --fs-base: 14px; --fs-md: 16px;
  --fs-lg: 18px; --fs-xl: 22px; --fs-2xl: 28px; --fs-3xl: 36px;

  /* Layered, realistic depth — softer & more professional than a single hard drop. */
  --shadow-sm: 0 1px 0 rgba(255,255,255,0.04) inset, 0 2px 6px -2px rgba(0,0,0,0.45);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.05) inset, 0 8px 18px -10px rgba(0,0,0,0.5), 0 24px 48px -28px rgba(0,0,0,0.65);
  --shadow-pop: 0 1px 0 rgba(255,255,255,0.07) inset, 0 12px 28px -12px rgba(0,0,0,0.55), 0 36px 64px -24px rgba(0,0,0,0.6);
  --glow-violet: 0 0 0 1px rgba(124,92,255,0.35), 0 18px 60px -12px rgba(124,92,255,0.45);
  --glow-cyan: 0 0 0 1px rgba(34,211,238,0.35), 0 18px 60px -12px rgba(34,211,238,0.45);

  /* Motion + focus tokens — consistent feel across the whole app. */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: .15s;
  --dur: .22s;
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--violet-soft);

  /* Unified site font — IBM Plex Sans Thai everywhere (Thai + Latin). Mono kept for figures. */
  /* Emoji/symbol fonts appended so glyphs (✓ ✕ → ● 🏆 …) keep consistent size & baseline. */
  --font-display: 'IBM Plex Sans Thai', system-ui, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', sans-serif;
  --font-body: 'IBM Plex Sans Thai', system-ui, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', monospace;
}

[data-theme="light"] {
  --bg: #F5F7FF;
  --bg-deep: #ECEEFB;
  --surface: rgba(255, 255, 255, 0.85);
  --surface-2: rgba(255, 255, 255, 0.95);
  --surface-3: #ffffff;
  --border: rgba(11, 16, 32, 0.08);
  --border-strong: rgba(11, 16, 32, 0.14);
  --text: #0B1020;
  --text-dim: rgba(11, 16, 32, 0.66);
  --text-faint: rgba(11, 16, 32, 0.42);
  --grad-bg: radial-gradient(1200px 800px at 12% -10%, rgba(124,92,255,0.18), transparent 60%),
             radial-gradient(900px 700px at 95% 10%, rgba(34,211,238,0.16), transparent 55%),
             radial-gradient(900px 700px at 60% 110%, rgba(255,107,154,0.10), transparent 55%);
  --shadow-card: 0 1px 0 rgba(255,255,255,1) inset, 0 18px 40px -28px rgba(11,16,32,0.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  background-image: var(--grad-bg);
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* Accessible, consistent keyboard focus (only for keyboard users, not mouse clicks). */
:where(a, button, input, select, textarea, [tabindex], [role="button"]):focus-visible {
  outline: 2px solid var(--violet-soft);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* Respect reduced-motion preferences for a calmer, more stable experience. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Typography */
.h-display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.02;
}
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.tnum { font-variant-numeric: tabular-nums; }

/* Surfaces */
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow-card);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
/* Opt-in lift for interactive cards (e.g. clickable scenario/feature cards). */
.glass-hover:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow-pop); }

/* Skeleton shimmer primitive (for async-loading placeholders). */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); color: transparent !important; }
.skeleton::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.09), transparent);
  animation: pp-shimmer 1.4s infinite;
}
@keyframes pp-shimmer { 100% { transform: translateX(100%); } }

/* Deterministic content entrance — fill-mode:both guarantees the final (visible)
   state holds even if the animation is shortened (reduced-motion) or skipped. */
@keyframes pp-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.rise-in { animation: pp-rise .5s var(--ease) both; }
.glass-2 {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border-radius: var(--r-pill);
  font-weight: 600; font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              background var(--dur) var(--ease), border-color var(--dur) var(--ease), filter var(--dur) var(--ease);
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[disabled], .btn[aria-disabled="true"] {
  opacity: .45; cursor: default; transform: none; box-shadow: none; filter: none; pointer-events: none;
}
.btn-primary {
  background: var(--grad-primary);
  color: #0B1020;
  box-shadow: 0 6px 20px -8px rgba(124,92,255,0.55), inset 0 0 0 1px rgba(255,255,255,0.12);
}
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 12px 30px -10px rgba(124,92,255,0.7), inset 0 0 0 1px rgba(255,255,255,0.18); }
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  backdrop-filter: blur(12px);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-danger {
  background: rgba(255,107,107,0.14);
  color: #FF8E8E;
  border-color: rgba(255,107,107,0.32);
}
.btn-icon {
  width: 44px; padding: 0; justify-content: center;
}
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }

/* Chips & badges */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px;
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.chip-violet { background: rgba(124,92,255,0.14); border-color: rgba(124,92,255,0.32); color: var(--violet-soft); }
.chip-cyan { background: rgba(34,211,238,0.12); border-color: rgba(34,211,238,0.32); color: var(--cyan-soft); }
.chip-green { background: rgba(52,211,153,0.12); border-color: rgba(52,211,153,0.32); color: #6EE7B7; }
.chip-pink { background: rgba(255,107,154,0.12); border-color: rgba(255,107,154,0.32); color: #FFA0BD; }
.chip-amber { background: rgba(245,181,68,0.14); border-color: rgba(245,181,68,0.32); color: #FFD27A; }

.dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.dot-live { background: #FF6B6B; box-shadow: 0 0 0 0 rgba(255,107,107,0.6); animation: pulse 1.6s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,107,107,0.6); }
  70% { box-shadow: 0 0 0 8px rgba(255,107,107,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,107,107,0); }
}

/* Page nav (top) */
.topnav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 18px 40px;
  background: linear-gradient(180deg, var(--bg) 60%, transparent);
  backdrop-filter: blur(14px);
}
.topnav .brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.topnav .brand svg { width: 28px; height: 28px; }
.topnav nav { display: flex; gap: 4px; align-items: center; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pill); backdrop-filter: blur(20px); }
.topnav nav a { padding: 8px 16px; border-radius: var(--r-pill); font-size: 13px; color: var(--text-dim); border: 1px solid transparent; transition: color var(--dur-fast), background var(--dur) var(--ease), border-color var(--dur); font-weight: 500; white-space: nowrap; }
.topnav nav a:hover { color: var(--text); background: var(--surface); }
.topnav nav a.active { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

/* i18n: show only the active language */
[data-i18n] [data-lang="th"], [data-i18n] [data-lang="en"] { display: none; }
html[lang="th"] [data-i18n] [data-lang="th"] { display: inline; }
html[lang="en"] [data-i18n] [data-lang="en"] { display: inline; }
html[lang="th"] [data-i18n][data-block] [data-lang="th"],
html[lang="en"] [data-i18n][data-block] [data-lang="en"] { display: block; }

/* Section spacing */
.section { padding: 80px 40px; }
.container { max-width: 1280px; margin: 0 auto; }

/* Stat label */
.kbd-cap {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-faint);
}

/* Scrollbars — slim, subtle, with breathing room */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 999px;
  border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Selection */
::selection { background: rgba(124,92,255,0.4); color: var(--text); }

/* ===== Mobile globals (phones ≤640px) ===== */
@media (max-width: 640px) {
  .section { padding: 44px 16px; }
  .container { padding: 0; }
  .topnav { padding: 12px 14px; gap: 8px; }
  .topnav .brand { font-size: 16px; }
  .topnav .brand svg { width: 24px; height: 24px; }
  .topnav nav { overflow-x: auto; flex-wrap: nowrap; max-width: 60vw; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .topnav nav::-webkit-scrollbar { display: none; }
  .topnav nav a { padding: 7px 12px; font-size: 12.5px; }
  .btn { height: 42px; padding: 0 16px; }
  .btn-sm { height: 34px; }
}

/* ===== Normalize micro "small-caps" labels site-wide =====
   Tiny mono + wide letter-spacing + UPPERCASE reads cramped & techy (esp. in Thai).
   Use the normal body font, gentle spacing, no forced caps, and a slightly larger size
   so labels look human, not machine-generated. */
.side .group-label,
.stat .lbl,
.sr-head,
.float .lbl,
.float-tip .head,
.transcript-strip .who,
.scn .difficulty,
.code-block .lbl,
.add-form .lbl,
.pcard .mini .l,
.score-meta .deltas .lbl,
.breakdown-card .head .lbl,
.breakdown-card .target,
.ai-q-hint-lbl,
.cam-metric .lbl,
.coach-tip .body .head,
.section-label,
.expanded-section-title,
.set-section-title,
.plan-badge,
.kbd-cap,
.crumbs {
  font-family: var(--font-body) !important;
  text-transform: none !important;
  letter-spacing: 0.01em !important;
  font-size: 11.5px !important;
}
/* Keep these as headings but drop the shouty caps / wide tracking */
.ai-col h4 { text-transform: none !important; letter-spacing: 0.01em !important; }
