/* ═══════════════════════════════════════════════════
   causa.inff.cc — Design System
   A research journal sub-brand of inff.cc.
   Tokens adapted from inff.cc, tuned for long-form
   controversy / case-study reading.
   ═══════════════════════════════════════════════════ */

:root, [data-theme="dark"] {
  --bg: #0d0b1a;
  --bg-elevated: #161330;
  --bg-card: #1a1640;
  --bg-hover: #231d4f;
  --text: #f0f0f5;
  --text-dim: #c8c6d4;
  --text-muted: #8f8aa3;
  --text-subtle: #6b6780;
  --accent: #8CBF3F;
  --accent-hover: #BED996;
  --accent-soft: rgba(140, 191, 63, 0.12);
  --primary: #8078E8;
  --primary-dark: #2B2766;
  --primary-soft: rgba(128, 120, 232, 0.12);
  --cta: #8CBF3F;
  --cta-hover: #BED996;
  --border: #2B2766;
  --border-dim: #1e1a40;
  --surface-0: #0d0b1a;
  --surface-1: #131025;
  --surface-2: #1a1640;
  --surface-3: #2B2766;
  --surface-4: #3e3794;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --max-w: 760px;
  --max-w-wide: 1120px;
  --font-serif: 'Noto Serif TC', 'Noto Serif SC', Georgia, serif;
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #fafbfc;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f4f6f0;
  --text: #1a1a2e;
  --text-dim: #3d3b50;
  --text-muted: #6b6880;
  --text-subtle: #9a97a8;
  --accent: #3d6b14;
  --accent-hover: #2B2766;
  --accent-soft: rgba(61, 107, 20, 0.08);
  --primary: #4D41C2;
  --primary-dark: #2B2766;
  --primary-soft: rgba(77, 65, 194, 0.08);
  --cta: #3d6b14;
  --cta-hover: #2B2766;
  --border: #e4e2ee;
  --border-dim: #f0eef8;
  --surface-0: #fafbfc;
  --surface-1: #ffffff;
  --surface-2: #f5f4fa;
  --surface-3: #eceaf5;
  --surface-4: #e0deeb;
  --shadow: 0 4px 20px rgba(27, 24, 60, 0.08);
  color-scheme: light;
}

/* ── Reset & Base ───────────────────────────────── */

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.7;
  min-height: 100vh;
}

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

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

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

/* ── Typography ─────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.25;
  margin: 2.4rem 0 1rem;
  color: var(--text);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.85rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
h3 { font-size: 1.45rem; }
h4 { font-size: 1.2rem; }

p {
  margin: 0 0 1.2rem;
}

ul, ol {
  margin: 0 0 1.2rem;
  padding-left: 1.6rem;
}

li {
  margin: 0.35rem 0;
}

code {
  background: var(--surface-2);
  color: var(--accent);
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}

pre {
  background: var(--surface-2);
  padding: 1.1rem;
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin: 0 0 1.5rem;
}

pre code {
  background: transparent;
  color: var(--text);
  padding: 0;
}

blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-dim);
}

blockquote p:last-child {
  margin-bottom: 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ── Tables ─────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

th, td {
  border: 1px solid var(--border);
  padding: 0.65rem 0.85rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  font-weight: 600;
  font-family: var(--font-sans);
}

tr:nth-child(even) td {
  background: var(--surface-1);
}

/* ── Site Header ────────────────────────────────── */

.ca-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.ca-brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.ca-logo {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.ca-logo span {
  color: var(--accent);
}

.ca-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ca-nav {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.ca-nav a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-dim);
}

.ca-nav a:hover {
  color: var(--accent);
}

.ca-theme-toggle {
  cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
}

/* ── Hero ───────────────────────────────────────── */

.ca-hero {
  padding: 4rem 1.5rem 3.5rem;
  text-align: center;
  background:
    radial-gradient(circle at 20% 30%, var(--primary-soft) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, var(--accent-soft) 0%, transparent 35%),
    var(--bg);
  border-bottom: 1px solid var(--border);
}

.ca-hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  margin: 0 0 1rem;
  line-height: 1.1;
}

.ca-hero .ca-tagline {
  font-size: 1.15rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.75rem;
  letter-spacing: 0.02em;
}

.ca-hero .ca-lead {
  max-width: 680px;
  margin: 0 auto;
  font-size: 1.15rem;
  color: var(--text-muted);
}

/* ── Main & Containers ──────────────────────────── */

.ca-main {
  max-width: var(--max-w-wide);
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.ca-container {
  max-width: var(--max-w);
  margin: 0 auto;
}

.ca-wide {
  max-width: var(--max-w-wide);
  margin: 0 auto;
}

/* ── Section Headers ────────────────────────────── */

.ca-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.ca-section-head h2 {
  margin: 0;
  font-size: 1.35rem;
  border: none;
  padding: 0;
}

.ca-section-head a {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ── Cards ──────────────────────────────────────── */

.ca-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.ca-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.ca-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.ca-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  line-height: 1.35;
}

.ca-card h3 a {
  color: var(--text);
}

.ca-card h3 a:hover {
  color: var(--accent);
  text-decoration: none;
}

.ca-card-summary {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.6;
  flex: 1;
  margin: 0 0 1rem;
}

.ca-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ── Article Header ─────────────────────────────── */

.ca-article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.ca-article-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0 0 1rem;
}

.ca-article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.ca-article-meta time {
  color: var(--text-subtle);
}

/* ── Article Body ───────────────────────────────── */

.ca-article {
  max-width: var(--max-w);
  margin: 0 auto;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.85;
}

.ca-article h2, .ca-article h3, .ca-article h4 {
  font-family: var(--font-serif);
}

.ca-article p, .ca-article ul, .ca-article ol, .ca-article table {
  font-family: var(--font-serif);
}

.ca-article a {
  color: var(--primary);
  border-bottom: 1px dotted var(--primary);
}

.ca-article a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

/* ── Labels / Tags / Categories ─────────────────── */

.ca-label, .ca-tag, .ca-category {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.ca-label-accent {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.ca-label-primary {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}

/* ── Table of Contents ──────────────────────────── */

.ca-toc {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin: 0 0 2rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

.ca-toc-title {
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--text);
}

.ca-toc ul {
  margin: 0;
  padding-left: 1.2rem;
}

.ca-toc li {
  margin: 0.35rem 0;
}

.ca-toc a {
  color: var(--text-dim);
}

.ca-toc a:hover {
  color: var(--accent);
}

/* ── Summary / Lead Box ─────────────────────────── */

.ca-summary {
  background: var(--primary-soft);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1.1rem 1.3rem;
  margin: 0 0 2rem;
  color: var(--text-dim);
  font-size: 1.05rem;
  font-family: var(--font-sans);
  line-height: 1.7;
}

.ca-summary p:last-child {
  margin-bottom: 0;
}

/* ── Methodology Block ──────────────────────────── */

.ca-method {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

.ca-method h4 {
  margin-top: 0;
  color: var(--accent);
}

.ca-method ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

/* ── Footer ─────────────────────────────────────── */

.ca-footer {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

.ca-footer a {
  color: var(--text-muted);
  margin: 0 0.5rem;
}

.ca-footer a:hover {
  color: var(--accent);
}

/* ── Utilities ──────────────────────────────────── */

.ca-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;
}

.ca-text-muted {
  color: var(--text-muted);
}

.ca-text-center {
  text-align: center;
}

/* ── Responsive ─────────────────────────────────── */

@media (max-width: 640px) {
  .ca-header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }

  .ca-hero {
    padding: 2.5rem 1.25rem;
  }

  .ca-hero h1 {
    font-size: 2rem;
  }

  .ca-card-grid {
    grid-template-columns: 1fr;
  }

  .ca-article {
    font-size: 1rem;
  }
}
