/**
 * Reader Core CSS - Essential Styles for Web, EPUB & PDF Reader
 */

/* ==========================================================================
   1. CUSTOM SCROLLBARS
   ========================================================================== */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.3);
  border-radius: 9999px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(156, 163, 175, 0.5);
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb,
[data-theme="dark"] .custom-scrollbar::-webkit-scrollbar-thumb,
[data-theme="oled"] .custom-scrollbar::-webkit-scrollbar-thumb,
[data-theme="darker"] .custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] .custom-scrollbar::-webkit-scrollbar-thumb:hover,
[data-theme="oled"] .custom-scrollbar::-webkit-scrollbar-thumb:hover,
[data-theme="darker"] .custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ==========================================================================
   2. EPUB CONTENT & TYPOGRAPHY
   ========================================================================== */
.epub-content {
  width: 100%;
}

.epub-chapter {
  margin-bottom: 3rem;
}

.epub-chapter h1,
.epub-chapter h2,
.epub-chapter h3,
.epub-chapter h4,
.epub-chapter h5,
.epub-chapter h6 {
  font-weight: 700;
  margin: 1.5em 0 0.6em;
  line-height: 1.3;
}

.epub-chapter h1 {
  font-size: 1.75em;
  text-align: center;
  margin: 2em 0 1em;
}

.epub-chapter h2 {
  font-size: 1.45em;
}

.epub-chapter h3 {
  font-size: 1.25em;
}

.epub-chapter p {
  margin-bottom: 1.25em;
  text-align: inherit;
  hyphens: auto;
}

.epub-chapter p:first-of-type {
  text-indent: 0;
}

/* Paragraph indentation controlled via user settings */
.indent-paragraphs .epub-chapter p + p {
  text-indent: var(--indent-size, 1.5rem);
}

article:not(.indent-paragraphs) .epub-chapter p + p {
  text-indent: 0;
}

/* EPUB Images & Media */
.epub-chapter img,
.epub-chapter svg,
.epub-chapter image {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5em auto;
  border-radius: 0.5rem;
  filter: none !important;
  mix-blend-mode: normal !important;
  opacity: 1 !important;
}

:is([data-theme="dark"], [data-theme="oled"], [data-theme="darker"]) .epub-chapter img {
  opacity: 0.88;
  transition: opacity 0.3s ease;
}

:is([data-theme="dark"], [data-theme="oled"], [data-theme="darker"]) .epub-chapter img:hover {
  opacity: 1;
}

/* Links & Quotes */
.epub-chapter a {
  color: #6366f1;
  text-decoration: underline;
  text-underline-offset: 2px;
}

:is([data-theme="dark"], [data-theme="oled"], [data-theme="darker"]) .epub-chapter a {
  color: #818cf8;
}

.epub-chapter blockquote {
  margin: 1.5em 0;
  padding: 0.875em 1.25em;
  border-left: 4px solid #6366f1;
  background: rgba(99, 102, 241, 0.06);
  border-radius: 0 0.5rem 0.5rem 0;
  font-style: italic;
}

:is([data-theme="dark"], [data-theme="oled"], [data-theme="darker"]) .epub-chapter blockquote {
  background: rgba(99, 102, 241, 0.12);
  border-left-color: #818cf8;
}

/* Code blocks inside EPUB */
.epub-chapter pre,
.epub-chapter code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}

.epub-chapter pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 1em;
  border-radius: 0.5rem;
  overflow-x: auto;
}

:is([data-theme="dark"], [data-theme="oled"], [data-theme="darker"]) .epub-chapter pre {
  background: rgba(255, 255, 255, 0.05);
}

.epub-chapter-error {
  padding: 1.5rem;
  text-align: center;
  color: #ef4444;
  font-style: italic;
}

.chapter-separator {
  border: none;
  border-top: 1px solid rgba(156, 163, 175, 0.2);
  margin: 3rem auto;
  width: 60%;
}

/* ==========================================================================
   3. UNIVERSAL THEME OVERRIDES (Fix hardcoded white/black publisher styles)
   ========================================================================== */
.epub-chapter *:not(a):not(img):not(svg):not(video):not(pre):not(code):not(hr) {
  background-color: transparent !important;
  color: inherit !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

/* ==========================================================================
   4. GLOSSARY TERM INTERACTION
   ========================================================================== */
.glossary-term {
  position: relative;
  transition: all 0.2s ease;
  cursor: pointer;
  color: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.glossary-term:hover {
  background: rgba(99, 102, 241, 0.12);
  border-radius: 4px;
}

:is([data-theme="dark"], [data-theme="oled"], [data-theme="darker"]) .glossary-term:hover {
  background: rgba(129, 140, 248, 0.18);
}

/* ==========================================================================
   5. PDF MODE CANVAS & TEXT LAYER
   ========================================================================== */
.pdf-page-wrapper {
  position: relative;
  margin: 0 auto !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: hidden;
  line-height: 0 !important;
  display: block;
}

.pdf-page-wrapper canvas {
  display: block;
  margin: 0 auto;
}

.pdf-text-layer {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  opacity: 0.25;
  line-height: 1.0;
}

.pdf-text-layer span {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}