/* ==========================================================================
   Adhore Khuwab - Novel Reader Stylesheet (Book Page-by-Page Experience)
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables & Themes
   -------------------------------------------------------------------------- */
:root {
  /* Fonts */
  --font-serif: 'Merriweather', 'Lora', Georgia, 'Times New Roman', serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-display: 'Cinzel', 'Playfair Display', Georgia, serif;

  /* Sizing & Spacing */
  --reader-font-size: 18px;
  --reader-line-height: 1.8;
  --reader-max-width: 680px;
  --font-family-current: var(--font-serif);

  /* Radius & Shadows */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --transition-page: 0.35s cubic-bezier(0.25, 1, 0.5, 1);

  /* Z-indices */
  --z-progress: 100;
  --z-header: 90;
  --z-bottom-nav: 80;
  --z-drawer: 120;
  --z-toast: 150;
}

/* --- THEME 1: Obsidian Dark (Eye-Care Ergonomic Default) --- */
[data-theme="dark"],
:root {
  --bg-primary: #121419;
  --bg-secondary: #1a1d24;
  --bg-tertiary: #222730;
  --bg-card: rgba(26, 29, 36, 0.88);
  --bg-card-border: rgba(255, 255, 255, 0.07);
  --bg-blur: rgba(18, 20, 25, 0.92);

  --text-primary: #ded7ce;      /* Warm soft linen for headings */
  --text-secondary: #9aa2ad;    /* Relaxed secondary */
  --text-muted: #6a727f;
  --text-novel: #c7cdd6;        /* Soft muted book-slate tone: zero harsh glare */

  --accent-gold: #d4a574;
  --accent-gold-hover: #e2b88b;
  --accent-gold-rgb: 212, 165, 116;
  --accent-rose: #de7f9a;
  --accent-blue: #6ca0e8;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(212, 165, 116, 0.12);

  --divider-color: rgba(255, 255, 255, 0.08);
  --quote-border: #d4a574;
  --msg-bubble-bg: #1f242d;
  --msg-bubble-text: #ded7ce;
}

/* --- THEME 2: AMOLED Pure Black (Comfort Muted) --- */
[data-theme="amoled"] {
  --bg-primary: #000000;
  --bg-secondary: #0c0d10;
  --bg-tertiary: #15171c;
  --bg-card: #0f1013;
  --bg-card-border: #202228;
  --bg-blur: rgba(0, 0, 0, 0.92);

  --text-primary: #d6cfc5;
  --text-secondary: #8e949e;
  --text-muted: #60656e;
  --text-novel: #c0c6cf;

  --accent-gold: #cb9b69;
  --accent-gold-hover: #dcad7d;
  --accent-gold-rgb: 203, 155, 105;
  --accent-rose: #d6718d;
  --accent-blue: #5d97e2;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.8);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.9);
  --shadow-glow: 0 0 20px rgba(203, 155, 105, 0.1);

  --divider-color: #1a1c22;
  --quote-border: #cb9b69;
  --msg-bubble-bg: #14161b;
  --msg-bubble-text: #d6cfc5;
}

/* --- THEME 3: Warm Sepia (Paperback feel) --- */
[data-theme="sepia"] {
  --bg-primary: #fbf0d9;
  --bg-secondary: #f4e3c1;
  --bg-tertiary: #eed8ad;
  --bg-card: rgba(244, 227, 193, 0.9);
  --bg-card-border: rgba(92, 64, 51, 0.15);
  --bg-blur: rgba(251, 240, 217, 0.92);

  --text-primary: #382923;
  --text-secondary: #705446;
  --text-muted: #8c7365;
  --text-novel: #2d1e18;

  --accent-gold: #9d5b24;
  --accent-gold-hover: #b86e2f;
  --accent-gold-rgb: 157, 91, 36;
  --accent-rose: #be3a5f;
  --accent-blue: #2f6690;

  --shadow-sm: 0 2px 8px rgba(92, 64, 51, 0.08);
  --shadow-md: 0 8px 24px rgba(92, 64, 51, 0.12);
  --shadow-glow: 0 0 20px rgba(157, 91, 36, 0.1);

  --divider-color: rgba(92, 64, 51, 0.15);
  --quote-border: #9d5b24;
  --msg-bubble-bg: #eed8ad;
  --msg-bubble-text: #2d1e18;
}

/* --- THEME 4: Light (Clean Minimalist) --- */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e2e8f0;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-border: rgba(148, 163, 184, 0.2);
  --bg-blur: rgba(248, 250, 252, 0.92);

  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-novel: #1e293b;

  --accent-gold: #c27803;
  --accent-gold-hover: #d9822b;
  --accent-gold-rgb: 194, 120, 3;
  --accent-rose: #db2777;
  --accent-blue: #2563eb;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 20px rgba(194, 120, 3, 0.1);

  --divider-color: rgba(148, 163, 184, 0.25);
  --quote-border: #c27803;
  --msg-bubble-bg: #e2e8f0;
  --msg-bubble-text: #0f172a;
}

/* --------------------------------------------------------------------------
   Reset & Base Setup
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-gold);
}

/* --------------------------------------------------------------------------
   Top Progress Bar
   -------------------------------------------------------------------------- */
.reading-progress-track {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3.5px;
  background: transparent;
  z-index: var(--z-progress);
}

.reading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-rose));
  box-shadow: 0 0 10px rgba(var(--accent-gold-rgb), 0.7);
  transition: width 0.3s ease;
}

/* --------------------------------------------------------------------------
   Header Navigation (Sticky)
   -------------------------------------------------------------------------- */
.reader-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-blur);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--bg-card-border);
  z-index: var(--z-header);
  transition: all var(--transition-normal);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-center {
  flex: 1;
  text-align: center;
  padding: 0 8px;
  min-width: 0;
}

.header-novel-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-chapter-subtitle {
  font-size: 0.72rem;
  color: var(--accent-gold);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Icon Buttons */
.btn-icon {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-card-border);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--bg-tertiary);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  transform: translateY(-1px);
}

.btn-icon:active {
  transform: scale(0.94);
}

.btn-icon.active {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  background: rgba(var(--accent-gold-rgb), 0.15);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

/* Badges */
.badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--bg-card-border);
  color: var(--text-secondary);
}

.badge-accent {
  background: rgba(var(--accent-gold-rgb), 0.15);
  color: var(--accent-gold);
  border-color: rgba(var(--accent-gold-rgb), 0.3);
}

/* --------------------------------------------------------------------------
   COVER SCREEN VIEW (View 0: The Book Front)
   -------------------------------------------------------------------------- */
.book-cover-view {
  min-height: calc(100vh - 60px);
  margin-top: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 40px 20px;
  position: relative;
  text-align: center;
}

.cover-wrapper {
  max-width: 440px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 3D Realistic Book Cover Frame */
.book-3d-stage {
  perspective: 1200px;
  margin: 10px 0 26px 0;
}

.book-3d-card {
  position: relative;
  width: 200px;
  height: 295px;
  border-radius: 4px 14px 14px 4px;
  box-shadow: 
    -6px 6px 15px rgba(0, 0, 0, 0.4),
    -15px 15px 35px rgba(0, 0, 0, 0.6),
    0 0 25px rgba(var(--accent-gold-rgb), 0.2);
  transform: rotateY(-14deg) rotateX(4deg);
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.5s ease;
  transform-style: preserve-3d;
  cursor: pointer;
}

.book-3d-card:hover {
  transform: rotateY(0deg) rotateX(0deg) scale(1.04);
  box-shadow: 
    0 12px 30px rgba(0, 0, 0, 0.5),
    0 0 35px rgba(var(--accent-gold-rgb), 0.35);
}

.book-cover-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px 14px 14px 4px;
  display: block;
}

/* Book spine effect */
.book-spine-effect {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 14px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.15), rgba(0, 0, 0, 0.35) 70%, rgba(255, 255, 255, 0.1));
  border-radius: 4px 0 0 4px;
  pointer-events: none;
}

.cover-meta {
  margin-top: 8px;
}

.cover-novel-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 2.6rem);
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.15;
}

.cover-author-line {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.cover-author-line span {
  color: var(--text-primary);
  font-weight: 700;
}

.cover-chapter-pill {
  display: inline-block;
  background: var(--bg-card);
  border: 1px solid var(--accent-gold);
  padding: 6px 18px;
  border-radius: var(--radius-full);
  margin-bottom: 22px;
}

.cover-chapter-pill span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cover-chapter-pill h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-top: 2px;
}

/* Open Book Button */
.btn-open-book {
  background: linear-gradient(135deg, var(--accent-gold), #b86e2f);
  color: #ffffff;
  border: none;
  padding: 14px 34px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(var(--accent-gold-rgb), 0.35);
  transition: all var(--transition-normal);
}

.btn-open-book:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 28px rgba(var(--accent-gold-rgb), 0.5);
}

.btn-open-book:active {
  transform: scale(0.97);
}

.btn-open-book svg {
  width: 22px;
  height: 22px;
}

/* --------------------------------------------------------------------------
   READING PAGES STAGE (View 1: Pages Turn Mode)
   -------------------------------------------------------------------------- */
.book-reader-stage {
  display: none; /* hidden until Open Book is clicked */
  width: 100%;
  max-width: var(--reader-max-width);
  margin: 0 auto;
  padding: 80px 18px 110px 18px;
  flex: 1;
}

.book-reader-stage.active {
  display: block;
}

/* Page Card Container */
.book-pages-deck {
  position: relative;
  min-height: 480px;
}

.book-page {
  display: none;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--transition-page), transform var(--transition-page);
}

.book-page.active-page {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Page animations */
.page-slide-left {
  animation: pageSlideFromRight 0.32s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

.page-slide-right {
  animation: pageSlideFromLeft 0.32s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

@keyframes pageSlideFromRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pageSlideFromLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.page-header-ribbon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--divider-color);
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.page-scene-tag {
  color: var(--accent-gold);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Novel Reading Body Typography */
.novel-reading-body {
  font-family: var(--font-family-current);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text-novel);
  letter-spacing: 0.015em;
  transition: font-size var(--transition-fast), line-height var(--transition-fast);
}

.novel-reading-body p {
  margin-bottom: 1.5em;
  text-align: left;
  text-indent: 1.5em;
  hyphens: auto;
  word-break: break-word;
}

.novel-reading-body p.no-indent {
  text-indent: 0;
}

.novel-reading-body p.lead-paragraph::first-letter {
  float: left;
  font-family: var(--font-display);
  font-size: 3.2em;
  line-height: 0.8;
  padding-top: 4px;
  padding-right: 10px;
  padding-bottom: 2px;
  color: var(--accent-gold);
  font-weight: 700;
}

.novel-reading-body p.dialogue {
  text-indent: 0;
  padding-left: 14px;
  border-left: 2px solid rgba(var(--accent-gold-rgb), 0.4);
}

/* Section Breaks / Dividers */
.section-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 2.2em 0;
  color: var(--accent-gold);
  opacity: 0.7;
}

.section-divider::before,
.section-divider::after {
  content: "";
  height: 1px;
  width: 50px;
  background: linear-gradient(90deg, transparent, var(--divider-color), transparent);
}

.section-divider-symbol {
  font-size: 0.9rem;
  letter-spacing: 0.3em;
}

/* Instagram Post Aesthetic Card */
.instagram-post-card {
  margin: 2.2em 0;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.ig-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--divider-color);
}

.ig-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ig-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ig-avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.ig-username {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.ig-badge-verified {
  color: var(--accent-blue);
  width: 14px;
  height: 14px;
}

.ig-location {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.ig-poetry-content {
  font-family: var(--font-serif);
  font-style: italic;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-rose);
  font-size: 1.05em;
  line-height: 1.9;
  color: var(--text-primary);
  white-space: pre-line;
  margin-bottom: 12px;
}

.ig-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.ig-actions-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ig-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.82rem;
  transition: color var(--transition-fast);
}

.ig-action-btn:hover,
.ig-action-btn.liked {
  color: var(--accent-rose);
}

.ig-action-btn.liked svg {
  fill: var(--accent-rose);
}

/* Direct Message Alert Card */
.dm-message-card {
  margin: 2.2em 0;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.dm-message-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent-gold), var(--accent-blue));
}

.dm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.dm-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--accent-blue);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dm-sender-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.dm-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--bg-card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-blue);
}

.dm-sender-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.dm-bubble {
  background: var(--msg-bubble-bg);
  color: var(--msg-bubble-text);
  padding: 12px 16px;
  border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 4px;
  font-family: var(--font-serif);
  font-size: 1.02em;
  font-style: italic;
  line-height: 1.5;
  border: 1px solid var(--bg-card-border);
  display: inline-block;
}

/* --------------------------------------------------------------------------
   PAGE TURN NAVIGATION BAR (Fixed Bottom for thumb reach)
   -------------------------------------------------------------------------- */
.reader-turn-bar {
  display: none; /* hidden on cover view */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg-blur);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--bg-card-border);
  padding: 0 16px;
  z-index: var(--z-bottom-nav);
  align-items: center;
  justify-content: space-between;
  transition: all var(--transition-normal);
}

.reader-turn-bar.active {
  display: flex;
}

.page-turn-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-card-border);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-full);
  font-size: 0.84rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.page-turn-btn:hover:not(:disabled) {
  background: var(--accent-gold);
  color: #fff;
  border-color: var(--accent-gold);
}

.page-turn-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-turn-btn svg {
  width: 16px;
  height: 16px;
}

/* Center Page Indicator */
.turn-bar-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.turn-page-counter {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.page-dots-list {
  display: flex;
  align-items: center;
  gap: 5px;
}

.page-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  opacity: 0.4;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.page-dot.active {
  width: 14px;
  background: var(--accent-gold);
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Settings Drawer (Bottom Sheet)
   -------------------------------------------------------------------------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: var(--z-drawer);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.settings-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 20px 32px 20px;
  z-index: calc(var(--z-drawer) + 1);
  transform: translateY(100%);
  transition: transform var(--transition-spring);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
}

.settings-drawer.open {
  transform: translateY(0);
}

.drawer-drag-handle {
  width: 40px;
  height: 4px;
  background: var(--text-muted);
  opacity: 0.5;
  border-radius: var(--radius-full);
  margin: 0 auto 16px auto;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--divider-color);
}

.drawer-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-close-btn {
  background: var(--bg-tertiary);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.setting-section {
  margin-bottom: 22px;
}

.setting-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Theme Options Swatches */
.theme-selector-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.theme-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.swatch-dark { background: #121419; }
.swatch-amoled { background: #000000; border-color: #333; }
.swatch-sepia { background: #fbf0d9; border-color: #d4a373; }
.swatch-light { background: #ffffff; border-color: #cbd5e1; }

.theme-btn.active {
  border-color: var(--accent-gold);
  background: rgba(var(--accent-gold-rgb), 0.12);
}

/* Font Size Stepper */
.size-stepper-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 6px;
}

.step-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-card-border);
  color: var(--text-primary);
  width: 44px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.step-btn:hover {
  background: var(--accent-gold);
  color: #fff;
}

.size-display-val {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-gold);
}

/* Font Family Selection */
.font-family-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.font-btn {
  padding: 10px 8px;
  background: var(--bg-tertiary);
  border: 1.5px solid transparent;
  color: var(--text-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.85rem;
  text-align: center;
  transition: all var(--transition-fast);
}

.font-btn.serif { font-family: var(--font-serif); }
.font-btn.sans { font-family: var(--font-sans); }
.font-btn.mono { font-family: var(--font-mono); }

.font-btn.active {
  border-color: var(--accent-gold);
  background: rgba(var(--accent-gold-rgb), 0.12);
  color: var(--accent-gold);
  font-weight: 700;
}

/* Line Height Selector */
.line-height-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.lh-btn {
  padding: 8px 6px;
  background: var(--bg-tertiary);
  border: 1.5px solid transparent;
  color: var(--text-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.82rem;
  text-align: center;
  transition: all var(--transition-fast);
}

.lh-btn.active {
  border-color: var(--accent-gold);
  background: rgba(var(--accent-gold-rgb), 0.12);
  color: var(--accent-gold);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Table of Contents Modal / Drawer
   -------------------------------------------------------------------------- */
.toc-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 20px 32px 20px;
  z-index: calc(var(--z-drawer) + 1);
  transform: translateY(100%);
  transition: transform var(--transition-spring);
  max-height: 80vh;
  overflow-y: auto;
}

.toc-drawer.open {
  transform: translateY(0);
}

.chapter-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chapter-item.active {
  border-color: var(--accent-gold);
  background: rgba(var(--accent-gold-rgb), 0.12);
}

.chapter-item-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chap-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-transform: uppercase;
}

.chap-name {
  font-size: 0.95rem;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Interactive Notification Toast
   -------------------------------------------------------------------------- */
.toast-notice {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--bg-card);
  border: 1px solid var(--accent-gold);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-normal);
  z-index: var(--z-toast);
}

.toast-notice.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Desktop & Tablet Responsive Tweaks
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  .book-reader-stage {
    padding-top: 90px;
    padding-bottom: 90px;
  }

  .settings-drawer,
  .toc-drawer {
    max-width: 480px;
    left: auto;
    right: 20px;
    bottom: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--bg-card-border);
    transform: translateY(30px) scale(0.95);
    opacity: 0;
    pointer-events: none;
  }

  .settings-drawer.open,
  .toc-drawer.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
  }

  .reader-turn-bar {
    max-width: 520px;
    margin: 0 auto;
    left: 0;
    right: 0;
    bottom: 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--bg-card-border);
    box-shadow: var(--shadow-md);
  }
}
