/* =========================================================================
   Tradingthaiview — Design System
   Mobile-first. Vanilla CSS. No build step.
   ========================================================================= */

:root {
  /* Color — LIGHT MODE (cream + green-teal) */
  --bg:           #FAFAF7;     /* warm cream page bg */
  --bg-alt:       #F4F7F4;     /* alt section bg for two-tone rhythm */
  --surface:      #FFFFFF;     /* card bg */
  --surface-grad: linear-gradient(180deg, #FFFFFF 0%, #F8FAF8 100%);
  --elevated:     #F1F5F9;     /* hover, subtle fills */
  --accent:       #0EA47A;     /* darker teal — readable on white */
  --accent-2:     #22D3A5;     /* bright teal — for gradients */
  --accent-3:     #F59E0B;     /* amber */
  --text:         #0F172A;     /* near-black slate */
  --text-2:       #475569;     /* slate-600 */
  --text-mute:    #94A3B8;     /* slate-400 */
  --border:       #E2E8F0;     /* slate-200 */
  --border-accent: rgba(14,164,122,0.18);
  --border-accent-strong: rgba(14,164,122,0.35);

  /* Footer remains dark for visual rhythm */
  --footer-bg:    #0F172A;
  --footer-text:  #CBD5E1;
  --footer-text-strong: #F8FAFC;
  --footer-border: rgba(255,255,255,0.08);

  /* Page-level gradient backdrops */
  --bg-hero:      radial-gradient(60% 80% at 15% 0%, rgba(34,211,165,0.18) 0%, transparent 60%),
                  radial-gradient(50% 70% at 95% 10%, rgba(245,158,11,0.10) 0%, transparent 60%),
                  linear-gradient(180deg, #F0FDF7 0%, #FAFAF7 100%);
  --button-grad:  linear-gradient(135deg, #22D3A5 0%, #0EA47A 100%);
  --button-grad-hover: linear-gradient(135deg, #2BE5B4 0%, #0EBE8B 100%);

  /* Type */
  --f-display: "Kanit", system-ui, sans-serif;
  --f-body:    "Noto Sans Thai", system-ui, sans-serif;
  --f-mono:    "JetBrains Mono", ui-monospace, monospace;

  /* Spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;
  --s-24: 96px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-pill: 999px;

  /* Layout */
  --max-w: 1200px;
  --max-w-article: 720px;

  /* Header heights */
  --h-header-mobile: 56px;
  --h-header-desk:   72px;
  --h-sticky-cta:    64px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.75;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  padding-bottom: var(--h-sticky-cta);
}
img, svg, video { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
ul, ol { padding-left: 1.25em; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-8) 0; }
::selection { background: var(--accent); color: #FFFFFF; }

/* ---------- Headings ---------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--f-display);
  color: var(--text);
  line-height: 1.25;
  margin: 0 0 var(--s-4);
  font-weight: 700;
}
h1 { font-size: 2.25rem; letter-spacing: -0.01em; }
h2 {
  font-size: 1.5rem;
  margin-top: var(--s-12);
  padding-left: var(--s-2);
  border-left: 2px solid var(--accent);
  font-weight: 700;
}
h3 { font-size: 1.25rem; margin-top: var(--s-8); font-weight: 600; }
h4 { font-size: 1.05rem; margin-top: var(--s-6); font-weight: 600; }
p  { margin: 0 0 var(--s-5); }

/* Numeric/data */
.num, code, pre, kbd { font-family: var(--f-mono); }
code { background: var(--elevated); padding: 2px 6px; border-radius: var(--r-sm); font-size: 0.9em; }

/* ---------- Layout primitives ---------- */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--s-5);
}
.section { padding: var(--s-12) 0; }
.section-tight { padding: var(--s-8) 0; }

.grid { display: grid; gap: var(--s-5); }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--h-header-mobile);
  background: rgba(255,255,255,0.88);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}
.brand {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}
.brand__mark {
  display: inline-block;
  width: 24px; height: 24px;
  background: var(--button-grad);
  border-radius: 6px;
  position: relative;
  box-shadow: 0 2px 8px -2px rgba(14,164,122,0.45);
}
.brand__mark::after {
  content: "";
  position: absolute; inset: 6px 7px 6px 7px;
  background:
    linear-gradient(transparent 50%, #FFFFFF 50%) 0 0/4px 100%,
    linear-gradient(transparent 70%, #FFFFFF 70%) 6px 0/4px 100%,
    linear-gradient(transparent 30%, #FFFFFF 30%) 12px 0/4px 100%;
}
.brand:hover { text-decoration: none; }

.nav-desktop { display: none; }
.btn-hamburger {
  background: transparent;
  border: 1px solid var(--border);
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center; justify-content: center;
  color: var(--text);
}
.btn-hamburger:hover { border-color: var(--border-accent-strong); }
.btn-hamburger svg { width: 22px; height: 22px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 48px;
  padding: 0 var(--s-5);
  border-radius: var(--r-md);
  font-family: var(--f-body);
  font-weight: 700;
  font-size: 1rem;
  border: 1px solid transparent;
  text-decoration: none;
  transition: transform 120ms ease, background 200ms ease, border-color 200ms ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--button-grad);
  color: #FFFFFF;
  box-shadow: 0 6px 18px -6px rgba(14,164,122,0.55), 0 0 0 1px rgba(14,164,122,0.15) inset;
  position: relative;
  overflow: hidden;
}
.btn--primary::after {
  content: "";
  position: absolute;
  top: -50%; left: -120%;
  width: 60%; height: 200%;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%);
  transform: skewX(-20deg);
  transition: left 600ms ease;
  pointer-events: none;
}
.btn--primary:hover {
  background: var(--button-grad-hover);
  box-shadow: 0 10px 24px -8px rgba(14,164,122,0.65);
}
.btn--primary:hover::after { left: 130%; }
.btn--ghost {
  background: #FFFFFF;
  color: var(--text);
  border-color: var(--border);
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); background: #F8FAF8; }
.btn--block { width: 100%; }
.btn--sm { height: 40px; padding: 0 var(--s-4); font-size: 0.95rem; }

/* ---------- Hero ---------- */
.hero {
  padding: var(--s-10) 0 var(--s-8);
  background: var(--bg-hero);
  position: relative;
  overflow: hidden;
}
.hero::before {
  /* Decorative grid lines for trading-terminal feel */
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(14,164,122,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14,164,122,0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 30%, transparent 80%);
  pointer-events: none;
}
.hero > .container { position: relative; z-index: 1; }
.hero__eyebrow {
  display: inline-block;
  font-family: var(--f-body);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: var(--s-3);
}
.hero h1 {
  font-size: 2.25rem;
  line-height: 1.2;
  max-width: 22ch;
  margin-bottom: var(--s-4);
}
.hero__sub {
  font-size: 1.05rem;
  color: var(--text-2);
  max-width: 56ch;
  margin-bottom: var(--s-6);
}
.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3) var(--s-5);
  font-size: 0.875rem;
  color: var(--text-2);
  margin-bottom: var(--s-6);
}
.hero__meta span { display: inline-flex; align-items: center; gap: var(--s-2); }

/* ---------- Article body ---------- */
.article {
  padding: var(--s-6) 0 var(--s-12);
}
.article__body {
  max-width: var(--max-w-article);
}
.article__body p,
.article__body ul,
.article__body ol { color: var(--text); }
.article__body ul, .article__body ol { margin: 0 0 var(--s-5); }
.article__body li { margin-bottom: var(--s-2); }
.article__body strong { color: var(--text); font-weight: 700; }
.article__body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.article__body a:hover { text-decoration-thickness: 2px; }
.article__body blockquote {
  border-left: 3px solid var(--accent);
  background: var(--surface);
  padding: var(--s-4) var(--s-5);
  margin: var(--s-6) 0;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  color: var(--text-2);
}

/* ---------- Footer (stays dark for visual rhythm) ---------- */
.site-footer {
  background: var(--footer-bg);
  background-image: linear-gradient(180deg, #0F172A 0%, #0B1220 100%);
  border-top: 1px solid var(--footer-border);
  padding: var(--s-12) 0 var(--s-10);
  margin-top: var(--s-12);
  color: var(--footer-text);
  font-size: 0.9rem;
}
.site-footer .brand { color: var(--footer-text-strong); }
.site-footer__cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-8);
  margin-bottom: var(--s-8);
}
.site-footer h4 {
  font-family: var(--f-body);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94A3B8;
  margin: 0 0 var(--s-3);
  font-weight: 500;
}
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: var(--s-2); }
.site-footer a { color: var(--footer-text-strong); }
.site-footer a:hover { color: var(--accent-2); }
.site-footer__bottom {
  border-top: 1px solid var(--footer-border);
  padding-top: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  font-size: 0.8rem;
  color: #94A3B8;
}
.site-footer__disclosure {
  font-size: 0.78rem;
  color: #94A3B8;
  line-height: 1.6;
}

/* ---------- Utility ---------- */
.muted { color: var(--text-2); }
.mono  { font-family: var(--f-mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: var(--s-3);
}
.text-center { text-align: center; }

/* Section header */
.section-head { margin-bottom: var(--s-6); }
.section-head h2 { margin-top: 0; }
.section-head p { color: var(--text-2); max-width: 60ch; }

/* Body lock when drawer open */
body.is-nav-open { overflow: hidden; }

/* ---------- Tablet (≥768px) ---------- */
@media (min-width: 768px) {
  body { font-size: 17px; }
  h1 { font-size: 2.75rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.35rem; }
  .container { padding: 0 var(--s-6); }
  .section { padding: var(--s-16) 0; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 2.75rem; }
  .site-footer__cols { grid-template-columns: 2fr 1fr 1fr 1fr; }
}

/* ---------- Desktop (≥1024px) ---------- */
@media (min-width: 1024px) {
  html { scroll-padding-top: 96px; }
  body { padding-bottom: 0; }
  .site-header { height: var(--h-header-desk); }
  .container { padding: 0 var(--s-8); }

  .nav-desktop {
    display: flex;
    align-items: center;
    gap: var(--s-6);
    margin-left: auto;
  }
  .nav-desktop a {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 500;
  }
  .nav-desktop a:hover { color: var(--accent); text-decoration: none; }
  .nav-desktop a.is-active { color: var(--accent); }
  .header-cta { margin-left: var(--s-4); }
  .btn-hamburger { display: none; }

  h1 { font-size: 3rem; }
  .hero h1 { font-size: 3rem; }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }

  /* Article 2-column layout */
  .article__layout {
    display: grid;
    grid-template-columns: minmax(0, 65%) minmax(0, 35%);
    gap: var(--s-12);
    align-items: start;
  }
  .article__sidebar {
    position: sticky;
    top: calc(var(--h-header-desk) + var(--s-5));
    display: flex;
    flex-direction: column;
    gap: var(--s-5);
  }
}

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