/* Design tokens: warm paper, blue ink for lines and links, carmine ink for points and findings. */
:root {
  --paper: #F6F4EF;
  --paper-2: #EEEBE4;
  --card: #FBFAF7;
  --ink: #1F2328;
  --ink-2: #54585F;
  --ink-3: #8E897F;
  --rule: #DDD8CE;
  --blue: #27466F;
  --red: #B0303F;
  --ok: #3B6D11;

  --serif: "Newsreader", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  --wrap: 1080px;
  --prose: 680px;
  --radius: 14px;

  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #191816;
    --paper-2: #221F1C;
    --card: #1F1D1A;
    --ink: #EAE6DE;
    --ink-2: #ABA59A;
    --ink-3: #7A7469;
    --rule: #34312C;
    --blue: #93B3DB;
    --red: #E48A8F;
    --ok: #9CC66B;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #191816;
  --paper-2: #221F1C;
  --card: #1F1D1A;
  --ink: #EAE6DE;
  --ink-2: #ABA59A;
  --ink-3: #7A7469;
  --rule: #34312C;
  --blue: #93B3DB;
  --red: #E48A8F;
  --ok: #9CC66B;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}
p { margin: 0 0 1em; }
a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.15; margin: 0; }
img, svg, canvas { max-width: 100%; }
code { font-family: var(--mono); font-size: 0.84em; background: var(--paper-2); padding: 0.15em 0.45em; border-radius: 6px; }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
}
.prose { max-width: var(--prose); }

.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 16px; top: 12px; background: var(--card); padding: 6px 12px; z-index: 10; }

/* Header and footer */
.site-header { padding: 22px 0; }
.header-inner { display: flex; align-items: baseline; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.site-name { font-family: var(--serif); font-size: 1.2rem; font-weight: 500; color: var(--ink); text-decoration: none; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 0.95rem; }
.nav a { color: var(--ink); text-decoration: none; }
.nav a:hover { color: var(--blue); }
.nav a[aria-current="page"] { color: var(--blue); text-decoration: underline; text-underline-offset: 0.3em; }

.site-footer { border-top: 1px solid var(--rule); margin-top: 5rem; padding: 2rem 0 3rem; color: var(--ink-2); font-size: 0.92rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 1rem 2rem; flex-wrap: wrap; align-items: baseline; }
.footer-inner p { margin: 0; }
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 20px; }

/* Home: hero */
.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; align-items: center; padding: clamp(1.5rem, 5vw, 3.5rem) 0 2rem; }
@media (min-width: 880px) { .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 3rem; } }
.hero h1 { font-size: clamp(2.6rem, 6.2vw, 4.1rem); letter-spacing: -0.01em; line-height: 1.04; }
.hero .lede { font-family: var(--serif); font-size: clamp(1.25rem, 2.2vw, 1.45rem); line-height: 1.45; margin: 1.1rem 0 0; max-width: 30em; }
.hero .currently { color: var(--ink-2); font-size: 0.98rem; margin: 1.2rem 0 0; max-width: 34em; }
.hero .currently strong { color: var(--ink); font-weight: 500; }
.hero .links { margin-top: 1.6rem; font-size: 0.98rem; }

.volume { position: relative; width: 100%; max-width: 540px; aspect-ratio: 1 / 1; justify-self: center; touch-action: pan-y; cursor: grab; }
.volume canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 0.6s ease; }
.volume.is-ready canvas { opacity: 1; }
.volume .placeholder { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--blue); opacity: 0.35; transition: opacity 0.6s ease; }
.volume.is-ready .placeholder { opacity: 0; }
.volume-caption { color: var(--ink-3); font-size: 0.85rem; text-align: center; margin: 0.4rem 0 0; }
@media (prefers-reduced-motion: reduce) { .volume canvas, .volume .placeholder { transition: none; } }

/* Sections */
.section { padding: 3rem 0 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; border-top: 1px solid var(--rule); padding-top: 1.4rem; margin-bottom: 1.2rem; }
.section-head h2 { font-size: clamp(1.5rem, 3vw, 1.85rem); }
.section-head a { font-size: 0.95rem; }

.page-head { padding: clamp(1.5rem, 5vw, 3rem) 0 1.5rem; }
.page-head h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); }
.page-head p { font-family: var(--serif); font-size: 1.25rem; line-height: 1.5; color: var(--ink-2); margin: 0.8rem 0 0; max-width: 34em; }

/* Publications */
.pubs { list-style: none; margin: 0; padding: 0; }
.pub { padding: 1.1rem 0; border-top: 1px solid var(--rule); max-width: 820px; }
.pub:first-child { border-top: 0; padding-top: 0.2rem; }
.pub-title { font-family: var(--serif); font-size: 1.18rem; font-weight: 500; line-height: 1.35; margin: 0 0 0.3rem; }
.pub-title a { color: var(--ink); text-decoration: none; }
.pub-title a:hover { color: var(--blue); text-decoration: underline; }
.pub-authors, .pub-venue { color: var(--ink-2); font-size: 0.95rem; margin: 0; }
.pub-authors .me { color: var(--ink); font-weight: 600; }
.pub-venue i { font-style: italic; }
.pub-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 0.55rem; font-size: 0.85rem; }
.badge { border: 1px solid var(--rule); color: var(--ink-2); border-radius: 999px; padding: 0.05rem 0.65rem; }
.badge.accent { border-color: var(--red); color: var(--red); }
.pub-meta a { color: var(--blue); }
.pub-group { margin-top: 2.2rem; }
.pub-group h2 { font-size: 1.45rem; margin-bottom: 0.8rem; }
.footnote { color: var(--ink-3); font-size: 0.88rem; margin-top: 2rem; }

/* Notes cards */
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.1rem 1.25rem 1.2rem; display: flex; flex-direction: column; gap: 0.35rem; }
.card .course { color: var(--ink-3); font-size: 0.85rem; margin: 0; }
.card h3 { font-size: 1.25rem; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; }
.card { position: relative; }
.card:hover { border-color: var(--blue); }
.card p { margin: 0; color: var(--ink-2); font-size: 0.95rem; }
.notice { color: var(--ink-3); font-size: 0.9rem; margin-top: 1rem; }

/* Research */
.theme { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.5rem 2.5rem; padding: 2rem 0; border-top: 1px solid var(--rule); }
@media (min-width: 880px) { .theme { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); } }
.theme h2 { font-size: 1.6rem; }
.theme .n { display: block; color: var(--ink-3); font-family: var(--serif); font-size: 1rem; margin-bottom: 0.3rem; }
.theme p { color: var(--ink); }
.theme .related { list-style: none; padding: 0; margin: 0.4rem 0 0; font-size: 0.95rem; }
.theme .related li { padding: 0.35rem 0; border-top: 1px solid var(--rule); }
.theme .related li:first-child { border-top: 0; }
.theme .related span { color: var(--ink-3); }

@media print {
  .site-header nav, .volume, .skip { display: none; }
  body { background: #fff; color: #000; }
}
