/* ==================== */
/* The DRAFT badge on an incomplete page's sidebar entry (a page marked `<!-- todo -->` in
   SUMMARY.md; preprocessor-todo.py and todo.js add the element) */
/* ==================== */

:root {
    --todo-badge-color: #c0392b;
    --todo-badge-bg: rgba(192, 57, 43, 0.10);
}

/* The coal theme's text, slightly whiter than mdBook's: its body text is #98a3ad, 7.1 to 1
   against the background, and its sidebar text #a1adb8, 6.1 to 1. These are 9.8 and 8.1.
   Its two blues are lighter at the same hue, since they were under the 4.5 to 1 that text
   needs: links #2b79a2 at 3.8 are 7.2 here, and the sidebar's active entry #3473ad at 2.8
   is 5.6. */
.coal {
    --fg: #b6bfc7;
    --sidebar-fg: #bcc6cf;
    --links: #5eabd4;
    --sidebar-active: #76a8d6;
    --icons: #7a838b;
    --icons-hover: #f3f5f7;
}

/* The navy theme has the same two blues as coal had, both #2b79a2: links at 3.6 to 1 and the
   sidebar's active entry at 2.8. With coal's lighter ones they are 6.9 and 5.4. */
.navy {
    --links: #5eabd4;
    --sidebar-active: #76a8d6;
    --icons: #82838f;
    --icons-hover: #f7f7f9;
}

/* The menu bar's title and controls take `--icons`, which mdBook sets below what text needs
   against the page in every theme but the light one: 3.5 to 1 in rust, 2.0 in coal, 3.8 in
   navy, 4.0 in ayu. Each is moved, at its own hue, to just over 4.5; coal's and navy's are
   above. Rust's links, the same #2b79a2 on a light page at 3.7, are darker, at 4.8.
   scripts/check-contrast.py holds all of these when the book is built.

   Moving `--icons` brought it nearer to the colour of a control under the pointer, so that
   colour moves further: to black on rust's light page and near white on the dark ones,
   about 3.5 to 1 against the control at rest (it was about 2). This is a preference and not
   something WCAG asks for.

   A link has no underline, so its colour has to set it apart from the text around it. On the
   light and rust pages the text is near black, and a link cannot be both dark enough against
   the page and much lighter than the text. So there the links are more saturated than
   mdBook's: fully on light, #006bd4 (it was #20609f), and about halfway on rust, #12629d. */
.light {
    --links: #006bd4;
}

.rust {
    --links: #12629d;
    --icons: #60616b;
    --icons-hover: #000000;
}

.ayu {
    --icons: #80818d;
    --icons-hover: #f4f5f7;
}

/* The badge sits in the sidebar, which is dark in every theme but the light one. There the
   badge's red is lighter, about 5 to 1 against its own tint on the sidebar (it was about
   2.5); the light theme's is 4.5. */
.rust,
.coal,
.navy,
.ayu {
    --todo-badge-color: #f5aba2;
    --todo-badge-bg: rgba(245, 171, 162, 0.18);
}

.todo-badge::after {
    content: "DRAFT";
    font-size: 0.68em;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--todo-badge-color);
    background: var(--todo-badge-bg);
    padding: 0.1em 0.45em;
    border-radius: 3px;
    margin-left: 0.4em;
    vertical-align: middle;
    position: relative;
    top: -0.05em;
}

/* ==================== */

.chapter-item > div {
    font-weight: bold;
    color: var(--sidebar-fg);
}

/* Center mermaid diagrams */
.mermaid {
    text-align: center;
}

/* ==================== */
/* mdbook-admonish base styling */
/* ==================== */

:is(.admonition) {
  display: flow-root;
  margin: 1.5625em 0;
  padding: 0 1.2rem;
  color: var(--fg);
  page-break-inside: avoid;
  background-color: var(--bg);
  border: 0 solid black;
  border-inline-start-width: 0.4rem;
  border-radius: 0.2rem;
  box-shadow: 0 0.2rem 1rem rgba(0, 0, 0, 0.05), 0 0 0.1rem rgba(0, 0, 0, 0.1);
}

@media print {
  :is(.admonition) {
    box-shadow: none;
  }
}

:is(.admonition) > * {
  box-sizing: border-box;
}

:is(.admonition) :is(.admonition) {
  margin-top: 1em;
  margin-bottom: 1em;
}

html :is(.admonition) > :last-child {
  margin-bottom: 1.2rem;
}

:is(.admonition-title, summary.admonition-title) {
  position: relative;
  min-height: 4rem;
  margin-block: 0;
  margin-inline: -1.6rem -1.2rem;
  padding-block: 0.8rem;
  padding-inline: 4.4rem 1.2rem;
  font-weight: 700;
  background-color: rgba(68, 138, 255, 0.1);
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
  display: flex;
  border-inline-start-width: 0.4rem;
  border-inline-start-style: solid;
  border-color: inherit;
}

:is(.admonition-title, summary.admonition-title) p {
  margin: 0;
}

:is(.admonition-title, summary.admonition-title)::before {
  position: absolute;
  top: 0.625em;
  inset-inline-start: 1.6rem;
  width: 2rem;
  height: 2rem;
  background-color: #448aff;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-size: contain;
  -webkit-mask-size: contain;
  content: "";
}

/* Icon SVG definitions */
:root {
  --md-admonition-icon--admonish-note: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25z'/></svg>");
  --md-admonition-icon--admonish-info: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M13 9h-2V7h2m0 10h-2v-6h2m-1-9A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2z'/></svg>");
  --md-admonition-icon--admonish-tip: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M17.66 11.2c-.23-.3-.51-.56-.77-.82-.67-.6-1.43-1.03-2.07-1.66C13.33 7.26 13 4.85 13.95 3c-.95.23-1.78.75-2.49 1.32-2.59 2.08-3.61 5.75-2.39 8.9.04.1.08.2.08.33 0 .22-.15.42-.35.5-.23.1-.47.04-.66-.12a.58.58 0 0 1-.14-.17c-1.13-1.43-1.31-3.48-.55-5.12C5.78 10 4.87 12.3 5 14.47c.06.5.12 1 .29 1.5.14.6.41 1.2.71 1.73 1.08 1.73 2.95 2.97 4.96 3.22 2.14.27 4.43-.12 6.07-1.6 1.83-1.66 2.47-4.32 1.53-6.6l-.13-.26c-.21-.46-.77-1.26-.77-1.26m-3.16 6.3c-.28.24-.74.5-1.1.6-1.12.4-2.24-.16-2.9-.82 1.19-.28 1.9-1.16 2.11-2.05.17-.8-.15-1.46-.28-2.23-.12-.74-.1-1.37.17-2.06.19.38.39.76.63 1.06.77 1 1.98 1.44 2.24 2.8.04.14.06.28.06.43.03.82-.33 1.72-.93 2.27z'/></svg>");
  --md-admonition-icon--admonish-success: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='m9 20.42-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z'/></svg>");
  --md-admonition-icon--admonish-warning: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M13 14h-2V9h2m0 9h-2v-2h2M1 21h22L12 2 1 21z'/></svg>");
  --md-admonition-icon--admonish-danger: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M11 15H6l7-14v8h5l-7 14v-8z'/></svg>");
  --md-admonition-icon--admonish-bug: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M14 12h-4v-2h4m0 6h-4v-2h4m6-6h-2.81a5.985 5.985 0 0 0-1.82-1.96L17 4.41 15.59 3l-2.17 2.17a6.002 6.002 0 0 0-2.83 0L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8z'/></svg>");
  --md-admonition-icon--admonish-example: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.25-7a.75.75 0 0 1 .75.75c0 .2-.08.39-.21.52L3.12 13H5v1H2v-.92L4 11H2v-1h2.25z'/></svg>");
}

/* Default colors for all types */
:is(.admonition):is(.admonish-note) {
  border-color: #448aff;
}
:is(.admonish-note) > :is(.admonition-title, summary.admonition-title) {
  background-color: rgba(68, 138, 255, 0.1);
}
:is(.admonish-note) > :is(.admonition-title, summary.admonition-title)::before {
  background-color: #448aff;
  mask-image: var(--md-admonition-icon--admonish-note);
  -webkit-mask-image: var(--md-admonition-icon--admonish-note);
}

:is(.admonition):is(.admonish-info, .admonish-todo) {
  border-color: #00b8d4;
}
:is(.admonish-info, .admonish-todo) > :is(.admonition-title, summary.admonition-title) {
  background-color: rgba(0, 184, 212, 0.1);
}
:is(.admonish-info, .admonish-todo) > :is(.admonition-title, summary.admonition-title)::before {
  background-color: #00b8d4;
  mask-image: var(--md-admonition-icon--admonish-info);
  -webkit-mask-image: var(--md-admonition-icon--admonish-info);
}

:is(.admonition):is(.admonish-tip, .admonish-hint, .admonish-important) {
  border-color: #00bfa5;
}
:is(.admonish-tip, .admonish-hint, .admonish-important) > :is(.admonition-title, summary.admonition-title) {
  background-color: rgba(0, 191, 165, 0.1);
}
:is(.admonish-tip, .admonish-hint, .admonish-important) > :is(.admonition-title, summary.admonition-title)::before {
  background-color: #00bfa5;
  mask-image: var(--md-admonition-icon--admonish-tip);
  -webkit-mask-image: var(--md-admonition-icon--admonish-tip);
}

:is(.admonition):is(.admonish-success, .admonish-check, .admonish-done) {
  border-color: #00c853;
}
:is(.admonish-success, .admonish-check, .admonish-done) > :is(.admonition-title, summary.admonition-title) {
  background-color: rgba(0, 200, 83, 0.1);
}
:is(.admonish-success, .admonish-check, .admonish-done) > :is(.admonition-title, summary.admonition-title)::before {
  background-color: #00c853;
  mask-image: var(--md-admonition-icon--admonish-success);
  -webkit-mask-image: var(--md-admonition-icon--admonish-success);
}

:is(.admonition):is(.admonish-warning, .admonish-caution, .admonish-attention) {
  border-color: #ff9100;
}
:is(.admonish-warning, .admonish-caution, .admonish-attention) > :is(.admonition-title, summary.admonition-title) {
  background-color: rgba(255, 145, 0, 0.1);
}
:is(.admonish-warning, .admonish-caution, .admonish-attention) > :is(.admonition-title, summary.admonition-title)::before {
  background-color: #ff9100;
  mask-image: var(--md-admonition-icon--admonish-warning);
  -webkit-mask-image: var(--md-admonition-icon--admonish-warning);
}

:is(.admonition):is(.admonish-danger, .admonish-error) {
  border-color: #ff1744;
}
:is(.admonish-danger, .admonish-error) > :is(.admonition-title, summary.admonition-title) {
  background-color: rgba(255, 23, 68, 0.1);
}
:is(.admonish-danger, .admonish-error) > :is(.admonition-title, summary.admonition-title)::before {
  background-color: #ff1744;
  mask-image: var(--md-admonition-icon--admonish-danger);
  -webkit-mask-image: var(--md-admonition-icon--admonish-danger);
}

:is(.admonition):is(.admonish-bug) {
  border-color: #f50057;
}
:is(.admonish-bug) > :is(.admonition-title, summary.admonition-title) {
  background-color: rgba(245, 0, 87, 0.1);
}
:is(.admonish-bug) > :is(.admonition-title, summary.admonition-title)::before {
  background-color: #f50057;
  mask-image: var(--md-admonition-icon--admonish-bug);
  -webkit-mask-image: var(--md-admonition-icon--admonish-bug);
}

:is(.admonition):is(.admonish-example) {
  border-color: #7c4dff;
}
:is(.admonish-example) > :is(.admonition-title, summary.admonition-title) {
  background-color: rgba(124, 77, 255, 0.1);
}
:is(.admonish-example) > :is(.admonition-title, summary.admonition-title)::before {
  background-color: #7c4dff;
  mask-image: var(--md-admonition-icon--admonish-example);
  -webkit-mask-image: var(--md-admonition-icon--admonish-example);
}

/* ==================== */
/* Rust theme color overrides */
/* Based on: https://github.com/tommilligan/mdbook-admonish/issues/172 */
/* ==================== */

.rust :is(.admonition) {
    background-color: #f5ede4;
    color: #262625;
}

/* Note - muted blue */
.rust :is(.admonition):is(.admonish-note) {
    border-color: #6b8fb3;
    background-color: #e8f0f7;
}
.rust :is(.admonish-note) > :is(.admonition-title, summary.admonition-title) {
    background-color: #d5e4f0;
}
.rust :is(.admonish-note) > :is(.admonition-title, summary.admonition-title)::before {
    background-color: #6b8fb3;
}

/* Info - muted teal */
.rust :is(.admonition):is(.admonish-info, .admonish-todo) {
    border-color: #5a94aa;
    background-color: #e6f3f7;
}
.rust :is(.admonish-info, .admonish-todo) > :is(.admonition-title, summary.admonition-title) {
    background-color: #d0e8f0;
}
.rust :is(.admonish-info, .admonish-todo) > :is(.admonition-title, summary.admonition-title)::before {
    background-color: #5a94aa;
}

/* Tip - muted green */
.rust :is(.admonition):is(.admonish-tip, .admonish-hint, .admonish-important) {
    border-color: #5a9a82;
    background-color: #e8f5f0;
}
.rust :is(.admonish-tip, .admonish-hint, .admonish-important) > :is(.admonition-title, summary.admonition-title) {
    background-color: #d5ebe5;
}
.rust :is(.admonish-tip, .admonish-hint, .admonish-important) > :is(.admonition-title, summary.admonition-title)::before {
    background-color: #5a9a82;
}

/* Success - soft sage */
.rust :is(.admonition):is(.admonish-success, .admonish-check, .admonish-done) {
    border-color: #6a9a6a;
    background-color: #ecf5ec;
}
.rust :is(.admonish-success, .admonish-check, .admonish-done) > :is(.admonition-title, summary.admonition-title) {
    background-color: #dceadc;
}
.rust :is(.admonish-success, .admonish-check, .admonish-done) > :is(.admonition-title, summary.admonition-title)::before {
    background-color: #6a9a6a;
}

/* Warning - rust orange */
.rust :is(.admonition):is(.admonish-warning, .admonish-caution, .admonish-attention) {
    border-color: #c07850;
    background-color: #f7ede5;
}
.rust :is(.admonish-warning, .admonish-caution, .admonish-attention) > :is(.admonition-title, summary.admonition-title) {
    background-color: #f0e0d0;
}
.rust :is(.admonish-warning, .admonish-caution, .admonish-attention) > :is(.admonition-title, summary.admonition-title)::before {
    background-color: #c07850;
}

/* Danger/Error - muted red */
.rust :is(.admonition):is(.admonish-danger, .admonish-error) {
    border-color: #b75555;
    background-color: #f7e8e8;
}
.rust :is(.admonish-danger, .admonish-error) > :is(.admonition-title, summary.admonition-title) {
    background-color: #ecd5d5;
}
.rust :is(.admonish-danger, .admonish-error) > :is(.admonition-title, summary.admonition-title)::before {
    background-color: #b75555;
}

/* Bug - muted mauve */
.rust :is(.admonition):is(.admonish-bug) {
    border-color: #b76a8a;
    background-color: #f7e8f0;
}
.rust :is(.admonish-bug) > :is(.admonition-title, summary.admonition-title) {
    background-color: #ead5e0;
}
.rust :is(.admonish-bug) > :is(.admonition-title, summary.admonition-title)::before {
    background-color: #b76a8a;
}

/* Example - muted purple */
.rust :is(.admonition):is(.admonish-example) {
    border-color: #8a72aa;
    background-color: #f0eaf5;
}
.rust :is(.admonish-example) > :is(.admonition-title, summary.admonition-title) {
    background-color: #e0d5ea;
}
.rust :is(.admonish-example) > :is(.admonition-title, summary.admonition-title)::before {
    background-color: #8a72aa;
}

/* ==================== */
/* Raleway Italic for <em>, matching the ZIPs' slanted type for pool         */
/* identifiers such as *Orchard pool* / *Ironwood pool*.                      */
/* ==================== */

@font-face {
    font-family: ralewayitalic;
    src: url('fonts/Raleway-Italic-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: italic;
}

@font-face {
    font-family: raleway;
    src: url('fonts/Raleway-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
}

em {
    font-family: 'ralewayitalic', Arial, 'Helvetica Neue', Helvetica, sans-serif;
    font-weight: 500;
    font-stretch: 85%;
}

/* Pool identifiers written inside KaTeX as \textit{...}, to match *...* in prose. */
.katex .textit {
    font-family: 'ralewayitalic', Arial, 'Helvetica Neue', Helvetica, sans-serif !important;
    font-style: italic !important;
    font-weight: 500 !important;
    font-size: 0.92em !important;
}

.katex .textsf {
    font-family: 'raleway', Arial, 'Helvetica Neue', Helvetica, sans-serif !important;
    font-style: normal !important;
    font-weight: 500 !important;
    font-size: 0.83em !important;
}

.raleway {
    font-family: 'raleway', Arial, 'Helvetica Neue', Helvetica, sans-serif !important;
    font-style: normal !important;
    font-weight: 500 !important;
}

/* A link whose text is the title of the section or chapter it points to, set as the titles
   are (the repo-links preprocessor marks them). */
.title-ref {
    font-family: 'raleway', 'Open Sans', sans-serif;
    font-weight: 500;
}

/* Headings and the book title in upright Raleway (body text stays the theme font).
   The menu title shares the font but must not share the headings' top margin:
   a margin inside the fixed-height menu bar makes the bar taller than
   --menu-bar-height, so anchor scroll offsets no longer clear it and its
   contents sit at uneven heights. */
.content :is(h1, h2, h3, h4, h5, h6) {
    font-family: 'raleway', 'Open Sans', sans-serif;
    margin-top: 3.5rem;
}

.menu-title {
    font-family: 'raleway', 'Open Sans', sans-serif;
    font-weight: 400;
}

/* A figure's caption, set a little below the figure. */
figure figcaption {
    margin-top: 0.8em;
}

/* A table's column titles: less of mdBook's 20px side padding, and closer lines, so that a
   title of several words takes fewer lines and less room. */
table thead th {
    padding: 3px 14px;
    line-height: 1.3;
    /* The lines between columns carry on through the titles, lighter than the titles'
       background in every theme. */
    border-inline: 1px solid var(--table-title-line);
}

/* A table's lines, around it and between its cells, a little stronger than mdBook's: its
   line colour with a fifth of the text colour mixed in. */
table {
    --table-line: color-mix(in srgb, var(--table-border-color) 80%, var(--fg));
    --table-title-line: color-mix(in srgb, var(--table-header-bg) 60%, white);
}

table td,
table thead tr {
    border-color: var(--table-line);
}

/* The sidebar's chapter list is all titles, so it is set as the titles are. */
.sidebar {
    font-family: 'raleway', 'Open Sans', sans-serif;
    /* Raleway's figures are old-style by default; a list of numbered titles wants lining ones. */
    font-variant-numeric: lining-nums;
}

/* The headings of the page that is open, listed under its entry, at the entries' own weight:
   the rule for `.chapter-item > div` above would make them bold. */
.chapter-item > div.on-this-page {
    font-weight: 320;
}

/* The chapters' titles a very little heavier than the open page's headings under them. Their
   numbers are in <strong>, whose "bolder" comes to the same weight as before. */
li.chapter-item > .chapter-link-wrapper > a {
    font-weight: 450;
}

/* The sidebar's spacing. mdBook separates sibling headings of the open page by a margin below
   each, which leaves a heading's own subsections, and the page's first heading, hard against
   the title above them. Give those the siblings' gap. Then everything is a tenth closer than
   mdBook's own 1.5em lines, 0.6em between chapters, and 0.5em between headings. */
.chapter li.chapter-item {
    line-height: 1.35em;
    margin-block-start: 0.54em;
}

.chapter li.header-item {
    line-height: 1.35em;
    margin-block-end: 0.45em;
}

.chapter li.header-item > ol,
.chapter-item > div.on-this-page {
    margin-block-start: 0.45em;
}

/* A little more room after a list ends than between its items, so that the list is set off
   from the entry that follows it. These margins collapse with the neighbouring ones, so each
   is the whole gap, not an addition to it. */
.chapter li.header-item > ol {
    margin-block-end: 0.7em;
}

.chapter li.chapter-item > ol,
.chapter-item > div.on-this-page {
    margin-block-end: 0.8em;
}

/* Inside headings, italic pool identifiers should take the heading's weight,
   not the lighter weight used for em in body text. */
.content :is(h1, h2, h3, h4, h5, h6) em {
    font-weight: inherit;
}

/* Narrow the fixed previous/next chapter strips (theme default is
   90-150px wide), so they claim less of the side gutters on wide pages
   such as the proof map. 44px keeps a comfortable click target. */
.nav-chapters {
    min-width: 44px;
    max-width: 56px;
}

/* The theme insets .next by --page-padding (clearing the scrollbar) but
   leaves .previous flush against the viewport edge; inset both equally. */
.previous {
    left: var(--page-padding);
}
[dir=rtl] .previous {
    left: unset;
}

/* ==================== */
/* A section without a page of its own renders as a draft in the sidebar, in mdbook's draft
   colour, which is near the background in every theme. Derive it from the sidebar's text
   instead, so that a draft entry stays readable. */
/* ==================== */

:root, .light, .rust, .coal, .navy, .ayu {
    --sidebar-non-existant: color-mix(in srgb, var(--sidebar-fg) 70%, var(--sidebar-bg));
}
