@import url("https://fonts.googleapis.com/css2?family=Literata:ital,wght@0,400;0,700;1,400&family=PT+Serif:ital,wght@0,400;0,700;1,400&family=Merriweather:ital,wght@0,400;0,700;1,400&family=EB+Garamond:ital,wght@0,400;0,700;1,400&family=Inter:wght@400;600&display=swap");

:root {
  --reader-font-family: Georgia, "PT Serif", "Times New Roman", serif;
  --reader-font-size: 19px;
  --reader-line-height: 1.7;
  --reader-content-max-width: 44rem;
  --reader-paragraph-indent: 0;
}

.content {
  font-family: var(--reader-font-family);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  hyphens: auto;
  -webkit-hyphens: auto;
  text-align: justify;
}

.content ol,
.content ul,
.content li,
.content p,
.content blockquote {
  font-size: inherit;
}

/* Numbered paragraphs in the source render as <ol><li>. Move the marker
   inline so the text occupies the full reading width instead of leaving
   a gutter. */
.content ol {
  list-style: none;
  counter-reset: paragraph;
  padding-left: 0;
  margin-left: 0;
}

.content ol > li {
  counter-increment: paragraph;
  padding-left: 0;
  margin-left: 0;
}

.content ol > li > p:first-child::before,
.content ol > li:not(:has(p))::before {
  content: counter(paragraph) ". ";
  font-weight: 700;
  margin-right: 0.25em;
}

.content main {
  max-width: var(--reader-content-max-width);
  margin: 0 auto;
  padding: 0 1.2rem;
}

.content p {
  text-indent: var(--reader-paragraph-indent);
  margin: 0.6em 0;
}

.content h1,
.content h2,
.content h3 {
  font-family: var(--reader-font-family);
  text-align: left;
  hyphens: manual;
  margin-top: 1.4em;
}

.content h1 {
  font-size: 1.9em;
  border-bottom: 1px solid rgba(128, 128, 128, 0.25);
  padding-bottom: 0.3em;
}

.content h2 {
  font-size: 1.35em;
}

/* Drop cap on the first paragraph of each chapter */
.content main > p:first-of-type::first-letter {
  font-size: 3em;
  float: left;
  line-height: 0.9;
  padding: 0.05em 0.08em 0 0;
  font-weight: 700;
}

/* Touch-friendly nav bar: bigger bar, bigger icon tap targets. */
:root {
  --menu-bar-height: 60px;
}

.menu-bar,
.menu-bar #menu-bar-hover-placeholder {
  min-height: 60px;
}

.menu-bar .icon-button,
.nav-chapters {
  min-width: 52px;
  min-height: 52px;
  font-size: 2.2rem;
  padding: 0 0.6rem;
}

.nav-chapters i,
.menu-bar .icon-button i {
  font-size: 2rem;
}

.menu-title {
  font-size: 1.7rem;
}

/* Reader settings popover */
#reader-settings-btn {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1.5rem;
  font-weight: 600;
  min-width: 52px;
  min-height: 52px;
  padding: 0 0.8rem;
}

#reader-settings-panel {
  position: fixed;
  top: calc(var(--menu-bar-height, 60px) + 4px);
  right: 1rem;
  z-index: 200;
  min-width: 300px;
  padding: 1.2rem 1.3rem 1.3rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--table-border-color, rgba(128, 128, 128, 0.35));
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
  font-family: Inter, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

#reader-settings-panel[hidden] {
  display: none;
}

#reader-settings-panel h4 {
  margin: 0 0 0.6rem;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

#reader-settings-panel label {
  display: block;
  margin: 0.7rem 0 0.25rem;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

#reader-settings-panel select,
#reader-settings-panel .stepper {
  width: 100%;
  box-sizing: border-box;
}

#reader-settings-panel select {
  padding: 0.55rem 0.6rem;
  min-height: 2.8rem;
  background: var(--sidebar-bg, var(--bg));
  color: inherit;
  border: 1px solid var(--table-border-color, rgba(128, 128, 128, 0.35));
  border-radius: 6px;
  font: inherit;
  font-size: 15px;
}

#reader-settings-panel input[type="checkbox"] {
  width: 1.3rem;
  height: 1.3rem;
  cursor: pointer;
}

#reader-settings-panel .stepper {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#reader-settings-panel .stepper button {
  flex: 0 0 auto;
  width: 3rem;
  height: 2.8rem;
  border: 1px solid var(--table-border-color, rgba(128, 128, 128, 0.35));
  background: var(--sidebar-bg, var(--bg));
  color: inherit;
  border-radius: 6px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

#reader-settings-panel .stepper button:hover {
  background: var(--theme-hover, rgba(128, 128, 128, 0.15));
}

#reader-settings-panel .stepper .value {
  flex: 1 1 auto;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#reader-settings-panel .reset-row {
  margin-top: 1rem;
  text-align: right;
}

#reader-settings-panel .reset-row button {
  background: transparent;
  border: none;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  opacity: 0.7;
}

#reader-settings-panel .reset-row button:hover {
  opacity: 1;
}

@media (max-width: 600px) {
  #reader-settings-panel {
    right: 0.5rem;
    left: 0.5rem;
  }
  :root {
    --reader-font-size: 17px;
  }
}
