:root {
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-text-muted: #555555;
  --color-accent: #1a3a5c;
  --color-accent-light: #2a5a8c;
  --color-border: #e0e0e0;
  --color-surface: #f7f7f7;
  --color-numeral: #1a3a5c;
  --font-body: "Georgia", "Times New Roman", serif;
  --font-heading: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Menlo", "Consolas", monospace;
  --max-width: 48rem;
  --gutter: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0e0e0e;
    --color-text: #d4d4d4;
    --color-text-muted: #999999;
    --color-accent: #6a9fd8;
    --color-accent-light: #8ab8e8;
    --color-border: #2a2a2a;
    --color-surface: #1a1a1a;
    --color-numeral: #6a9fd8;
  }
}

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

html {
  font-size: 1.0625rem;
  line-height: 1.7;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
}

/* ---- Header / Nav ---- */

header {
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background-color: var(--color-bg);
  z-index: 100;
}

nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 3.5rem;
  font-family: var(--font-heading);
  font-size: 0.9rem;
}

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

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

.nav-brand {
  font-weight: 600;
  color: var(--color-accent);
  letter-spacing: -0.01em;
}

/* ---- Main ---- */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---- Hero ---- */

.hero {
  text-align: center;
  padding: 3rem 0 1.5rem;
}

.hero h1 {
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--color-accent);
}

.hero .subtitle {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--color-text-muted);
  margin-top: 0.75rem;
  font-weight: 400;
}

/* ---- Sections ---- */

section {
  padding: 1.75rem 0;
}

section + section {
  border-top: 1px solid var(--color-border);
}

section h2 {
  font-family: var(--font-heading);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
  color: var(--color-accent);
}

section h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

section p {
  margin-bottom: 1rem;
}

section strong {
  color: var(--color-accent);
}

section em {
  font-style: italic;
}

section code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-surface);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

/* ---- Factor Grid (index) ---- */

.factor-grid h2 {
  text-align: center;
  margin-bottom: 2rem;
}

.factor-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.factor-card {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 1rem 0;
  border-top: 1px solid var(--color-border);
  transition: background-color 0.15s;
}

.factor-card:last-child {
  border-bottom: 1px solid var(--color-border);
}

.factor-card:hover {
  background-color: var(--color-surface);
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.factor-card-numeral {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-numeral);
  letter-spacing: 0.05em;
}

.factor-card h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--color-accent);
  margin: 0.25rem 0 0.4rem;
  text-align: left;
}

.factor-card p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin: 0;
}

/* ---- Factor Page ---- */

.factor {
  padding: 2rem 0;
}

.factor-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

.factor-numeral {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-numeral);
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.5rem;
}

.factor-header h1 {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--color-accent);
  margin-bottom: 0.5rem;
}

.tagline {
  font-size: 1.15rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.factor section {
  padding: 1rem 0;
}

.factor section + section {
  border-top: 1px solid var(--color-border);
}

.factor section h2 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 1rem;
}

/* ---- Factor Nav ---- */

.factor-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 0;
  margin-top: 2rem;
  border-top: 1px solid var(--color-border);
  font-family: var(--font-heading);
  font-size: 0.9rem;
}

.factor-nav a {
  color: var(--color-accent);
  text-decoration: none;
}

.factor-nav a:hover {
  text-decoration: underline;
}

.factor-nav .prev::before {
  content: "\2190 ";
}

.factor-nav .next::after {
  content: " \2192";
}

/* ---- Footer ---- */

footer {
  border-top: 1px solid var(--color-border);
  text-align: center;
  padding: 2rem var(--gutter);
  margin-top: 3rem;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

footer p {
  margin-bottom: 0.25rem;
}

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

/* ---- Antipatterns ---- */

.factor section h2.antipatterns-heading {
  color: var(--color-text-muted);
}

section ul {
  list-style: none;
  padding: 0;
}

section ul li {
  padding: 0.4rem 0 0.4rem 1.5rem;
  position: relative;
  color: var(--color-text-muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

section ul li::before {
  content: "\d7";
  position: absolute;
  left: 0;
  top: 0.35rem;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  font-weight: 700;
}

/* ---- Responsive ---- */

@media (min-width: 768px) {
  .hero h1 {
    font-size: 3.75rem;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 1rem;
  }

  .hero h1 {
    font-size: 2.25rem;
  }

  nav {
    gap: 1rem;
    font-size: 0.85rem;
  }

  .factor-header h1 {
    font-size: 1.75rem;
  }
}
