@import "custom.css";
@import "fonts.css";
@import "dark-mode-toggle.css";

html {
  height: 100vh;
  overflow-y: hidden;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--background);
  color: var(--foreground);
  text-rendering: optimizeLegibility;
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
  transition: color var(--transition),
              background-color var(--transition);
}

/* Screen reader only content - leave it there but make it take no space */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: rect(0 0 0 0);
  border: 0;
}

#page {
  display: flex;
  flex-direction: row;
  width: 100vw;
  height: 100vh;
  margin: 0px;
  padding: 0px;
  overflow: hidden;
}

#main-content {
  display: inline-block;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Computer Modern Serif", serif;
  font-size: 20px;
  overflow-x: hidden;
}

#padded-content {
  width: var(--content-width);
  margin: 0 calc( (100vw - var(--sidebar-width) - var(--content-width) - var(--navi-width)) / 2 );
  padding: 0;
}

code, pre, tt {
  font-family: "Computer Modern Typewriter", SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
}

p {
  margin-top: 0px;
  margin-bottom: 16px;
  line-height: 1.4128;
}

a {
  color: var(--link-colour);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  text-decoration: underline;
}

a[rel*="external"]::after {
  content: "↗";
  font-size: 10px;
  vertical-align: top;
}

code {
  font-size: 95%;
}

/*** Wrapping long lines of hex ***/
span.wrap {
  word-break: break-all;
}

/*** Constant line heights ***/

sup, sub {
  font-size: 0.75em;
  line-height: 0;
  vertical-align: baseline;
  position: relative;
  display: inline-block;
}

sup {
  top: -0.6em;
  left: 0.1em;
}

sub {
  bottom: -0.25em;
}

sup a, sub a, sup span, sub span {
  line-height: normal;
  font-size: inherit;
  vertical-align: baseline;
}

/*** Headings ***/

h2, h3, h4, h5, h6 {
  position: relative;
}

h3 {
  padding-bottom: 6px;
  margin-bottom: 1ex;
}

h4, h5, h6 {
  margin-top: 4ex;
  margin-bottom: 1ex;
}

h3 + h4 {
  margin-top: 1ex;
}

h1 + p,
h2 + p,
h3 + p,
h4 + p,
h5 + p,
h6 + p {
  margin-top: 1ex;
}

h3 {
  font-size: 130%;
}

h4 {
  font-size: 120%;
}

h5 {
  font-size: 110%;
}

h6 {
  font-size: 100%;
}

h4 code, h5 code, h6 code {font-size: inherit; }

/*** Heading autolinks ***/

a.anchor {
  position: absolute;
  left: -20px;
  display: inline-block;
}

a.anchor svg {
  width: 16px;
  height: 16px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

h2:hover svg, h3:hover svg, h4:hover svg, h5:hover svg, h6:hover svg  {
  opacity: 1;
}

/*** Others ***/

figure {
  text-align: center;
  padding: 0;
  margin: 3ex auto;
}

figcaption {
  text-align: center;
  padding: 0;
  margin: 0 auto 3ex auto;
  font-style: italic;
}

table {
  border: solid var(--table-border) 1px;
  border-collapse: collapse;
  margin: 3ex 0;
}

td, th {
  border: solid var(--table-border) 1px;
  padding: 4px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--th-colour);
  background-color: var(--th-background);
  border: solid var(--th-border) 1px;
  border-top-style: inherit;
}

th:first-child {
  border-left-style: inherit;
}

th:last-child {
  border-right-style: inherit;
}

th:empty {
  display: none;
}

main li {
  line-height: 1.4128;
  padding-bottom: 3px;
}

main ol {
  list-style-type: decimal;
}

main ol ol {
  list-style-type: lower-alpha;
}

main ol ol ol {
  list-style-type: lower-roman;
}

blockquote {
  margin-left: 0;
  padding-left: 2em;
  border-left: solid #ccc 4px;
}

/*** Title page format ***/

div.title-page {
  display: flex;
  min-height: 80vh;
  margin: 0 20%;
  text-align: center;
  flex-direction: column;
  justify-content: space-around;
  font-weight: bold;
}

div.title-page .h2, div.title-page .h3, div.title-page .h4 {
  border: none;
  padding: 0;
  margin: 1ex 0;
}

div.title-page .h2 {
  font-size: 30px;
}

div.title-page .h3 {
  font-size: 26px;
}

div.title-page .h4 {
  font-size: 24px;
}

div.title-page svg {
  margin: 1ex auto;
}

/*** Headings for chapters ***/
div.chapter-header h1 {
  display:inline;
  font-size: 90%;
}

/*** Headings for sections ***/
div.section-header h1, div.section-header h2 {
  display:inline;
  font-size: 0.9em;
}

div.section-header h1::after {
  content: " | ";
}

div.section-header, div.chapter-header {
  padding: 0;
  border-bottom: solid 1px #999;
}

details {
  margin-bottom: 2ex;
}

details summary {
  font-weight: bold;
}

details p:first-of-type {
  padding-top: 2ex;
}

/*** Code prettifier ***/

pre[class^="language-"] {
  padding: 1ex 1em;
  border-radius: 1ex;
  line-height: 1.0;
}

pre[class^="language-"] code {
  font-size: 0.8em;
  line-height: 1.0;
}

/*** Equations ***/

/* Keep inline equations the same size as surrounding text */
p span.katex, li span.katex, td span.katex {
  font-size: inherit;
}

/* Control size of the displayed equations - this makes them a little smaller */
.katex-display .katex {
  font-size: 1em;
}

/*** Footnotes ***/
section.footnotes {
  margin-top: 6ex;
  border: 0;
  border-top: solid 1px #ccc;
  font-size: 85%;
}

/*** Summary boxes ***/
div.summary {
  width: 80%;
  margin: 1ex auto 4ex auto;
  padding: 1ex 1em;
  border: double #999 3.5px;
}

/*** SVG stuff - dark mode support ***/

/* Heading anchors */
a.anchor svg path {
  fill:  var(--foreground);
}

/* Fix up chart axes and labels */
figure.chart svg path[class$="Text"]
{
  fill: currentColor;
}

figure.chart svg path[class*="Axis"][stroke="#000"]
{
  stroke: currentColor!important;
}

/* Diagrams now come with light and dark mode built-in */
figure.diagram svg {
  color-scheme: var(--color-scheme)!important;
}

/* Dark/light mode transitions */
figure svg path {
  transition: stroke var(--transition),
              fill var(--transition);
}

figure.diagram svg foreignObject div,
figure.diagram svg rect,
figure.diagram svg text,
figure.diagram svg span
{
  transition: color var(--transition),
              background-color var(--transition),
              fill var(--transition);
}

/* Always display my avatar as positive */
div.title-page svg g#layer101 path {
  fill: #343434!important;
}

@media print {
  html, body, #page, #main-content {
    --background: #fff;
    --foreground: #000;
    display: block !important;
    overflow: visible !important;
    width: 100% !important;
    max-width: initial !important;
    min-width: initial !important;
    margin: initial !important;
    padding: initial !important;
    background-color: var(--background);
    color: var(--foreground);
  }
  #main-content {
    font-size: 12pt !important;
  }
  #padded-content {
    width: auto !important;
    margin: 0 !important;
    padding: 0 12mm !important;
  }
  h1, h2, h3, h4, h5, h6 {
    position: initial !important;
    break-after: avoid; /* Not working with Chrome? */
    page-break-after: avoid;
  }
  td, th {
    color: inherit;
    border: solid #999999 1px;
  }
  a {
    color: black;
  }
  a[rel*="external"] {
    color: blue;
  }
  a[rel*="external"]::after {
    content: "";
  }
  a.anchor {
    display: none;
  }
  a.data-footnote-backref {
    display: none;
  }
  /* Undo code styling */
  pre[class*="language-"] {
    background: none;
    overflow: hidden;
  }
  pre[class*="language-"] code {
    color: black !important;
    font-size: 75% !important;
  }
  pre[class*="language-"] code span {
    color: black !important;
  }
  summary {
    list-style: none;
  }
}

/* For wide displays */
@media screen and (min-width: 1920px) {
  body {
    position: relative;
    width: var(--max-page-width);
    margin: 0 auto;
  }
  #padded-content {
    width: calc( var(--max-page-width) / 2 );
    margin: 0 calc( var(--max-page-width) / 20 );
  }
}

/* For mobile */
@media screen and (max-width: 1200px) {
  #main-content {
    width: auto;
  }
  #padded-content {
    width: auto;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 5rem 1.5rem;
    min-width: auto;
  }
  footer {
    padding-bottom: 1rem;
  }
  div.title-page {
    margin: 0;
  }
}

/* Further changes for very narrow screens */
@media screen and (max-width: 600px) {
  #padded-content {
    padding: 1.5rem 0.75rem 5rem 0.75rem;
  }
  figure {
    width: 100%!important;
  }
  footer {
    margin-top: 3rem;
  }
  blockquote {
    padding-left: 1rem;
  }
  ul {
    padding-left: 1.2rem;
  }
  ol {
    padding-left: 1.5rem;
  }
}
