/* ==========================================================================
   NithanYai.com (นิทานยาย) - Interactive Reader View CSS (Crown Jewel)
   ========================================================================== */

/* Reading Container Page Shell */
.reader-wrapper {
  position: relative;
  min-height: 100vh;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Sticky Top Reading Bar */
.reader-top-bar {
  position: sticky;
  top: 0;
  z-index: 1050;
  height: 60px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.reader-progress-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(0, 0, 0, 0.08);
}

.reader-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-orange), var(--accent-amber));
  transition: width 0.1s ease-out;
}

.reader-title-mini {
  font-weight: 600;
  font-size: 0.95rem;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-time-estimate {
  font-size: 0.8rem;
  color: var(--accent-orange);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.reader-controls-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Customize Settings Drawer / Panel */
.reader-settings-panel {
  position: fixed;
  top: 70px;
  right: 1.5rem;
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  z-index: 1100;
  display: none;
  flex-direction: column;
  gap: 1.25rem;
  animation: fadeInDown 0.25s ease-out;
}

.reader-settings-panel.active {
  display: flex;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

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

.theme-opt-btn {
  height: 38px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-color);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.theme-opt-btn[data-theme-val="light"] { background: #FFFDF7; color: #2C221E; }
.theme-opt-btn[data-theme-val="sepia"] { background: #F4ECD8; color: #423228; }
.theme-opt-btn[data-theme-val="dark"] { background: #18151E; color: #F3EFEA; }
.theme-opt-btn[data-theme-val="night"] { background: #000000; color: #00FF66; }

.theme-opt-btn.active {
  border-color: var(--accent-orange);
  box-shadow: 0 0 0 2px rgba(232, 106, 51, 0.3);
}

/* Font Family & Size Selector */
.font-selector {
  width: 100%;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.font-size-adjuster {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.5rem;
}

.font-size-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: bold;
  cursor: pointer;
}

/* Main Reader Article Frame */
.reader-article-frame {
  max-width: 760px;
  margin: 2.5rem auto 5rem;
  padding: 0 1.5rem;
  transition: max-width var(--transition-normal);
}

.reader-article-frame[data-width="narrow"] { max-width: 620px; }
.reader-article-frame[data-width="medium"] { max-width: 760px; }
.reader-article-frame[data-width="wide"] { max-width: 960px; }

/* Dynamic Content Formatting */
.reader-story-title {
  font-size: 2.25rem;
  text-align: center;
  margin-bottom: 0.75rem;
  line-height: 1.25;
}

.reader-story-subtitle {
  font-size: 1.1rem;
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.reader-chapter-heading {
  font-size: 1.5rem;
  color: var(--accent-orange);
  margin: 2rem 0 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border-color);
}

.reader-illustration-box {
  margin: 2rem 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.reader-illustration-box img {
  width: 100%;
  height: auto;
  display: block;
}

.reader-text-body {
  font-size: 1.125rem;
  line-height: 1.85;
  color: var(--text-primary);
}

.reader-text-body p {
  margin-bottom: 1.5rem;
  text-indent: 1.75em;
}

.reader-text-body p:first-of-type::first-letter {
  font-size: 3rem;
  float: left;
  line-height: 1;
  padding-right: 0.4rem;
  color: var(--accent-orange);
  font-family: var(--font-heading);
}

/* Audio Player Floating Controller */
.reader-audio-bar {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 520px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  padding: 0.6rem 1.25rem;
  display: none;
  align-items: center;
  gap: 1rem;
  z-index: 1040;
}

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

/* Bottom Chapter Sticky Navigation Bar */
.reader-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 64px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 1030;
}

/* Table of Contents Drawer */
.toc-drawer {
  position: fixed;
  top: 0;
  left: -320px;
  width: 320px;
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 1200;
  padding: 1.5rem;
  transition: left var(--transition-normal);
  overflow-y: auto;
}

.toc-drawer.open {
  left: 0;
}

.toc-item {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toc-item.active {
  color: var(--accent-orange);
  font-weight: 600;
}

/* Highlight Text Quote Share Modal */
.quote-share-popover {
  position: absolute;
  background: var(--accent-orange);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 1100;
  display: none;
}
