/* The lectern: the text set as the reader sets it, the dock, the level meter
   and the take under its bayt. Also the try-a-bayt panel. */

/* ---------- verse: staggered dīwān (D-2026-10-01-j reader B) ---------- */

.verse {
  font-family: var(--font-arabic);
  font-weight: 400;
  direction: rtl;
  color: var(--ink);
  letter-spacing: 0;
}

.stag {
  display: grid;
  line-height: 1.85;
}

/* Sadr flush right, ʿajuz flush left. */
.stag .s {
  justify-self: start;
}

.stag .j {
  justify-self: end;
}

/* Measured on one line each; settleStagger() stacks a bayt that does not fit. */
.stag:not(.stacked) .s,
.stag:not(.stacked) .j {
  white-space: nowrap;
}

/* The stacked fallback for a bayt too long to stagger: ʿajuz stepped in under
   a right-aligned sadr (bayt_setting.dart stackedAjuzIndent). */
.stag.stacked .j {
  justify-self: start;
  padding-inline-start: 1.5em;
}

/* Transliteration under each half (the English help flow). */
.stag .tr {
  font: italic 400 15px/1.45 var(--font-latin);
  color: var(--faded);
  letter-spacing: 0;
  white-space: normal;
  margin-bottom: 6px;
}

.stag .ts {
  justify-self: start;
  text-align: right;
}

.stag .tj {
  justify-self: end;
  text-align: left;
}

.stag.stacked .tj {
  justify-self: start;
  text-align: right;
  padding-inline-start: 1.5em;
}

.verse-num {
  font: 400 17px/1 var(--font-arabic);
  color: var(--quiet);
  font-variant-numeric: tabular-nums;
}

.loz {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--gold);
  transform: rotate(45deg);
  flex: none;
}

.loz.hollow {
  background: transparent;
  border: 1px solid currentColor;
}

/* ---------- the text page ---------- */

#text-screen.active {
  height: 100dvh;
  min-height: 0;
}

.text-sub {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: var(--hairline) solid var(--rule);
}

.text-sub .ar-inline {
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-layout {
  flex: 1;
  min-height: 0;
  display: flex;
}

.page-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 16px 24px;
  outline: none;
  scroll-padding-block: 96px;
}

.chapter-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 18px 0 6px;
  direction: rtl;
  flex-wrap: wrap;
}

.chapter-head:first-child {
  padding-top: 4px;
}

.chapter-head .ar-inline {
  font-size: 21px;
  color: var(--gold-text);
}

.chapter-head .eyebrow {
  direction: ltr;
}

.bayt {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 0 12px;
  align-items: start;
  padding: 6px 0;
  direction: rtl;
  border-radius: var(--radius-s);
  cursor: pointer;
}

.bayt:hover .verse {
  color: var(--ink);
}

.bayt-margin {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding-top: 8px;
}

.bayt-select {
  min-width: 32px;
  min-height: 32px;
  border-radius: var(--radius-s);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bayt .loz {
  opacity: 0;
  transition: opacity var(--duration) ease;
}

.bayt.current .loz {
  opacity: 1;
}

.bayt.current .verse-num {
  color: var(--gold-text);
}

.bayt .verse {
  font-size: 23px;
}

.bayt.done .verse {
  color: var(--faded);
}

.bayt-body {
  min-width: 0;
}

.bayt-state {
  grid-column: 2;
  direction: ltr;
  text-align: left;
  margin-top: 2px;
  min-height: 0;
}

html[dir="rtl"] .bayt-state {
  direction: rtl;
  text-align: right;
}

@media (min-width: 900px) {
  .bayt {
    grid-template-columns: 32px minmax(0, 1fr) 140px;
  }

  .bayt .verse {
    font-size: 27px;
  }

  .bayt-state {
    grid-column: 3;
    padding-top: 16px;
    margin-top: 0;
  }

  .page {
    padding: 16px 8px 24px;
  }
}

/* ---------- status words: text first, never colour alone ---------- */

.st {
  font: 500 12px/1.2 var(--font-latin);
  color: var(--quiet);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

html[lang="ar"] .st {
  font: 400 15px/1.2 var(--font-arabic);
}

.st.ok {
  color: var(--success);
}

.st.again {
  color: var(--error);
}

.st.review,
.st.queue,
.st.draft {
  color: var(--faded);
}

.st.quiet {
  color: var(--quiet);
}

.st .dot,
.st .ring {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.st .dot {
  background: currentColor;
}

.st .ring {
  border: 1.5px solid currentColor;
}

.st .ring.dashed {
  border-style: dashed;
}

/* A draft: half kept, half open. */
.st .half {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

.take-honesty {
  margin-top: 10px;
}

.dock-submit:empty {
  display: none;
}

/* ---------- the chapter rail ---------- */

.chapter-rail {
  display: grid;
  width: 280px;
  flex: none;
  padding: 28px 0 24px;
  overflow-y: auto;
  align-content: start;
  gap: 2px;
}

@media (min-width: 900px) {
  .text-layout {
    justify-content: center;
    gap: 64px;
    padding: 0 40px;
  }

  .page-column {
    max-width: 760px;
  }
}

.chapter-rail #rail-sent {
  margin-bottom: 12px;
}

.chapter-rail .under-review-note {
  margin-bottom: 12px;
}

.chapter-rail ol {
  display: grid;
  gap: 2px;
}

.chapter-link {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: baseline;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-s);
  text-align: start;
  min-height: var(--target);
}

.chapter-link .ar-inline {
  font-size: 18px;
  line-height: 1.3;
  color: var(--faded);
}

.chapter-link[aria-current="true"] {
  background: var(--wash);
}

.chapter-link[aria-current="true"] .ar-inline {
  color: var(--ink);
}

.chapter-rail > .rule {
  margin: 16px 0 12px;
}

.chapter-rail > .lnk {
  justify-self: start;
}

/* ---------- the dock ---------- */

.dock {
  flex: none;
  border-top: var(--hairline) solid var(--rule);
  background: var(--surface);
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
}

.dock-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 10px;
}

.dock .lbl,
.try-panel .lbl,
.dock .rec-status,
.dock .help:first-of-type {
  white-space: nowrap;
}

.dock-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.dock-info-stack {
  display: grid;
  gap: 4px;
}

.dock-centre {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.dock-note {
  font: 400 13px/1.45 var(--font-latin);
  color: var(--faded);
}

html[lang="ar"] .dock-note {
  font: 400 16px/1.5 var(--font-arabic);
}

.dock-note.alert {
  color: var(--error);
}

.dock-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dock-actions .btn {
  padding: 0 14px;
}

.dock-panel {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: var(--hairline) solid var(--rule);
  border-radius: var(--radius-m);
  background: var(--page);
}

.dock-panel .icon {
  color: var(--warning);
}

.dock-panel.mic .icon {
  color: var(--error);
}

.dock-panel.submit .icon {
  color: inherit;
}

.dock-panel.submit .dock-panel-body {
  flex: 1;
}

.dock-panel-body {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.dock-panel-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  align-items: center;
}

.dock-panel .btn {
  white-space: normal;
  text-align: center;
  line-height: 1.3;
  padding-block: 8px;
  max-width: 100%;
}

.mic-select {
  min-height: var(--target);
  border: 1px solid var(--veil);
  border-radius: var(--radius-s);
  background: var(--surface);
  padding: 0 10px;
  max-width: 100%;
}

@media (min-width: 900px) {
  .dock {
    padding: 14px 24px 16px;
  }

  .dock-row {
    grid-template-columns: 1fr auto 1fr;
    gap: 24px;
  }

  .dock-row > :last-child {
    justify-self: end;
  }

  .dock-row.review {
    grid-template-columns: auto 1fr;
  }

  .dock-keys {
    display: flex;
    justify-content: flex-end;
  }

  .dock-actions {
    grid-template-columns: auto auto;
    justify-content: center;
  }

  .dock-actions .btn.pri {
    min-width: 200px;
  }

  .dock-actions .btn.sec {
    min-width: 170px;
  }
}

/* The record key: ink disc, error dot; stop: on-ink square in a ring. */
.rec {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  position: relative;
}

.rec i {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--error);
}

.rec.stop svg {
  width: 20px;
  height: 20px;
  fill: var(--on-ink);
}

.rec.stop::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--error);
}

.rec:disabled {
  opacity: 0.5;
}

.rec-status {
  color: var(--error);
}

.timer {
  font: 600 18px/1 var(--font-latin);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

html[lang="ar"] .timer {
  font: 400 22px/1 var(--font-arabic);
}

/* ---------- level meter with a target band ---------- */

.meter {
  position: relative;
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--container-highest);
  overflow: hidden;
  direction: ltr;
}

html[dir="rtl"] .meter {
  transform: scaleX(-1);
}

.meter .band {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 37.5%;
  width: 54.17%;
  border-inline: 1.5px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 14%, transparent);
}

.meter .lv {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: 0;
  border-radius: var(--radius-pill);
  background: var(--ink);
}

.meter .pk {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--ink);
}

.meter.clip .lv,
.meter.clip .pk {
  background: var(--error);
}

.mscale {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font: 500 11px/1 var(--font-latin);
  color: var(--quiet);
}

html[lang="ar"] .mscale {
  font: 400 14px/1 var(--font-arabic);
}

.mscale .good {
  margin-inline-start: auto;
  margin-inline-end: 9%;
}

/* ---------- the take, under its bayt ---------- */

.take {
  direction: ltr;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  margin-top: 8px;
  padding: 10px 12px;
  border: var(--hairline) solid var(--rule);
  border-radius: var(--radius-m);
  background: var(--surface);
}

html[dir="rtl"] .take {
  direction: rtl;
}

.take .play {
  background: var(--ink);
  color: var(--on-ink);
}

.take .play:hover {
  background: var(--ink);
}

.take .play .icon {
  width: 18px;
  height: 18px;
}

.take-wave {
  position: relative;
  height: 34px;
  cursor: pointer;
  direction: ltr;
  border-radius: var(--radius-s);
}

html[dir="rtl"] .take-wave svg {
  transform: scaleX(-1);
}

.take-wave svg {
  display: block;
  width: 100%;
  height: 100%;
}

.take-wave rect {
  fill: var(--quiet);
}

.take-wave rect.p {
  fill: var(--ink);
}

.take-wave .ph {
  stroke: var(--gold);
  stroke-width: 2;
}

.take-time {
  direction: ltr;
  unicode-bidi: isolate;
}

.take-quality {
  grid-column: 2 / -1;
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.take-quality .icon {
  width: 14px;
  height: 14px;
  margin-top: 2px;
}

.take-quality.ok .icon {
  color: var(--success);
}

.take-quality.warn .icon {
  color: var(--warning);
}

/* ---------- try a bayt ---------- */

.try-bayt {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 0 12px;
  direction: rtl;
  align-items: start;
}

.try-bayt > .bayt {
  grid-column: 1 / -1;
}

.try-bayt .verse {
  font-size: 25px;
}

.try-panel {
  position: sticky;
  bottom: 0;
  margin: 0 -16px;
  padding: 14px 16px calc(22px + env(safe-area-inset-bottom));
  border-top: var(--hairline) solid var(--rule);
  background: var(--surface);
  display: grid;
  gap: 12px;
}

.try-actions {
  display: flex;
  gap: 10px;
  flex-direction: column;
}

@media (min-width: 900px) {
  .try {
    padding-top: 48px;
    gap: 24px;
  }

  .try-bayt .verse {
    font-size: 30px;
  }

  .try-panel {
    position: static;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .try-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
