/* The dissertation, read in the browser: a sheet of paper for the text, a contents rail beside it, and the
   typography of the printed thesis carried over (Newsreader for the text, KaTeX's Computer Modern for the math). */

.thesis {
  --paper: #fffdf7;
  --page: #fffff0;
  --ink: #1b1b20;
  --ink-2: #4a4a55;
  --ink-3: #8a8a93;
  --rule: rgba(20, 20, 30, 0.1);
  --rule-2: rgba(20, 20, 30, 0.055);
  --accent: #1f3fd0;
  --accent-soft: rgba(31, 63, 208, 0.07);
  --warm: #a8431c;
  --warm-soft: rgba(168, 67, 28, 0.06);
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.35  0 0 0 0 0.3  0 0 0 0 0.2  0 0 0 0.07 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  display: grid;
  grid-template-columns: 17rem minmax(0, 46rem);
  gap: 2.5rem;
  justify-content: center;
  max-width: 1120px;
  margin: 0 auto;
  padding: 6.5rem 20px 0;
  color: var(--ink);
}
.dark .thesis {
  --paper: #232427;
  --page: #1f2022;
  --ink: #e9eaee;
  --ink-2: #b0b1ba;
  --ink-3: #7c7d86;
  --rule: rgba(255, 255, 255, 0.12);
  --rule-2: rgba(255, 255, 255, 0.06);
  --accent: #8fb0ff;
  --accent-soft: rgba(143, 176, 255, 0.09);
  --warm: #e5875c;
  --warm-soft: rgba(229, 135, 92, 0.08);
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.035 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---------------------------------------------------------------- the reading progress line */
.progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: #1f3fd0; z-index: 60; transition: width 0.1s linear; }
.dark .progress { background: #8fb0ff; }

/* ---------------------------------------------------------------- the contents rail */
.rail { position: sticky; top: 5rem; align-self: start; max-height: calc(100vh - 6rem); overflow-y: auto; font-size: 0.86rem;
  padding-right: 6px; scrollbar-width: thin; font-family: ui-sans-serif, system-ui, sans-serif; }
.rail .book { display: block; font-family: Newsreader, Georgia, serif; font-size: 1.05rem; line-height: 1.3; color: var(--ink);
  text-decoration: none; margin-bottom: 1rem; }
.rail ol { list-style: none; margin: 0; padding: 0; }
.rail .toc > li > a { display: flex; gap: 0.6rem; padding: 0.32rem 0.5rem; border-radius: 6px; color: var(--ink-2); text-decoration: none; line-height: 1.35; }
.rail .toc > li > a:hover { background: var(--rule-2); color: var(--ink); }
.rail .toc > li.here > a { color: var(--ink); font-weight: 600; background: var(--accent-soft); }
.rail .lab { font-variant-numeric: tabular-nums; color: var(--ink-3); min-width: 1.4rem; flex: none; }
.rail .here .lab { color: var(--accent); }
.rail .secs { margin: 0.2rem 0 0.5rem 0.5rem; border-left: 1px solid var(--rule); }
.rail .secs a { display: flex; gap: 0.5rem; padding: 0.22rem 0.6rem; color: var(--ink-3); text-decoration: none; line-height: 1.35; font-size: 0.82rem;
  border-left: 2px solid transparent; margin-left: -1px; }
.rail .secs a:hover { color: var(--ink); }
.rail .secs a.on { color: var(--accent); border-left-color: var(--accent); }
.rail .secs .lab { min-width: 2.2rem; }
.rail .pdf { display: inline-block; margin: 1.2rem 0 1rem; color: var(--accent); text-decoration: none; font-size: 0.84rem; }

/* ---------------------------------------------------------------- the sheet */
.paper { position: relative; background: var(--paper) var(--grain); border: 1px solid var(--rule-2); border-radius: 3px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02), 0 12px 40px -18px rgba(40, 30, 10, 0.18); padding: 3.2rem 3.4rem 2.6rem; min-width: 0; }
.dark .paper { box-shadow: 0 12px 40px -18px rgba(0, 0, 0, 0.6); }
.kicker { font: 0.72rem ui-sans-serif, system-ui, sans-serif; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 2.2rem; }
.kicker a { color: inherit; text-decoration: none; }
.kicker a:hover { color: var(--accent); }

.body { font-family: Newsreader, "Iowan Old Style", Georgia, serif; font-size: 1.14rem; line-height: 1.68; color: var(--ink);
  hyphens: auto; -webkit-hyphens: auto; font-optical-sizing: auto; }
.body p { margin: 0 0 1.05em; }
.body a { color: var(--accent); text-decoration: none; }
.body a:hover { text-decoration: underline; text-underline-offset: 3px; }
.body h1, .body h2, .body h3, .body h4 { font-family: Newsreader, Georgia, serif; font-weight: 500; color: var(--ink); scroll-margin-top: 5rem; }
.body h1 { font-size: clamp(2rem, 4.2vw, 2.85rem); line-height: 1.08; letter-spacing: -0.02em; margin: 0 0 2rem; }
.body h1 .secnum { display: block; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.8rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-bottom: 0.9rem; }
.body section.level1 + section.level1 { margin-top: 4.5rem; padding-top: 3rem; border-top: 1px solid var(--rule); }
.body h2 { font-size: 1.62rem; line-height: 1.2; margin: 3rem 0 1rem; letter-spacing: -0.01em; }
.body h3 { font-size: 1.28rem; margin: 2.2rem 0 0.7rem; }
.body h4 { font-size: 1.1rem; margin: 1.6rem 0 0.5rem; font-style: italic; }
.body .secnum { color: var(--ink-3); font-variant-numeric: tabular-nums; margin-right: 0.6em; font-weight: 400; }
.body h2 .secnum, .body h3 .secnum { font-size: 0.8em; }
.body [id] { scroll-margin-top: 5.5rem; }
.body em { font-style: italic; }
.body strong { font-weight: 600; }
.body ul, .body ol { padding-left: 1.4em; margin: 0 0 1.05em; }
.body li { margin: 0.25em 0; }
.body blockquote { margin: 1.2em 0; padding: 0.2em 0 0.2em 1.1em; border-left: 2px solid var(--rule); color: var(--ink-2); }
.body hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* the mathematics */
.body .math.display { display: block; overflow-x: auto; overflow-y: hidden; padding: 0.35em 0.1em; margin: 0.2em 0; scrollbar-width: thin; }
.body .math.display .katex-display { margin: 0.35em 0; }
.body .katex { font-size: 1.06em; }
.body .math.display:target, .body :target > .math.display { background: var(--accent-soft); border-radius: 6px; }

/* theorems, definitions, remarks, proofs */
.body .thm { margin: 1.6em 0; padding: 0.95em 1.15em 0.2em; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; }
.body .thm-definition, .body .thm-assumption, .body .thm-example, .body .thm-problem { border-left-color: var(--warm); background: var(--warm-soft); }
.body .thm-remark, .body .thm-question { border-left-color: var(--rule); background: transparent; }
.body .thm > p:first-child > strong:first-child { font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.8rem; letter-spacing: 0.08em;
  text-transform: uppercase; font-weight: 700; color: var(--accent); margin-right: 0.25em; }
.body .thm-definition > p:first-child > strong:first-child, .body .thm-assumption > p:first-child > strong:first-child { color: var(--warm); }
.body .thm-remark > p:first-child > strong:first-child { color: var(--ink-3); }
.body .thm:target { box-shadow: 0 0 0 2px var(--accent); }
.body .proof { margin: -0.4em 0 1.6em; color: var(--ink-2); font-size: 1.05rem; }
.body .proof > p:first-child > em:first-child { font-family: ui-sans-serif, system-ui, sans-serif; font-style: normal; font-size: 0.78rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3); margin-right: 0.35em; }

/* figures and tables */
.body figure { margin: 2em -1.2rem; padding: 1.2rem 1.2rem 0.9rem; background: #fff; border: 1px solid var(--rule-2); border-radius: 4px; }
.dark .body figure { background: #f6f4ee; }
.dark .body figure figcaption { color: #3e3e46; }
.body figure img { display: block; width: 100%; height: auto; margin: 0 auto; }
.body figure img[src$=".svg"] { max-width: 34rem; }
.body figcaption { font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.84rem; line-height: 1.5; color: var(--ink-2); margin-top: 0.9rem; }
.body .fignum { font-weight: 700; color: var(--ink); }
.dark .body .fignum { color: #1b1b20; }
.body figure figure { margin: 0.4rem 0; padding: 0; border: 0; }
.body .tablewrap { overflow-x: auto; margin: 1.2em 0; }
.body table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.body th, .body td { padding: 0.4em 0.6em; border-bottom: 1px solid var(--rule-2); text-align: left; vertical-align: top; }
.body thead th { border-bottom: 1px solid var(--rule); font-weight: 600; }
.body caption { caption-side: top; text-align: left; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.84rem; color: var(--ink-2); padding-bottom: 0.5rem; }

/* cross-references and citations */
.body a.xref { font-variant-numeric: tabular-nums; }
.body a[href*="/references/#ref-"] { font-variant-numeric: tabular-nums; }

/* footnotes */
.body aside.footnotes { font-size: 0.92rem; color: var(--ink-2); margin-top: 3rem; }
.body aside.footnotes hr { margin: 0 0 1rem; width: 6rem; }
.body .footnote-ref { font-size: 0.75em; vertical-align: super; line-height: 0; }

/* the references page */
.body .refs .bib { list-style: none; padding: 0; font-size: 1rem; }
.body .refs .bib li { position: relative; padding: 0.45em 0 0.45em 3rem; border-bottom: 1px solid var(--rule-2); scroll-margin-top: 5.5rem; }
.body .refs .bib li:target { background: var(--accent-soft); }
.body .refs .bn { position: absolute; left: 0; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* the front matter's notation tables */
.body section#notation table td:first-child { white-space: nowrap; }

/* ---------------------------------------------------------------- the pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 3.5rem; padding-top: 1.6rem; border-top: 1px solid var(--rule); font-family: ui-sans-serif, system-ui, sans-serif; }
.pager a { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.9rem 1rem; border: 1px solid var(--rule); border-radius: 8px; text-decoration: none; color: var(--ink); }
.pager a:hover { border-color: var(--accent); }
.pager span { font-size: 0.78rem; color: var(--ink-3); }
.pager b { font-family: Newsreader, Georgia, serif; font-weight: 500; font-size: 1.05rem; line-height: 1.3; }
.pager .next { text-align: right; grid-column: 2; }

/* ---------------------------------------------------------------- the reference preview */
.peek { position: absolute; z-index: 70; width: min(34rem, calc(100vw - 24px)); max-height: 22rem; overflow: auto; background: var(--paper, #fffdf7);
  border: 1px solid rgba(20, 20, 30, 0.14); border-radius: 8px; box-shadow: 0 18px 50px -12px rgba(20, 20, 40, 0.35); padding: 0.9rem 1.1rem;
  font-family: Newsreader, Georgia, serif; font-size: 1rem; line-height: 1.55; color: #1b1b20; }
.dark .peek { background: #26272b; color: #e9eaee; border-color: rgba(255, 255, 255, 0.14); }
.peek .where { font: 0.7rem ui-sans-serif, system-ui, sans-serif; letter-spacing: 0.12em; text-transform: uppercase; color: #8a8a93; margin-bottom: 0.4rem; }
.peek .thm { margin: 0; border: 0; padding: 0; background: transparent; }
.peek p { margin: 0 0 0.6em; }
.peek h1, .peek h2, .peek h3, .peek h4 { font-family: Newsreader, Georgia, serif; font-weight: 500; font-size: 1.15rem; line-height: 1.3; margin: 0 0 0.5rem; }
.peek .secnum { color: #8a8a93; margin-right: 0.5em; font-size: 0.9em; }
.peek .math.display { display: block; overflow-x: auto; }
.peek figure { margin: 0; padding: 0.4rem; background: #fff; border-radius: 4px; }
.peek figure img { width: 100%; }
.peek figcaption { font: 0.78rem ui-sans-serif, system-ui, sans-serif; color: #55555e; }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 1060px) {
  .thesis { grid-template-columns: minmax(0, 46rem); padding-top: 5rem; }
  .rail { position: static; max-height: none; overflow: visible; border-bottom: 1px solid var(--rule); padding-bottom: 0.6rem; }
  .rail .toc { display: none; }
  .rail.open .toc { display: block; }
  .rail .book::after { content: " \25BE"; color: var(--ink-3); font-size: 0.8rem; }
  .rail .pdf { margin: 0.4rem 0 0; }
}
@media (max-width: 640px) {
  .thesis { padding-left: 0; padding-right: 0; gap: 1rem; }
  .rail { padding: 0 16px 0.6rem; }
  .paper { border-radius: 0; border-left: 0; border-right: 0; padding: 2rem 18px 2rem; }
  .body { font-size: 1.06rem; }
  .body figure { margin-left: -6px; margin-right: -6px; padding: 0.7rem; }
  .body .thm { padding: 0.8em 0.85em 0.1em; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}

/* ---------------------------------------------------------------- chapter vignettes (vignettes.js) */
.vignette-wrap { margin: -0.4rem 0 1.4rem; }
.vignette { display: block; width: 100%; max-width: 36rem; height: auto; overflow: visible; color: var(--ink); }
.vignette .v-line { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.vignette .v-line.soft { opacity: 0.35; }
.vignette .v-line.dash { stroke-dasharray: 4 5; }
.vignette .v-line.acc { stroke: var(--accent); opacity: 1; }
.vignette .v-line.warm { stroke: var(--warm); opacity: 1; }
.vignette .v-dot { fill: currentColor; opacity: 0.75; }
.vignette .v-dot.acc { fill: var(--accent); opacity: 1; }
.vignette .v-bar { fill: currentColor; opacity: 0.25; }
.vignette .v-bar.acc { fill: var(--accent); opacity: 0.85; }
.vignette .v-fill.acc { fill: var(--accent); opacity: 0.07; }
.vignette .v-text { fill: currentColor; font: 15px Newsreader, Georgia, serif; }
.vignette .v-text.small { font: 10.5px ui-monospace, Menlo, monospace; fill: var(--ink-3); letter-spacing: 0.03em; }
.vignette .v-text.acc { fill: var(--accent); }
.vignette .v-text.warm { fill: var(--warm); }

/* ---------------------------------------------------------------- "in pictures" cards on the intro and Chapter 1 */
.pictures { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 12px; margin: 0 0 2.2rem; }
.pictures a { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.8rem 1rem; border: 1px solid var(--rule); border-radius: 8px; text-decoration: none;
  color: var(--ink); background: color-mix(in srgb, var(--accent) 4%, transparent); font-family: ui-sans-serif, system-ui, sans-serif; }
.pictures a:hover { border-color: var(--accent); }
.pictures span { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.pictures b { font-family: Newsreader, Georgia, serif; font-weight: 500; font-size: 1.08rem; }

/* a pencil tick beside the sections already read */
.rail .secs a { position: relative; }
.rail .secs a.read::after { content: ""; position: absolute; right: 0.15rem; top: 0.4rem; width: 0.7rem; height: 0.6rem; opacity: 0.7;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 12'%3E%3Cpath d='M1.5 6.5 Q3.5 8 5 10.5 Q8 4.5 12.8 1.2' fill='none' stroke='%23888' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  animation: tick-in 0.4s ease-out both; }
@keyframes tick-in { from { opacity: 0; transform: scale(0.4) rotate(-20deg); } to { opacity: 0.7; transform: none; } }

/* the end of a page: a shock, dying out */
.fin { display: flex; justify-content: center; margin: 3rem 0 -1.5rem; }
.fin svg { width: 180px; height: 28px; overflow: visible; }
.fin path { fill: none; stroke: var(--ink-3); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.fin circle { fill: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .fin path { stroke-dasharray: 320; stroke-dashoffset: 320; }
  .fin circle { opacity: 0; }
  .fin.drawn path { transition: stroke-dashoffset 2.2s cubic-bezier(.3, .1, .3, 1); stroke-dashoffset: 0; }
  .fin.drawn circle { transition: opacity 0.4s 2s; opacity: 1; }
}
