/* Clarity UPSC — Design System v2
   Typography, color tokens, layout, components, and page-targeted refinements
   Safe to include after existing styles; uses CSS variables with sensible defaults. */

/* 1) Design Tokens */
/* Default to light; override via .dark or [data-theme="dark"] */
:root,
[data-theme="light"],
.light {
  /* Colors (Light) */
  --color-bg: #f8fafc;          /* gray-50 */
  --color-surface: #ffffff;
  --color-surface-2: #f1f5f9;    /* gray-100 */
  --color-text: #0f172a;         /* slate-900 */
  --color-text-muted: #475569;   /* slate-600 */
  --color-border: #e5e7eb;       /* gray-200 */
  --color-primary: #0ea5e9;      /* sky-500 */
  --color-primary-700: #0369a1;  /* hover */
  --color-accent: #f59e0b;      
  --color-danger: #ef4444;

  /* Typography */
  --font-heading: "Merriweather", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-body: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";

  /* Type scale */
  --fs-hero: clamp(2rem, 1.5rem + 2vw, 3rem);
  --fs-h1: clamp(1.75rem, 1.25rem + 1.6vw, 2.5rem);
  --fs-h2: clamp(1.375rem, 1.05rem + 1vw, 1.75rem);
  --fs-h3: 1.25rem;
  --fs-body: 1.05rem;
  --fs-small: 0.9375rem;

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

  /* Radius & shadow */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.10);
  --shadow-md: 0 6px 16px rgba(0,0,0,0.14);
  --shadow-lg: 0 12px 28px rgba(0,0,0,0.18);

  /* Layout */
  --container: 1100px;
}

/* Dark overrides */
[data-theme="dark"],
.dark {
  --color-bg: #0b1324;          /* deep navy background */
  --color-surface: #0f172a;     /* slate-900 */
  --color-surface-2: #111827;   /* header depth */
  --color-text: #e5e7eb;        /* gray-200 */
  --color-text-muted: #9ca3af;  /* gray-400 */
  --color-border: #1f2937;      /* gray-800 */
  --color-primary: #22c55e;     /* emerald-500 */
  --color-primary-700: #15803d; /* hover */
  --color-accent: #f59e0b;      
  --color-danger: #ef4444;
}

/* 2) Base */
html { scroll-behavior: smooth; }
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  color: var(--color-text);
  margin: 0 0 var(--space-3);
}
h1 { font-size: var(--fs-h1); font-weight: 700; line-height: 1.2; }
h2 { font-size: var(--fs-h2); font-weight: 700; line-height: 1.25; }
h3 { font-size: var(--fs-h3); font-weight: 600; }
p { margin: 0 0 var(--space-4); }

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-700); }

.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--space-6); }

/* 3) Header / Navigation (targets existing news header structure) */
.news-header { background: var(--color-surface-2) !important; border-bottom: 1px solid var(--color-border) !important; }
.header-container { height: 64px; }
.header-nav a {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--color-text-muted) !important;
  padding: 8px 12px;
  border-radius: 8px;
  transition: color .2s, background .2s, transform .15s ease;
}
.header-nav a:hover { color: var(--color-text) !important; background: rgba(148,163,184,0.12); }

.nav-cta { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; font-weight: 700; }
.nav-cta.primary { background: var(--color-primary); color: #0b1220; }
.nav-cta.primary:hover { background: var(--color-primary-700); color: #e6f6ff; transform: translateY(-1px); }

/* 3.5) Global Header (subjects/home use .nav markup) */
.nav { background: var(--color-surface-2); border-bottom: 1px solid var(--color-border); position: sticky; top: 0; z-index: 100; }
.nav .nav-container { max-width: var(--container); margin: 0 auto; padding: 12px var(--space-6); display: flex; align-items: center; justify-content: space-between; }
.nav .logo { height: 40px; width: auto; display: block; }
.nav .nav-links { display: flex; gap: 20px; align-items: center; }
.nav .nav-links a { font-weight: 600; font-size: 0.98rem; color: var(--color-text-muted); padding: 8px 12px; border-radius: 8px; transition: color .2s, background .2s, transform .15s; }
.nav .nav-links a:hover { color: var(--color-text); background: rgba(148,163,184,0.12); }
.theme-toggle { background: transparent; border: 1px solid var(--color-border); color: var(--color-text); padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: 0.95rem; }
.theme-toggle:hover { background: var(--color-surface); }

/* 4) Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 12px; font-weight: 600; border: 1px solid transparent; transition: background .2s, color .2s, border-color .2s, transform .15s; }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--color-primary); color: #0b1220; }
.btn-primary:hover { background: var(--color-primary-700); color: #e6f6ff; }
.btn-secondary { background: var(--color-surface-2); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-surface); }

/* 5) Cards & Lists */
.grid { display: grid; gap: var(--space-6); grid-template-columns: repeat(12, 1fr); }
.grid.cards-3 > * { grid-column: span 12; }
@media (min-width: 720px) { .grid.cards-3 > * { grid-column: span 6; } }
@media (min-width: 1024px) { .grid.cards-3 > * { grid-column: span 4; } }

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--space-6); transition: box-shadow .2s, transform .15s, border-color .2s; }
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: rgba(148,163,184,0.35); }
.card .card-title { font-family: var(--font-heading); font-weight: 700; font-size: 1.15rem; margin-bottom: var(--space-3); }
.card .meta { font-size: 0.9rem; color: var(--color-text-muted); margin-bottom: var(--space-3); }
.card .summary { color: var(--color-text); }

.tag { display: inline-block; font-size: 0.75rem; padding: 4px 10px; border-radius: 999px; background: rgba(34,197,94,0.18); color: #86efac; border: 1px solid rgba(34,197,94,0.35); }

/* 6) Article pages (existing classes in news/article.php) */
.article-header { margin-top: var(--space-8) !important; margin-bottom: var(--space-8) !important; }
.article-title { font-family: var(--font-heading); font-size: var(--fs-h1); font-weight: 700; }
.article-meta { color: var(--color-text-muted); font-size: 0.95rem; gap: 10px; }
.featured-image { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.article-content { font-size: 1.0625rem; line-height: 1.8; }
.article-content h2 { margin-top: var(--space-8); margin-bottom: var(--space-3); }
.article-content h3 { margin-top: var(--space-6); margin-bottom: var(--space-2); }
.article-content p + p { margin-top: var(--space-3); }
.breadcrumb { color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--color-primary); }

/* 6.1) Subjects listing grid (scoped) */
.subject-list { list-style: none; padding: 0; margin: var(--space-6) 0; display: grid; gap: var(--space-6); grid-template-columns: repeat(12,1fr); }
.subject-list > li { grid-column: span 12; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.subject-list > li a { display: block; padding: var(--space-5); font-weight: 600; color: var(--color-text); text-decoration: none; }
.subject-list > li a:hover { color: var(--color-text); transform: translateY(-1px); }
@media (min-width: 720px) { .subject-list > li { grid-column: span 6; } }
@media (min-width: 1024px) { .subject-list > li { grid-column: span 4; } }

/* 6.2) Preserve bullets inside article content */
.article-content ul { list-style: disc; padding-left: 1.25rem; margin-left: 0.5rem; }
.article-content ol { list-style: decimal; padding-left: 1.25rem; margin-left: 0.5rem; }
.article-content li { margin-bottom: var(--space-2); background: transparent; border: 0; box-shadow: none; border-radius: 0; }

/* 7) Hero & CTAs (for home/subjects pages if classes exist) */
.hero { background: linear-gradient(180deg, rgba(2,6,23,0) 0%, rgba(2,6,23,0.6) 100%), var(--color-surface-2); padding: var(--space-16) 0; }
.hero h1 { font-size: var(--fs-hero); margin-bottom: var(--space-4); }
.hero .cta-group { display: flex; gap: var(--space-4); flex-wrap: wrap; margin-top: var(--space-6); }

/* 8) Utilities */
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
/* end */
