/* ==== 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);
}

.fb-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
}

.fb-overlay[hidden] {
  display: none !important;
}

.blur-behind {
  filter: blur(2px);
  pointer-events: none;
}

.fb-overlay.active {
  display: grid;
}

.fb-modal {
  width: min(92vw, 640px);
  background: #0c0f10;
  color: #f4f9f8;
  border: 1px solid rgba(0,255,200,.35); /* ← needs decimal */
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 0 32px rgba(0,255,200,.25); /* ← also needs decimal */
  position: relative;
}

.fb-modal h3 {
  margin: 0 0 .5rem;
  color: #00ffcc;
  text-align: center;
}

.fb-modal label {
  display: block;
  margin: .8rem 0;
  font-size: .95rem;
}

/* ⭐ Star rating styles */
.fb-rating .stars {
  display: inline-flex;
  gap: 6px;
  direction: rtl;        /* lets us fill from right-to-left so hovering works nicely */
}

/* ⭐ Group wrapper */
.fb-ratings { margin: 4px 0 6px; }
.fb-rating {  display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.fb-rating .fb-aspect { display:inline-block; min-width: 90px; font-weight:600; }

/* Stars (shared) */
.fb-rating .stars {
  display: inline-flex;
  gap: 6px;
  direction: rtl;     /* lets selected/hover fill leftwards visually */
  vertical-align: middle;
}
.fb-rating .stars input { display: none; }
.fb-rating .stars label {
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #2b3a3a;     /* base */
  transition: transform .1s ease-in-out;
}
.fb-rating .stars label:hover,
.fb-rating .stars label:focus { transform: scale(1.08); }
.fb-rating .stars input:checked ~ label { color: #ffd900; }   /* selected fill */
.fb-rating .stars label:focus-visible { outline: 2px solid #fbff00; outline-offset: 2px; }

#ratingHelp { display:block; margin-top:4px; opacity:.85; }

/* --- Gold stars for the new .fb-stars system --- */
.fb-stars .stars span { 
  color: #888;                 /* base grey */
  transition: color .15s ease; 
}

.fb-stars .stars span.active {
  color: gold !important;      /* force gold on */
  filter: drop-shadow(0 0 4px rgba(255,215,0,.45));
}


/* Compact gold star row for feedback modal */
.fb-stars { margin: 0.25rem 0 0.25rem; }
.fb-stars label { display: flex;
  align-items: center;
  gap: 6px;
  margin: 0.1rem 0; }

.fb-stars .stars {
  font-size: 1.35rem;
  letter-spacing: 3px;
  color: #888;
  cursor: pointer;
  user-select: none;
}
.fb-stars .stars span { transition: color .15s ease; }



.fb-rating .stars input {
  display: none;         /* hide the radios, we click the labels */
}

.fb-rating .stars label {
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  filter: drop-shadow(0 0 2px rgba(0,255,200,.25));
  transition: transform .1s ease-in-out;
}

.fb-rating .stars label:hover,
.fb-rating .stars label:focus {
  transform: scale(1.1);
}

/* default/star colors */
.fb-rating .stars label {
  color: #2b3a3a;
}

/* when a radio is checked, color all labels to its left (thanks to rtl) */
.fb-rating .stars input:checked ~ label {
  color: #00ffcc;
}

/* keyboard focus ring for accessibility */
.fb-rating .stars label:focus-visible {
  outline: 2px solid #00ffcc;
  outline-offset: 2px;
}

.fb-rating small {
  display: block;
  margin-top: .25rem;
  opacity: .8;
}

/* Make the modal scroll on small screens */
.fb-modal {
  max-height: 92vh;      /* never exceed viewport height */
  overflow: auto;        /* scroll the modal body, not the page */
  display: block;        /* ensure sticky children work reliably */
}

/* Keep the title visible while scrolling */
.fb-modal h3 {
  position: sticky;
  top: 0;
  background: #0c0f10;
  padding-top: .25rem;
  padding-bottom: .5rem;
  z-index: 2;
  border-bottom: 1px solid rgba(0,255,200,.15);
}

/* Keep the buttons visible at the bottom */
.fb-actions {
  position: sticky;
  bottom: 0;
  background: #0c0f10;
  padding-top: .6rem;
  margin-top: 1rem;
  border-top: 1px solid rgba(0,255,200,.15);
  z-index: 2;
}

/* Mobile niceties: slightly smaller stars/labels so everything fits */
@media (max-width: 480px) {
  .fb-rating .fb-aspect { min-width: 80px; }
  .fb-rating .stars label { font-size: 1.3rem; }
  #fbMessage { min-height: 6.5rem; }
}


/* ← this one’s crucial: add the dot before fb-modal the second time */
.fb-modal input,
.fb-modal textarea {
  width: 100%;
  background: #101516;
  color: #eafffb;
  border: 1px solid #244;
  border-radius: 8px;
  padding: .6rem .7rem;
  font-family: inherit;
}

.fb-remember {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .4rem;
}

.fb-actions {
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
  margin-top: .6rem;
}

/* ← add the dot before fb-send here */
.fb-cancel,
.fb-send {
  border: 0;
  border-radius: 10px;
  padding: .6rem 1rem;
  cursor: pointer;
  font-family: Georgia, serif;
}

.fb-cancel {
  background: #2b2b2b;
  color: #ddd;
}

.fb-send {
  background: #00bfa6;
  color: #00110d;
  box-shadow: 0 0 14px rgba(0,255,200,.35);
}

.fb-close {
  position: absolute;
  top: 8px;
  right: 12px;
  border: 0;
  background: transparent;
  color: #8ff;
  font-size: 1.6rem;
  cursor: pointer;
}

.fb-toast {
  position: fixed;
  left: 50%;
  top: 22px;
  transform: translateX(-50%);
  background: #111;
  color: #00ffcc;
  border: 1px solid teal;
  border-radius: 10px;
  padding: .6rem 1rem;
  z-index: 10000;
  box-shadow: 0 0 16px rgba(0,255,200,.5);
}

/* ==== Disable Text Selection & Copy ==== */
body, p, div, span, section, article {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body {
  touch-action: manipulation;
}

