/* prevent overscroll https://stackoverflow.com/questions/12046315/prevent-overscrolling-of-web-page */
html {
  overflow: hidden;
  height: 100%;
}

body {
  height: 100%;
  overflow: hidden;

  margin: 0;
  padding: 0;

  /* github font see http://markdotto.com/2018/02/07/github-system-fonts/ */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  font-size: 16px;
  color: rgb(35, 35, 35);
}

h1 svg, h2 svg, h3 svg {
  margin-left: 8px;
  fill: transparent;
  height: 0.6em;
}

h1:hover svg, h2:hover svg, h3:hover svg {
  fill: #4183c4;
}

#page-toc {
  margin-bottom: 1rem;
}

.body-book-index {
  display: flex;
  flex-direction: column;
}

/* this is cover on the left and book summary on the right */
#book-cover-summary {
  display: flex;
  flex-direction: row;

  margin-top: 8px;
}

#book-cover-image {
  margin-left: 16px;
}

#book-cover-description {
  margin-left: 16px;
  margin-top: -8px; /* don't get why I need this */
}

#book-index-toc-header {
  margin-top: 16px;
  padding-bottom: 8px;
  font-size: 1em;
  font-weight: 700;
  margin-left: auto;
  margin-right: auto;
  max-width: fit-content;
}

/* hide by default, show when small width */
#chapter-toc-wrapper {
  display: none;
  font-size: 0.9em;
}

@media screen and (max-width: 780px) {
  #chapter-toc-wrapper {
    display: block;
  }
}

/* dim toc on a book chapter page, to de-emphasize it 
  visually, until user hovers over the element */
#chapter-toc-wrapper {
  filter: opacity(0.6);
}

#chapter-toc-wrapper:hover {
  filter: opacity(1);
}
  
  
#chapter-toc-wrapper hr {
    border: 1px solid rgba(1, 1, 1, 0.1);
    border-style: dashed;
    margin-top: 24px;
    margin-bottom: 8px;
}

#chapter-toc-wrapper div.hdr {
  margin-top: 16px;
  padding-bottom: 8px;
  font-size: 1em;
  font-weight: bold;
  margin-left: auto;
  margin-right: auto;
  max-width: fit-content;
}


#header,
#footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 16px;
  background-color: #f5f5f5;
}

#footer {
  font-size: 0.8em;
  padding: 4px 16px;
}

#book-toc {
  font-size: 0.9em;

  margin-left: 16px;
  margin-right: 16px;
  margin-bottom: 16px;
}

#header-left,
#footer-left {
  min-width: 180px;
}

#header-center {
  width: 50vw;
}

#footer-center {
  min-width: 180px;
}

#header-right,
#footer-right {
  min-width: 180px;
  text-align: right;
}

#content-book-index {
  background-color: white;

  height: 100%;
  flex: 1 1 auto;
  position: relative;
  overflow-y: auto;
}

.page {
  display: -ms-grid;
  display: grid;

  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr auto;

  grid-template-areas:
    "header   header"
    "toc      content"
    "footer   footer";

  height: 100vh;
}

.page__header {
  grid-area: header;

  display: flex;
  justify-content: space-between;
  align-items: baseline;

  padding: 8px 16px;
  background-color: #f5f5f5;
}

/* set left and right to be the same size so that
  middle gets y-centered */
.page__header__left {
  min-width: 180px;
}

.page__header__right {
  width: 180px;
  text-align: right;
}

.page__footer {
  grid-area: footer;

  display: flex;
  justify-content: space-between;
  align-items: baseline;

  font-size: 0.8em;
  padding: 4px 16px;
  background-color: #f5f5f5;
}

/* set min size of left / right so that midde is v-centered */
.page__footer__left {
  min-width: 240px;
}

.page__footer__right {
  min-width: 240px;
  text-align: right;
}

.content {
  grid-area: content;
  overflow-y: scroll;
}

#toc {
  grid-area: toc;
  overflow-y: scroll;

  margin-top: 8px;
  margin-bottom: 8px;

  padding-left: 8px;
  padding-right: 8px;

  width: 240px;

  font-size: 0.8em;
  line-height: 1.3em;
}

.article {
  max-width: 660px;
  padding-top: 8px;
  padding-bottom: 16px;
  padding-left: 8px;
  padding-right: 8px;
}

.book-body {
  max-width: 100vw;
  padding: 0px 16px;
}


.bold {
  font-weight: bold;
}

.forum-link {
  color: gray;
  font-size: 0.8em;
  padding-bottom: 16px;
  display: block;
}

@media screen and (max-width: 780px) {
  .article {
    margin-left: auto;
    margin-right: auto;
    padding-left: 0px;
    padding-right: 0px;
  }
  #toc {
    display: none;
  }

}

.page__header__center {
  width: 50vw;
}

/* for very small screens (i.e. phones) remove rarely needed elements and other tweaks */
@media screen and (max-width: 500px) {
  .page__footer {
    display: none;
  }
  .page__header__left {
    display: none;
  }
  .page__header__right {
    display: none;
  }
  .article-contribute {
    display: none;
  }
  /* TODO: not centered perfectly */
  .page__header__center {
    width: 80vw;
    margin-left: auto;
    margin-right: auto;
  }
  .content {
    padding-left: 4px;
    padding-right: 4px;
  }
}

#toc .lvl1 {
  padding-left: 18px;
}

#toc .lvl2 {
  padding-left: 36px;
}

#toc .lvl3 {
  padding-left: 54px;
}

/*
.article div {
  width: 660px;
}

.article p {
  width: 660px;
}

.article pre {
  width: 660px;
}
*/

/* TODO: for code div, set min-width to 660px */

.article-contribute {
  float: right;
}

/*
.article {
  width: 660px;
  margin-left: auto;
  margin-right: auto;
}
*/

tr:nth-child(even) {
  background-color: #eee;
}

.article table {
  font-size: 0.85em;
}

td,
th {
  padding: 0.5em 1em;
  text-align: left;
  /* vertical-align: top; */
}

/*th {
  vertical-align: bottom;
}*/

th:not(:first-child):not(:last-child),
td:not(:first-child):not(:last-child) {
  padding: 0 10px;
}

tbody tr td.with-decimal {
  padding-left: 10px !important;
  padding-right: 0px !important;
}

tbody tr td.decimal {
  padding-left: 0 !important;
  padding-right: 10px !important;
}

.article-top-hdr {
  font-size: 0.8em;
}

/* TODO: could make it more explicit by
setting class on h* elements */
.article h1:target,
.article h2:target,
.article h3:target,
.article h4:target {
  transition: all 1s linear;
  animation: temphilight 1.7s 1;
}

@keyframes temphilight {
  0% {
    background-color: transparent;
  }
  50% {
    background-color: yellow;
  }
  100% {
    background-color: transparent;
  }
}

.light {
  color: gray;
}

.book-name {
  padding-right: 32px;
  padding-left: 0px;
}

table.book-list th {
  padding-right: 16px;
}

.article blockquote {
  border-left: 2px solid rgb(203, 203, 203);
  padding-left: 8px;
  margin-left: 16px;
}

.article img {
  max-width: 100%;
  height: auto;
}

.markdown-book-index {
  margin: 2rem 0;
}

.markdown-book-index > ul {
  padding-left: 1.5rem;
}

.toc-article {
  padding-left: 1em;
}

a {
  color: #4183c4;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a.blue {
  color: rgb(138, 178, 219);
}

a.blue:hover {
  color: #4183c4;
}

.covers {
  padding-top: 16px;
  padding-right: 32px;
  padding-left: 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.img-cover-small-wrapper {
  margin-bottom: 12px;
  padding-left: 16px;
}

.img-cover-wrapper {
  margin-bottom: 16px;
  /* width: 256px; height: 363px; */
  /* ratio: 1.41 */
  width: 200px;
  height: 283px;

  /* width: 100px;  height: 241px; */
}

.img-cover-small {
  width: 140px;
  transition: all 0.1s ease-in-out;
}

.img-cover-small:hover {
  transform: scale(1.05);
  border: 1px solid lightgray;
}

.img-cover {
  width: 100%;
  height: 100%;
  transition: all 0.1s ease-in-out;
}

.img-cover:hover {
  transform: scale(1.05);
  border: 1px solid lightgray;
}

.book-img-cover-wrapper {
  float: right;
}

.edit-link {
  /* margin-right: 24px; */
  padding-right: 8px;
  padding-left: 8px;
  padding-bottom: 2px;
  text-decoration: none;
  color: #cccccc;
  white-space: nowrap;
}

.edit-link:hover {
  text-decoration: underline;
  color: #999999;
}

/*
style of an image <img> tag:
- centered horizontally
- limit width to container (i.e. the page)
*/
.img {
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
  display: block; /* needed for margin-left/margin-right to work */
}

.book-img-cover {
  width: 264px;
  height: scale-down;
}

/* styling inspired by http://gameprogrammingpatterns.com/dirty-flag.html#local-and-world-transforms
*/
.article h1,
.article h2,
.article h3,
.article h4,
.article h5 {
  color: #1481b8;
  /* border-left: solid 8px #d9eaf2;
    padding-left: 8px; */
}

h1.title {
  margin-top: 0px;
  margin-bottom: 0px;
}

/* add visual indication that this is the end of the article */
hr.article-bottom-sep {
  border: 1px solid rgba(1, 1, 1, 0.1);
  border-style: dotted;
  margin-top: 4px;
}

/* Note: there might be more elements we need to add here */
details.notion-toggle > div,
details.notion-toggle > details {
  margin-left: 1.4em;
}

/* neutralize dy margin at the top and the bottom of lists
   when nested inside toggle list */
details.notion-toggle > ul,
details.notion-toggle > ol {
  margin-block-start: 0;
  margin-block-end: 0;
}

details.notion-toggle > summary::-webkit-details-marker:hover {
  color: gray;
  cursor: pointer;
}

.notion-column-list {
  display: flex;
  justify-content: space-between;
}

.notion-date {
  opacity: 0.5;
}

hr.notion-divider {
  border: 0;
  border-top: 1px solid #eee;
}

.view-switch {
  margin-top: 8px;
  margin-bottom: 8px;
  font-size: 0.9em;
}

.book-list {
  /* center the table with list of books */
  margin-left: auto;
  margin-right: auto;
  min-width: 50%;
}


.page-404 {
  background: #eee;
  padding: 40px 60px;
  border-radius: 6px;
  width: 40em;
  margin: 50px auto;
  max-width: 100%;
}

.breadcrumb-sep:after {
  content: "\2192";
  font-family: Lucida Grande, Lucida Sans Unicode, Arial, Helvetica, sans-serif;
  color: #a9a9a9;
  display: inline-block;
  margin: 0 0px 0 4px;
}

.breadcrumb-sep:last-child {
  display: none;
}

.mtoc-0 {
  padding-left: 0;
}

.mtoc-1 {
  padding-left: 16px;
}

.mtoc-2 {
  padding-left: 32px;
}

.mtoc-3 {
  padding-left: 48px;
}

.hcenter {
  text-align: center;
}

#msg-for-chris {
  width: 100%;
  height: 8em;
}

form > textarea {
  font-size: 12pt;
}

#contact-form {
  /* background-color: lightsteelblue; */
  padding: 1em 2em;
  width: 75vw;
  position: fixed;
  right: 8px;
  bottom: 2em;
  background-color: white;
  background-color: #fafafa;
  z-index: 99;
  border: 1px solid lightgray;

  /* initially hidden */
  display: none;
}

.noshow {
  display: none;
}

.contact-hidden {
  display: none;
}

#contact-page-url {
  font-size: 85%;
  border: 0;
  color: grey;
  margin-left: 2px;
  background-color: #fafafa;
}

form > input {
  width: 100%;
  font-size: 16px;
}

form button {
  font-size: 16px;
  background-color: white;
  padding: 4px 8px;
}

form button:hover {
  background-color: lightblue;
}

.contact-light {
  font-size: 85%;
  color: gray;
  margin-left: 2px;
  margin-bottom: 4px;
}

.code-box {
  margin: 1.25rem 0;
  overflow: hidden;
  color: #24292f;
  background: #f6f8fa;
  border: 1px solid #d8dee4;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(31, 35, 40, 0.06);
}

.code-box:focus-within {
  border-color: #8c959f;
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.12);
}

.code-box-header {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.45rem 0 0.85rem;
  color: #57606a;
  background: #eef1f4;
  border-bottom: 1px solid #d8dee4;
}

.code-box-language {
  overflow: hidden;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.045em;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.code-box-copy {
  min-width: 3.6rem;
  padding: 0.28rem 0.5rem;
  color: #57606a;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
}

.code-box-copy:hover {
  color: #24292f;
  background: rgba(175, 184, 193, 0.2);
  border-color: rgba(27, 31, 36, 0.15);
}

.code-box-copy:focus-visible {
  outline: 2px solid #0969da;
  outline-offset: 1px;
}

.code-box-copy[data-copied="true"] {
  color: #1a7f37;
}

.lang-output {
  background: #fbfcfd;
  border-color: #d0d7de;
}

.lang-output .code-box-header {
  background: #f6f8fa;
}

/* for compact output */
div.lang-output pre:has(> code) {
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* for non-compact output */
div.lang-text pre:has(> code) {
  word-wrap: break-word;
  white-space: pre-wrap;
}

.code-box pre {
  display: block;
  overflow-x: auto;
  tab-size: 2;
  margin: 0;
  padding: 1rem;
  scrollbar-color: #afb8c1 transparent;
  scrollbar-width: thin;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.code-box code {
  font-family: inherit;
}

@media screen and (max-width: 500px) {
  .code-box {
    margin-right: -4px;
    margin-left: -4px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .code-box pre {
    padding: 0.85rem;
  }
}

/* for showing a link to forum at the bottom of article / chapter */
.forum-link {
  font-size: 85%;
  color: gray;
  font-style: italic;
  padding-bottom: 8px;
}

/* the same size as arrow */
.toc-nav-empty-arrow {
  min-width: 16px;
  width: 16px;
  height: 16px;
  align-self: center;
  transform: translateY(-1px);
  padding-right: 2px;
}

.arrow {
  /* kind of a hack because it got squished if the link
     is long in .toc-item. probably could fix with
     rigth flexbox attributes */
  min-width: 16px;
  width: 16px;
  height: 16px;
  align-self: center;
  transform: translateY(-1px);
  padding-right: 2px;
}

.arrow:hover {
  background-color: #b3b3b3;
}

.icon-home {
  width: 16px;
  height: 16px;
  fill: #4183c4;
  transform: translateY(2px);
}

.icon-edit {
  width: 16px;
  height: 16px;
  fill: #4183c4;
  transform: translateY(2px);
}

.icon-twitter {
  width: 12px;
  height: 12px;
  fill: #4183c4;
  transform: translateY(2px);
}

.github {
  width: 16px;
  height: 16px;
  fill: #4183c4;
  transform: translateY(3px);
}

.toc-item {
  display: flex;

  white-space: nowrap;
  text-overflow: ellipsis;
  /* overflow-x: hidden; */ /* this shows scroller on latest chrome */
}

.toc-item:hover {
  background-color: #eaeaea;
}

.toc-link {
  align-self: center;
  white-space: nowrap;
  text-overflow: ellipsis;

  /* overflow-x: hidden; */
  color: rgb(88, 88, 88);
}

.bold .toc-link {
  color: black;
}

/* when #toc is hovered on with mouse, increase the contrast
   of link color.
   TODO: not sure about this, flickers when going to another page.
   Maybe use mouseover and mouseout events
   https://developer.mozilla.org/en-US/docs/Web/Events/mouseover
   https://developer.mozilla.org/en-US/docs/Web/Events/mouseout
*/
/*
#toc:hover .toc-link {
  color: black;
}
*/


/* Keep the light theme consistent with the rest of the site. */
body[data-syntax-theme="github"] {
  color-scheme: light;
}
