:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b2232;
  --muted: #5a6478;
  --border: #e2e5eb;
  --accent: #3554d1;
  --accent-strong: #2440b3;
  --accent-soft: #eaeefc;
  --hero-from: #1f2f7a;
  --hero-to: #3554d1;
  --hero-text: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 16px rgba(16, 24, 40, 0.06);
  --shadow-hover: 0 2px 4px rgba(16, 24, 40, 0.06), 0 12px 28px rgba(16, 24, 40, 0.12);
  --radius: 14px;
  --wrap: 1120px;
  --header-height: 64px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f131c;
    --surface: #171c28;
    --text: #e6e9f0;
    --muted: #9aa3b5;
    --border: #2a3142;
    --accent: #8ea4ff;
    --accent-strong: #b3c1ff;
    --accent-soft: #1f2740;
    --hero-from: #141c3d;
    --hero-to: #263c9e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 16px rgba(0, 0, 0, 0.25);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.35), 0 12px 28px rgba(0, 0, 0, 0.4);
  }
}

*,
*::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.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

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

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--header-height);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  color: #ffffff;
  font-family: var(--font-serif);
  font-size: 1.1rem;
}

.site-nav {
  display: flex;
  gap: 4px;
}

.site-nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Hero */

.hero {
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  color: var(--hero-text);
  padding: 72px 0 64px;
}

.hero h1 {
  max-width: 18ch;
  margin: 0 0 16px;
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
}

.lead {
  max-width: 62ch;
  margin: 0 0 28px;
  font-size: 1.15rem;
  opacity: 0.92;
}

.hero-actions {
  margin: 0;
}

.button {
  display: inline-block;
  padding: 11px 20px;
  border-radius: 10px;
  background: #ffffff;
  color: var(--hero-from);
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease;
}

.button:hover {
  color: var(--hero-from);
  transform: translateY(-1px);
}

.hero-stats {
  margin: 20px 0 0;
  font-size: 0.95rem;
  opacity: 0.8;
}

/* Theme chips */

.theme-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 32px 0 8px;
}

.theme-chips a {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
}

.theme-chips a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Home: themes and study cards */

.home-content {
  padding-bottom: 48px;
}

.home-content h2 {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  margin: 48px 0 4px;
  font-family: var(--font-serif);
  font-size: 1.6rem;
  scroll-margin-top: calc(var(--header-height) + 16px);
}

.home-content h2 .count {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
}

.home-content h2 + p {
  margin: 0 0 18px;
  color: var(--muted);
}

.home-content ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-content li {
  position: relative;
  padding: 20px 20px 18px;
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.home-content li:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.home-content li a {
  display: block;
  margin-bottom: 10px;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
}

/* Makes the whole card clickable. */
.home-content li a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.home-content li:hover a {
  color: var(--accent);
}

/* Reading pages */

.with-toc {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

.prose {
  max-width: 76ch;
  padding: 40px 0 64px;
  overflow-wrap: anywhere;
}

.prose h1 {
  margin: 0 0 24px;
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 2.6rem);
  line-height: 1.15;
}

.prose h2 {
  margin: 56px 0 8px;
  padding: 8px 0 8px 14px;
  border-left: 4px solid var(--accent);
  font-family: var(--font-serif);
  font-size: 1.6rem;
  line-height: 1.25;
}

.prose h3 {
  margin: 32px 0 12px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.45;
}

.prose h2 + h3 {
  border-top: 0;
  padding-top: 8px;
}

.prose h2,
.prose h3 {
  scroll-margin-top: calc(var(--header-height) + 16px);
}

.prose p {
  margin: 0 0 1em;
}

.back-to-top {
  margin-top: 48px;
  font-size: 0.9rem;
}

/* Contents sidebar */

.toc {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  max-height: calc(100vh - var(--header-height) - 48px);
  overflow-y: auto;
  margin-top: 40px;
  font-size: 0.88rem;
}

.toc summary {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
}

.toc summary::-webkit-details-marker {
  display: none;
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc > details > nav > ol > li {
  margin-bottom: 10px;
}

.toc > details > nav > ol > li > a {
  color: var(--text);
  font-weight: 600;
}

.toc ol ol {
  margin-top: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.toc ol ol a {
  color: var(--muted);
}

.toc a {
  display: block;
  padding: 2px 0;
  text-decoration: none;
}

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

/* Footer */

.site-footer {
  padding: 28px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0;
}

/* Small screens */

@media (max-width: 900px) {
  .with-toc {
    display: block;
  }

  .toc {
    position: static;
    max-height: none;
    margin-top: 24px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
  }

  .toc summary {
    display: flex;
    justify-content: space-between;
  }

  .toc summary::after {
    content: "+";
    font-size: 1rem;
    line-height: 1;
  }

  .toc details[open] summary::after {
    content: "\2212";
  }

  .toc details:not([open]) summary {
    margin-bottom: 0;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .wrap {
    padding: 0 16px;
  }

  .hero {
    padding: 48px 0 44px;
  }

  .home-content ul {
    grid-template-columns: minmax(0, 1fr);
  }

  .site-header-inner {
    gap: 8px;
  }

  .brand {
    gap: 8px;
    font-size: 0.95rem;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
  }

  .site-nav a {
    padding: 6px 8px;
    font-size: 0.88rem;
  }
}
