@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

/* =============================================
   DARK MODE (default)
   ============================================= */
:root {
  /* Brand palette */
  --color-primary:       #1A1A2E;
  --color-secondary:     #16213E;
  --color-accent:        #F5A623;
  --color-accent-dark:   #D4891A;
  --color-highlight:     #00D4AA;
  --color-highlight-dark:#00A882;

  /* Semantic */
  --color-success:  #2ED573;
  --color-danger:   #FF4757;
  --color-warning:  #FFA502;
  --color-info:     #3B82F6;

  /* Backgrounds */
  --color-bg:           #0D0D1A;
  --color-surface:      #1A1A2E;
  --color-surface-2:    #1E2340;
  --color-surface-3:    #242847;
  --color-card:         rgba(255,255,255,0.04);
  --color-card-hover:   rgba(255,255,255,0.07);
  --color-hero-bg:      #0D0D1A;

  /* Text */
  --color-text:         #E8EAED;
  --color-text-2:       #B0BCC8;
  --color-text-muted:   #6B7280;
  --color-border:       rgba(255,255,255,0.10);
  --color-border-light: rgba(255,255,255,0.06);

  /* Glassmorphism */
  --glass-bg:     rgba(255,255,255,0.05);
  --glass-border: rgba(255,255,255,0.10);
  --glass-blur:   blur(16px);

  /* Glows */
  --glow-gold:    0 0 24px rgba(245,166,35,0.35);
  --glow-teal:    0 0 24px rgba(0,212,170,0.35);
  --glow-blue:    0 0 24px rgba(59,130,246,0.35);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 4px rgba(0,0,0,0.25);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.30);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.40);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.50);
  --shadow-xl: 0 24px 64px rgba(0,0,0,0.60);

  /* Animation */
  --ease: cubic-bezier(0.4,0,0.2,1);
  --transition: 200ms var(--ease);
  --transition-md: 350ms var(--ease);

  /* Layout */
  --container-max: 1240px;
  --section-y: 60px;
  --section-y-sm: 36px;
}

/* =============================================
   LIGHT MODE
   ============================================= */
[data-theme="light"] {
  --color-primary:       #F0F4FF;
  --color-secondary:     #E8EFFE;
  --color-accent:        #D4891A;
  --color-accent-dark:   #B8731A;
  --color-highlight:     #00A882;
  --color-highlight-dark:#007A5E;

  --color-success:  #16A34A;
  --color-danger:   #DC2626;
  --color-warning:  #D97706;
  --color-info:     #2563EB;

  --color-bg:           #F8F9FF;
  --color-surface:      #FFFFFF;
  --color-surface-2:    #F0F4FF;
  --color-surface-3:    #E8EFFE;
  --color-card:         rgba(0,0,0,0.03);
  --color-card-hover:   rgba(0,0,0,0.06);
  --color-hero-bg:      #1A1A2E;

  --color-text:         #1A1A2E;
  --color-text-2:       #374151;
  --color-text-muted:   #6B7280;
  --color-border:       rgba(0,0,0,0.12);
  --color-border-light: rgba(0,0,0,0.07);

  --glass-bg:     rgba(255,255,255,0.80);
  --glass-border: rgba(0,0,0,0.12);
  --glass-blur:   blur(16px);

  --glow-gold:    0 0 24px rgba(212,137,26,0.25);
  --glow-teal:    0 0 24px rgba(0,168,130,0.25);
  --glow-blue:    0 0 24px rgba(37,99,235,0.25);

  --shadow-xs: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.12);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.15);
  --shadow-xl: 0 24px 64px rgba(0,0,0,0.18);
}

body {
  font-family: 'Sarabun', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.8;
  font-size: 1.05rem;
  min-height: 100vh;
  transition: background var(--transition-md), color var(--transition-md);
  /* Padding-top is set dynamically by JS to match actual header height.
     Default fallback: 40px banner + 66px nav = 106px */
  padding-top: 106px;
}

/* Container */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

/* Section spacing */
section { padding: var(--section-y) 0; }
@media (max-width: 768px) { section { padding: var(--section-y-sm) 0; } }

/* Typography scale */
h1 { font-size: clamp(2rem,5vw,3.2rem); font-weight: 800; letter-spacing: -0.025em; line-height: 1.2; }
h2 { font-size: clamp(1.5rem,3.5vw,2.2rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.3; }
h3 { font-size: clamp(1.1rem,2.5vw,1.35rem); font-weight: 600; line-height: 1.4; }
h4 { font-size: 1.1rem; font-weight: 600; }
p  { font-size: 1.05rem; line-height: 1.8; color: var(--color-text-2); margin-bottom: 1.2rem; }
p:last-child { margin-bottom: 0; }

/* Links */
a { color: var(--color-accent); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--color-accent-dark); }

/* Utility classes */
.text-gold    { color: var(--color-accent); }
.text-teal    { color: var(--color-highlight); }
.text-muted   { color: var(--color-text-muted); }
.text-center  { text-align: center; }
.text-white   { color: #fff; }
.fw-800       { font-weight: 800; }
.fw-700       { font-weight: 700; }
.mb-0         { margin-bottom: 0; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.mt-32        { margin-top: 32px; }
.mt-48        { margin-top: 48px; }

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 20px; }
@media (max-width:1024px) { .grid-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width:768px)  { .grid-2,.grid-3,.grid-4 { grid-template-columns: 1fr; } }

/* Section header */
.section-header { text-align: center; margin-bottom: 56px; }
.section-header .eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent);
  background: rgba(245,166,35,0.12);
  border: 1px solid rgba(245,166,35,0.25);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  margin-bottom: 16px;
}
.section-header h2 { color: var(--color-text); margin-bottom: 16px; }
.section-header p  { color: var(--color-text-2); max-width: 600px; margin: 0 auto; font-size: 1.1rem; }

/* Divider */
.divider { height: 1px; background: var(--color-border-light); margin: 0; }

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.breadcrumbs a { color: var(--color-text-2); }
.breadcrumbs a:hover { color: var(--color-accent); }
.breadcrumbs .sep { color: var(--color-text-muted); }
.breadcrumbs .current { color: var(--color-text); }

/* Sidebar layout */
.layout-sidebar {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 40px;
  align-items: start;
}
@media (max-width: 1024px) {
  .layout-sidebar { grid-template-columns: 1fr; }
}

/* Tables */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
thead th {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-weight: 700;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text-2);
  vertical-align: middle;
}
tbody tr:hover td { background: var(--color-card-hover); }
tbody tr:last-child td { border-bottom: none; }

/* Focus */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Selection */
::selection {
  background: rgba(245,166,35,0.2);
  color: var(--color-text);
}

/* Hidden */
.hidden { display: none !important; }

/* Desktop/mobile only */
.desktop-only { display: block; }
.mobile-only { display: none; }
@media (max-width: 768px) {
  .desktop-only { display: none; }
  .mobile-only { display: block; }
}

/* Theme toggle button */
.theme-toggle {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-2);
  white-space: nowrap;
}
.theme-toggle:hover {
  background: var(--color-card-hover);
  color: var(--color-text);
  border-color: rgba(255,255,255,0.2);
}
.theme-toggle .theme-icon-dark { display: inline; }
.theme-toggle .theme-icon-light { display: none; }
[data-theme="light"] .theme-toggle .theme-icon-dark { display: none; }
[data-theme="light"] .theme-toggle .theme-icon-light { display: inline; }

/* Light mode overrides for dark-specific elements */
[data-theme="light"] .hero {
  background: linear-gradient(135deg, #1A1A2E 0%, #16213E 50%, #1A1A2E 100%);
}
[data-theme="light"] .hero h1,
[data-theme="light"] .hero .hero-sub,
[data-theme="light"] .hero-eyebrow {
  /* Keep hero dark in light mode */
}
[data-theme="light"] .site-header {
  background: rgba(255,255,255,0.92) !important;
  border-bottom-color: rgba(0,0,0,0.10);
}
[data-theme="light"] .nav-logo .logo-text { color: #1A1A2E; }
[data-theme="light"] .nav-logo .logo-text span { color: var(--color-accent); }
[data-theme="light"] .main-nav a { color: #374151; }
[data-theme="light"] .main-nav a:hover,
[data-theme="light"] .main-nav a.active { color: #1A1A2E; background: rgba(0,0,0,0.05); }
[data-theme="light"] .announcement-banner {
  background: linear-gradient(90deg, #fff8e1, #fff3cd, #fff8e1);
  border-bottom-color: rgba(212,137,26,0.4);
}
[data-theme="light"] .spreads-ticker {
  background: rgba(0,0,0,0.05);
}
[data-theme="light"] .trust-bar {
  background: rgba(0,0,0,0.04);
}
[data-theme="light"] .score-circle::before { background: var(--color-surface); }
[data-theme="light"] h1, [data-theme="light"] h2, [data-theme="light"] h3, [data-theme="light"] h4 {
  color: #1A1A2E;
}
[data-theme="light"] .section-header h2 { color: #1A1A2E; }
[data-theme="light"] .broker-name { color: #1A1A2E; }
[data-theme="light"] .stat-value { color: #1A1A2E; }
[data-theme="light"] .hqc-name { color: #1A1A2E; }
[data-theme="light"] .blog-card-title { color: #1A1A2E; }
[data-theme="light"] .table-broker-name { color: #1A1A2E; }
[data-theme="light"] .comparison-table th { background: var(--color-surface-2); }
[data-theme="light"] .site-footer {
  background: #1A1A2E;
}
[data-theme="light"] .site-footer,
[data-theme="light"] .site-footer p,
[data-theme="light"] .site-footer a,
[data-theme="light"] .site-footer h5 {
  color: #B0BCC8;
}
[data-theme="light"] .site-footer a:hover { color: var(--color-accent); }
[data-theme="light"] .mobile-sticky-cta {
  background: linear-gradient(135deg, #1A1A2E, #16213E);
}
