/* ============================================================
   CHINA COMPASS — Design System
   Particle.news-inspired dark theme with image card grid
   ============================================================ */

/* ---------- Dark Theme (default) — Deep Navy-Black ---------- */
:root,
[data-theme="light"],
[data-theme="dark"] {
  /* Surface — Dark news aesthetic */
  --bg-primary:    #0f0f1a;
  --bg-secondary:  #1a1a2e;
  --bg-tertiary:   #252540;
  --bg-card:       #1a1a2e;
  --bg-code:       #252540;

  /* Text — Light on dark */
  --text-primary:   #e8e8f0;
  --text-secondary: #b0b0c8;
  --text-muted:     #8888a0;
  --text-inverse:   #0f0f1a;

  /* Accent — Coral */
  --accent:         #FF5A5F;
  --accent-hover:   #FF7A7F;
  --accent-light:   rgba(255,90,95,0.15);
  --accent-text:    #FF5A5F;

  /* Borders */
  --border-light:   #2a2a40;
  --border-medium:  #353555;
  --border-strong:  #454570;
  --border-hairline: #222238;

  /* Perspective Colors */
  --perspective-canada:    #FF5A5F;
  --perspective-canada-bg: rgba(255,90,95,0.1);
  --perspective-china:     #e8e8f0;
  --perspective-china-bg:  rgba(255,255,255,0.05);
  --perspective-neutral:   #60A5FA;
  --perspective-neutral-bg: rgba(96,165,250,0.1);

  /* Severity */
  --severity-critical: #FF4757;
  --severity-high:     #FF6B3D;
  --severity-elevated: #FFA94D;
  --severity-moderate: #4A90D9;
  --severity-low:      #20C997;

  /* Category Colors */
  --cat-diplomatic:    #60A5FA;
  --cat-trade:         #FBBF24;
  --cat-military:      #F87171;
  --cat-technology:    #60A5FA;
  --cat-political:     #A78BFA;
  --cat-economic:      #FBBF24;
  --cat-social:        #34D399;
  --cat-legal:         #C084FC;

  /* Market colors */
  --market-up:     #4ADE80;
  --market-down:   #FF6B70;
  --market-flat:   #888888;

  /* Shadows */
  --shadow-sm:   0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md:   0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg:   0 8px 32px rgba(0, 0, 0, 0.6);

  /* Nav */
  --nav-bg:      rgba(15, 15, 26, 0.95);
  --nav-border:  #2a2a40;
  --nav-text:    #e8e8f0;

  /* Focus */
  --focus-ring:  #FF5A5F;

  /* Misc */
  --code-bg:     #252540;
  --callout-bg:  rgba(255,90,95,0.08);
  --callout-border: rgba(255,90,95,0.3);
  --disruption-bg: rgba(255,71,87,0.1);
  --disruption-border: rgba(255,71,87,0.3);
  --disruption-text: #FF8080;

  /* Breaking/Alert styling */
  --breaking-bg: #FF5A5F;
  --breaking-text: #FFFFFF;
}

/* ---------- Typography ---------- */
:root {
  --font-headline: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: 'IBM Plex Mono', "SF Mono", "Cascadia Code", Consolas, monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;
  --text-5xl:  3rem;

  --leading-tight:  1.2;
  --leading-snug:   1.35;
  --leading-normal: 1.6;
  --leading-loose:  1.8;

  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  --tracking-tight:  -0.02em;
  --tracking-normal: 0;
  --tracking-wide:   0.05em;
  --tracking-wider:  0.1em;

  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --container-sm:  640px;
  --container-md:  768px;
  --container-lg:  1024px;
  --container-xl:  1200px;
  --container-2xl: 1400px;

  --transition-fast:   100ms ease;
  --transition-normal: 200ms ease;
  --transition-slow:   300ms ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Headlines ---------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-headline);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); margin-bottom: var(--space-6); }
h2 { font-size: var(--text-3xl); margin-bottom: var(--space-5); }
h3 { font-size: var(--text-2xl); margin-bottom: var(--space-4); }
h4 { font-size: var(--text-xl); margin-bottom: var(--space-3); }
h5 { font-size: var(--text-lg); margin-bottom: var(--space-2); font-weight: var(--weight-semibold); }
h6 { font-size: var(--text-base); margin-bottom: var(--space-2); font-weight: var(--weight-semibold); }

/* ---------- Body text ---------- */
p {
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

.lead {
  font-size: var(--text-lg);
  line-height: var(--leading-loose);
  color: var(--text-primary);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

strong { font-weight: var(--weight-semibold); }
small  { font-size: var(--text-sm); }

/* ---------- Metadata ---------- */
.meta, .timestamp, .byline {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.meta-divider {
  margin: 0 var(--space-2);
  color: var(--border-medium);
}

/* ---------- Code ---------- */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--code-bg);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

/* ---------- Lists ---------- */
ul, ol {
  padding-left: var(--space-6);
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

li { margin-bottom: var(--space-2); }

/* ---------- Dividers ---------- */
hr, .divider {
  border: none;
  border-top: 0.5px solid var(--border-hairline);
  margin: var(--space-6) 0;
}

.divider--strong {
  border-top-width: 1px;
  border-color: var(--border-medium);
}

/* ---------- Breaking Tag ---------- */
.tag--breaking {
  display: inline-block;
  background: var(--breaking-bg);
  color: var(--breaking-text);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

/* ---------- Category Tags ---------- */
.tag--category {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border-medium);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

/* ---------- Utilities ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-sm      { font-size: var(--text-sm); }
.text-xs      { font-size: var(--text-xs); }
.text-lg      { font-size: var(--text-lg); }
.text-2xl     { font-size: var(--text-2xl); }
.font-headline { font-family: var(--font-headline); }
.font-mono    { font-family: var(--font-mono); }
.font-medium  { font-weight: var(--weight-medium); }
.font-bold    { font-weight: var(--weight-bold); }
.tracking-wide { letter-spacing: var(--tracking-wide); }
.uppercase    { text-transform: uppercase; }

.mt-1  { margin-top: var(--space-1); }
.mt-2  { margin-top: var(--space-2); }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mt-8  { margin-top: var(--space-8); }
.mb-2  { margin-bottom: var(--space-2); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.mb-8  { margin-bottom: var(--space-8); }

img {
  max-width: 100%;
  height: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

/* ---------- Selection ---------- */
::selection {
  background: var(--accent-light);
  color: var(--text-primary);
}
