/* Advanced responsive reader additions. */

.df-container .df-ui-download,
.df-container .df-ui-sound {
  display: none !important;
}

.df-advanced-close {
  display: none;
}

.df-advanced-reopen {
  display: none;
}

html.df-advanced-reader-open,
body.df-advanced-reader-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

.df-container.df-advanced-vertical {
  position: relative;
  display: block;
  height: 82vh;
  height: min(82vh, 900px);
  min-height: 420px;
  overflow-x: auto !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  touch-action: pan-y !important;
  -webkit-overflow-scrolling: touch;
  background: #777;
}

.df-vertical-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-height: 100%;
  padding: 68px 12px 138px;
  box-sizing: border-box;
}

.df-vertical-page {
  position: relative;
  flex: 0 0 auto;
  max-width: none;
  overflow: hidden;
  scroll-snap-align: start;
  background: #fff;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.28);
}

.df-vertical-page canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  background: #fff;
}

.df-vertical-placeholder,
.df-vertical-page-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #777;
  font: 600 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.df-page-rendering::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px;
  border: 3px solid rgba(0, 0, 0, 0.15);
  border-top-color: #168db5;
  border-radius: 50%;
  animation: df-vertical-spin 0.8s linear infinite;
}

@keyframes df-vertical-spin {
  to {
    transform: rotate(360deg);
  }
}

.df-vertical-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 5;
  max-width: calc(100% - 40px);
  transform: translate(-50%, -50%);
  padding: 12px 18px;
  border-radius: 8px;
  background: rgba(20, 20, 20, 0.88);
  color: #fff;
  text-align: center;
  font: 600 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.df-vertical-loading.df-vertical-error {
  background: #8b1f1f;
}

.df-vertical-indicator {
  position: sticky;
  right: 0;
  bottom: 72px;
  z-index: 20;
  width: max-content;
  min-width: 72px;
  margin: -110px auto 64px;
  padding: 9px 13px;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.82);
  color: #fff;
  text-align: center;
  font: 600 13px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  pointer-events: none;
}

.df-vertical-zoom-controls {
  position: sticky;
  bottom: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  margin: -54px auto 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.9);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.32);
}

.df-vertical-zoom-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 46px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0;
  background: transparent;
  color: #fff;
  font: 600 22px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.df-vertical-zoom-controls button:last-child {
  border-right: 0;
}

.df-vertical-zoom-controls button:active,
.df-vertical-zoom-controls button:focus-visible {
  background: rgba(255, 255, 255, 0.16);
}

.df-vertical-zoom-controls button:focus-visible {
  outline: 2px solid #29c5f6;
  outline-offset: -3px;
}

.df-vertical-zoom-controls button:disabled {
  opacity: 0.38;
  cursor: default;
}

.df-vertical-zoom-controls .df-vertical-zoom-reset {
  min-width: 76px;
  font-size: 13px;
}

.df-container.df-advanced-vertical.df-vertical-zoomed {
  touch-action: pan-x pan-y !important;
}

@media (max-width: 1024px), (pointer: coarse) {
  .df-container.df-advanced-vertical[data-advanced-fullscreen-closed="true"] {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: min(72vh, 680px) !important;
    min-height: 420px !important;
    max-height: 680px !important;
    margin: 12px 0 !important;
    overflow: hidden !important;
    overscroll-behavior: auto;
    touch-action: pan-y !important;
    background: #343434;
  }

  .df-container.df-advanced-vertical[data-advanced-fullscreen-closed="true"] > .df-vertical-indicator,
  .df-container.df-advanced-vertical[data-advanced-fullscreen-closed="true"] > .df-vertical-zoom-controls,
  .df-container.df-advanced-vertical[data-advanced-fullscreen-closed="true"] > .df-advanced-close {
    display: none !important;
  }

  .df-container.df-advanced-vertical[data-advanced-fullscreen-closed="true"] > .df-vertical-pages {
    display: flex !important;
    width: 100% !important;
    min-height: 100%;
    gap: 0;
    padding: 12px;
    overflow: hidden;
    pointer-events: none;
  }

  .df-container.df-advanced-vertical[data-advanced-fullscreen-closed="true"] .df-vertical-page {
    display: none;
  }

  .df-container.df-advanced-vertical[data-advanced-fullscreen-closed="true"] .df-vertical-page.df-closed-preview-page {
    display: block;
  }

  .df-container.df-advanced-vertical[data-advanced-fullscreen-closed="true"] > .df-advanced-reopen {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: 12px;
    border: 0;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.06);
    box-shadow: none;
    color: #fff;
    text-align: left;
    cursor: pointer;
    touch-action: pan-y;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .df-advanced-reopen-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    max-width: calc(100% - 24px);
    min-height: 52px;
    padding: 10px 18px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 10px;
    background: rgba(18, 18, 18, 0.9);
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.34);
  }

  .df-advanced-reopen-icon {
    flex: 0 0 auto;
    font: 400 24px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  .df-advanced-reopen-text {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .df-advanced-reopen-text strong {
    white-space: nowrap;
    font: 700 15px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  .df-advanced-reopen-text small {
    min-height: 13px;
    color: rgba(255, 255, 255, 0.76);
    font: 500 12px/1.1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  .df-advanced-reopen:focus-visible {
    outline: 3px solid #29c5f6;
    outline-offset: -6px;
  }

  .df-container.df-advanced-fullscreen {
    touch-action: pan-x;
  }

  .df-container.df-advanced-fullscreen.df-advanced-vertical {
    overflow-x: auto !important;
    overflow-y: auto !important;
    scroll-snap-type: y proximity;
    touch-action: pan-y !important;
  }

  .df-container.df-advanced-fullscreen.df-advanced-vertical.df-vertical-zoomed {
    touch-action: pan-x pan-y !important;
  }

  .df-container.df-advanced-fullscreen.df-advanced-vertical.df-vertical-pinching {
    scroll-behavior: auto;
  }

  .df-container.df-advanced-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147483000 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
  }

  .df-advanced-fullscreen .df-advanced-close {
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    z-index: 2147483640;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 44px;
    min-height: 44px;
    padding: 8px 13px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    background: rgba(18, 18, 18, 0.86);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
    color: #fff;
    font: 600 13px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .df-advanced-fullscreen .df-vertical-indicator {
    position: fixed;
    right: auto;
    bottom: max(70px, calc(env(safe-area-inset-bottom) + 62px));
    left: 50%;
    margin: 0;
    transform: translateX(-50%);
  }

  .df-advanced-fullscreen .df-vertical-zoom-controls {
    position: fixed;
    right: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 50%;
    z-index: 2147483635;
    margin: 0;
    transform: translateX(-50%);
  }

  .df-advanced-close span {
    font-size: 25px;
    font-weight: 300;
    line-height: 18px;
  }

  .df-advanced-close:focus-visible {
    outline: 3px solid #29c5f6;
    outline-offset: 2px;
  }

  .df-advanced-fullscreen .df-ui-controls {
    bottom: max(10px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 480px) {
  .df-advanced-close strong {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* Automatic category-based related books displayed after an individual book. */
.df-related-books {
  width: 100%;
  margin: 34px auto 24px;
  padding: 0 12px;
  box-sizing: border-box;
}

.df-related-books-title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 22px;
  color: inherit;
  font: 700 22px/1.25 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: center;
}

.df-related-books-title::before,
.df-related-books-title::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: currentColor;
  opacity: 0.35;
}

.df-related-books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 24px 18px;
  align-items: start;
}

.df-related-book-card {
  min-width: 0;
  margin: 0;
  text-align: center;
}

.df-related-books ._df_thumb {
  display: inline-block;
  width: 140px;
  max-width: 100%;
  margin: 0 auto;
  vertical-align: top;
}

.df-related-books ._df_book-title {
  bottom: 0;
  opacity: 1;
}

@media (max-width: 480px) {
  .df-related-books {
    margin-top: 26px;
    padding: 0 8px;
  }

  .df-related-books-title {
    gap: 10px;
    margin-bottom: 18px;
    font-size: 19px;
  }

  .df-related-books-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 8px;
  }
}
