/* ==========================================================================
   English Reading Platform - Reader Mode Stylesheet
   Focus: Readability, Editorial Typography, Sentence Highlighting, Audio Bar
   ========================================================================== */

.reader-container {
  max-width: var(--reader-width);
  margin: 0 auto;
}

/* Reader Top Navigation Bar */
.reader-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

/* Reader Breadcrumb Navigation */
.reader-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  overflow: hidden;
  white-space: nowrap;
}

.reader-breadcrumb .breadcrumb-item {
  display: inline-flex;
  align-items: center;
}

.reader-breadcrumb .breadcrumb-link {
  background: transparent;
  border: none;
  padding: 0.2rem 0.4rem;
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm, 4px);
  transition: color 0.15s ease, background-color 0.15s ease;
  text-decoration: none;
  line-height: 1.2;
}

.reader-breadcrumb .breadcrumb-link:hover {
  color: var(--accent-primary, #2563eb);
  background-color: var(--bg-tertiary);
}

.reader-breadcrumb .breadcrumb-separator {
  color: var(--text-muted);
  font-size: 0.85rem;
  user-select: none;
  opacity: 0.6;
}

.reader-breadcrumb .breadcrumb-current {
  color: var(--text-primary);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
  line-height: 1.2;
}

@media (max-width: 680px) {
  .reader-breadcrumb .breadcrumb-current {
    max-width: 130px;
  }
}

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

.cefr-badge {
  background-color: var(--text-primary);
  color: var(--bg-primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.score-badge {
  background-color: var(--success-bg);
  color: var(--success-text);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
}

.reader-save-btn {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.reader-save-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.reader-save-btn.active {
  color: #f59e0b;
  border-color: #f59e0b;
  background-color: var(--bg-tertiary);
}

/* Article Header */
.article-header {
  margin-bottom: 2rem;
}

.reader-image-box {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background-color: var(--bg-secondary);
  margin-bottom: 1.5rem;
}

.reader-header-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.reader-category {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.reader-title {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 0.85rem;
}

.reader-meta-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Level Switcher Component */
.level-switcher-bar {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 0.4rem;
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.level-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.65rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.level-tab-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.level-tab-btn.active {
  background-color: var(--text-primary);
  color: var(--bg-primary);
}

/* Audio Player Bar */
.audio-player-panel {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}

.audio-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.audio-left-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: 1;
}

.audio-btn {
  background-color: var(--bg-tertiary);
  border: none;
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.audio-btn:hover {
  background-color: var(--bg-hover);
}

.audio-btn-main {
  width: 42px;
  height: 42px;
  min-width: 42px;
  background-color: var(--text-primary);
  color: var(--bg-primary);
  flex-shrink: 0;
}

.audio-btn-main:hover {
  opacity: 0.9;
  background-color: var(--text-primary);
  transform: scale(1.03);
}

.audio-info-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.audio-article-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.audio-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.audio-status-text {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  line-height: 1.2;
}

/* Compact Audio Speed Dropdown */
.audio-speed-wrap {
  position: relative;
  display: inline-flex;
}

.audio-speed-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background-color: var(--bg-tertiary);
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 0.38rem 0.65rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.audio-speed-btn:hover {
  background-color: var(--bg-hover, rgba(0, 0, 0, 0.08));
}

.audio-speed-wrap.active .audio-speed-btn {
  background-color: var(--bg-primary);
  border-color: var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.speed-chevron {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.audio-speed-wrap.active .speed-chevron {
  transform: rotate(180deg);
}

.audio-speed-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 145px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  padding: 0.3rem;
  z-index: 60;
  display: none;
  flex-direction: column;
  gap: 0.15rem;
  animation: speedMenuPop 0.15s ease-out;
}

[data-theme="dark"] .audio-speed-menu {
  background: var(--bg-secondary);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

@keyframes speedMenuPop {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.audio-speed-wrap.active .audio-speed-menu {
  display: flex;
}

.speed-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.42rem 0.65rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.12s ease;
  text-align: left;
}

.speed-menu-item:hover {
  background-color: var(--bg-tertiary);
}

.speed-menu-item.active {
  background-color: var(--text-primary);
  color: var(--bg-primary);
}

.speed-menu-item .speed-desc {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.75;
}

.audio-progress-track {
  width: 100%;
  height: 5px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: height 0.15s ease;
}

.audio-progress-track:hover {
  height: 7px;
}

.audio-progress-bar {
  height: 100%;
  width: 0%;
  background-color: var(--text-primary);
  transition: width 0.1s linear;
  pointer-events: none;
}

/* Sentence Translating Outline Highlight */
.reader-sentence.sentence-translating {
  background-color: rgba(99, 102, 241, 0.12);
  border-radius: 4px;
  box-shadow: 0 0 0 2px var(--primary-accent, #6366f1);
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

/* Floating Sentence-Based Google Translation Popover */
.sentence-translation-popover {
  position: absolute;
  z-index: 1200;
  width: 360px;
  max-width: calc(100vw - 32px);
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
  padding: 0.9rem 1.1rem;
  animation: popoverFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(12px);
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.trans-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--bg-tertiary);
}

.trans-popover-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-accent, #6366f1);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.trans-popover-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.trans-popover-lang-select {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease;
}

.trans-popover-lang-select:hover,
.trans-popover-lang-select:focus {
  border-color: var(--primary-accent, #6366f1);
}

.trans-popover-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.trans-popover-close-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.trans-popover-body {
  margin-bottom: 0.75rem;
}

.trans-popover-original {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0 0 0.45rem 0;
}

.trans-popover-translated {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
  margin: 0;
}

.trans-popover-translated.loading-translation {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
}

.trans-popover-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 0.5rem;
  border-top: 1px solid var(--bg-tertiary);
}

.trans-google-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background-color: var(--bg-secondary);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: all 0.15s ease;
  border: 1px solid var(--border-color);
}

.trans-google-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
  border-color: var(--text-muted);
}

/* Reader Typography Preference Bar */
.reader-preferences-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.65rem 0;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--bg-tertiary);
}

.pref-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pref-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-right: 0.2rem;
}

.pref-pill-btn {
  background-color: var(--bg-secondary);
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.pref-pill-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.pref-pill-btn.active {
  background-color: var(--text-primary);
  color: var(--bg-primary);
  font-weight: 600;
}


/* Article Body & Typography */
.article-body {
  margin-bottom: 3.5rem;
}

/* Font Family Classes */
.article-body.family-serif {
  font-family: var(--font-serif);
}

.article-body.family-sans {
  font-family: var(--font-sans);
}

.article-body.family-dyslexic {
  font-family: var(--font-dyslexic);
}

/* Font Size Classes */
.article-body.font-sm {
  font-size: 1.05rem;
  line-height: 1.7;
}

.article-body.font-md {
  font-size: 1.25rem;
  line-height: 1.8;
}

.article-body.font-lg {
  font-size: 1.45rem;
  line-height: 1.85;
}

.article-body.font-xl {
  font-size: 1.65rem;
  line-height: 1.9;
}

.reader-paragraph {
  margin-bottom: 1.6em;
  color: var(--text-primary);
}

/* Sentences & Highlighting */
.reader-sentence {
  display: inline;
  padding: 0.1em 0.2em;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.reader-sentence:hover {
  background-color: var(--bg-hover);
}

.reader-sentence.sentence-active {
  background-color: var(--bg-hover);
  box-shadow: 0 0 0 3px var(--bg-hover);
}

/* Highlighted Vocabulary */
.vocab-highlight {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  cursor: pointer;
  color: inherit;
  transition: opacity 0.15s ease;
}

.vocab-highlight:hover {
  opacity: 0.8;
}

/* Vocabulary Popover */
.vocab-popover {
  position: absolute;
  z-index: 1000;
  width: 280px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  animation: fadeInPop 0.15s ease;
}

@keyframes fadeInPop {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.popover-word-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.popover-word {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.popover-pos {
  font-size: 0.75rem;
  font-style: italic;
  color: var(--text-muted);
}

.popover-audio-btn {
  background: var(--bg-tertiary);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
}

.popover-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.popover-phonetics {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.popover-def {
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.popover-example {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 0.85rem;
  padding-left: 0.5rem;
  border-left: 2px solid var(--bg-tertiary);
}

.popover-save-btn {
  width: 100%;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: none;
  padding: 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.popover-save-btn.saved {
  background-color: var(--success-bg);
  color: var(--success-text);
}

/* Key Vocabulary Section Below Article */
.reader-vocab-section {
  margin-bottom: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--bg-tertiary);
}

.section-headline {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.section-subtext {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.vocab-card {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.vocab-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.vocab-card-left {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.vocab-term {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.vocab-pos {
  font-size: 0.75rem;
  font-style: italic;
  color: var(--text-muted);
}

.vocab-phonetics {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.vocab-card-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.vocab-pronounce-btn,
.vocab-save-btn {
  background-color: var(--bg-tertiary);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  transition: background-color 0.15s ease, transform 0.1s ease, color 0.15s ease;
  user-select: none;
}

.vocab-pronounce-btn:hover,
.vocab-save-btn:hover {
  background-color: var(--border-color);
  transform: scale(1.05);
}

.vocab-save-btn.saved {
  background-color: var(--success-bg);
  color: var(--success-text);
  font-size: 0.85rem;
}

.vocab-save-btn.saved:hover {
  background-color: var(--success-bg);
  filter: brightness(0.92);
}

.vocab-definition {
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.45;
  margin-bottom: 0.4rem;
}

.vocab-example {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

@media (max-width: 640px) {
  .translation-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
  .translation-actions-row {
    width: 100%;
    justify-content: space-between;
  }
}

