/* irsync book theme: the landing page's look, from the same design tokens
   (theme/tokens.css, generated from site/tokens.json). mdbook's variables
   are mapped onto the --ir-* tokens; the same mapping serves all five
   mdbook themes, because tokens.css switches the --ir-* values by theme
   class (light, rust: light; coal, navy, ayu: dark). Written against
   mdbook v0.5.4. */

/* The landing page's web fonts: Barlow for headings and controls, Inter
   for running text, JetBrains Mono for code. The files are the site's own,
   in its top-level fonts/ directory: this stylesheet is served from
   book/theme/, so ../../fonts/ is that directory. None are copied into the
   book. A bare `mdbook serve` has no fonts/ and falls back to the next
   faces in each stack. */
@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 400;
  font-display: fallback;
  src: url("../../fonts/barlow-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 600;
  font-display: fallback;
  src: url("../../fonts/barlow-latin-600-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Barlow Semi Condensed";
  font-style: normal;
  font-weight: 600;
  font-display: fallback;
  src: url("../../fonts/barlow-semi-condensed-latin-600-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: fallback;
  src: url("../../fonts/inter-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 400;
  font-display: fallback;
  src: url("../../fonts/inter-latin-400-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: fallback;
  src: url("../../fonts/inter-latin-600-normal.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: fallback;
  src: url("../../fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: italic;
  font-weight: 400;
  font-display: fallback;
  src: url("../../fonts/jetbrains-mono-latin-400-italic.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 600;
  font-display: fallback;
  src: url("../../fonts/jetbrains-mono-latin-600-normal.woff2") format("woff2");
}

/* mdbook sets the root font size to 62.5%, so 1rem is 10px here, not 16px
   as on the landing page. Text sizes from the tokens (in rem) are
   multiplied by this to come out the same. */
:root {
  --ir-book-rem: 1.6;
}

html.light,
html.rust,
html.coal,
html.navy,
html.ayu {
  --bg: var(--ir-ground);
  --fg: var(--ir-ink);
  --sidebar-bg: var(--ir-raised);
  --sidebar-fg: var(--ir-ink);
  --sidebar-non-existant: var(--ir-muted);
  --sidebar-active: var(--ir-aqua-ink);
  --sidebar-spacer: var(--ir-rule);
  --sidebar-header-border-color: var(--ir-aqua);
  --scrollbar: var(--ir-muted);
  --icons: var(--ir-muted);
  --icons-hover: var(--ir-ink);
  --links: var(--ir-aqua-ink);
  --inline-code-color: var(--ir-ink);
  --theme-popup-bg: var(--ir-raised);
  --theme-popup-border: var(--ir-rule);
  --theme-hover: var(--ir-aqua-soft);
  --quote-bg: var(--ir-raised);
  --quote-border: var(--ir-rule);
  /* The site's beta note: a signal-yellow bar beside the text. */
  --warning-border: var(--ir-signal);
  --table-border-color: var(--ir-rule);
  --table-header-bg: var(--ir-rule);
  --table-alternate-bg: var(--ir-raised);
  --searchbar-border-color: var(--ir-rule);
  --searchbar-bg: var(--ir-raised);
  --searchbar-fg: var(--ir-ink);
  --searchbar-shadow-color: var(--ir-aqua-ink);
  --searchresults-header-fg: var(--ir-muted);
  --searchresults-border-color: var(--ir-rule);
  --searchresults-li-bg: var(--ir-raised);
  --search-mark-bg: var(--ir-aqua-soft);
  --footnote-highlight: var(--ir-aqua-soft);
  --overlay-bg: color-mix(in srgb, var(--ir-ground) 60%, transparent);
  --blockquote-note-color: var(--ir-aqua-ink);
  --blockquote-tip-color: var(--ir-aqua-ink);
  --blockquote-important-color: var(--ir-muted);
  --blockquote-warning-color: var(--ir-warn-ink);
  --blockquote-caution-color: var(--ir-danger-ink);
  --mono-font: var(--ir-font-mono);
  /* Code blocks at 0.875 of the text size; inline code takes the
     landing page's code size, below. */
  --code-font-size: 0.875em;
}

html.light,
html.rust {
  --color-scheme: light;
}

html.coal,
html.navy,
html.ayu {
  --color-scheme: dark;
}

/* Type: running text in Inter, headings and the book's controls in Barlow,
   code in JetBrains Mono, as on the landing page. */
body {
  font-family: var(--ir-font-body);
  font-size: calc(var(--ir-text-body) * var(--ir-book-rem));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.content main {
  line-height: var(--ir-text-body-line);
}

h1, h2, h3, h4, h5, h6,
.sidebar,
.menu-title,
.menu-bar,
.theme-popup,
#mdbook-searchbar,
#mdbook-searchresults-header,
.nav-chapters,
.mobile-nav-chapters {
  font-family: var(--ir-font-display);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  text-wrap: balance;
}

/* Running text keeps to about 75 characters a line; code blocks and tables
   may use the full width of the page (mdbook's 750px), which holds an
   80-column line of code. No single word alone on a last line. */
.content main > :is(p, ul, ol, dl, blockquote) {
  box-sizing: border-box;
  max-width: 35em;
}

.content main :is(p, li) {
  text-wrap: pretty;
}

::selection {
  background: var(--ir-aqua-ink);
  color: var(--ir-on-aqua);
}

/* Bold is the semibold that ships; 700 would be synthesised. */
strong,
b {
  font-weight: 600;
}

/* Page titles take the landing page's section heading size; its display
   size is for the one headline on the front page. */
h1 {
  font-size: calc(var(--ir-text-heading) * var(--ir-book-rem));
  line-height: var(--ir-text-heading-line);
}

h2 {
  font-size: calc(var(--ir-text-lede) * var(--ir-book-rem));
  line-height: var(--ir-text-lede-line);
}

h3, h4, h5, h6 {
  font-size: calc(var(--ir-text-label) * var(--ir-book-rem));
  line-height: var(--ir-text-label-line);
}

code,
pre,
.hljs,
kbd {
  font-family: var(--ir-font-mono) !important;
}

/* Shape: nearly square corners */
pre,
:not(pre) > code,
.hljs,
kbd,
table,
blockquote,
.theme-popup,
#mdbook-searchbar {
  border-radius: var(--ir-radius-md);
}

pre > code.hljs,
pre > .buttons button {
  border-radius: var(--ir-radius-sm);
}

/* Code blocks and inline code on the raised surface */
pre,
.hljs {
  background: var(--ir-raised);
  color: var(--ir-ink);
}

pre {
  border: 1px solid var(--ir-rule);
}

pre > code.hljs {
  border: 0;
}

:not(pre) > code {
  font-size: var(--ir-text-code);
  background: var(--ir-raised);
  border: 1px solid var(--ir-rule);
  padding: 0 0.25em;
}

.content main pre {
  max-width: 100%;
  overflow-x: auto;
}

/* A table that is wider than the page scrolls inside itself; as a block box
   it can, and its rows and cells keep their table layout in an anonymous
   table. */
.content main table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

/* The copy button's icon. mdbook draws it as an image tinted by per-theme
   CSS filters, which cannot take a token (Light turned it blue on hover).
   Here the same octicons clipboard (MIT licence) is a mask over a token
   colour, so every theme shows muted, and aqua-ink on hover. */
pre > .buttons button.clip-button::before {
  content: "";
  display: inline-block;
  width: 21px;
  height: 20px;
  filter: none;
  background-color: var(--ir-muted);
  -webkit-mask: url('data:image/svg+xml,<svg width="21" height="20" viewBox="0 0 24 25" xmlns="http://www.w3.org/2000/svg" aria-label="Copy to clipboard"><path d="M18 20h2v3c0 1-1 2-2 2H2c-.998 0-2-1-2-2V5c0-.911.755-1.667 1.667-1.667h5A3.323 3.323 0 0110 0a3.323 3.323 0 013.333 3.333h5C19.245 3.333 20 4.09 20 5v8.333h-2V9H2v14h16v-3zM3 7h14c0-.911-.793-1.667-1.75-1.667H13.5c-.957 0-1.75-.755-1.75-1.666C11.75 2.755 10.957 2 10 2s-1.75.755-1.75 1.667c0 .911-.793 1.666-1.75 1.666H4.75C3.793 5.333 3 6.09 3 7z"/><path d="M4 19h6v2H4zM12 11H4v2h8zM4 17h4v-2H4zM15 15v-3l-4.5 4.5L15 21v-3l8.027-.032L23 15z"/></svg>') no-repeat center / contain;
  mask: url('data:image/svg+xml,<svg width="21" height="20" viewBox="0 0 24 25" xmlns="http://www.w3.org/2000/svg" aria-label="Copy to clipboard"><path d="M18 20h2v3c0 1-1 2-2 2H2c-.998 0-2-1-2-2V5c0-.911.755-1.667 1.667-1.667h5A3.323 3.323 0 0110 0a3.323 3.323 0 013.333 3.333h5C19.245 3.333 20 4.09 20 5v8.333h-2V9H2v14h16v-3zM3 7h14c0-.911-.793-1.667-1.75-1.667H13.5c-.957 0-1.75-.755-1.75-1.666C11.75 2.755 10.957 2 10 2s-1.75.755-1.75 1.667c0 .911-.793 1.666-1.75 1.666H4.75C3.793 5.333 3 6.09 3 7z"/><path d="M4 19h6v2H4zM12 11H4v2h8zM4 17h4v-2H4zM15 15v-3l-4.5 4.5L15 21v-3l8.027-.032L23 15z"/></svg>') no-repeat center / contain;
}

pre > .buttons button.clip-button:hover::before {
  filter: none;
  background-color: var(--ir-aqua-ink);
}

/* mdbook colours the .warning icon with --warning-border, the yellow bar,
   which is too faint as an icon on the light ground. */
.warning::before {
  color: var(--ir-warn-ink);
}

/* Focus: the landing page's outline */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--ir-aqua-ink);
  outline-offset: 3px;
  box-shadow: none;
}

#mdbook-searchbar:focus,
#mdbook-searchbar:active {
  outline: 2px solid var(--ir-aqua-ink);
  outline-offset: 0;
  box-shadow: none;
}

/* The "Skip to content" link (theme/a11y.js): off the page until the Tab
   key reaches it. The page it leads to shows no outline of its own. */
.irsync-skip {
  position: absolute;
  top: -10rem;
  left: 1rem;
  z-index: 1000;
  padding: 0.8rem 1.2rem;
  font-family: var(--ir-font-display);
  font-size: calc(var(--ir-text-label) * var(--ir-book-rem));
  font-weight: 600;
  color: var(--ir-on-aqua);
  background: var(--ir-aqua-ink);
  border-radius: var(--ir-radius-sm);
  text-decoration: none;
}

.irsync-skip:focus {
  top: 1rem;
}

.content main:focus {
  outline: none;
}

/* Links keep an underline so colour is not the only cue; thicker on hover,
   as on the landing page. */
.content a:link,
.content a:visited {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.content a:hover {
  text-decoration-thickness: 2px;
}

/* The title in the menu bar links to the landing page (theme/home-link.js)
   and looks like the landing page's "irsync": Barlow semibold in ink. */
.menu-title a,
.menu-title a:visited {
  display: inline-block;
  color: var(--ir-ink);
  font-weight: 600;
  text-decoration: none;
}

/* The mark beside it, as on the landing page: the favicon's two stops and
   their link, drawn as a mask so it takes the aqua of the theme. */
.menu-title a::before {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 0.33em;
  vertical-align: -0.1em;
  background-color: var(--ir-aqua);
  -webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M13.2 18.8 21 11" stroke="black" stroke-width="4" fill="none"/><circle cx="8.5" cy="23.5" r="5.5" fill="none" stroke="black" stroke-width="4"/><circle cx="23.5" cy="8.5" r="7.5"/></svg>') no-repeat center / contain;
  mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M13.2 18.8 21 11" stroke="black" stroke-width="4" fill="none"/><circle cx="8.5" cy="23.5" r="5.5" fill="none" stroke="black" stroke-width="4"/><circle cx="23.5" cy="8.5" r="7.5"/></svg>') no-repeat center / contain;
}

.menu-title a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* The name and where the book was built from (theme/home-link.js) are the
   size of the version picker, like the bar's other controls. */
.menu-title a.menu-home {
  font-size: calc(var(--ir-text-body) * var(--ir-book-rem));
}

/* Where the book was built from, after an aqua dot: in ink at regular
   weight, without the mark; the "@" between the links too. */
.menu-source-parts {
  font-size: calc(var(--ir-text-body) * var(--ir-book-rem));
  color: var(--ir-ink);
  font-weight: 400;
  margin-left: 0.4em;
}

.menu-source-dot {
  color: var(--ir-aqua);
  margin-right: 0.4em;
}

.menu-title a.menu-source,
.menu-title a.menu-source:visited {
  color: var(--ir-ink);
  font-weight: 400;
}

.menu-title a.menu-source::before {
  content: none;
}

/* On a narrow screen only "irsync" fits beside the controls
   (theme/home-link.js puts the rest of the title in this span). */
@media only screen and (max-width: 520px) {
  .menu-title-rest {
    display: none;
  }
}

/* The print and repository links are as tall as the bar, like its buttons;
   on a touch screen they and the chapter links are 44px targets. */
.right-buttons a {
  display: inline-block;
}

@media (pointer: coarse) {
  .right-buttons a {
    min-width: 44px;
    text-align: center;
  }

  .chapter li a {
    padding: 11px 0;
  }

  #irsync-book-list a {
    padding-block: 1rem;
  }
}

/* Headings are links to themselves; they keep the text colour. */
.content a.header:link,
.content a.header:visited {
  color: var(--fg);
  text-decoration: none;
}

/* Highlighting: ink for code, aqua for keywords, muted comments, yellow
   for literals, red for deletions; no further hues. These beat the
   per-theme highlight.js sheets by specificity. Every class one of those
   sheets colours is listed here, including the older names only
   tomorrow-night.css (Coal and Navy) still uses. */
html .hljs-comment,
html .hljs-quote {
  color: var(--ir-muted);
  font-style: italic;
}

html .hljs-keyword,
html .hljs-selector-tag,
html .hljs-built_in,
html .hljs-builtin-name,
html .hljs-name,
html .hljs-tag,
html .hljs-section {
  color: var(--ir-aqua-ink);
}

html .hljs-string,
html .hljs-symbol,
html .hljs-bullet,
html .hljs-regexp,
html .hljs-addition,
html .hljs-number,
html .hljs-literal,
html .hljs-meta,
html .hljs-type,
html .hljs-params,
html .hljs-constant,
html .hljs-hexcolor,
html .hljs-preprocessor,
html .hljs-pragma,
html .hljs-pi,
html .hljs-doctype,
html .hljs-cdata {
  color: var(--ir-warn-ink);
}

html .hljs-variable,
html .hljs-template-variable,
html .hljs-attribute,
html .hljs-attr,
html .hljs-link,
html .hljs-title,
html .hljs-selector-id,
html .hljs-selector-class,
html .hljs-function,
html .hljs-class,
html .hljs-id,
html .hljs-inheritance,
html .hljs-header,
html .hljs-sub,
html .hljs-pseudo,
html .hljs-rule,
html .hljs-value,
html .hljs-decorator {
  color: var(--ir-ink);
}

html .hljs-title,
html .hljs-section,
html .hljs-strong {
  font-weight: 600;
}

html .hljs-addition,
html .hljs-deletion {
  background: transparent;
}

html .hljs-deletion {
  color: var(--ir-danger-ink);
}

/* The version switcher (site/tools/switcher.py writes it into the built
   books, theme/switcher.js opens it). The button reads like the bar's
   other controls; the list looks like the theme list. */
.irsync-book {
  position: relative;
  display: inline-block;
}

#irsync-book-toggle {
  width: auto;
  padding: 0 0.6rem;
  font-family: var(--ir-font-display);
  font-size: calc(var(--ir-text-body) * var(--ir-book-rem));
  color: var(--icons);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

#irsync-book-toggle::after {
  content: "▾";
  margin-left: 0.3em;
}

#irsync-book-toggle:hover,
#irsync-book-toggle[aria-expanded="true"] {
  color: var(--icons-hover);
}

#irsync-book-list {
  position: absolute;
  top: calc(var(--menu-bar-height) - 0.4rem);
  right: 0;
  z-index: 1000;
  margin: 0;
  padding: 0.2rem 0;
  list-style: none;
  text-align: left;
  font-family: var(--ir-font-display);
  font-size: calc(var(--ir-text-body) * var(--ir-book-rem));
  line-height: var(--ir-text-body-line);
  background: var(--theme-popup-bg);
  border: 1px solid var(--theme-popup-border);
  border-radius: var(--ir-radius-md);
}

#irsync-book-list[hidden] {
  display: none;
}

#irsync-book-list a {
  display: flex;
  gap: 0.8rem;
  justify-content: space-between;
  padding: 0.2rem 1.2rem;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
}

#irsync-book-list a:hover,
#irsync-book-list a:focus {
  background: var(--theme-hover);
}

#irsync-book-list a[aria-current="true"] {
  font-weight: 600;
}

#irsync-book-list a[aria-current="true"]::before {
  content: "✓";
  margin-left: -0.9rem;
  width: 0.9rem;
}

.irsync-book-version {
  color: var(--ir-muted);
  font-weight: 400;
}
