/* ==== Base Reset ==== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ==== Body and Theme ==== */
body {
  background-color: #000000;
  color: #e0e0e0;
  font-family: 'Georgia', serif;
  line-height: 1.7;
  padding: 2rem;
}

/* ==== Header ==== */
header {
  text-align: center;
  margin-top: 4rem; /* 👈 This adds that breathing room above the title */
  margin-bottom: 1rem; /* Optional: controls space below it */
}

h1 {
  font-size: 3rem;
  color: #f9f9f9;
}

h2 {
  font-size: 2rem;
  color: #ffffff;
  font-weight: 600;
  text-align: center;
  margin-top: 2rem;
  margin-bottom: 1rem;
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.1);
  border-bottom: 2px solid #ffffff33;
  display: inline-block;
  padding-bottom: 0.4rem;
  margin-left: auto;
  margin-right: auto;
}

h3 {
  font-size: 1.5rem;
  color: #dddddd;
  font-weight: 500;
  margin-top: 2rem;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 6px;
}

/* Light Mode (default) */
.subtitle {
  color: #000;
  transition: color 0.3s ease;
}

/* Dark Mode */
.chapter-title {
  color: #000;
  transition: color 0.3s ease;
}

body.dark-mode .chapter-title {
  color: #fff;
}



/* ==== Main Book Content ==== */
main {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  padding: 0 2rem;
}

.book h2 {
  margin-top: 5rem;
  margin-bottom: 3rem;
  font-size: 3rem;
  text-align: center;
  letter-spacing: 1px;
  transition: color 0.3s ease;
}

.book {
  font-size: 16px; /* This is the default that JS will override */
}

.book p {
  margin: 0.5rem 0;
  text-indent: 2em;
  line-height: 1.7;
  text-align: left;
  font-weight: normal !important;
  font-family: 'Georgia', serif !important;
  font-weight: normal !important;
  font-family: 'Georgia', serif !important;
  font-size: inherit !important;
}

.book p:empty {
  display: none;
}

.book p, .book strong, .book em, .book span {
  text-transform: none;
}

/* ==== Footer ==== */
footer {
  text-align: center;
  margin-top: 3rem;
  font-size: 0.9rem;
  color: #888;
}

/* ==== Cleaned Up & Mobile-Friendly ==== */
@media (max-width: 600px) {
  body {
    padding: 1rem;
    font-size: 1rem;
    line-height: 1.6;
  }

  main, section, article {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  h1 {
    font-size: 1.6rem;
    text-align: center;
    line-height: 1.4;
    margin: 2rem 0;
    white-space: normal;
    word-break: break-word;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
  }

  .book h2 {
    font-size: 1.5rem;
    margin-top: 4rem;
    margin-bottom: 1.5rem;
    text-align: center;
  }

  .book p {
    text-indent: 1.5em;
    margin: 0.3rem 0;
    line-height: 1.6;
    font-size: 0.95rem;
  }

  .book p:empty {
    display: none;
  }

.chapter-jump select {
  width: 85%;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
}
}

/* ==== Chapter Dropdown Styles ==== */
.chapter-jump {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
  margin-bottom: 2rem;
}

.chapter-jump select {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border-radius: 6px;
  border: none;
  background-color: #222;
  color: #fff;
  font-family: 'Georgia', serif;
}

.chapter-jump select:focus {
  outline: 2px solid #ffcc66;
}



/* ==== Enforce Consistent Text Size in Story ==== */
.book p,
.book div,
.book h3,
.book h4,
.book span {
  font-size: 1rem !important;
  line-height: 1.7;
  font-weight: normal;
}

/* ==== hamburger menu ==== */
/* ==== Hamburger Button ==== */
.hamburger-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
}

.hamburger {
  background-color: #222;
  color: #fff;
  font-size: 1.5rem;
  border: none;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: 5px;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 2.5rem;
  right: 0;
  background-color: #333;
  border: 1px solid #444;
  border-radius: 5px;
  padding: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  width: 200px;
}

.dropdown-menu a {
  display: block;
  color: #fff;
  text-decoration: none;
  padding: 0.4rem 0;
  font-size: 0.95rem;
}

.dropdown-menu a:hover {
  background-color: #555;
}


/* === Theme Toggle Styling === */
.theme-toggle {
  position: fixed;
  top: 7rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
}

.theme-toggle input {
  display: none;
}

.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #444;
  border-radius: 50px;
  width: 60px;
  height: 30px;
  padding: 0 5px;
  position: relative;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.toggle-label .icon {
  font-size: 16px;
  z-index: 2;
  pointer-events: none;
}

.toggle-ball {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.3s ease;
  z-index: 1;
}

#theme-switch:checked + .toggle-label .toggle-ball {
  transform: translateX(30px);
}

/* Optional: Light/Dark Theme Styles */

.theme-toggle {
  position: relative;
  display: flex;
  justify-content: center;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  z-index: 999;
}


body.light-mode {
  background-color: #ffffff;
  color: #000000;
}

body.dark-mode {
  background-color: #000000;
  color: #ffffff;
}
/* Title and Chapter Header Colors */
body.light-mode h1,
body.light-mode .book h2 {
  color: #000000;
}

body.dark-mode h1,
body.dark-mode .book h2 {
  color: #ffffff;
}

.back-to-library {
  position: relative;
  display: inline-block;
  margin: 1rem 0 0 1rem; /* Top space, no crowding */
  color: #fff;
  font-size: 0.95rem;
  text-decoration: none;
  background-color: #444;
  padding: 0.4rem 0.7rem;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}


.back-to-library:hover {
  background-color: #666;
}

/* Light mode variant */
body.light-mode .back-to-library {
  color: #000;
  background-color: #ddd;
}

body.light-mode .back-to-library:hover {
  background-color: #bbb;
}

/* ==== Back to Top Button ==== */
#back-to-top {
  text-align: center;
  margin: 4rem 0 2rem;
}

#back-to-top a {
  display: inline-block;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  color: #ffffff;
  background-color: #444;
  border-radius: 6px;
  text-decoration: none;
  transition: background-color 0.3s ease;
}

#back-to-top a:hover {
  background-color: #666;
}

/* Light mode version */
body.light-mode #back-to-top a {
  color: #000000;
  background-color: #ddd;
}

body.light-mode #back-to-top a:hover {
  background-color: #bbb;
}

/* ==== Reading Progress Bar ==== */
#scroll-progress-container {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background-color: rgba(36, 120, 245, 0.1); /* faint base */
  z-index: 9999;
}

#scroll-progress-bar {
  height: 100%;
  width: 0%;
  background-color: #a0f0e0; /* pale teal */
  transition: width 0.2s ease-out;
}

.back-button {
  display: inline-block;
  padding: 8px 12px;
  background-color: #444;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  font-weight: bold;
  font-size: 0.9rem;
  margin: 10px;
  max-width: 90%;
  text-align: center;
}

.back-button:hover {
  background-color: #666;
}

@media (max-width: 600px) {
  .back-button {
    font-size: 0.85rem;
    padding: 6px 10px;
    margin: 8px;
  }
}

.text-size-selector {
  margin-top: 10px;
  margin-bottom: 10px;
  text-align: center;
}

.text-size-selector select {
  padding: 6px;
  font-size: 1em;
  border-radius: 4px;
}

/* ==== Font Size Inheritance Fix for Chapters ==== */
.book,
.book section,
.book section[id^="chapter"],
.book section[id^="chapter"] p {
  font-size: inherit !important;
}

/* === Font Size Scaling Fix === */
.book {
  font-size: 16px; /* base size for all content */
}

.book,
.book p,
.book li,
.book span,
.book section,
.book section[id^="chapter"],
.book section[id^="chapter"] p {
  font-size: inherit;
  font-family: 'Georgia', serif !important;
}

/* Restore proper size to chapter titles */



h1, h2, h3, h4, h5, h6 {
  text-align: center !important;
  margin-left: auto !important;
  margin-right: auto !important;
  display: block;
}

h1, h2, h3, h4, h5, h6 {
  border-bottom: none !important;
  text-decoration: none !important;
}

.book h1,
.book h2,
.book h3 {
  font-size: 2.8rem !important;
  font-weight: 700;
  
  text-align: center;
  line-height: 1.3;
}



html body .book section[id^="chapter"] > h2 {
  all: unset;
  font-size: 2.8rem !important;
  font-weight: 700 !important;
  color: #ffffff
  font-family: 'Georgia', serif !important;
  text-align: center !important;
  line-height: 1.3 !important;
  margin-top: 5rem !important;
  margin-bottom: 3rem !important;
  display: block !important;
}




.book section[id^="chapter"] h2 {
  all: unset;
  font-size: 2.8rem;
  font-weight: 700 !important;
  color: #ffffff
  text-align: center !important;
  line-height: 1.3 !important;
  font-family: 'Georgia', serif !important;
  margin-top: 5rem !important;
  margin-bottom: 3rem !important;
  display: block !important;
}

/* Adjust main title and chapter headers */
.book h1 {
  font-size: 2rem !important;
  font-weight: 700 !important;
  text-align: center !important;
  font-family: 'Georgia', serif !important;
  color: #ffffff
  margin-top: 3rem !important;
  margin-bottom: 2rem !important;
}

.book section[id^="chapter"] h2 {
  font-size: 1.6rem !important;
  font-weight: 600 !important;
  text-align: center !important;
  font-family: 'Georgia', serif !important;
  color: #000000
  margin-top: 3rem !important;
  margin-bottom: 2rem !important;
}

@media screen and (max-width: 600px) {
  .book h1 {
    font-size: 1.8rem !important;
  }

  .chapter-content h2,
  .book h2,
  section[id^="chapter"] h2 {
    font-size: 1.5rem !important;
    line-height: 1.2;
    margin-top: 3rem;
    margin-bottom: 2rem;
  }

  .book p {
    font-size: 1rem;
  }
}

@media screen and (max-width: 600px) {
  .book section[id^="chapter"] h2 {
    font-size: 1.8rem !important;
  }
}

@media (max-width: 768px) {
  .theme-toggle {
    top: 0rem;         /* Move it higher or lower on mobile */
    left: 1rem;        /* Push it toward the left side */
    transform: none;   /* Remove center transform */
  }
}

.chapter-text-size-selector {
  text-align: center;
  margin: 1rem auto 2rem;
}

.chapter-text-size-selector select {
  padding: 6px 12px;
  font-size: 1rem;
  border-radius: 4px;
  font-family: 'Georgia', serif;
  background-color: #222;
  color: #fff;
  border: none;
}

body.light-mode .chapter-text-size-selector select {
  background-color: #eee;
  color: #000;
}

/* === Text Size Selector Styles === */
.text-size-selector {
  margin: 1rem auto;
  text-align: center;
  font-family: 'Georgia', serif;
}

.text-size-selector select {
  padding: 0.3em;
  font-size: 1em;
  border-radius: 5px;
  border: 1px solid #999;
}

/* 🔥 FINAL OVERRIDE FOR THEME-AWARE TITLE COLORS */

body.light-mode html body .book section[id^="chapter"] > h2 {
  color: #000000 !important;
}

body.dark-mode html body .book section[id^="chapter"] > h2 {
  color: #ffffff !important;
}

/* 💬Comment Button */
.chapter-button-container {
  display: flex;
  justify-content: center;
  margin: 2em 0;
}

.chapter-button {
  background-color: #000; /* black button */
  color: #fff;            /* white text */
  padding: 0.75em 1.5em;
  border-radius: 999px;   /* super rounded */
  font-size: 1.1em;
  font-weight: bold;
  text-decoration: none;
  box-shadow: 0 0 10px #f3efef80;
  transition: all 0.3s ease;
}

.chapter-button:hover {
  background-color: #1a1a1a;
  transform: scale(1.05);
}

/* === Anti-copy + Blur-on-blur + Watermark === */
.noselect, .noselect * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.blurred .book {  /* blur the reading area when tab not active */
  filter: blur(8px);
  transition: filter 150ms ease;
}

/* Hide preview in print */
@media print {
  body { display: none !important; }
}

/* Subtle, full-page watermark (pointer-events off so it can't be clicked) */
.watermark {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: 0.20;
  mix-blend-mode: multiply;
}
.watermark::before {
  content: attr(data-watermark);
  position: absolute;
  top: -20%;
  left: -20%;
  width: 200%;
  height: 200%;
  display: grid;
  place-items: center;
  transform: rotate(-25deg);
  font: 600 18px/1.2 Georgia, serif;
  color: #ffffff;
  letter-spacing: 1px;
  text-align: center;
}
