/** Texts reader */

.article,
.chapter {
  display: grid;
  grid-template-columns: 18rem minmax(0, 1fr);
  align-items: start;
  margin-inline: auto;
  padding-inline: 1rem;
  max-width: 70rem;
}

.article-toc,
.chapter-toc {
  grid-column: 1;
  grid-row: 1;

  position: sticky;
  top: 0;
  /* set to your header offset */
  max-height: calc(100vh);
  overflow: auto;
}


.article-flow,
.book-abstract,
.chapter-flow {
  position: relative;
  background-color: var(--reader-bg);
  color: var(--reader-fg);
  font-family: var(--reader-font-family);
  font-size: var(--reader-font-size);
}

.article-flow,
.chapter-flow {
  grid-column: 2;
  grid-row: 1;
  /* prevents overflow issues */
  min-width: 0;
  max-width: var(--reader-width);
  padding: 3rem 5vw;
}


/* watermark layer */
.article-flow.hourglass,
.chapter-flow.hourglass {
  background-image: url('data:image/svg+xml;utf8,<svg stroke="hsla(356, 79%, 42%, 0.1)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round"><path d="M5 2h14M5 22h14M7 2v6c0 3 3.5 4.5 3.5 4.5S7 14 7 17v5M17 2v6c0 3-3.5 4.5-3.5 4.5S17 14 17 17v5"/></svg>');
  background-origin: content-box;
  background-size: auto 80%;
  background-position: 70% 95%;
  background-repeat: no-repeat;
  background-attachment: fixed;

}


h1[id],
h2[id],
h3[id],
h4[id],
h5[id],
h6[id],
a[id] {
  scroll-margin-top: calc(2rem + var(--header-height));
}

.book #scroll-handle {
  display: none;
}

aside.note {
  margin: 0 0 0 0;
  padding: 0;
  border: none;
}

section {
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
  margin-bottom: 0;
}

p.booktitle a {
  display: block;

}

p.booktitle a:hover {
  text-decoration: none;
  background-color: var(--ui-bg-hover);
  color: var(--ui-fg-hover);
}


/* book layout */

main {
  padding-bottom: 0;
}

article.book {
  display: flex;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
  margin-left: auto;
  margin-right: auto;
  justify-content: center;
}

article.book>* {
  overflow: auto;
  margin: 0;
}

.book-cover {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 2rem 2rem 2rem;
}

.book-cover .cover,
.book-cover .cover:hover {
  box-shadow: none;
  background-color: hsla(0, 0%, 100%, 0.8);
}

article.book .cover {
  min-width: 250px;

}

.book-abstract {
  flex-basis: 60ex;
  padding: 2em;
  box-shadow: 0 0 10px hsla(0, 0%, 0%, 0.2);
}



.book-abstract>div {
  /* safe vertical align for abstract content */
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* toc */

.book-toc {
  max-width: 40ex;
  width: auto;
  overflow: auto;
  padding-top: 0;
  background: transparent;
  color: inherit;
  padding: 1rem 0 1rem 1rem;
}


@media (max-width: 768px) {

  /* TODO phone 
  #toc-panel {
    position: absolute;
    background-color: var(--ui-bg);
    color: var(--ui-fg);
    width: 90vw;
    max-width: var(--toc-width);
    max-height: 85vh;
    overflow-y: auto;
    padding: 1rem;
    line-height: 130%;
  }
    */
}

#app-toc {
  display: none;
  /* Hide menu button */
}


#close-toc {
  background: none;
  color: var(--reader-fg);
  position: fixed;
  z-index: 101;
  top: 5vh;
  left: 82vw;
}

#toc-panel h2 {
  font-size: inherit;
  font-weight: 600;
  color: inherit;
}

#toc-panel header {
  padding-right: 0.7rem;
}

.toc {
  background-color: inherit;
}

.toc a,
.toc li>div {
  display: block;
  padding: 1rem 0.7rem;
  font-size: 1em;
  border-radius: 0;
}

.toc a:active,
.toc a:focus,
.toc a:hover {
  background-color: var(--ui-bg-hover);
  color: var(--ui-fg-hover);
  box-shadow: inset 5px 0 8px -5px rgba(0, 0, 0, .25);
}

.toc ol ol {
  margin-left: 0.9em;
}