:root {
  --brown-900: #3b2416;
  --brown-800: #4a2c18;
  --brown-600: #6b4226;
  --brown-500: #7d4f2e;
  --green-800: #234a35;
  --green-700: #2c5539;
  --green-100: #e7efe9;
  --cream: #faf7f2;
  --sand: #f2ede5;
  --ink: #2a2522;
  --ink-soft: #5a524c;
  --rule: #e2dad0;
  --white: #ffffff;

  --font-display: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Source Serif 4", Georgia, "Times New Roman", serif;

  --max: 1120px;
  --gutter: clamp(16px, 4vw, 40px);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 110px;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
}

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

a {
  color: var(--green-700);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--brown-600);
}

:focus-visible {
  outline: 3px solid #c9a227;
  outline-offset: 2px;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
}

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--white);
  padding: 8px 12px;
  z-index: 100;
}

.skip-link:focus {
  left: 8px;
  top: 8px;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--brown-800);
  color: var(--white);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.brand {
  color: var(--white);
  text-decoration: none;
  font-family: var(--font-display);
  line-height: 1.2;
}

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

.brand-name {
  display: block;
  font-size: 1.5rem;
  font-weight: 400;
}

.brand-sub {
  display: block;
  font-size: 0.95rem;
  font-weight: 300;
  opacity: 0.8;
  letter-spacing: 0.04em;
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: clamp(16px, 4vw, 48px);
}

.site-nav a {
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1rem;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.site-nav a:hover {
  color: var(--white);
}

.site-nav a[aria-current="page"] {
  color: var(--white);
  border-bottom-color: #c9a227;
}

/* ---------- Home: hero ---------- */

.hero {
  background: var(--green-700);
  background-image: linear-gradient(135deg, var(--green-800) 0%, var(--green-700) 60%);
  color: var(--white);
}

.hero .container {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: center;
  padding-top: clamp(40px, 5vw, 64px);
}

.portrait {
  margin: 0 0 -96px;
  position: relative;
  z-index: 1;
}

.portrait img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 24px 48px -16px rgba(20, 30, 24, 0.45);
}

.hero-text {
  padding-bottom: 32px;
}

.hero-text h1 {
  font-size: clamp(2.4rem, 5.5vw, 3.75rem);
  font-weight: 700;
}

.hero-text .title {
  margin: 12px 0 0;
  font-size: 1.5rem;
  font-weight: 300;
  opacity: 0.9;
}

/* ---------- Home: credentials ---------- */

.credentials {
  background: var(--white);
}

.credentials .container {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 96px);
  padding-top: 48px;
  padding-bottom: 72px;
}

.credentials dl {
  grid-column: 2;
  margin: 0;
  display: grid;
  gap: 24px;
}

.credentials dt {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brown-500);
  margin-bottom: 6px;
}

.credentials dd {
  margin: 0;
}

.credentials ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.credentials li {
  padding: 4px 0;
  font-size: 1.05rem;
  line-height: 1.5;
}

.credentials .when {
  display: block;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* ---------- Home: intro ---------- */

.intro {
  background: var(--sand);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.intro .container {
  max-width: 860px;
  padding-top: clamp(56px, 8vw, 96px);
  padding-bottom: clamp(56px, 8vw, 96px);
}

.intro p {
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  line-height: 1.75;
  margin: 0 0 1.4em;
}

.intro .cta {
  text-align: center;
  margin-top: 40px;
}

.button {
  display: inline-block;
  background: var(--brown-600);
  color: var(--white);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  padding: 14px 28px;
  border-radius: 3px;
  transition: background 0.15s, transform 0.15s;
}

.button:hover {
  background: var(--brown-800);
  color: var(--white);
  transform: translateY(-1px);
}

/* ---------- Home: publications ---------- */

.publications .container {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
  gap: clamp(32px, 6vw, 96px);
  padding-top: clamp(56px, 8vw, 104px);
  padding-bottom: clamp(56px, 8vw, 104px);
}

.publications h2 {
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 300;
  position: sticky;
  top: 120px;
  align-self: start;
}

.publications ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: pub;
}

.publications li {
  padding: 22px 0;
  border-top: 1px solid var(--rule);
  line-height: 1.6;
  font-size: 1.05rem;
}

.publications li:first-child {
  border-top: 0;
  padding-top: 0;
}

.publications .year {
  display: block;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--brown-500);
  margin-bottom: 4px;
}

.publications cite {
  font-style: italic;
}

/* ---------- Calculator page ---------- */

.page-head {
  background: var(--white);
  border-bottom: 1px solid var(--rule);
}

.page-head .container {
  max-width: 900px;
  padding-top: clamp(40px, 6vw, 72px);
  padding-bottom: clamp(32px, 5vw, 48px);
  text-align: center;
}

.page-head h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 300;
}

.prose .container {
  max-width: 860px;
  padding-top: 48px;
  padding-bottom: 48px;
}

.prose p,
.prose ul {
  margin: 0 0 1.2em;
}

.prose h2 {
  font-size: 1.5rem;
  margin: 2em 0 0.6em;
}

.prose ul {
  padding-left: 1.4em;
}

.prose li {
  margin-bottom: 0.4em;
}

.notice {
  background: #fdf6e7;
  border-left: 4px solid #c9a227;
  padding: 18px 22px;
  border-radius: 0 4px 4px 0;
  margin: 0 0 2em;
}

.notice strong {
  font-family: var(--font-display);
}

.equation {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 22px 24px;
  margin: 0 0 1.4em;
  font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", Cambria, Georgia, serif;
  font-size: 1.15rem;
  overflow-x: auto;
}

.equation.display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-style: italic;
  flex-wrap: nowrap;
}

.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  white-space: nowrap;
}

.frac > span:first-child {
  border-bottom: 1.5px solid currentColor;
  padding: 0 6px 4px;
}

.frac > span:last-child {
  padding: 4px 6px 0;
}

.formula {
  margin: 0 0 2em;
}

.formula h2 {
  margin-top: 1.6em;
}

.formula .equation {
  font-style: italic;
}

.formula ul {
  font-size: 1rem;
  color: var(--ink-soft);
}

.legal .container {
  font-size: 1.05rem;
}

.legal h2 {
  padding-top: 1.2em;
  border-top: 1px solid var(--rule);
}

.legal h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.6em 0 0.5em;
}

.legal h2 + h3 {
  margin-top: 0.8em;
}

.legal .updated {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.legal .indent {
  margin: 0 0 0.4em 1.4em;
  font-size: 1rem;
  color: var(--ink-soft);
}

.legal li {
  overflow-wrap: anywhere;
}

.calculator-embed {
  /* Calconic uses z-index up to 9999; keep it all beneath the sticky header. */
  isolation: isolate;
  background: var(--white);
  border-top: 1px solid var(--rule);
}

.calculator-embed .container {
  max-width: 980px;
  padding-top: 48px;
  padding-bottom: 72px;
}

.calculator-embed h2 {
  font-size: 1.75rem;
  margin-bottom: 24px;
  text-align: center;
}

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

.site-footer {
  background: var(--brown-900);
  color: rgba(255, 255, 255, 0.75);
  font-family: var(--font-display);
  font-size: 0.9rem;
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding-top: 28px;
  padding-bottom: 28px;
}

.site-footer a {
  color: rgba(255, 255, 255, 0.85);
}

.site-footer a:hover {
  color: var(--white);
}

.site-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 20px;
}

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

@media (max-width: 820px) {
  .hero .container,
  .credentials .container,
  .publications .container {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero .container {
    padding-top: 40px;
    gap: 32px;
  }

  .portrait {
    order: 2;
    width: 100%;
    max-width: 260px;
    margin: 0 auto -72px;
  }

  .hero-text {
    order: 1;
    padding-bottom: 0;
    text-align: center;
  }

  .credentials .container {
    padding-top: 104px;
  }

  .credentials dl {
    grid-column: 1;
  }

  .publications h2 {
    position: static;
  }
}

@media (max-width: 560px) {
  html {
    scroll-padding-top: 72px;
  }

  .site-header .container {
    padding-top: 12px;
    padding-bottom: 12px;
    gap: 12px;
  }

  .brand-name {
    font-size: 1.1rem;
  }

  .brand-sub {
    display: none;
  }

  .site-nav ul {
    gap: 16px;
  }

  .site-nav a {
    font-size: 0.95rem;
  }

  .equation.display {
    font-size: 0.95rem;
    justify-content: flex-start;
  }
}
