/* The style of the web form of the notes. The design follows the PDF: STIX
   text and mathematics, a narrow column, a pastel box for every statement.
   tools/web.py copies this file to site/. */
@font-face { font-family: "STIX Two Text"; src: local("STIX Two Text"), url("fonts/STIXTwoText-Regular.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "STIX Two Text"; font-style: italic; src: local("STIX Two Text Italic"), url("fonts/STIXTwoText-Italic.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "STIX Two Text"; font-weight: bold; src: local("STIX Two Text Bold"), url("fonts/STIXTwoText-Bold.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "STIX Two Text"; font-weight: bold; font-style: italic; src: local("STIX Two Text Bold Italic"), url("fonts/STIXTwoText-BoldItalic.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "STIX Two Math"; src: local("STIX Two Math"), url("fonts/STIXTwoMath-Regular.woff2") format("woff2"); font-display: swap; }

:root {
  --bg: #ffffff; --fg: #1a1a1a; --muted: #5e5e5e; --rule: #d9d9d9; --link: #0000dc;
  --pop: #fbfaf4; --pop-rule: #9aa6c8;
  --definition: #eaf2fb; --theorem: #fdecec; --proposition: #fff3e3; --lemma: #eef7e9;
  --corollary: #f4eefb; --example: #fbf8e6; --other: #f3f3f3;
  /* the stronger pastels of the main page, one for each of the six colours */
  --a-blue: #8fb4e3; --a-rose: #e9a3a3; --a-peach: #efba7c; --a-green: #9fcb8a; --a-lavender: #b9a2de; --a-yellow: #d8c766;
  --paper: #fffdf8; --card-shadow: 0 1px 2px rgba(60, 50, 90, 0.06), 0 8px 28px rgba(60, 50, 90, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a; --fg: #e4e4e4; --muted: #a3a3a3; --rule: #3a3c42; --link: #8fa8ff;
    --pop: #22242a; --pop-rule: #55608a;
    --definition: #1c2733; --theorem: #33201f; --proposition: #33291a; --lemma: #1f2c1c;
    --corollary: #2a2233; --example: #2e2b18; --other: #25262a;
    --paper: #1b1c20; --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
  }
}

/* The type grows with the screen. A note uses the width of the page. */
html { font-size: clamp(18px, 12px + 0.6vw, 24px); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 1rem; }
body {
  margin: 0 auto; padding: 0 clamp(16px, 4vw, 3rem) 5rem; max-width: 68rem;
  background: var(--paper); color: var(--fg);
  font-family: "STIX Two Text", "STIX Two Math", Georgia, "Times New Roman", serif;
  line-height: 1.55; overflow-wrap: break-word;
}
math { font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", math; font-size: 1em; }
math[display="block"] { overflow-x: auto; overflow-y: hidden; padding: 0.15em 0; }
mrow.ol { border-top: 0.045em solid currentColor; padding-top: 0.09em; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0.8em 0; }
h2 { font-size: 1.45rem; line-height: 1.2; margin: 3.2em 0 1em; padding-bottom: 0.35em; border-bottom: 1px solid var(--rule); }
h3 { font-size: 1.1rem; margin: 2.4em 0 0.8em; }
ol, ul { padding-left: 2em; }
li { margin: 0.3em 0; }
/* numbered lists are numbered (1), (2), as in the PDF */
ol { list-style: none; counter-reset: item; }
ol > li { counter-increment: item; position: relative; }
ol > li::before { content: "(" counter(item) ")"; position: absolute; left: -2em; width: 1.7em; text-align: right; font-style: normal; color: var(--muted); }

/* Nothing makes the page wider than the screen. The band of colour behind a
   title is wider than the page and is cut at the edge of the screen. */
html { overflow-x: clip; }
body { overflow-x: clip; }

/* the head of a note: a soft band of colour, the place of the note, its title */
.note-cover { position: relative; padding: 2.2rem 0 2.4rem; margin-bottom: 1rem; }
.note-cover::before { content: ""; position: absolute; z-index: -1; top: 0; bottom: 0; left: -100vw; right: -100vw; background:
  radial-gradient(48rem 18rem at 30% 0%, var(--definition), transparent 70%),
  radial-gradient(40rem 16rem at 75% 10%, var(--corollary), transparent 70%),
  radial-gradient(40rem 14rem at 55% 100%, var(--theorem), transparent 72%); }
.note-cover .series { display: inline-block; font-variant-caps: all-small-caps; letter-spacing: 0.2em; font-size: 0.85rem; color: var(--fg); background: var(--bg); border: 1px solid var(--rule); border-radius: 99px; padding: 0.1em 1em 0.2em; }
.note-cover .series, .book .series { margin-right: 0.5em; text-decoration: none; }
.book .series:hover { border-color: var(--fg); }
.note-cover .series:hover { text-decoration: none; border-color: var(--fg); }
.note-cover .where { margin: 1.5rem 0 0; color: var(--muted); font-size: 0.9rem; }
.note-cover .where b { color: var(--fg); }
h1.title { font-size: clamp(1.9rem, 1.2rem + 2vw, 3rem); line-height: 1.1; letter-spacing: -0.01em; margin: 0.5rem 0 0; text-wrap: balance; }

/* how far the reader is in a note: a thin line at the top of the screen */
.read { position: fixed; z-index: 20; top: 0; left: 0; right: 0; height: 4px; background: var(--rule); pointer-events: none; }
.read i { display: block; height: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, var(--a-blue), var(--a-lavender), var(--a-rose)); }

/* the bar under the head of a note */
.bar { display: flex; justify-content: flex-end; margin: 0 0 1rem; font-size: 0.85rem; }
.bar button { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--rule); border-radius: 99px; padding: 0.25em 1em 0.3em; cursor: pointer; }
.bar button:hover { border-color: var(--fg); }

/* statements. One form for all, a card with a bar of colour at its left, a
   label of the same colour, and a tint of that colour that fades from the
   top to white. The colour names the kind. A theorem has a wider bar, a
   remark has a dashed frame and no shadow. */
.k-definition { --acc: var(--a-blue); --tint: var(--definition); }
.k-theorem { --acc: var(--a-rose); --tint: var(--theorem); }
.k-proposition { --acc: var(--a-peach); --tint: var(--proposition); }
.k-lemma { --acc: var(--a-green); --tint: var(--lemma); }
.k-corollary { --acc: var(--a-lavender); --tint: var(--corollary); }
.k-example { --acc: var(--a-yellow); --tint: var(--example); }
.k-remark, .k-notation, .k-problem, .k-question, .k-conjecture { --acc: #b9b9b9; --tint: var(--other); }
.stmt { position: relative; background: linear-gradient(180deg, var(--tint), var(--bg) 75%); border-radius: 14px; padding: 0.95rem 1.3rem 1.05rem 1.5rem; margin: 1.5em 0; box-shadow: var(--card-shadow); }
.stmt::before { content: ""; position: absolute; left: 0; top: 0.9rem; bottom: 0.9rem; width: 5px; border-radius: 0 5px 5px 0; background: var(--acc); }
.stmt.k-theorem::before { width: 7px; }
.stmt.k-remark, .stmt.k-notation, .stmt.k-problem, .stmt.k-question, .stmt.k-conjecture { box-shadow: none; border: 1px dashed var(--acc); }
.stmt-head { display: block; margin-bottom: 0.5em; font-size: 0.88em; color: var(--muted); }
.stmt-head strong { display: inline-block; color: var(--fg); background: var(--tint); border: 1px solid var(--acc); border-radius: 99px; padding: 0.05em 0.85em 0.12em; margin-right: 0.4em; }
.stmt-body.italic { font-style: italic; }
.stmt-body.italic em { font-style: normal; }
.stmt-body > :first-child { margin-top: 0; }
.stmt-body > :last-child { margin-bottom: 0; }
.stmt:target, .ref:target, .eq:target { outline: 2px solid var(--pop-rule); outline-offset: 3px; }

/* the label of a statement and a heading link to themselves */
a.self { color: inherit; text-decoration: none; }
a.self:hover { text-decoration: underline; text-decoration-color: var(--muted); text-underline-offset: 0.2em; }
.stmt, .eq, figure, h2, h3, .anchor { scroll-margin-top: 1rem; }

/* numbered equations */
.eq { display: flex; align-items: center; gap: 0.6em; margin: 0.9em 0; font-style: normal; border-radius: 6px; }
.eq > math { flex: 1; min-width: 0; }
.eq > p { margin: 0; }
.eqno { color: var(--muted); }

/* the idea of an argument */
.idea { margin: 1.4em 0; padding: 0.7rem 1.1rem 0.75rem; border-radius: 12px; background: var(--example); }
.idea > em:first-child { font-style: normal; font-variant-caps: all-small-caps; letter-spacing: 0.12em; font-weight: bold; margin-right: 0.3em; }

/* proofs and their steps */
.proof { margin: 1.2em 0 2em 0.3rem; padding-left: 1.15rem; border-left: 2px solid var(--rule); }
.proof-head { font-variant-caps: all-small-caps; letter-spacing: 0.1em; margin-right: 0.3em; color: var(--muted); }
.proof-head em { font-style: normal; }
.proof::after { content: "\25A1"; display: block; text-align: right; color: var(--muted); margin-top: -0.2em; }
/* a step is its claim in a box, with its number small at the left. A click
   on the box opens the argument. */
details.step { margin: 0.45em 0; }
details.step > summary { position: relative; cursor: pointer; list-style: none; padding: 0.4em 0.9em 0.45em 2.5em; border-radius: 10px; background: var(--bg); border: 1px solid var(--rule); transition: border-color 0.15s, box-shadow 0.15s; }
details.step > summary::-webkit-details-marker { display: none; }
details.step > summary:hover { border-color: var(--pop-rule); box-shadow: var(--card-shadow); }
details.step[open] > summary { border-color: var(--pop-rule); }
.step-name { position: absolute; left: 0; top: 0.4em; width: 2.1em; text-align: right; font-size: 0.8em; line-height: 1.94; color: var(--muted); font-variant-numeric: tabular-nums; }
details.step[open] .step-name { color: var(--fg); }
.step-body { margin: 0.4em 0 0.9em 2.5em; padding: 0.7em 1em; background: var(--pop); border: 1px solid var(--pop-rule); border-radius: 12px; font-size: 0.94em; }
.step-body > :first-child { margin-top: 0; }
.step-body > :last-child { margin-bottom: 0; }

/* pop-ups: a gray keyword, and its explanation, which opens under the paragraph */
a.hk { color: var(--muted); text-decoration: underline dotted; text-underline-offset: 0.2em; cursor: pointer; border-radius: 4px; }
a.hk:hover { color: var(--fg); text-decoration-style: solid; }
a.hk.on { color: var(--fg); background: var(--example); text-decoration: none; box-shadow: 0 0 0 0.15em var(--example); }
.hv { margin: 0.6em 0 1em; padding: 0.7em 1em; background: var(--pop); border: 1px solid var(--pop-rule); border-radius: 12px; font-size: 0.94em; font-style: normal; font-weight: normal; text-align: left; }
.hv > :first-child { margin-top: 0; }
.hv > :last-child { margin-bottom: 0; }
/* without scripts the explanations are a list at the end of the page */
.hovers[hidden] { display: none; }
.hovers:has(:target) { display: block; }

/* the preview of a statement, an equation or a reference under the mouse */
.peek { position: absolute; z-index: 10; max-width: min(36rem, calc(100vw - 32px)); background: var(--paper); border: 1px solid var(--rule); border-radius: 16px; box-shadow: 0 10px 40px rgba(60, 50, 90, 0.25); padding: 0.5em; font-size: 0.88em; }
.peek .stmt, .peek .eq, .peek .ref { margin: 0; }
.peek .eq, .peek .ref { padding: 0.4em 0.8em; }
.peek .ref { text-indent: 0; }
.peek .ref-label { min-width: 0; margin-right: 0.3em; }

/* tables */
table { border-collapse: collapse; width: 100%; font-size: 0.88em; margin: 1em 0; display: block; overflow-x: auto; }
td { padding: 0.4em 0.6em; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tr:first-child td { border-bottom: 2px solid var(--acc, var(--fg)); }
tr:last-child td { border-bottom: 0; }

/* figures */
figure { margin: 1.6em 0; text-align: center; }
figure > svg, figure img { max-width: 100%; height: auto; margin: 0 auto; background: var(--bg); border-radius: 14px; box-shadow: var(--card-shadow); padding: 0.8rem; box-sizing: border-box; }
@media (prefers-color-scheme: dark) { figure > svg { background: #f4f4f4; } }
figcaption { font-size: 0.88em; color: var(--muted); margin-top: 0.8em; text-align: left; }

/* references */
.ref { font-size: 0.9em; margin: 0.5em 0; padding-left: 4.6em; text-indent: -4.6em; }
.ref-label { display: inline-block; min-width: 4.2em; text-indent: 0; font-weight: bold; }

/* the way to the notes before and after */
.turn { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 4rem; }
.turn a { display: block; background: var(--bg); border-radius: 14px; box-shadow: var(--card-shadow); padding: 0.9rem 1.2rem 1rem; color: var(--fg); transition: transform 0.15s; }
.turn a:hover { text-decoration: none; transform: translateY(-2px); }
.turn a.next { text-align: right; grid-column: 2; }
.turn small { display: block; color: var(--muted); font-variant-caps: all-small-caps; letter-spacing: 0.12em; }

/* the main page: a cover with a faint drawing, and the themes as cards in pastel
   colours, one under the other */
body.book { max-width: 96rem; margin: 0 auto; padding: 0 clamp(16px, 4vw, 4rem) 5rem; background: var(--paper); }
.book .cover { position: relative; padding: 4.5rem 0 3.5rem; }
.book .cover::before { content: ""; position: absolute; z-index: -1; inset: 0 -100vw; background:
  radial-gradient(60rem 30rem at 18% 0%, var(--definition), transparent 70%),
  radial-gradient(50rem 28rem at 85% 20%, var(--corollary), transparent 70%),
  radial-gradient(50rem 26rem at 55% 100%, var(--theorem), transparent 70%); }
.book .series { display: inline-block; font-variant-caps: all-small-caps; letter-spacing: 0.22em; font-size: 0.95rem; color: var(--fg); background: var(--bg); border: 1px solid var(--rule); border-radius: 99px; padding: 0.15em 1.1em 0.25em; }
.book h1 { font-size: clamp(2.1rem, 1.1rem + 3vw, 3.9rem); line-height: 1.08; letter-spacing: -0.01em; margin: 1.3rem 0 0; text-wrap: balance; }
.book h1 em { font-style: italic; font-weight: normal; }
.book .lede { font-size: 1.15rem; color: var(--muted); margin: 1.4rem 0 0; max-width: 30em; }
.book .actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 2rem; }
.book .btn { display: inline-block; padding: 0.55em 1.4em 0.6em; border-radius: 99px; border: 1px solid var(--fg); color: var(--fg); background: transparent; transition: transform 0.15s, box-shadow 0.15s; }
.book .btn.go { background: var(--fg); color: var(--bg); }
.book .btn:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--card-shadow); }
/* the drawing lies behind the title, faint, at the right */
.book .disc { position: absolute; z-index: -1; right: -4rem; top: 50%; width: min(34rem, 70vw); transform: translateY(-50%); opacity: 0.32; pointer-events: none; }
.book .disc svg { display: block; width: 100%; height: auto; }
.book .disc path { stroke: var(--paper); stroke-width: 0.006; stroke-linejoin: round; }
.book .disc .t0 { fill: var(--a-blue); } .book .disc .t1 { fill: var(--a-rose); } .book .disc .t2 { fill: var(--a-peach); }
.book .disc .t3 { fill: var(--a-green); } .book .disc .t4 { fill: var(--a-lavender); } .book .disc .t5 { fill: var(--a-yellow); }
.book .disc circle { fill: none; stroke: none; }
@media (max-width: 820px) { .book .disc { opacity: 0.2; right: -30vw; } }
.book .cover > :not(.disc) { position: relative; }
body.book { overflow-x: hidden; }

.book .contents-head { text-align: center; font-size: 1.9rem; margin: 2rem 0 2.2rem; border: 0; }
.book .themes { max-width: 54rem; margin: 0 auto; }
.book .theme { break-inside: avoid; margin: 0 0 1.6rem; border-radius: 18px; padding: 1.3rem 1.4rem 1.2rem; background: var(--tint); box-shadow: var(--card-shadow); transition: transform 0.2s; }
.book .theme:hover { transform: translateY(-3px); }
.book .theme.c0 { --tint: var(--definition); --acc: var(--a-blue); } .book .theme.c1 { --tint: var(--theorem); --acc: var(--a-rose); }
.book .theme.c2 { --tint: var(--proposition); --acc: var(--a-peach); } .book .theme.c3 { --tint: var(--lemma); --acc: var(--a-green); }
.book .theme.c4 { --tint: var(--corollary); --acc: var(--a-lavender); } .book .theme.c5 { --tint: var(--example); --acc: var(--a-yellow); }
.book .theme-head { display: grid; grid-template-columns: auto 1fr; column-gap: 0.9rem; align-items: center; margin-bottom: 0.8rem; }
.book .roman { min-width: 2.9rem; height: 2.9rem; padding: 0 0.5rem; box-sizing: border-box; border-radius: 99px; background: var(--acc); color: #fff; display: grid; place-items: center; font-size: 1.15rem; font-style: italic; font-weight: bold; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15); }
.book .theme h2 { font-size: 1.2rem; line-height: 1.25; margin: 0; padding: 0; border: 0; }
.book ol.toc { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.book ol.toc > li { display: grid; grid-template-columns: 2.4rem 1fr; column-gap: 0.3rem; align-items: baseline; margin: 0 -0.6rem; padding: 0.33em 0.6rem; border-radius: 8px; font-size: 0.9rem; line-height: 1.35; counter-increment: none; position: static; }
.book ol.toc > li::before { content: none; }
.book .no { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.85em; }
.book li.written .name a { color: var(--fg); }
.book li.written:hover { background: var(--bg); }
.book li.written .name a:hover { text-decoration: none; }
.book li.written .no { color: var(--fg); }
.book li.planned .name { color: var(--muted); }
.book .colophon { text-align: center; color: var(--muted); font-size: 0.8rem; font-style: italic; margin-top: 3rem; }

/* Phones and tablets. The page never scrolls sideways. A formula, a table
   or a line that is wider than the screen scrolls inside its own box. The
   boxes lose most of their padding, so that the text keeps the width. */
@media (max-width: 900px) {
  p, li, summary, figcaption, .stmt-body, .hv, .step-body, .proof { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
  ol > li { overflow: visible; }
}
@media (max-width: 640px) {
  html { font-size: 17px; }
  body { padding-left: 14px; padding-right: 14px; }
  .note-cover { padding: 1.3rem 0 1.5rem; }
  .note-cover .where { margin-top: 1rem; }
  h1.title { font-size: 1.7rem; }
  h2 { font-size: 1.25rem; margin: 2.4em 0 0.8em; }
  .stmt { padding: 0.75rem 0.8rem 0.85rem 1rem; margin: 1.1em 0; border-radius: 10px; }
  .stmt::before { width: 4px; top: 0.7rem; bottom: 0.7rem; }
  .stmt-head { font-size: 0.85em; }
  .proof { margin-left: 0; padding-left: 0.7rem; }
  details.step > summary { padding: 0.35em 0.6em 0.4em 1.9em; }
  .step-name { width: 1.6em; }
  .step-body, .hv { margin-left: 0; padding: 0.55em 0.7em; }
  ol, ul { padding-left: 1.7em; }
  ol > li::before { left: -1.9em; }
  .eq { gap: 0.3em; }
  .turn { grid-template-columns: 1fr; }
  .turn a.next { grid-column: 1; }
  .book .cover { padding: 2.5rem 0 2rem; }
  .book .theme { padding: 1rem 1rem 0.9rem; border-radius: 14px; }
  .book ol.toc > li { grid-template-columns: 2.1rem 1fr; }
}

@media print { .bar, .turn, .read { display: none; } details.step > .step-body { display: block; } }
