/**
 * Tanach study reader. RTL. Uses the theme brand tokens (css/brand.css).
 */
.reader {
  direction: rtl;
  max-width: var(--maxw, 1200px);
  margin: 0 auto;
  color: var(--c-text, #2f3236);
}

/* ---- Navigation bar ---- */
.reader-nav {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  padding: .6rem 0 1rem;
}
.rsel {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border, #e6e2da);
  border-radius: var(--radius, 10px);
  box-shadow: var(--shadow);
  min-width: 8.5rem;
}
.rsel select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  font: inherit;
  font-family: var(--font-ui);
  color: var(--c-text);
  padding: .5rem 1rem .5rem 2.2rem;
  width: 100%;
  cursor: pointer;
  border-radius: inherit;
}
.rsel select:focus { outline: 2px solid var(--c-teal); outline-offset: 1px; }
.rsel-caret {
  position: absolute;
  left: .7rem;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--c-teal, #159aa6);
  pointer-events: none;
}
.rsel-caret::after {
  content: "";
  position: absolute;
  left: 5px; top: 6px;
  width: 6px; height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
}

/* ---- Reading controls ---- */
.reader-tools {
  display: flex;
  gap: .4rem;
  justify-content: flex-start;
  padding: .5rem .8rem;
  background: #eef1f0;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.rtool {
  border: 1px solid var(--c-border);
  background: #fff;
  color: var(--c-teal-dark, #16575e);
  border-radius: var(--radius-pill, 999px);
  padding: .35rem .8rem;
  font-family: var(--font-ui);
  font-size: .9rem;
  cursor: pointer;
}
.rtool:hover { background: var(--c-teal-dark); color: #fff; }
.rtool.is-on { background: var(--c-teal-dark); color: #fff; }

/* ---- Body layout: text + study toolbar ---- */
.reader-body { display: flex; align-items: flex-start; gap: 1rem; }
.reader-text {
  flex: 1;
  min-width: 0;
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 2rem 2rem;
}
.chapter-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.book-title {
  font-family: var(--font-scripture);
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin: 0;
  color: var(--c-text);
}
.chapter-label {
  text-align: center;
  color: var(--c-bordeaux, #a81f38);
  font-family: var(--font-scripture);
  font-size: 1.4rem;
  font-weight: 700;
  margin: .1rem 0 1.2rem;
}
.ch-nav {
  text-decoration: none;
  color: var(--c-muted);
  font-size: 1.6rem;
  line-height: 1;
  padding: .1rem .4rem;
  border-radius: 50%;
}
.ch-nav:hover { color: var(--c-teal-dark); background: #eef1f0; }

/* Flowing scripture with inline verse numbers */
.scripture {
  font-family: var(--font-scripture);
  font-size: 1.35rem;
  line-height: 2.15;
  text-align: justify;
  color: #1c1e20;
}
.scripture .verse { cursor: pointer; border-radius: 4px; transition: background .12s; }
.scripture .verse:hover { background: #fbf6e8; }
.scripture .verse.is-active { background: #fdeecf; box-shadow: inset 0 0 0 1px #f0d089; }
.scripture .vnum {
  color: var(--c-bordeaux, #a81f38);
  font-size: .62em;
  font-weight: 700;
  vertical-align: .35em;
  margin-inline: .1em;
  font-family: var(--font-ui);
}
.scripture .pmark {
  color: var(--c-teal, #159aa6);
  font-weight: 700;
  margin-inline: .15em;
}
.chapter-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--c-border);
}
.foot-link { color: var(--c-teal-dark); text-decoration: none; font-family: var(--font-ui); }
.foot-link:hover { text-decoration: underline; }

/* ---- Study toolbar ---- */
.study-toolbar { order: -1; display: flex; align-items: flex-start; gap: .8rem; }
.study-buttons {
  order: -1;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: 5.2rem;
  flex: 0 0 auto;
}
.sbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--c-surface, #fff);
  box-shadow: var(--shadow);
  color: var(--c-text);
  font-family: var(--font-ui);
  font-size: .72rem;
  padding: .5rem .2rem;
  cursor: pointer;
  border-inline-start: 3px solid var(--sc, #999);
}
.sbtn:hover { background: #fafafa; }
.sbtn.is-active { background: var(--sc, #999); color: #fff; }
.sbtn-ic {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem; height: 1.7rem;
  border-radius: 50%;
  border: 2px solid var(--sc, #999);
  color: var(--sc, #999);
  font-family: var(--font-scripture);
  font-weight: 700;
  font-size: .95rem;
}
.sbtn.is-active .sbtn-ic { border-color: #fff; color: #fff; }
.c-translations { --sc: var(--c-circle-shorts, #f39c12); }
.c-commentators { --sc: var(--c-circle-commentators, #d24b8f); }
.c-maps { --sc: var(--c-teal, #159aa6); }
.c-articles { --sc: var(--c-circle-articles, #16a085); }
.c-lessons { --sc: var(--c-circle-topics, #2f8fd0); }
.c-topics { --sc: var(--c-circle-lessons, #3b4a5a); }
.c-people { --sc: var(--c-circle-figures, #e2453f); }
.c-shorts { --sc: var(--c-circle-places, #7b68c9); }

/* Study panel */
.study-panel {
  width: 22rem;
  flex: 0 0 auto;
  align-self: stretch;
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.study-panel[hidden] { display: none; }
.study-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem 1rem;
  background: var(--c-teal-dark, #16575e);
  color: #fff;
}
.study-panel-title { font-family: var(--font-ui); font-weight: 700; }
.study-close { background: none; border: 0; color: #fff; font-size: 1rem; cursor: pointer; }
.study-panel-verse {
  padding: .4rem 1rem;
  color: var(--c-muted);
  font-family: var(--font-ui);
  font-size: .85rem;
  border-bottom: 1px solid var(--c-border);
}
.study-panel-verse:empty { display: none; }
.study-panel-body { padding: .8rem 1rem; overflow-y: auto; }
.study-item { padding: .6rem 0; border-bottom: 1px solid var(--c-border); }
.study-item:last-child { border-bottom: 0; }
.study-name { margin: 0 0 .3rem; color: var(--c-bordeaux); font-family: var(--font-ui); font-size: .95rem; }
.study-text { font-family: var(--font-scripture); font-size: 1.05rem; line-height: 1.8; }
.study-link a { color: var(--c-teal-dark); text-decoration: none; font-family: var(--font-ui); font-weight: 600; }
.study-link a:hover { text-decoration: underline; }
.study-by { display: block; color: var(--c-muted); font-size: .8rem; font-family: var(--font-ui); }
.study-empty, .study-loading { color: var(--c-muted); font-family: var(--font-ui); text-align: center; padding: 1rem 0; }

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .reader-body { display: block; }
  .study-toolbar { display: block; margin-top: 1.2rem; }
  .study-buttons { flex-direction: row; flex-wrap: wrap; width: auto; }
  .sbtn { flex: 1 0 4rem; }
  .study-panel { width: auto; margin-top: .8rem; max-height: none; }
  .reader-text { padding: 1.2rem 1rem; }
  .scripture { font-size: 1.2rem; }
}
