/* =========================================================
   WordGeek Books Article Reader & Dyslexia Accessibility Suite
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&display=swap');

.wordgeek-article .article-reader {
  margin: 0 0 2rem;
  padding: clamp(0.85rem, 2.5vw, 1.5rem);
  border: 1px solid var(--article-line, #c8d6e5);
  border-radius: 14px;
  background: rgba(236, 244, 250, 0.85);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.wordgeek-article .article-reader-intro {
  text-align: center;
  margin-bottom: 1rem;
}

.wordgeek-article .article-reader-intro h2 {
  margin: 0;
  color: var(--article-ink, #102a43);
  font-size: clamp(1.2rem, 3.2vw, 1.6rem);
  line-height: 1.3;
}

.wordgeek-article .article-reader-intro p {
  margin: 0.4rem 0 0;
  color: var(--article-muted, #486581);
  font-size: clamp(0.9rem, 2vw, 1rem);
  line-height: 1.5;
}

/* --- Reflow-Safe Controls Grid --- */
.wordgeek-article .article-reader-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1rem;
}

.wordgeek-article .article-reader-controls .article-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 48px;
  padding: 0.6rem 1.1rem;
  border: 1px solid rgba(38, 55, 71, 0.28);
  border-radius: 8px;
  background: #ffffff;
  color: var(--article-slate, #1f364d);
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.wordgeek-article .article-reader-controls .article-tool:hover:not(:disabled) {
  background: #f0f4f8;
  border-color: #102a43;
}

.wordgeek-article .article-reader-controls .article-tool:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  background: #f8fafc;
}

.wordgeek-article .article-reader-rate-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.wordgeek-article .article-reader-rate-label {
  color: var(--article-slate, #1f364d);
  font-weight: 700;
  font-size: 0.9rem;
}

.wordgeek-article .article-reader-rate {
  min-height: 48px;
  padding: 0.5rem 1.8rem 0.5rem 0.8rem;
  border: 1px solid rgba(38, 55, 71, 0.28);
  border-radius: 8px;
  background: #ffffff;
  color: var(--article-slate, #1f364d);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.wordgeek-article .article-reader-rate:focus-visible,
.wordgeek-article .article-reader-controls .article-tool:focus-visible,
.wordgeek-article .accessibility-tool:focus-visible {
  outline: 3px solid #b75c00;
  outline-offset: 3px;
}

/* --- Native Audio Element Wrapper --- */
.wordgeek-article .article-reader-audio {
  display: block;
  width: 100%;
  min-width: 0;
  margin-top: 1rem;
}

/* --- Status and Timing --- */
.wordgeek-article .article-reader-status,
.wordgeek-article .article-reader-duration {
  min-height: 1.5em;
  margin: 0.7rem 0 0;
  color: var(--article-slate, #1f364d);
  font-size: clamp(0.88rem, 2vw, 0.96rem);
  font-weight: 650;
  text-align: center;
  line-height: 1.4;
}

/* --- Dyslexia & Accessibility Toolbar --- */
.wordgeek-article .article-accessibility-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(16, 42, 67, 0.12);
}

.wordgeek-article .accessibility-heading {
  width: 100%;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--article-muted, #486581);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.4rem;
}

.wordgeek-article .accessibility-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(38, 55, 71, 0.22);
  border-radius: 20px;
  background: #ffffff;
  color: var(--article-slate, #1f364d);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.wordgeek-article .accessibility-tool:hover {
  background: #f0f4f8;
  border-color: #102a43;
  transform: translateY(-1px);
}

.wordgeek-article .accessibility-tool.is-active {
  background: #102a43;
  color: #ffffff;
  border-color: #102a43;
  box-shadow: 0 2px 6px rgba(16, 42, 67, 0.25);
}

/* --- Article Reading Measure & Passage Spacing --- */
.wordgeek-article .article-body {
  width: 100%;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.wordgeek-article .article-body > p {
  margin-bottom: 1.6rem;
  line-height: 1.82;
  text-align: justify;
  text-justify: inter-word;
  text-align-last: left;
  hyphens: auto;
  -webkit-hyphens: auto;
  scroll-margin-top: calc(var(--anchor-offset, 80px) + 24px);
  border-left: 4px solid transparent;
  border-radius: 0 8px 8px 0;
  padding: 0.5rem 0.8rem;
  margin-left: -0.8rem;
  margin-right: -0.8rem;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.wordgeek-article .article-body > p:hover {
  background: rgba(236, 244, 250, 0.5);
}

.wordgeek-article .article-body > p.is-being-read {
  background: rgba(245, 158, 11, 0.12);
  border-left-color: #b75c00;
  box-shadow: 0 2px 8px rgba(183, 92, 0, 0.08);
}

/* --- Dyslexia Font Mode --- */
.wordgeek-article.mode-dyslexic-font .article-body,
.wordgeek-article.mode-dyslexic-font .article-body p,
.wordgeek-article.mode-dyslexic-font .article-reader {
  font-family: 'Lexend', 'OpenDyslexic', -apple-system, BlinkMacSystemFont, sans-serif !important;
  letter-spacing: 0.035em;
  word-spacing: 0.07em;
  line-height: 1.88 !important;
}

/* --- Text Size Scaling Modes --- */
.wordgeek-article.mode-text-medium .article-body p {
  font-size: 1.2rem !important;
  line-height: 1.8 !important;
}

.wordgeek-article.mode-text-large .article-body p {
  font-size: 1.38rem !important;
  line-height: 1.9 !important;
}

/* --- High Contrast & Reading Tint Modes --- */
.wordgeek-article.mode-contrast-warm {
  background-color: #fcf8ec !important;
}

.wordgeek-article.mode-contrast-warm .article-frame {
  background: #fffdf5 !important;
  color: #1a1a1a !important;
}

.wordgeek-article.mode-contrast-dark {
  background-color: #12181f !important;
  color: #e2e8f0 !important;
}

.wordgeek-article.mode-contrast-dark .article-frame {
  background: #1a222c !important;
  color: #e2e8f0 !important;
  border-color: #2d3748 !important;
}

.wordgeek-article.mode-contrast-dark .article-reader {
  background: #242f3d !important;
  border-color: #3e4c5e !important;
}

.wordgeek-article.mode-contrast-dark .article-reader-intro h2,
.wordgeek-article.mode-contrast-dark .article-body p,
.wordgeek-article.mode-contrast-dark .article-reader-status,
.wordgeek-article.mode-contrast-dark .article-reader-duration {
  color: #f1f5f9 !important;
}

.wordgeek-article.mode-contrast-dark .article-reader-controls .article-tool,
.wordgeek-article.mode-contrast-dark .accessibility-tool,
.wordgeek-article.mode-contrast-dark .article-reader-rate {
  background: #1a222c !important;
  color: #f1f5f9 !important;
  border-color: #4a5568 !important;
}

.wordgeek-article.mode-contrast-dark .article-body > p.is-being-read {
  background: rgba(245, 158, 11, 0.15) !important;
  border-left-color: #f59e0b !important;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15) !important;
}

/* --- High-Zoom / Mobile Reflow Rules --- */
@media (max-width: 680px) {
  .wordgeek-article .article-reader-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .wordgeek-article .article-reader-rate-wrap {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .wordgeek-article .article-accessibility-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .wordgeek-article .accessibility-heading {
    grid-column: 1 / -1;
  }

  .wordgeek-article .accessibility-tool {
    width: 100%;
  }
}

.wordgeek-article .article-reader-controls[hidden] {
  display: none;
}
