/**
 * Reading track shell (hub #reading): warm page background, document scroll,
 * centered titles. Bilingual lessons: terracotta story + teal vocab cards.
 */

.reader-passage {
  --read-story-border: rgba(168, 93, 44, 0.5);
  --read-story-glow: rgba(168, 93, 44, 0.12);
  --read-vocab-border: rgba(15, 118, 110, 0.5);
  --read-vocab-glow: rgba(15, 118, 110, 0.1);
}

body.reader.reader-passage {
  height: auto;
  min-height: 100dvh;
  min-height: 100svh;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(165deg, #fdfcfa 0%, var(--paper) 42%, #f5f1e8 100%);
}

body.reader.reader-passage .reader-flow {
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

html:fullscreen body.reader.reader-passage,
html:-webkit-full-screen body.reader.reader-passage {
  height: auto;
  min-height: 100%;
  max-height: none;
  overflow-y: auto;
}

body.reader.reader-passage .reader-article {
  flex: 0 0 auto;
  min-height: auto;
}

body.reader.reader-passage .reader-article-stack {
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
}

body.reader.reader-passage .reader-foot {
  margin-top: auto;
}

/* Premium passage: no inner scroll; terracotta “story card” frame */
body.reader.reader-passage .reader-passage-wrap {
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
  width: calc(100% - 2 * var(--reader-inset));
  max-width: min(1100px, 100% - 2 * var(--reader-inset));
  margin-inline: auto;
  margin-top: clamp(8px, 1.5vw, 16px);
  padding: clamp(0.85rem, 2vw, 1.15rem);
  border: 2px solid var(--read-story-border);
  border-radius: var(--radius);
  background: linear-gradient(168deg, #fffefb 0%, #faf6f0 45%, #f7f2ea 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 14px 42px var(--read-story-glow),
    0 6px 20px rgba(44, 40, 37, 0.06);
}

body.reader.reader-passage .reading-scroll {
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
}

/* Premium hard-words drawer: align with vocab styling */
body.reader.reader-passage .reader-trans {
  max-width: min(1100px, 100% - 2 * var(--reader-inset));
  margin-inline: auto;
  padding: 10px var(--reader-inset) calc(12px + env(safe-area-inset-bottom, 0px));
}

body.reader.reader-passage .reader-trans .translation-toggle {
  border: 2px solid rgba(15, 118, 110, 0.35);
  border-radius: var(--radius);
  background: linear-gradient(185deg, #f5fcfb 0%, #eef8f6 55%, #fafdfb 100%);
}

.reader-passage .reader-article-stack > .lesson-wrap--fit {
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
  flex-shrink: 0;
}

.reader-passage .lesson-wrap--fit {
  width: 100%;
  max-width: min(1100px, 100% - clamp(0.75rem, 3vw, 2rem));
  margin-inline: auto;
  padding: 0 var(--reader-inset) clamp(0.5rem, 1.5dvh, 0.85rem);
  padding-top: 0;
  gap: clamp(0.65rem, 1.5vw, 1rem);
  min-height: auto;
  max-height: none;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

.reader-passage .lesson-fit-body {
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(0.85rem, 2vw, 1.25rem);
  padding: 4px 0 calc(0.5rem + env(safe-area-inset-bottom, 0px));
}

.reader-passage .lesson-bilingual {
  display: block;
  width: 100%;
  flex: 0 0 auto;
}

.reader-passage .lesson-wrap--fit .read-en {
  display: block;
  direction: ltr;
  unicode-bidi: isolate;
  width: 100%;
  overflow: visible;
}

.reader-passage .lesson-wrap--fit .read-en__text {
  display: block;
  overflow: visible;
  max-width: min(65ch, 100%);
  margin-inline: auto;
}

.reader-passage .lesson-wrap--fit .read-ar {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  width: 100%;
  overflow: visible;
}

.reader-passage .lesson-wrap--fit .read-teacher-note {
  flex-shrink: 0;
}

.reader-passage .read-en {
  background: linear-gradient(168deg, #fffefb 0%, #faf6f0 45%, #f7f2ea 100%);
  color: var(--ink);
  border: 2px solid var(--read-story-border);
  border-radius: var(--radius);
  margin-top: 0;
  padding: clamp(0.85rem, 2vw, 1.15rem) clamp(0.85rem, 2.2vw, 1.15rem);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 14px 42px var(--read-story-glow),
    0 6px 20px rgba(44, 40, 37, 0.06);
}

.reader-passage .read-en__label {
  margin: 0 0 0.45rem;
  padding-bottom: 0.42rem;
  border-bottom: 1px solid rgba(168, 93, 44, 0.28);
  font-size: 0.72rem;
  font-weight: 800;
  font-family: var(--font-ui);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pop);
}

.reader-passage .read-en__text {
  font-size: clamp(1.04rem, 0.92rem + 1.05vmin, 1.36rem);
  line-height: 1.58;
  letter-spacing: 0.012em;
  font-family: var(--font-reading);
  font-weight: 450;
  font-optical-sizing: auto;
  max-width: min(65ch, 100%);
  margin-inline: auto;
}

.reader-passage .read-en__text p {
  margin: 0 0 0.4em;
}

.reader-passage .read-en__text p:last-child {
  margin-bottom: 0;
}

.reader-passage .read-en__text strong {
  color: var(--accent-name);
  font-family: var(--font-reading);
  font-weight: 600;
}

.reader-passage .read-en__text u {
  text-decoration-thickness: 2px;
  cursor: default;
  text-underline-offset: 3px;
  text-decoration-color: var(--pop);
}

.reader-passage .read-ar.read-ar--keywords {
  background: linear-gradient(185deg, #f5fcfb 0%, #eef8f6 40%, #fafdfb 100%);
  color: var(--ink);
  border: 2px solid var(--read-vocab-border);
  border-radius: var(--radius);
  padding: clamp(0.75rem, 1.8vw, 1.05rem) clamp(0.8rem, 2vw, 1.1rem);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 14px 40px var(--read-vocab-glow),
    0 6px 18px rgba(15, 23, 42, 0.05);
  direction: rtl;
  text-align: right;
  font-family: "Tajawal", system-ui, sans-serif;
}

.reader-passage .read-ar--bottom {
  width: 100%;
  margin-top: 0;
  max-height: none;
  overflow: visible;
}

.reader-passage .read-ar--keywords .read-ar__label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.2rem 0.45rem;
  margin: 0 0 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(15, 118, 110, 0.22);
  font-size: clamp(0.74rem, 0.62rem + 0.55vmin, 0.84rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #0d3d38;
  font-family: "Tajawal", system-ui, sans-serif;
  line-height: 1.35;
}

.reader-passage .read-ar--keywords .read-ar__label .read-ar__label-en {
  font-family: var(--font-reading);
  letter-spacing: 0.03em;
  font-weight: 700;
  color: #0d3d38;
}

.reader-passage .read-kw-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr));
  gap: 0.42rem;
  font-family: "Tajawal", system-ui, sans-serif;
}

.reader-passage .read-ar--keywords .read-kw-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.18rem 0.5rem;
  align-items: center;
  padding: 0.48rem 0.52rem;
  background: #fff;
  border-radius: 10px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  box-shadow: 0 2px 10px rgba(15, 118, 110, 0.06);
}

.reader-passage .read-ar--keywords .read-kw-en {
  font-family: var(--font-reading);
  font-size: clamp(0.72rem, 0.62rem + 0.48vmin, 0.84rem);
  font-weight: 600;
  font-optical-sizing: auto;
  color: var(--ink);
  direction: ltr;
  text-align: left;
  line-height: 1.28;
}

.reader-passage .read-ar--keywords .read-kw-ar {
  font-size: clamp(0.8rem, 0.72rem + 0.48vmin, 0.95rem);
  font-weight: 700;
  color: #0f766e;
  line-height: 1.38;
  text-align: right;
}

.reader-passage .read-ar--keywords .read-teacher-note {
  display: none !important;
}

.reader-passage .read-ar:not(.read-ar--keywords) {
  background: linear-gradient(160deg, #453a32 0%, var(--accent) 45%, #2f2620 100%);
  color: var(--paper-cream);
  border: 1px solid rgba(226, 212, 194, 0.45);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.5rem 0.5rem;
  box-shadow: none;
  direction: rtl;
  text-align: right;
  font-family: "Tajawal", system-ui, sans-serif;
}

.reader-passage .read-teacher-note {
  display: none;
}

.reader-passage .read-ar:not(.read-ar--keywords) .read-teacher-note {
  display: block;
  margin: 0.55rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-family: "Tajawal", system-ui, sans-serif;
  font-size: 0.62rem;
  line-height: 1.4;
  font-weight: 500;
  color: rgba(243, 235, 220, 0.88);
  text-align: right;
}

.reader-passage .reader-trans .translation-panel.is-open {
  max-height: min(50vh, 360px);
}

.reader-passage .reader-trans .read-kw-item {
  background: rgba(255, 255, 255, 0.72);
  border-color: var(--line);
}

.reader-passage .reader-trans .read-kw-en {
  color: var(--ink);
}

.reader-passage .reader-trans .read-kw-ar {
  color: var(--ink-soft);
}

.reader-passage .reader-trans .translation-toggle {
  font-family: "Tajawal", var(--font-ui), system-ui, sans-serif;
}

@media (min-width: 1024px) and (min-height: 700px) {
  .reader-passage .lesson-wrap--fit .read-en__text {
    font-size: clamp(1.06rem, 1.18dvh + 0.7rem, 1.4rem);
    line-height: 1.6;
  }

  .reader-passage .lesson-wrap--fit .read-ar--keywords .read-kw-ar {
    font-size: clamp(0.82rem, 0.78dvh + 0.62rem, 0.98rem);
    line-height: 1.4;
  }

  .reader-passage .lesson-wrap--fit .read-ar--keywords .read-kw-en {
    font-size: clamp(0.72rem, 0.65dvh + 0.58rem, 0.82rem);
  }
}

.reader-passage .reader-article-stack > .reader-eyebrow,
.reader-passage .reader-article-stack > .reader-eyebrow-ar,
.reader-passage .reader-article-stack > .reader-h1,
.reader-passage .reader-article-stack > .reader-h1-ar {
  text-align: center;
}

.reader-passage .reader-article-stack > .reader-lede {
  text-align: center;
  max-width: min(62ch, 100%);
  margin-inline: auto;
}

.reader-passage:has(.lesson-wrap--fit) .reader-article-stack > .reader-h1-ar {
  margin-bottom: clamp(10px, 1.8vw, 20px);
}

.reader-passage:not(:has(.lesson-wrap--fit)) .reader-article-stack > .reader-h1-ar {
  margin-bottom: clamp(6px, 1vw, 12px);
}

.reader-passage .reader-article-stack > .reader-tools {
  justify-content: center;
}

.reader-passage .read-token:focus-visible {
  outline: 2px solid rgba(59, 130, 196, 0.9);
  outline-offset: 2px;
}

.reader-passage .read-kw-item--interactive:focus-visible {
  outline: 2px solid rgba(251, 191, 36, 0.95);
  outline-offset: 2px;
}

.reader-passage .read-token.is-kw-active {
  background: rgba(59, 130, 196, 0.2);
  box-shadow: 0 0 0 2px rgba(59, 130, 196, 0.45);
}

.reader-passage .read-kw-item--interactive {
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.reader-passage .read-kw-item--interactive.is-kw-active {
  background: rgba(15, 118, 110, 0.08);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.45);
}

.reader-passage .reader-trans .read-kw-item--interactive.is-kw-active {
  background: rgba(15, 118, 110, 0.12);
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.35);
}

.reader-passage .interactive-word--linked {
  cursor: pointer;
  transition: box-shadow 0.15s ease, background-color 0.15s ease;
}

.reader-passage .interactive-word--linked.is-kw-active {
  box-shadow: 0 0 0 2px rgba(59, 130, 196, 0.55);
  background: rgba(59, 130, 196, 0.12);
}
