@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Merriweather:wght@700&display=swap');

:root {
  --navy: #1b3a6b;
  --navy-dark: #112347;
  --navy-light: #2855a0;
  --gold: #c49a0a;
  --gold-light: #f0c040;
  --gold-pale: #fdf6dc;
  --bg: #ffffff;
  --bg-alt: #f4f7fb;
  --text: #1a202c;
  --text-muted: #64748b;
  --border: #dde3f0;
  --teal: #0b6e69;
  --coral: #d95d39;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Merriweather', Georgia, serif;
  --shadow-sm: 0 1px 4px rgba(27, 58, 107, .08);
  --shadow: 0 4px 16px rgba(27, 58, 107, .10);
  --shadow-md: 0 8px 32px rgba(27, 58, 107, .14);
  --radius: 8px;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.8rem;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.72;
  background:
    linear-gradient(180deg, rgba(244, 247, 251, .98) 0%, #fff 34%, rgba(253, 246, 220, .32) 100%),
    repeating-linear-gradient(90deg, rgba(27, 58, 107, .035) 0 1px, transparent 1px 38px);
}

a {
  color: inherit;
}

img,
video,
canvas {
  display: block;
  max-width: 100%;
}

.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: 100%;
  height: 3px;
  background: transparent;
}

.read-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--navy-light));
}

.site-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.5rem;
  padding: .85rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
}

.brand {
  color: var(--navy-dark);
  font-weight: 800;
  text-decoration: none;
}

.site-bar nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .35rem;
}

.site-bar nav a,
.button,
.chapter-nav a {
  border-radius: var(--radius);
  text-decoration: none;
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}

.site-bar nav a {
  padding: .5rem .72rem;
  color: var(--text-muted);
  font-size: .92rem;
  font-weight: 700;
}

.site-bar nav a:hover {
  color: var(--navy);
  background: var(--gold-pale);
}

main {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(460px, 1.1fr);
  gap: 1.4rem;
  align-items: center;
  min-height: min(680px, calc(100vh - 7rem));
  padding: 2.8rem 0 2rem;
}

.eyebrow {
  margin: 0 0 .7rem;
  color: var(--gold);
  font-size: .85rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  color: var(--navy-dark);
  font-family: var(--font-heading);
  line-height: 1.22;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 3.55rem;
}

h2 {
  margin: 0 0 1rem;
  font-size: 2rem;
}

h3 {
  margin-top: 2rem;
  font-size: 1.35rem;
}

.hero-meta {
  margin: 1rem 0 0;
  color: var(--navy);
  font-weight: 700;
}

.hero-lede {
  max-width: 62ch;
  margin: 1.1rem 0 0;
  color: #334155;
  font-size: 1.08rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  margin-top: 1.35rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .68rem 1rem;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--navy-dark);
  box-shadow: var(--shadow-sm);
  font-weight: 800;
}

.button.primary {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}

.button:hover {
  transform: translateY(-2px);
  border-color: rgba(196, 154, 10, .62);
  box-shadow: var(--shadow-md);
}

.hero-visuals {
  display: grid;
  grid-template-columns: minmax(180px, .62fr) minmax(320px, 1.38fr);
  gap: .9rem;
  align-items: stretch;
}

.media-card {
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.media-card img,
.media-card video,
.media-card canvas {
  width: 100%;
  height: 100%;
  min-height: 250px;
  object-fit: contain;
  background: #f6f2e8;
}

.media-card:first-child img {
  background: var(--navy-dark);
}

.media-card-wide {
  align-self: center;
  grid-template-rows: auto auto;
  min-height: 0;
}

.media-card-wide img {
  height: auto;
  min-height: 0;
  aspect-ratio: auto;
}

.media-card figcaption {
  display: grid;
  gap: .18rem;
  min-height: 4.7rem;
  padding: .82rem .95rem .95rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .9rem;
  line-height: 1.35;
}

.media-card figcaption strong {
  color: var(--navy);
  font-size: .98rem;
}

.media-card code {
  color: var(--coral);
  font-family: inherit;
  font-weight: 700;
}

.overview-band {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(280px, 1fr);
  gap: 1.2rem;
  align-items: end;
  margin: 1rem 0 1.2rem;
  padding: 1.4rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.overview-band p:last-child {
  margin: 0;
  color: #334155;
  font-size: 1.02rem;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
  gap: .9rem;
  margin: 1.3rem 0 2.3rem;
}

.chapter-card {
  position: relative;
  min-height: 10.6rem;
  padding: 1rem 1rem 1rem 1.08rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.chapter-card::before {
  content: "";
  position: absolute;
  top: .95rem;
  bottom: .95rem;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--gold);
}

.chapter-card span {
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 800;
}

.chapter-card strong {
  display: block;
  margin: .22rem 0 .42rem;
  color: var(--navy);
  font-size: 1.02rem;
  line-height: 1.35;
}

.chapter-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: .92rem;
  line-height: 1.48;
}

.chapter-card:hover {
  transform: translateY(-3px);
  border-color: rgba(196, 154, 10, .55);
  box-shadow: var(--shadow-md);
}

.content-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 1.2rem;
  align-items: start;
  padding-bottom: 4rem;
}

.chapter-nav {
  position: sticky;
  top: 5.4rem;
  display: grid;
  gap: .22rem;
  max-height: calc(100vh - 6rem);
  overflow: auto;
  padding: .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow-sm);
}

.chapter-nav a {
  padding: .48rem .58rem;
  color: var(--text-muted);
  font-size: .88rem;
  font-weight: 700;
}

.chapter-nav a:hover,
.chapter-nav a.is-active {
  color: var(--navy);
  background: var(--gold-pale);
}

.chapter-nav .to-top {
  color: var(--navy-dark);
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  margin-bottom: .24rem;
  padding-bottom: .62rem;
}

.content-stack {
  display: grid;
  gap: 1.2rem;
  min-width: 0;
}

.dissertation-section {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow-sm);
}

.section-label {
  padding: .72rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, var(--gold-pale), #fff);
  color: var(--navy);
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.article-body {
  min-width: 0;
  padding: 1.4rem;
}

.article-body h1 {
  margin-top: 0;
  font-size: 2.05rem;
}

.article-body h2 {
  margin-top: 2.4rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.55rem;
}

.article-body h3 {
  font-family: var(--font-body);
  font-size: 1.12rem;
  font-weight: 800;
}

.article-body p,
.article-body li,
.article-body dd {
  color: #263445;
}

.article-body a {
  color: var(--navy-light);
  font-weight: 700;
  text-decoration-color: rgba(40, 85, 160, .28);
  text-underline-offset: 3px;
}

.article-body .unresolved-xref {
  color: var(--navy-light);
  font-weight: 700;
}

.article-body figure,
.article-body .animation-card,
.article-body .thesis-figure,
.article-body .thesis-table {
  margin: 1.6rem 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.article-body figure img,
.article-body figure video,
.article-body .animation-card img,
.article-body .animation-card video {
  width: 100%;
  height: auto;
  object-fit: contain;
  background: #fff;
}

.article-body figure video,
.article-body .animation-card video {
  aspect-ratio: 16 / 9;
  background: #101820;
}

.article-body figcaption,
.article-body .caption {
  padding: .85rem 1rem 1rem;
  color: var(--text-muted);
  font-size: .94rem;
  line-height: 1.55;
}

.article-body .animation-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: .85rem;
  margin: 1.1rem 0 1.8rem;
}

.article-body .animation-card {
  display: grid;
  grid-template-rows: auto 1fr;
}

.article-body .animation-card figcaption {
  display: grid;
  gap: .18rem;
}

.article-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.article-body th,
.article-body td {
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  vertical-align: top;
}

.article-body th {
  background: var(--bg-alt);
  color: var(--navy-dark);
}

.article-body .table-scroll {
  width: 100%;
  overflow-x: auto;
}

.article-body .thesis-table table {
  display: table;
  min-width: 720px;
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.article-body .thesis-table th {
  font-weight: 800;
  text-align: left;
}

.article-body .thesis-table th[scope="row"] {
  width: 8.5rem;
  color: var(--navy);
  white-space: nowrap;
}

.article-body .thesis-table td,
.article-body .thesis-table th {
  padding: .78rem .86rem;
}

.article-body .thesis-table .math-cell {
  color: #172033;
  font-size: .92rem;
  line-height: 1.5;
  vertical-align: middle;
}

.article-body .thesis-table .math-cell mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.article-body .compact-data-table {
  min-width: 540px;
}

.article-body .compact-data-table td,
.article-body .compact-data-table th {
  text-align: center;
}

.article-body pre {
  overflow-x: auto;
  padding: 1rem;
  border-radius: var(--radius);
  background: #101820;
  color: #fff;
}

.article-body .math {
  overflow-x: auto;
}

.article-body .footnote,
.article-body .citation {
  overflow-wrap: anywhere;
}

.build-note {
  margin: 0;
  padding: .9rem 1rem;
  border: 1px solid rgba(217, 93, 57, .28);
  border-radius: var(--radius);
  background: rgba(217, 93, 57, .08);
  color: #7a2e1c;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .55s ease, transform .55s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.content-stack .reveal {
  opacity: 1;
  transform: none;
}

@media (max-width: 1100px) {
  .hero,
  .overview-band,
  .content-shell {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .chapter-nav {
    position: static;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    max-height: none;
  }
}

@media (max-width: 780px) {
  .site-bar {
    align-items: flex-start;
    flex-direction: column;
    padding: .8rem 1rem;
  }

  main {
    width: min(100% - 1rem, 1180px);
  }

  h1 {
    font-size: 2.2rem;
  }

  .hero-visuals {
    grid-template-columns: 1fr;
  }

  .media-card-wide {
    min-height: 300px;
  }

  .article-body {
    padding: 1rem;
  }

  .article-body h1 {
    font-size: 1.55rem;
  }
}
