/*
vim: sw=2 ts=2 et
*/
:root {
  --main-text-color:         #101010;
  --link-text-color:         #1010a0;
  --link-visited-text-color: #5050a0;
  --comment-text-color:      #404040;
  --border-color:            #101010;
  --intense-color:           #000000;
  --bg-color:                #ffffe0;
  --green-color:             #10a010;
  --blue-color:              #1010a0;
  --red-color:               #a01010;
}

@media (prefers-color-scheme: dark) {
  :root {
    --main-text-color:         #ffffe0;
    --link-text-color:         #4060f0;
    --link-visited-text-color: #8080a0;
    --comment-text-color:      #a0a0a0;
    --border-color:            #ffffe0;
    --intense-color:           #ffffff;
    --bg-color:                #000020;
  }
}

@media print {
  :root {
    --main-text-color:         #000000;
    --link-text-color:         #1010a0;
    --link-visited-text-color: #1010a0;
    --comment-text-color:      #404040;
    --border-color:            #000000;
    --intense-color:           #000000;
    --bg-color:                transparent;
  }

  body {
    font-size: 12px !important;
  }
  p, h2, h3 {
    orphans: 3;
    widows: 3;
  }

  h1, h2, h3, h4, h5, h6, .point-header, .table-comment {
    break-after: avoid;
  }
}

html {
  background-color: var(--bg-color);
  color: var(--main-text-color);
  font-family:
    "Noto Serif", "DejaVu Serif",
    "Sitka Text", Georgia,
    "Cambria",
    "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.5;
}

body {
  margin: 0 auto;
  hyphens: auto;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
}

@media (max-width: 600px) {
  body {
    font-size: 0.9em;
  }
  h1 {
    font-size: 1.8em;
  }
}

/* General Page Layout */
.hseq { display: flex; }

main {
  max-width: min(700px, calc(100% - 20px));
  padding: 10px;
  margin: 0 auto;
}

aside {
  position: sticky;
  align-self: flex-start;
  top: 0;
  bottom: 0;
  width: 230px;
  min-height: 100vh;
  max-height: 100vh;
  overflow-y: scroll;
  margin-left: 20px;
  scrollbar-width: none;
}
@media (max-width: 1100px) {
  aside {
    margin-left: 10px;
  }
}

@media (max-width: 1000px) {
  .hseq:has(aside nav.leftMenu) {
    flex-direction: column-reverse;
  }
  .hseq:has(aside nav.toc) {
    display: block;
  }
  aside:has(nav.leftMenu) {
    position: relative;
    column-width: 250px;
    width: 100%;
    max-width: min(700px, 90%);
    min-height: 0;
    margin: 0 auto;
    padding-bottom: 50px;
  }
  aside nav.leftMenu {
    padding-top: 0;

    h1 { display: none; }

    h2, h3 { margin-top: 0; }
    h2, h3 { padding-top: 5px; }
  }

  aside:has(nav.toc) {
    position: relative;
    width: min(100%, 700px);
    margin: 0 auto;
    min-height: 0;
    padding-top: 50px;
  }
}
@media print {
  aside {
    display: none;
  }
}

nav.leftMenu {
  padding-top: 10px;

  a:has(h1) {
    color: var(--main-text-color);
    text-decoration: none;
  }

  h1 {
    margin: 1em 0;
    padding-left: 14px;
    font-weight: 1000;
    column-span: all;
  }

  h2 {
    padding-left: 14px;
    font-size: 20px;
    break-after: avoid;
  }
  h3 {
    padding-left: 14px;
    font-size: 17px;
    break-after: avoid;
  }

  .menu-break {
    column-break-before: always;
  }

  h1 + h2, h2 + section h2, h2 + h3, h3 + section h3 {
    margin-top: 0.1em;
  }

  ul, li {
    padding: 0; 
    margin: 0;
    break-inside: avoid;
  }

  li {
    font-size: 15px;
    padding-left: 28px;
    list-style: none;
  }

  .container {
    break-inside: avoid;

    ul {
      padding-left: 28px;
    }

    li { padding-left: 0; }
  }

  .container.symbols-list {
    padding-left: 0px;
  }
}

/* Single Page Pandoc menu */
nav.toc > ul {
  padding-left: 14px;

  a { font-size: 15px; }
}
nav.toc > ul > li > ul {
  padding-left: 0px;

  ul {
    padding-left: 14px;
  }
}
nav.toc > ul > li > a {
  font-weight: 1000;
  font-size: 34px;
}
nav.toc > ul > li > ul > li {
  margin-top: 1em;
}

nav.toc > ul > li > ul > li > a {
  font-weight: bold;
  color: var(--main-text-color);
  text-decoration: none;
  font-size: 20px;
}
nav.toc li { list-style: none; }

/* Main Elements */
hr {
  border: none;
  border-top: 1px solid var(--border-color);
  height: 1px;
  margin: 1em 0;
}

table {
  margin: 1em 0;
  border-collapse: collapse;
  width: 100%;
  overflow-x: auto;
  display: block;
  font-variant-numeric: lining-nums tabular-nums;

  caption {
    margin-bottom: 0.75em;
  }
  tbody {
    margin-top: 0.5em;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
  }
  th {
    border-top: 1px solid #1a1a1a;
    padding: 0.25em 0.5em 0.25em 0.5em;
  }
  td {
    padding: 0.125em 0.5em 0.25em 0.5em;
  }
}

p {
  text-align: justify;
  text-wrap: pretty;
  margin: 0.5em 0;
}

pre {
  margin: 1em 0em 1em 2.3em;
  overflow: visible;
  line-height: 1.2;
}
code {
  font-size: 85%;
  margin: 0;
  hyphens: manual;
  font-family: "Noto Sans Mono", "IBM Plex Mono", monospace;
  white-space: pre-wrap;
}

pre code {
  padding: 0;
  text-wrap: nowrap;
}
p code {
  margin: 0em 0.1em;
}
img {
  max-width: 100%;
}
svg {
  height: auto;
  max-width: 100%;
}

ol, ul {
  padding-left: 1.7em;
  margin-top: 1em;
}
li { text-align: justify; }
li > ol, li > ul { margin-top: 0; }
ul>li { list-style: square; }

/* The extra [class] is a hack that increases specificity enough to
   override a similar rule in reveal.js */
ul.task-list[class]{list-style: none;}
ul.task-list li input[type="checkbox"] {
  font-size: inherit;
  width: 0.8em;
  margin: 0 0.8em 0.2em -1.6em;
  vertical-align: middle;
}


a         { color: var(--link-text-color); }
a:visited { color: var(--link-visited-text-color); }
a:hover   { color: var(--link-text-color); }

.green { color: var(--green-color); }
.blue  { color: var(--blue-color);  }
.red   { color: var(--red-color);   }

h1, h2, h3, h4, h5, h6 {
  margin: 1em 0 0 0;
}
h5, h6 {
  font-size: 1em;
  font-style: italic;
}
h6 {
  font-weight: normal;
}


.point-header {
  font-weight: bold;
  display: block;
  margin-bottom: 0.2em;
}

li:has(> .point-header) {
  margin-bottom: 1em;
}

.explain-table {
  table {
    width: 100%;
    display: table;
  }

  td {
   line-height: 20px;
   font-size-adjust: ex-height;
  }

  tr td:first-child {
    font-style: italic;
    text-align: right;
    text-wrap: balance;
    font-size: 14px;

    user-select: none;

    code {
      font-size: 14px;
      font-style: normal;
      word-wrap: break-word;
    }
  }

  tr td:last-child {
    code {
      font-size: 15px;
    }
  }

  @media (width > 700px) {
    td {
      padding: 1px 16px;
    }
    tr td:first-child {
      padding: 4px 16px;
    }
    tr:first-child td {
      padding-top: 8px;
      padding-bottom: 4px;
    }
    tr:last-child td {
      padding-top: 4px;
      padding-bottom: 8px;
    }
    tr:first-child:last-child td {
      padding-top: 8px;
      padding-bottom: 8px;
    }
  }

  @media (width <= 700px) {
    table, tr, td, th, tbody {
      display: block;
    }

    table {
      margin-top: 0;
    }

    tr td:first-child {
      color: var(--comment-text-color);
      margin-top: 1em;
      margin-left: 20%;
      padding: 0;
      width: 80%;
    }

    tr td:last-child {
      width: 100%;
      padding: 0;
      margin-bottom: 1em;
    }
  }

  pre {
    margin: 0;
  }

  pre.indent-2 { margin-left: 1em; }
  pre.indent-4 { margin-left: 2em; }
  pre.indent-6 { margin-left: 3em; }
  pre.indent-8 { margin-left: 4em; }

  .table-comment {
    width: 80%;
    margin: 0 auto;
    break-before: avoid-page;
  }
  .table-comment p {
    text-align: center;
    text-wrap: balance;
  }
}

.explain-table.examples-table {
  tr {
    border-bottom: dashed 1px var(--comment-text-color);
  }

  tr td {
    padding-top: 0.5em;
    padding-bottom: 0.5em;
  }

  @media (width <= 700px) {
    tr td:first-child {
      text-align: left;
      font-style: normal;
      font-weight: bold;
      margin: 0.5em 0;
    }
  }
}

.centered-td td {
  text-align: center;
}

.full-width-table {
  table {
    width: 100%;
    display: table;
  }
}

.small-table {
  table {
    display: table;
    margin: 0 auto;
    width: auto;
  }

  table thead, table tbody, table th {
    border: 0;
  }
}

.dictionary-list {
  ul {
    column-width: 90px;
    column-fill: balance;
  }
  li {
    list-style: none;
  }
}

span.smallcaps{ font-variant: small-caps; }
div.columns{ display: flex; gap: min(4vw, 1.5em); }
div.column{ flex: auto; overflow-x: auto; }
div.hanging-indent{ margin-left: 1.5em; text-indent: -1.5em; }
.display.math{display: block; text-align: center; margin: 0.5rem auto;}


.chained-pages {
  padding: 1em 0 4em 0;

  a { text-decoration: none; }

  .prev-page {
    clear: left;
    float: left;
    max-width: 50%;
  }
  .next-page {
    clear: right;
    float: right;
    max-width: 50%;
    text-align: right;
  }

  .context { color: var(--main-text-color); }
  
  .prev-page, .next-page {
    svg { height: 1em; width: 1em; margin: 0 0.5em; }
    align-items: center;
    display: flex;
  }
  
  .prev-page svg {
    transform: rotate(180deg);
  }
}
