/*
  Leangineering: a maths paper.
  Scales (use only these):
    type:    14 16 18 20 24 30 36
    space:   4 8 12 16 24 32 48 64 96
  Two families: CMU Serif (everything) and JetBrains Mono (code).
  Black on white. The one colour is the infoview's tick.
*/

:root {
  --paper: #ffffff;
  --ink: #111111;
  --ink-2: #4d4d4d;   /* secondary text, 8.5:1 */
  --ink-3: #6b6b6b;   /* tertiary text, 5.3:1 */
  --rule: #d9d9d9;    /* hairlines, decorative */
  --rule-strong: #111111;
  --panel: #f6f6f6;
  --tick: #1a7f37;

  --serif: "CMU Serif", "Latin Modern Roman", "Computer Modern", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --measure: 36rem;
  --page: 48rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111111;
    --ink: #ededed;
    --ink-2: #b3b3b3;
    --ink-3: #969696;
    --rule: #333333;
    --rule-strong: #ededed;
    --panel: #1b1b1b;
    --tick: #4ac26b;
  }
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: var(--page);
  padding: 0 24px;
  font: 500 18px/1.6 var(--serif);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

p, li { text-wrap: pretty; }
p { margin: 0 0 16px; }

a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

code {
  font: 400 14px var(--mono);
  padding: 1px 3px;
  background: var(--panel);
}

h1, h2, h3 { font-weight: 700; line-height: 1.25; margin: 0; }

/* ── Header and footer ─────────────────────────────── */

.site-header nav {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 24px 0 16px;
  border-bottom: 1px solid var(--rule-strong);
}
.brand {
  font-size: 16px;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: lowercase;
}
.nav-links a { margin-left: 24px; font-size: 16px; font-style: italic; text-decoration: none; }
.nav-links a:hover { text-decoration: underline; }

main { padding: 64px 0 64px; }

.site-footer {
  padding: 24px 0 48px;
  border-top: 1px solid var(--rule);
  font-size: 14px;
  color: var(--ink-2);
}

/* ── Title block and abstract ──────────────────────── */

.title-block { text-align: center; margin-bottom: 48px; }
.title-block h1 { font-size: 36px; letter-spacing: -0.01em; margin-bottom: 16px; }
.author { font-size: 20px; margin: 0 0 4px; }
.author a { text-decoration: none; }
.author a:hover { text-decoration: underline; }
.venue { font-size: 16px; font-style: italic; color: var(--ink-2); margin: 0; }
.error-line { font: 400 14px var(--mono); color: var(--ink-2); margin-bottom: 24px; }

.abstract {
  max-width: 32rem;
  margin: 0 auto 64px;
  font-size: 16px;
  line-height: 1.6;
}
.abstract-title {
  text-align: center;
  font-size: 16px;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  margin-bottom: 8px;
}
.abstract p { text-align: justify; hyphens: auto; }

/* ── Sections ──────────────────────────────────────── */

section { margin-bottom: 48px; }
section > p, .proof > p, .theorem > p { max-width: var(--measure); }

h2 { font-size: 24px; margin: 0 0 16px; display: flex; align-items: baseline; gap: 16px; }
h2 a { text-decoration: none; }
h2 a:hover { text-decoration: underline; }
.sec-num { font-weight: 700; min-width: 32px; }
.count { font-size: 16px; font-weight: 500; font-style: italic; color: var(--ink-3); }

.button {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--rule-strong);
  font-size: 16px;
  text-decoration: none;
}
.button::after { content: " →"; }
.button:hover { background: var(--ink); color: var(--paper); }

.note { color: var(--ink-2); font-style: italic; }
.sorry { font: 700 14px var(--mono); font-style: normal; color: var(--ink); margin-right: 4px; }

/* ── Theorem, proof, figure ────────────────────────── */

.theorem { margin: 24px 0 16px; }
.thm-label { font-weight: 700; }
.proof { margin-bottom: 24px; }
.qed { text-align: right; max-width: none !important; margin: -8px 0 0; font-size: 20px; }

figure { margin: 32px 0 24px; }
figcaption { font-size: 16px; color: var(--ink-2); margin-top: 12px; text-align: center; }
figcaption p { margin: 0; }
.fig-label { font-weight: 700; color: var(--ink); }

.panes { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; align-items: start; }
.panes > * { min-width: 0; }
.pane { border: 1px solid var(--rule-strong); background: var(--paper); }
.pane-bar {
  padding: 4px 12px;
  border-bottom: 1px solid var(--rule);
  font: 400 12px var(--mono);
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.pane-code {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font: 400 14px/1.6 var(--mono);
}
.tk-kw { font-weight: 700; }
.tk-str { color: var(--ink-2); }
.tk-cm { color: var(--ink-3); font-style: italic; }
.caret {
  display: inline-block;
  width: 8px;
  height: 16px;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--ink);
  animation: blink 1.1s steps(1) infinite;
}
.pane-body { padding: 16px; font: 400 14px/1.6 var(--mono); }
.pane-body p { margin: 0 0 8px; max-width: none; }
.iv-loc { color: var(--ink-3); }
.iv-done { animation: settle 1.2s ease-out both 0.4s; }
.iv-win { animation: settle 1.2s ease-out both 1s; }
.iv-tick { color: var(--tick); font-weight: 700; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes settle { from { opacity: 0; } to { opacity: 1; } }

/* ── Search ────────────────────────────────────────── */

.search-box { position: sticky; top: 0; z-index: 1; background: var(--paper); padding: 16px 0; margin-bottom: 32px; }
.search-field {
  display: flex;
  align-items: baseline;
  gap: 12px;
  border-bottom: 1px solid var(--rule-strong);
  padding-bottom: 8px;
}
.search-cmd { font: 700 16px var(--mono); }
.search {
  flex: 1;
  border: 0;
  padding: 4px 0;
  background: transparent;
  color: var(--ink);
  font: 400 16px var(--mono);
}
.search::placeholder { color: var(--ink-3); }
.search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search:focus { outline: none; }
.search-field:focus-within { border-bottom-width: 2px; padding-bottom: 7px; }
.result-summary { font: 400 16px var(--mono); color: var(--ink-2); margin: 0 0 32px; }
.turnstile { color: var(--ink); font-weight: 700; }

/* ── Table of contents ─────────────────────────────── */

.toc { margin-bottom: 64px; }
.toc-title {
  font-size: 16px;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  margin-bottom: 16px;
}
.toc-list { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 48px; }
.toc-list li { break-inside: avoid; font-size: 16px; }
.toc-list a { display: flex; align-items: last baseline; gap: 8px; padding: 4px 0; text-decoration: none; }
.toc-list a:hover .toc-label { text-decoration: underline; }
.toc-num { min-width: 24px; font-weight: 700; align-self: flex-start; }
.toc-dots { flex: 1; border-bottom: 1px dotted var(--ink-3); transform: translateY(-4px); min-width: 16px; }
.toc-count { font-style: italic; color: var(--ink-2); }

/* ── Directory entries ─────────────────────────────── */

.category { margin-bottom: 64px; }
.group-label {
  font-size: 16px;
  font-weight: 700;
  font-style: italic;
  margin: 24px 0 4px;
}
.entries { list-style: none; padding: 0; margin: 0; }
.entry { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.entry:last-child { border-bottom: 0; }
.entry-name { font-weight: 700; margin-right: 8px; }
.entry-desc { color: var(--ink); }
.entry-repo { display: block; margin-top: 4px; font: 400 12px var(--mono); color: var(--ink-3); }

/* ── Category page ─────────────────────────────────── */

.crumb { font-size: 16px; font-style: italic; color: var(--ink-2); margin-bottom: 24px; }
.category-title { font-size: 36px; display: flex; gap: 16px; align-items: baseline; margin-bottom: 8px; }
.category-title + .venue { margin-bottom: 32px; }
.pager {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 16px;
  font-style: italic;
}

/* ── Small screens: big things shrink faster ───────── */

@media (max-width: 40rem) {
  body { padding: 0 16px; font-size: 17px; }
  main { padding: 48px 0; }
  .title-block h1, .category-title { font-size: 30px; }
  h2 { font-size: 20px; gap: 12px; }
  .panes { grid-template-columns: 1fr; }
  .toc-list { columns: 1; }
  .abstract p { text-align: left; }
  .nav-links a { margin-left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .caret, .iv-done, .iv-win { animation: none; }
}
