/* Reading passage & glossary popover. */

.passage {
  position: relative;
  max-width: var(--reading-max);
  background: var(--surface); /* #FFFCF4: approved text-page background */
  border: 2px solid var(--line-strong);
  border-radius: 4px;
  padding: 26px 28px;
}
.passage.has-illustration { max-width: none; }
.passage .lesson-illustration {
  position: relative;
  z-index: 1;
  float: right;
  width: min(49%, 460px);
  margin: -8px -8px var(--s-16) var(--s-28);
  overflow: hidden;
  border-radius: 2px;
  shape-outside: inset(0 round 2px);
}
.passage .lesson-illustration::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, var(--surface) 0%, rgba(255,252,244,.78) 7%, transparent 24%),
    linear-gradient(0deg, var(--surface) 0%, rgba(255,252,244,.62) 5%, transparent 21%);
}
.passage .lesson-illustration img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 2px;
}
.passage.has-illustration .para:first-of-type .para-text { max-width: none; }
.passage.has-illustration .para:not(:first-of-type) .para-text { max-width: none; }

.passage .para {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 2.4em 1fr;
  gap: var(--s-12);
  margin: 0 0 var(--s-20);
}
.passage .para:last-child { margin-bottom: 0; }
.passage .para-num {
  font-family: var(--utility-font);
  font-size: .78rem;
  color: var(--saffron-deep);
  padding-top: .35em;
  user-select: none;
}
.passage .para-text {
  display: block;
  font-family: var(--reading-font);
  font-size: var(--passage-size);
  line-height: var(--passage-leading);
  color: var(--ink);
}
/* Restrained drop cap on the first paragraph. */
.passage .para:first-child .para-text::first-letter {
  font-family: var(--display-font);
  font-weight: 700;
  font-size: 2.9em;
  line-height: .82;
  float: left;
  margin: .04em .08em 0 0;
  color: var(--blue-deep);
}

/* Static marker underline inspired by the reference vocabulary lesson. */
.gloss {
  font: inherit;
  font-weight: 700;
  color: inherit;
  background: linear-gradient(transparent 60%, var(--saffron-soft) 60%);
  border: 0;
  border-radius: 2px;
  padding: 0 2px;
  cursor: pointer;
  text-decoration: none;
}
.gloss:hover {
  color: inherit;
  background: linear-gradient(transparent 60%, var(--saffron-soft) 60%);
}
.gloss:active {
  color: inherit;
  background: linear-gradient(transparent 60%, var(--saffron-soft) 60%);
}
.gloss:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}
.passage .reference-word {
  color: var(--blue-deep);
  font-weight: 700;
  background: linear-gradient(transparent 62%, var(--blue-soft) 62%);
  border-bottom: 1px solid var(--blue);
  border-radius: 2px;
  padding: 0 2px;
}
.para.is-flash > .para-text { animation: para-flash 1.2s ease; }
@keyframes para-flash {
  0%, 100% { background: transparent; }
  30% { background: var(--blue-soft); }
}

/* Compact charcoal ink-note popup from the approved vocabulary reference. */
.popover {
  position: absolute;
  z-index: 60;
  width: min(340px, calc(100vw - 24px));
  max-height: min(440px, calc(100vh - 24px));
  overflow: visible;
  background: var(--ink);
  color: #F2F0EA;
  border: 0;
  border-radius: 4px;
  box-shadow: 4px 4px 0 rgba(43,42,38,.25);
  padding: 12px 16px 14px;
}
.popover::after {
  content: "";
  position: absolute;
  top: -7px;
  left: 14px;
  border: 7px solid transparent;
  border-bottom-color: var(--ink);
}
.popover .pop-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding-right: 26px;
}
.popover .pop-word { font-family: var(--display-font); font-weight: 800; font-size: 1.05rem; color: #F2C14E; }
.popover .pop-head .listen-btn {
  border-color: rgba(242,240,234,.35);
  background: rgba(255,255,255,.08);
  color: #F2F0EA;
}
.popover .pop-head .listen-btn:hover,
.popover .pop-head .listen-btn.playing {
  border-color: #F2C14E;
  background: rgba(242,193,78,.14);
  color: #F2C14E;
}
.popover .pop-pos { font-family: var(--utility-font); font-size: .68rem; color: var(--ink-faint); }
.popover .pop-ar { font-family: var(--arabic-font); font-size: 1.25rem; color: #F2F0EA; margin-top: 4px; padding-right: 26px; }
.popover .pop-ipa { font-family: var(--utility-font); font-size: .78rem; color: var(--ink-soft); }
.popover .pop-def {
  margin-top: 7px;
  font-family: var(--display-font); font-size: .86rem; line-height: 1.45; color: #F2F0EA;
}
.popover .pop-syn { margin-top: 6px; font-family: var(--display-font); font-size: .8rem; color: rgba(242,240,234,.8); }
.popover .pop-syn-label { font-family: var(--display-font); font-weight: 700; color: #F2C14E; }
.popover .pop-example {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid rgba(242,240,234,.2);
  font-family: var(--reading-font); font-size: .82rem; line-height: 1.45; color: rgba(242,240,234,.78);
  font-style: italic;
}
.popover .pop-close {
  position: absolute; top: 4px; right: 4px;
  width: 26px; height: 26px; padding: 0; border-radius: var(--r-sm);
  border: 0; background: transparent; color: rgba(242,240,234,.75); font-size: 1rem;
}
.popover .pop-close:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ---------- Interlinear bilingual reading ---------- */
.il-tok {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: top;
  margin: 0 0.5px;
}
.il-en { font: inherit; }
.il-ar {
  display: none;
  font-family: var(--arabic-font);
  font-size: .48em;
  line-height: 1.1;
  color: var(--ink-soft);
  white-space: nowrap;
  margin-top: -1px;
}
.il-ar.il-ar-bold {
  font-weight: 700;
  color: var(--ink);
}
.passage.bilingual .il-ar { display: block; }
.passage.bilingual .il-tok { vertical-align: top; }
.passage.bilingual .para-text { line-height: 2.2; }

/* ---------- Paragraph-level Arabic translation ---------- */
.para-ar {
  display: none;
  grid-column: 2;
  font-family: var(--arabic-font);
  font-size: .88em;
  line-height: 1.7;
  color: var(--saffron-deep);
  margin: 0;
  padding: 0;
}
.passage.bilingual .para-ar { display: block; }
.para-ar .ar-vocab { font-weight: 700; color: var(--blue-deep); }

/* ---------- Language toggle badge in masthead ---------- */
.lang-toggle {
  display: inline-flex !important;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  min-height: 34px;
  padding: 3px !important;
  border: 1px solid var(--line-strong) !important;
  border-radius: 999px !important;
  background: #fffdf8;
  box-shadow: 0 5px 14px -10px rgba(14, 66, 112, .85);
  transition: border-color .15s, box-shadow .15s, transform .15s;
  font-family: var(--utility-font);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .04em;
  user-select: none;
}
.lang-toggle .lt-en,
.lang-toggle .lt-ar {
  min-width: 34px;
  padding: 5px 7px;
  border-radius: 999px;
  text-align: center;
  transition: background .15s, color .15s;
}
.lang-toggle .lt-divider { display: none; }
.lang-toggle[aria-pressed="false"] .lt-en { background: var(--blue-deep); color: #fff; }
.lang-toggle[aria-pressed="false"] .lt-ar { color: var(--blue-deep); }
.lang-toggle[aria-pressed="true"] .lt-ar { background: var(--saffron-deep); color: #fff; }
.lang-toggle[aria-pressed="true"] .lt-en { color: var(--ink); }
.lang-toggle:hover {
  border-color: var(--saffron-deep) !important;
  background: #fffdf8;
  box-shadow: 0 7px 18px -10px rgba(154, 102, 0, .7);
  transform: translateY(-1px);
}
.lang-toggle:focus-visible {
  outline: 3px solid rgba(44, 111, 160, .28);
  outline-offset: 2px;
}
