@charset "UTF-8";

/* Import ET Book styles
   adapted from https://github.com/edwardtufte/et-book/blob/gh-pages/et-book.css */

@font-face {
    font-family: "et-book";
    src: url("et-book-vendored/et-book/et-book-roman-line-figures/et-book-roman-line-figures.eot");
    src: url("et-book-vendored/et-book/et-book-roman-line-figures/et-book-roman-line-figures.eot?#iefix") format("embedded-opentype"), url("et-book-vendored/et-book/et-book-roman-line-figures/et-book-roman-line-figures.ttf") format("truetype"), url("et-book-vendored/et-book/et-book-roman-line-figures/et-book-roman-line-figures.svg#etbookromanosf") format("svg");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "et-book";
    src: url("et-book-vendored/et-book/et-book-display-italic-old-style-figures/et-book-display-italic-old-style-figures.eot");
    src: url("et-book-vendored/et-book/et-book-display-italic-old-style-figures/et-book-display-italic-old-style-figures.eot?#iefix") format("embedded-opentype"), url("et-book-vendored/et-book/et-book-display-italic-old-style-figures/et-book-display-italic-old-style-figures.ttf") format("truetype"), url("et-book-vendored/et-book/et-book-display-italic-old-style-figures/et-book-display-italic-old-style-figures.svg#etbookromanosf") format("svg");
    font-weight: normal;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: "et-book";
    src: url("et-book-vendored/et-book/et-book-bold-line-figures/et-book-bold-line-figures.eot");
    src: url("et-book-vendored/et-book/et-book-bold-line-figures/et-book-bold-line-figures.eot?#iefix") format("embedded-opentype"), url("et-book-vendored/et-book/et-book-bold-line-figures/et-book-bold-line-figures.ttf") format("truetype"), url("et-book-vendored/et-book/et-book-bold-line-figures/et-book-bold-line-figures.svg#etbookromanosf") format("svg");
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "et-book-roman-old-style";
    src: url("et-book-vendored/et-book/et-book-roman-old-style-figures/et-book-roman-old-style-figures.eot");
    src: url("et-book-vendored/et-book/et-book-roman-old-style-figures/et-book-roman-old-style-figures.eot?#iefix") format("embedded-opentype"), url("et-book-vendored/et-book/et-book-roman-old-style-figures/et-book-roman-old-style-figures.woff") format("woff"), url("et-book-vendored/et-book/et-book-roman-old-style-figures/et-book-roman-old-style-figures.ttf") format("truetype"), url("et-book-vendored/et-book/et-book-roman-old-style-figures/et-book-roman-old-style-figures.svg#etbookromanosf") format("svg");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Tufte CSS styles */
html {
    font-size: 12px;
}

body {
    width: 87.5%;
    margin-left: auto;
    margin-right: auto;
    font-family: et-book, Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif;
    background-color: #fffff8;
    color: #111;
    max-width: 1400px;
    counter-reset: sidenote-counter;
}

/* Adds dark mode */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #151515;
        color: #ddd;
    }
}

/* 1. Fluid Responsive Headings h1-h7 */
h1, h2, h3, h4, h5, h6, h7 {
    font-family: et-book, Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-weight: 400;
    line-height: 1.2;
    margin-top: 2.8rem;
    margin-bottom: 1.2rem;
}
h1 {
    font-size: clamp(2.4rem, 1.8rem + 2.5vw, 3.8rem);
    border-bottom: 2px solid rgba(0,0,0,0.1);
    padding-bottom: 0.3rem;
}
h2 {
    font-size: clamp(2.1rem, 1.6rem + 2vw, 3.0rem);
    font-style: italic;
    color: #444;
}
h3 {
    font-size: clamp(1.9rem, 1.5rem + 1.8vw, 2.6rem);
    font-style: italic;
    color: #555;
}
h4 {
    font-size: clamp(1.6rem, 1.3rem + 1.5vw, 2.2rem);
    font-weight: 600;
}
h5 {
    font-size: clamp(1.4rem, 1.2rem + 1.2vw, 1.9rem);
    font-weight: 600;
}
h6 {
    font-size: clamp(1.2rem, 1rem + 1vw, 1.6rem);
    font-weight: 500;
    letter-spacing: 0.03em;
    color: #666;
}
h7, .h7 {
    display: block;
    font-size: clamp(1rem, 0.9rem + 0.8vw, 1.3rem);
    font-style: italic;
    font-weight: 400;
    color: #777;
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
}
@media (prefers-color-scheme: dark) {
    h1 { border-color: rgba(255,255,255,0.15); }
    h2, h3 { color: #ccc; }
    h4 { color: #ddd; }
    h5 { color: #ccc; }
    h6 { color: #bbb; }
    h7, .h7 { color: #aaa; }
}

/* 2. Prevent Squished Code Blocks Inside Any Heading: DISTINCT handling for block vs inline */
/* Block code only for pre inside headings */
h1 pre,
h2 pre,
h3 pre,
h4 pre,
h5 pre,
h6 pre,
h7 pre,
.h7 pre {
    width: 100%;
    max-width: 90vw;
    min-width: 300px;
    box-sizing: border-box;
    display: block;
    margin: 1em 0;
    overflow-x: auto;
    background: #f9f9fa;
    padding: 0.9em 1.2em;
    border-radius: 6px;
}
@media (prefers-color-scheme: dark) {
    h1 pre,
    h2 pre,
    h3 pre,
    h4 pre,
    h5 pre,
    h6 pre,
    h7 pre,
    .h7 pre {
        background: #23263a;
    }
}
/* Inline code in headings is always inline, sized, subtly highlighted */
h1 code,
h2 code,
h3 code,
h4 code,
h5 code,
h6 code,
h7 code,
.h7 code {
    display: inline;
    padding: 0.1em 0.4em;
    margin: 0;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 3px;
    font-size: 0.9em;
}
@media (prefers-color-scheme: dark) {
    h1 code,
    h2 code,
    h3 code,
    h4 code,
    h5 code,
    h6 code,
    h7 code,
    .h7 code {
        background: rgba(255, 255, 255, 0.08);
    }
}

/* 3. Global code block improvements (all pre/code) */
pre, pre > code {
    width: 100%;
    min-width: 280px;
    max-width: 90vw;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
    overflow-x: auto;
}
pre > code {
    padding: 0.9em 1.2em;
    display: block;
    background: #f9f9fa;
    border-radius: 6px;
}
@media (prefers-color-scheme: dark) {
    pre > code {
        background: #23263a;
    }
}

/* 4. Fluid Body and List Text Sizing */
body, p, dl, ol, ul, blockquote {
    font-size: clamp(1.1rem, 1rem + 0.6vw, 1.4rem);
    line-height: 2rem;
}

/* Keep readable measure for large screens, full width on mobile */
section > p,
section > footer,
section > table,
section > dl,
section > ol,
section > ul,
figure,
blockquote p,
blockquote footer {
    width: 100%;
    max-width: 55ch;
}
@media (max-width: 760px) {
    section > p,
    section > footer,
    section > table,
    section > dl,
    section > ol,
    section > ul,
    figure,
    blockquote p,
    blockquote footer {
        max-width: 98vw;
    }
}

/* 5. Deep Lists Padding */
ul ul, ol ol, ul ol, ol ul {
    padding-left: 2em;
}

hr {
    display: block;
    height: 1px;
    width: 55%;
    border: 0;
    border-top: 1px solid #ccc;
    margin: 1em 0;
    padding: 0;
}

p.subtitle {
    font-style: italic;
    margin-top: 1rem;
    margin-bottom: 1rem;
    font-size: 1.8rem;
    display: block;
    line-height: 1;
}

.numeral {
    font-family: et-book-roman-old-style;
}

.danger {
    color: red;
}

article {
    padding: 5rem 0rem;
}

section {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

p {
    margin-top: 1.4rem;
    margin-bottom: 1.4rem;
    padding-right: 0;
    vertical-align: baseline;
}

/* Chapter Epigraphs */
div.epigraph {
    margin: 5em 0;
}

div.epigraph > blockquote {
    margin-top: 3em;
    margin-bottom: 3em;
}
div.epigraph > blockquote,
div.epigraph > blockquote > p {
    font-style: italic;
}
div.epigraph > blockquote > footer {
    font-style: normal;
}
div.epigraph > blockquote > footer > cite {
    font-style: italic;
}
/* end chapter epigraphs styles */

blockquote {
    font-size: 1.4rem;
}

blockquote p {
    width: 55%;
    margin-right: 40px;
}
blockquote footer {
    width: 55%;
    font-size: 1.1rem;
    text-align: right;
}
section > p,
section > footer,
section > table {
    width: 55%;
}
section > dl,
section > ol,
section > ul {
    width: 50%;
    -webkit-padding-start: 5%;
}

dt:not(:first-child),
li:not(:first-child) {
    margin-top: 0.25rem;
}

figure {
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
    max-width: 55%;
    -webkit-margin-start: 0;
    -webkit-margin-end: 0;
    margin: 0 0 3em 0;
}
figcaption {
    float: right;
    clear: right;
    margin-top: 0;
    margin-bottom: 0;
    font-size: 1.1rem;
    line-height: 1.6;
    vertical-align: baseline;
    position: relative;
    max-width: 40%;
}

figure.fullwidth figcaption {
    margin-right: 24%;
}

a:link,
a:visited {
    color: inherit;
    text-underline-offset: 0.1em;
    text-decoration-thickness: 0.05em;
}

/* Sidenotes, margin notes, figures, captions */
img {
    max-width: 100%;
}

.sidenote,
.marginnote {
    float: right;
    clear: right;
    margin-right: -60%;
    width: 50%;
    margin-top: 0.3rem;
    margin-bottom: 0;
    font-size: 1.1rem;
    line-height: 1.3;
    vertical-align: baseline;
    position: relative;
}

.sidenote-number {
    counter-increment: sidenote-counter;
}

.sidenote-number:after,
.sidenote:before {
    font-family: et-book-roman-old-style;
    position: relative;
    vertical-align: baseline;
}

.sidenote-number:after {
    content: counter(sidenote-counter);
    font-size: 1rem;
    top: -0.5rem;
    left: 0.1rem;
}

.sidenote:before {
    content: counter(sidenote-counter) " ";
    font-size: 1rem;
    top: -0.5rem;
}

blockquote .sidenote,
blockquote .marginnote {
    margin-right: -82%;
    min-width: 59%;
    text-align: left;
}

div.fullwidth,
table.fullwidth {
    width: 100%;
}

div.table-wrapper {
    overflow-x: auto;
    font-family: "Trebuchet MS", "Gill Sans", "Gill Sans MT", sans-serif;
}

.sans {
    font-family: "Gill Sans", "Gill Sans MT", Calibri, sans-serif;
    letter-spacing: .03em;
}

code, pre > code {
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 1.0rem;
    line-height: 1.42;
    -webkit-text-size-adjust: 100%; /* Prevent adjustments of font size after orientation changes in iOS. See https://github.com/edwardtufte/tufte-css/issues/81#issuecomment-261953409 */
}

.sans > code {
    font-size: 1.2rem;
}

h1 > code,
h2 > code,
h3 > code {
    font-size: 0.80em;
}

.marginnote > code,
.sidenote > code {
    font-size: 1rem;
}

pre > code {
    font-size: 0.9rem;
    width: 52.5%;
    margin-left: 2.5%;
    overflow-x: auto;
    display: block;
}
pre.fullwidth > code {
    width: 90%;
}

.fullwidth {
    max-width: 90%;
    clear:both;
}

span.newthought {
    font-variant: small-caps;
    font-size: 1.2em;
}

input.margin-toggle {
    display: none;
}

label.sidenote-number {
    display: inline-block;
    max-height: 2rem;
}

label.margin-toggle:not(.sidenote-number) {
    display: none;
}

.iframe-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 25px;
    height: 0;
}
.iframe-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

@media (max-width: 760px) {
    body {
        width: 84%;
        padding-left: 8%;
        padding-right: 8%;
    }
    hr,
    section > p,
    section > footer,
    section > table {
        width: 100%;
    }
    pre > code {
        width: 97%;
    }
    section > dl,
    section > ol,
    section > ul {
        width: 90%;
    }
    figure {
        max-width: 90%;
    }
    figcaption,
    figure.fullwidth figcaption {
        margin-right: 0%;
        max-width: none;
    }
    blockquote {
        margin-left: 1.5em;
        margin-right: 0em;
    }
    blockquote p,
    blockquote footer {
        width: 100%;
    }
    label.margin-toggle:not(.sidenote-number) {
        display: inline;
    }
    .sidenote,
    .marginnote {
        display: none;
    }
    .margin-toggle:checked + .sidenote,
    .margin-toggle:checked + .marginnote {
        display: block;
        float: left;
        left: 1rem;
        clear: both;
        width: 95%;
        margin: 1rem 2.5%;
        vertical-align: baseline;
        position: relative;
    }
    label {
        cursor: pointer;
    }
    div.table-wrapper,
    table {
        width: 85%;
    }
    img {
        width: 100%;
    }
}

/* Tag container: no background, minimal spacing */
.tag {
  display: inline-flex;
  gap: 0.2em;
  align-items: center;
  padding: 0;
  margin: 0;
  background: none;
  border: none;
}
/* All tags: compact, pill-shaped, modern */
.tag > span {
  display: inline-block;
  padding: 0.08em 0.7em;
  border-radius: 999px;
  font-size: 0.82em;
  font-weight: 500;
  letter-spacing: 0.01em;
  background: #f3f6fa;
  color: #28516a;
  border: 1px solid #e0e6ef;
  line-height: 1.5;
  margin: 0;
  vertical-align: middle;
  box-sizing: border-box;
  transition: background 0.2s, color 0.2s, border 0.2s;
}
/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .tag {
        background: none;
    }
    .tag > span {
    background: #25303b;
    color: #c2d3e0;
    border-color: #2f3b48;
  }
}
/* Light mode collapsible */
.collapsible {
  border: 1px solid #e0e0e0;
  background: #f7f9fa;
  border-radius: 8px;
  margin-bottom: 1.5em;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}
.collapsible-header {
  background: linear-gradient(90deg, #f0f4f8 0%, #e9ecef 100%);
  color: #2d3748;
  font-weight: 600;
  padding: 0.9em 1.2em;
  cursor: pointer;
  border-bottom: 1px solid #e0e0e0;
  border-radius: 8px 8px 0 0;
  transition: background 0.2s;
}
.collapsible-header:hover {
  background: #e6eef7;
}
.collapsible-content {
  display: none;
  padding: 1.2em;
  background: #f9fafb;
  color: #222;
  border-radius: 0 0 8px 8px;
  font-family: 'Fira Code', 'Fira Mono', 'Consolas', 'Menlo', monospace;
  font-size: 1.04em;
  overflow-x: auto;
  transition: background 0.2s;
}
.collapsible-content code, .collapsible-content pre {
  background: #f4f6fb;
  color: #2d3748;
  border-radius: 6px;
  padding: 0.4em 0.7em;
  font-size: 1em;
  display: block;
  line-height: 1.6;
  margin: 0.5em 0;
}
.collapsible-content pre {
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  margin: 0.5em 0;
}
.collapsible-content pre::before {
  content: "Code";
  position: absolute;
  top: 0;
  left: 0;
  background: #e0e7ef;
  color: #6b7280;
  font-size: 0.85em;
  padding: 0.2em 0.7em;
  border-radius: 6px 0 6px 0;
  font-family: inherit;
}
/* Dark mode collapsible */
@media (prefers-color-scheme: dark) {
  .collapsible {
    border: 1px solid #32343a;
    background: #22232b;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  }
  .collapsible-header {
    background: linear-gradient(90deg, #23263a 0%, #23272e 100%);
    color: #f0f3fa;
    border-bottom: 1px solid #32343a;
  }
  .collapsible-header:hover {
    background: #2a2e3e;
  }
  .collapsible-content {
    background: #181a20;
    color: #e0e6f0;
    font-family: 'Fira Code', 'Fira Mono', 'Consolas', 'Menlo', monospace;
  }
  .collapsible-content code, .collapsible-content pre {
    background: #23263a;
    color: #f0f3fa;
    border-radius: 6px;
  }
  .collapsible-content pre::before {
    background: #23263a;
    color: #b3b9c5;
  }
}
/* Make code blocks and inline code always match surrounding text size */
code, pre, pre code, .collapsible-content code, .collapsible-content pre {
  font-size: inherit !important;
  line-height: inherit;
}
/* centralise tables */
table {
  margin-left:auto;
  margin-right:auto;
}

html {
  scroll-behavior:  smooth;
}


a.anchor {
  text-decoration: none;
  margin-left: 0.3em;   /* spacing from header text */
  font-size: 0.85em;
  color: #666;          /* subtle color */
  padding: 0.2em;       /* increase click/tap area */
}

@media (hover: hover) {
  a.anchor {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
  }
  h1:hover a.anchor,
  h2:hover a.anchor,
  h3:hover a.anchor,
  h4:hover a.anchor,
  h5:hover a.anchor,
  h6:hover a.anchor,
  h7:hover a.anchor,
  h8:hover a.anchor {
    opacity: 1;
  }
}

/* Always visible on touch screens */
@media (hover: none) {
  a.anchor {
    opacity: 1;
  }
}

/* Assign level variables for indent guide positioning */
h1 { --level: 1; margin-left: 0; }
h2 { --level: 2; margin-left: clamp(0.5em, 1vw, 1em); }
h3 { --level: 3; margin-left: clamp(1em, 2vw, 1.5em); }
h4 { --level: 4; margin-left: clamp(1.5em, 3vw, 2em); }
h5 { --level: 5; margin-left: clamp(2em, 4vw, 2.5em); }
h6 { --level: 6; margin-left: clamp(2.5em, 5vw, 3em); }
h7, .h7 { --level: 7; margin-left: clamp(3em, 6vw, 3.5em); }
h8, .h8 { --level: 8; margin-left: clamp(3.5em, 7vw, 4em); }
h9, .h9 { --level: 9; margin-left: clamp(4em, 8vw, 4.5em); }
h10, .h10 { --level: 10; margin-left: clamp(4.5em, 9vw, 5em); }

/* Optional indent guides for h2+ */
h2::before, h3::before, h4::before, h5::before,
h6::before, h7::before, h8::before, h9::before, h10::before {
  content: "";
  position: absolute;
  left: 0.25em;
  height: 1em;
  width: 2px;
  background: rgba(0,0,0,0.08);
  transform: translateX(calc((var(--level) - 1) * 0.8em));
}

/* Dark mode adjust for indent guides */
@media (prefers-color-scheme: dark) {
  h2::before, h3::before, h4::before, h5::before,
  h6::before, h7::before, h8::before, h9::before, h10::before {
    background: rgba(255,255,255,0.12);
  }
}
