/* ═══════════════════════════════════════════════════
   TGRA — CHAPTER PAGE STYLES
   Immersive Reading Experience
   ═══════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════
   BASE
   ═══════════════════════════════════════════════════ */
.chapter-page {
  padding-bottom: 100px;
}

/* ═══════════════════════════════════════════════════
   READING PROGRESS BAR
   ═══════════════════════════════════════════════════ */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  width: 0%;
  background: linear-gradient(90deg, #ff6b6b, #5f27cd, #ff6b6b);
  background-size: 200% 100%;
  animation: progressGlow 2s linear infinite;
  z-index: 9999;
  transition: width 0.15s ease;
  box-shadow: 0 0 12px rgba(255, 107, 107, 0.5);
}

@keyframes progressGlow {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ═══════════════════════════════════════════════════
   SETTINGS TOGGLE
   ═══════════════════════════════════════════════════ */
.settings-toggle {
  position: fixed;
  top: 20px;
  right: 80px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  cursor: pointer;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  color: var(--text-primary);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}

.settings-toggle:hover {
  transform: scale(1.12) rotate(45deg);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.settings-toggle.active {
  background: linear-gradient(135deg, #ff6b6b, #5f27cd);
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 25px rgba(255, 107, 107, 0.3);
}

.settings-toggle.active:hover {
  transform: scale(1.12) rotate(90deg);
}

/* ═══════════════════════════════════════════════════
   SETTINGS PANEL
   ═══════════════════════════════════════════════════ */
.settings-panel {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.settings-content {
  padding: 1.5rem;
  min-width: 280px;
}

.settings-content h4 {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.setting-row:last-child { margin-bottom: 0; }

.setting-row span {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

/* Font Controls */
.font-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.font-controls button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--glass-surface);
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.font-controls button:hover {
  background: linear-gradient(135deg, #ff6b6b, #5f27cd);
  color: white;
  border-color: transparent;
  transform: scale(1.1);
}

.font-controls button:active {
  transform: scale(0.95);
}

.font-controls #currentSize {
  min-width: 30px;
  text-align: center;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
}

/* Width Controls */
.width-controls {
  display: flex;
  gap: 6px;
}

.width-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.width-btn:hover {
  border-color: #ff6b6b;
  color: #ff6b6b;
  transform: translateY(-1px);
}

.width-btn.active {
  background: linear-gradient(135deg, #ff6b6b, #5f27cd);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

/* ═══════════════════════════════════════════════════
   READER CONTAINER
   ═══════════════════════════════════════════════════ */
.reader-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 20px;
  transition: max-width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ═══════════════════════════════════════════════════
   CHAPTER HEADER
   ═══════════════════════════════════════════════════ */
.chapter-header {
  text-align: center;
  padding: 2rem;
  margin-bottom: 2rem;
  position: relative;
}

.back-link {
  position: absolute;
  top: 1rem;
  left: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
  padding: 8px 14px;
  border-radius: 50px;
}

.back-link:hover {
  color: #ff6b6b;
  transform: translateX(-5px);
  background: rgba(255, 107, 107, 0.08);
}

/* Chapter Meta */
.chapter-meta {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0;
}

.chapter-number {
  display: inline-block;
  padding: 5px 16px;
  background: linear-gradient(135deg, #ff6b6b, #5f27cd);
  color: white;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.chapter-date,
.chapter-time {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Chapter Title */
.chapter-title {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 900;
  margin: 1rem 0 0.5rem;
  line-height: 1.15;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

body.dark-mode .chapter-title {
  background: linear-gradient(135deg, #fff, #aaa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Progress Info */
.chapter-progress-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 1rem;
}

#scrollPercent {
  font-weight: 700;
  color: #ff6b6b;
}

/* ═══════════════════════════════════════════════════
   CHAPTER CONTENT
   ═══════════════════════════════════════════════════ */
.chapter-content {
  background: var(--glass-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 2.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 8px 32px var(--glass-shadow);
  position: relative;
  overflow: hidden;
}

/* Subtle top accent */
.chapter-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #ff6b6b, #5f27cd, #1dd1a1);
  opacity: 0.6;
}

.chapter-content p {
  font-size: 1.125rem;
  line-height: 1.9;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  text-align: justify;
  hyphens: auto;
}

.chapter-content p:last-child {
  margin-bottom: 0;
}

/* ═══════════════════════════════════════════════════
   DIALOGUE
   ═══════════════════════════════════════════════════ */
.dialogue {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.06), rgba(95, 39, 205, 0.06));
  border-left: 4px solid #ff6b6b;
  border-radius: 0 16px 16px 0;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  position: relative;
  transition: all 0.3s ease;
}

.dialogue:hover {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.1), rgba(95, 39, 205, 0.1));
  transform: translateX(4px);
}

.dialogue .speaker {
  display: inline-block;
  background: linear-gradient(135deg, #ff6b6b, #5f27cd);
  color: white;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}

.dialogue p {
  margin: 0;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-primary);
  text-align: left;
}

.dialogue p::before {
  content: '\201C';
  font-size: 1.5rem;
  color: #ff6b6b;
  margin-right: 2px;
}

.dialogue p::after {
  content: '\201D';
  font-size: 1.5rem;
  color: #ff6b6b;
  margin-left: 2px;
}

/* Alternate Dialogue */
.dialogue.alt {
  border-left-color: #5f27cd;
  background: linear-gradient(135deg, rgba(95, 39, 205, 0.06), rgba(255, 107, 107, 0.06));
}

.dialogue.alt .speaker {
  background: linear-gradient(135deg, #5f27cd, #ff6b6b);
}

.dialogue.alt p::before,
.dialogue.alt p::after {
  color: #5f27cd;
}

/* ═══════════════════════════════════════════════════
   SCENE BREAK
   ═══════════════════════════════════════════════════ */
.scene-break {
  text-align: center;
  margin: 2.5rem 0;
  position: relative;
}

.scene-break::before,
.scene-break::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
}

.scene-break::before { left: 0; }
.scene-break::after { right: 0; }

.scene-break span {
  display: inline-block;
  font-size: 1.5rem;
  padding: 0 1rem;
  background: var(--glass-surface);
}

.scene-divider {
  mix-blend-mode: multiply;
  width: 150px;
  height: auto;
  display: block;
  margin: 30px auto;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* ═══════════════════════════════════════════════════
   CHAPTER END
   ═══════════════════════════════════════════════════ */
.chapter-end {
  text-align: center;
  margin: 2rem 0;
}

.end-divider {
  display: inline-block;
  padding: 12px 32px;
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.08), rgba(95, 39, 205, 0.08));
  border-radius: 30px;
  border: 1px solid var(--glass-border);
  transition: all 0.3s ease;
}

.end-divider:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.end-divider span {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════
   REACTIONS
   ═══════════════════════════════════════════════════ */
.chapter-reactions {
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.chapter-reactions p {
  margin: 0 0 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.reaction-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.reaction-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.45);
  border: 2px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reaction-btn:hover {
  background: rgba(255, 255, 255, 0.75);
  transform: translateY(-6px) scale(1.08);
}

.reaction-btn.active {
  border-color: #ff6b6b;
  background: rgba(255, 107, 107, 0.12);
}

.reaction-emoji {
  font-size: 1.8rem;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reaction-btn:hover .reaction-emoji {
  transform: scale(1.3) rotate(10deg);
}

.reaction-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.reaction-btn.active .reaction-count {
  color: #ff6b6b;
}

body.dark-mode .reaction-btn {
  background: rgba(50, 50, 70, 0.5);
}

body.dark-mode .reaction-btn:hover {
  background: rgba(70, 70, 90, 0.8);
}

/* ═══════════════════════════════════════════════════
   SHARE SECTION
   ═══════════════════════════════════════════════════ */
.share-section {
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.share-section > p {
  margin: 0 0 1rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.share-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 50px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.share-btn.twitter {
  background: #000;
  color: white;
}

.share-btn.twitter:hover {
  background: #333;
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.share-btn.copy {
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
}

.share-btn.copy:hover {
  background: rgba(255, 255, 255, 0.75);
  transform: scale(1.06) translateY(-2px);
}

.copy-confirm {
  margin-top: 0.75rem;
  color: #1dd1a1;
  font-weight: 600;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.copy-confirm.show {
  opacity: 1;
  transform: translateY(0);
}

/* ═══════════════════════════════════════════════════
   CHAPTER NAVIGATION
   ═══════════════════════════════════════════════════ */
.chapter-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  padding: 1rem;
  margin-bottom: 2rem;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.nav-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.08), rgba(95, 39, 205, 0.08));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.nav-btn:hover::before {
  opacity: 1;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.55);
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

.nav-btn.prev { justify-content: flex-start; }
.nav-btn.next { justify-content: flex-end; text-align: right; }

.nav-btn.toc {
  flex-direction: column;
  justify-content: center;
  padding: 1rem;
}

.nav-btn.toc i { font-size: 1.2rem; }
.nav-btn.toc span { font-size: 0.8rem; font-weight: 600; }

.nav-info {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.nav-info small {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-info span {
  font-weight: 600;
  font-size: 0.95rem;
}

.nav-btn i {
  font-size: 1rem;
  color: #ff6b6b;
  transition: transform 0.3s ease;
  position: relative;
  z-index: 1;
}

.nav-btn.prev:hover i { transform: translateX(-4px); }
.nav-btn.next:hover i { transform: translateX(4px); }

body.dark-mode .nav-btn {
  background: rgba(50, 50, 70, 0.5);
}

body.dark-mode .nav-btn:hover {
  background: rgba(70, 70, 90, 0.7);
}

/* ═══════════════════════════════════════════════════
   ADDITIONAL CHAPTER ELEMENTS
   ═══════════════════════════════════════════════════ */

/* Date Line */
.chapter-date-line {
  text-align: center;
  font-size: 1.1rem;
  color: #ff6b6b;
  margin: 1.5rem 0;
  padding: 0.75rem;
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.08), rgba(95, 39, 205, 0.08));
  border-radius: 12px;
  font-weight: 600;
}

/* Chapter Images */
.chapter-image {
  margin: 2rem 0;
  text-align: center;
}

.chapter-image img {
  max-width: 80%;
  border-radius: 16px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.15);
  transition: transform 0.4s ease;
}

.chapter-image img:hover {
  transform: scale(1.02);
}

/* Author's Note */
.author-note {
  margin-top: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.06), rgba(95, 39, 205, 0.06));
  border-radius: 16px;
  border-left: 4px solid #5f27cd;
  transition: all 0.3s ease;
}

.author-note:hover {
  transform: translateX(4px);
}

.author-note h3 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  color: #5f27cd;
}

.author-note p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.7;
}

/* To Be Continued */
.to-be-continued {
  text-align: center;
  font-size: 1.3rem;
  color: #ff6b6b;
  margin: 2rem 0;
  font-weight: 700;
  animation: continuePulse 2s ease-in-out infinite;
}

@keyframes continuePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.98); }
}

/* ═══════════════════════════════════════════════════
   THEME TOGGLE (Chapter Page)
   ═══════════════════════════════════════════════════ */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  cursor: pointer;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  color: var(--text-primary);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}

.theme-toggle:hover {
  transform: scale(1.12) rotate(20deg);
}

.theme-toggle i {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.dark-mode .theme-toggle {
  background: rgba(50, 50, 70, 0.8);
  border-color: rgba(255, 255, 255, 0.1);
}

/* ═══════════════════════════════════════════════════
   SCROLL TO TOP
   ═══════════════════════════════════════════════════ */
.scroll-top-btn {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #ff6b6b, #5f27cd);
  color: white;
  cursor: pointer;
  z-index: 999;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.8);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 6px 25px rgba(255, 107, 107, 0.4);
}

.scroll-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.scroll-top-btn:hover {
  transform: translateY(-6px) scale(1.12);
  box-shadow: 0 12px 35px rgba(255, 107, 107, 0.5);
}

.scroll-top-btn:active {
  transform: scale(0.95);
}

/* Floating dock visibility */
.chapter-page .floating-dock {
  opacity: 1;
  visibility: visible;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .settings-toggle {
    top: 15px;
    right: 70px;
    width: 42px;
    height: 42px;
  }

  .settings-panel {
    right: 10px;
    left: 10px;
  }

  .settings-content { min-width: auto; }

  .chapter-header { padding: 1.5rem 1rem; }

  .back-link {
    position: static;
    margin-bottom: 1rem;
    display: inline-flex;
  }

  .chapter-title { font-size: 1.8rem; }

  .chapter-content {
    padding: 1.5rem;
    border-radius: 20px;
  }

  .chapter-content p {
    font-size: 1rem;
    text-align: left;
  }

  .dialogue { padding: 1rem; }

  .chapter-nav {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .nav-btn.toc {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: center;
    gap: 10px;
  }

  .nav-info span { font-size: 0.85rem; }

  .theme-toggle {
    top: 15px;
    right: 15px;
    width: 42px;
    height: 42px;
  }

  .scroll-top-btn {
    bottom: 90px;
    right: 15px;
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 480px) {
  .reader-container { padding: 10px; }
  .chapter-meta { gap: 0.5rem; }
  .chapter-date, .chapter-time { font-size: 0.75rem; }
  .reaction-btn { padding: 10px 14px; }
  .reaction-emoji { font-size: 1.5rem; }
  .chapter-image img { max-width: 100%; }
}
