/* jarchi replay player (play.js): the class's page redrawn in step with its voice. Phone first: a thin title, the
   page as big as the screen allows on the stage's dark ground, the controls in the thumb zone; one panel (chapters,
   questions, chat) beside the stage on a wide screen, a sheet over its lower part on a phone. The stage is always
   dark (as in the class); the chrome follows the device's theme. */
.play {
  position: fixed; inset: 0;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  background: var(--bg); color: var(--ink);
}
.play-top {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.play-titles { min-width: 0; flex: 1; }
.play-titles h1 {
  margin: 0; font-size: var(--fs-md); font-weight: 700; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.play-sub { margin: 0; font-size: var(--fs-xs); color: var(--muted); line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.play-acts { display: flex; align-items: center; gap: 4px; flex: none; }
.play-pubnote {
  margin: 0; padding: 6px 16px; font-size: var(--fs-xs); line-height: 1.6;
  background: var(--bg-sunken); color: var(--muted); border-bottom: 1px solid var(--line);
}
.play-pubnote[data-on="1"] { color: var(--ink-2); background: var(--bg-sunken); }

/* Rows by name: a student has no publish line, and the stage still takes the rest of the height. */
.play-top { grid-row: 1; }
.play-pubnote { grid-row: 2; }
.play-body { grid-row: 3; position: relative; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.play-bar { grid-row: 4; }
.play-stage {
  position: relative; min-height: 0; overflow: hidden;
  display: grid; place-items: center; padding: 12px;
  background: var(--stage);
}
.play-page {
  position: relative; overflow: hidden;
  background: var(--paper); border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .35);
}
.play-page[hidden] { display: none; }
.play-img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.play-img { filter: brightness(var(--paper-dim, 1)); }
.play-empty { display: grid; justify-items: center; gap: 12px; max-width: 32ch; text-align: center; color: var(--stage-muted); }
.play-empty[hidden] { display: none; }
.play-empty p { margin: 0; font-size: var(--fs); line-height: 1.8; }
.play-empty-mark {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  background: var(--stage-hover); color: var(--stage-ink);
}
.play-empty-mark .ic { width: 28px; height: 28px; }
.play-chip {
  position: absolute; inset-block-start: 12px; inset-inline-start: 50%; transform: translateX(50%);
  display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 6px 12px;
  border-radius: var(--r-pill); background: var(--stage-chip-strong); color: var(--stage-ink);
  font-size: var(--fs-sm); white-space: nowrap; pointer-events: none;
}
.play-chip[hidden] { display: none; }
.play-chip .ic { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.play-resume {
  position: absolute; inset-block-start: 12px; inset-inline: 12px; margin: 0 auto; max-width: 420px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 14px;
  border-radius: var(--r); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2);
  font-size: var(--fs-sm); line-height: 1.6;
  animation: play-in var(--t-med) var(--ease);
}
.play-resume[hidden] { display: none; }
.play-linkbtn {
  flex: none; min-height: 44px; padding: 0 12px; border: 0; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer;
}
@keyframes play-in { from { opacity: 0; transform: translateY(calc(-6px * var(--move))); } to { opacity: 1; transform: none; } }

/* The video: the screen share on the stage (its own shape), the presenter's camera as a corner tile. */
.play-screen { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); object-fit: contain; background: var(--video-ground); border-radius: 6px; }
.play-cam {
  position: absolute; inset-block-end: 12px; inset-inline-start: 12px; z-index: 2;
  width: clamp(96px, 22%, 220px); aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: 8px; background: var(--video-ground); box-shadow: var(--shadow-stage);
}
.play-screen[hidden], .play-cam[hidden] { display: none; }
.play-gapchip .ic { stroke: currentColor; fill: none; }
.play-topbtn-label { display: none; }
.play-videobtn[aria-pressed="true"] { color: var(--accent-strong); }
.play-videobtn[aria-pressed="false"] { color: var(--muted); }
@media (min-width: 700px) {
  .play-videobtn { width: auto; padding: 0 12px; gap: 6px; display: inline-flex; border-radius: var(--r-pill); }
  .play-videobtn .play-topbtn-label { display: inline; font-size: var(--fs-sm); font-weight: 600; }
}

/* The panel: a sheet over the stage's lower part on a phone, a column beside it on a wide screen. */
.play-panel {
  position: absolute; inset-inline: 0; inset-block-end: 0; height: min(62%, 460px); z-index: 3;
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: var(--surface); color: var(--ink);
  border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-3);
  animation: play-up var(--t-med) var(--ease);
}
.play-panel[hidden] { display: none; }
@keyframes play-up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.play-panel-head { display: flex; align-items: center; gap: 4px; padding: 6px 8px 0 12px; border-bottom: 1px solid var(--line); }
.play-tabs { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
.play-tab {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px;
  border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.play-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.play-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill);
  display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-size: var(--fs-xs);
}
.play-close { width: 44px; height: 44px; }
.play-tabpanel { min-height: 0; overflow-y: auto; padding: 6px 8px 12px; overscroll-behavior: contain; }
.play-tabpanel:focus { outline: none; }
.play-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.play-chatlist { max-height: 100%; }
.play-row {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; min-height: 48px; padding: 8px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer;
  transition: background-color var(--t-fast);
}
@media (hover: hover) { .play-row:hover { background: var(--bg-sunken); } }
li[data-now] > .play-row { background: var(--accent-soft); }
li[data-now] > .play-row .play-row-t { color: var(--accent-ink); }
.play-row-t { flex: none; min-width: 3.4em; padding-top: 1px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.play-row-main { display: grid; gap: 2px; min-width: 0; flex: 1; line-height: 1.6; }
.play-row-main b { font-size: var(--fs-sm); }
.play-row-sub { font-size: var(--fs-xs); color: var(--muted); }
.play-q-text, .play-chat-text { font-size: var(--fs-sm); overflow-wrap: anywhere; }
.play-chat-who { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); }
.play-tag { padding: 0 6px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-ink); font-size: var(--fs-micro); line-height: 18px; }
.play-tag.q { background: var(--hand-soft); color: var(--hand-ink); }
.play-msg-row[data-role="teacher"] .play-chat-text { font-weight: 600; }
.play-h { margin: 14px 8px 4px; font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.play-none { margin: 16px 8px; color: var(--muted); font-size: var(--fs-sm); line-height: 1.8; }
.play-gaprow { padding: 6px 8px; }
.play-gapline { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: var(--fs-xs); border-block: 1px dashed var(--line-strong); padding: 6px 4px; }
.play-gapline .ic { width: 18px; height: 18px; }
.play-seg { display: flex; align-items: center; gap: 8px; padding: 6px 8px; min-height: 52px; }
.play-seg[data-deleted="1"] .play-row-main { opacity: .55; }
.play-seg .play-segdel { flex: none; }
.play-segdel[data-sure="1"] { background: var(--danger); color: var(--on-solid); }
.play-seghint { margin: 0 8px 6px; font-size: var(--fs-xs); }

@media (min-width: 900px) and (min-height: 520px) {
  .play[data-panel]:not([data-panel=""]) .play-body { grid-template-columns: minmax(0, 1fr) 360px; }
  .play-panel {
    position: relative; inset: auto; height: auto; min-height: 0; overflow: hidden; border-radius: 0; box-shadow: none; animation: none;
    border-inline-start: 1px solid var(--line);
  }
}

/* The bar. */
.play-bar {
  display: grid; gap: 2px; justify-items: stretch; grid-template-columns: minmax(0, 1fr);
  padding: 4px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.play-bar > * { width: 100%; max-width: 720px; justify-self: center; }
.play-where {
  margin: 0; min-height: 1.6em; text-align: center;
  font-size: var(--fs-sm); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.play-seekrow { display: flex; align-items: center; gap: 10px; }
.play-time { min-width: 3.4em; text-align: center; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.play-seekwrap { position: relative; flex: 1; min-width: 0; }
.play-seek { display: block; width: 100%; height: 44px; margin: 0; accent-color: var(--accent); cursor: pointer; position: relative; z-index: 1; background: transparent; }
/* Marks over the track: chapter starts (a gap in the line), questions (a dot above), hard moments (a tick below).
   The thumb is 16 px: its centre runs from 8 px to the width less 8 px. */
.play-marks { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.play-marks > span { position: absolute; left: calc(8px + (100% - 16px) * var(--x)); top: 50%; }
.mk-ch { width: 2px; height: 8px; margin: -4px 0 0 -1px; background: var(--surface); }
.mk-q { width: 6px; height: 6px; margin: -13px 0 0 -3px; border-radius: 50%; background: var(--accent-hover); }
.mk-lost { width: 4px; height: 6px; margin: 7px 0 0 -2px; border-radius: 1px; background: var(--hand-ink); opacity: var(--n); }
.mk-gap { width: 6px; height: 14px; margin: -7px 0 0 -3px; border-radius: 2px; background: var(--surface); border: 2px dashed var(--muted); box-sizing: border-box; }
.play-btns { display: flex; align-items: center; justify-content: center; gap: 12px; }
.play-main {
  display: grid; place-items: center; width: 60px; height: 60px; flex: none;
  border: 0; border-radius: 50%; background: var(--accent); color: var(--on-accent); cursor: pointer;
  transition: background-color var(--t-fast), transform var(--t-fast);
}
.play-main:hover { background: var(--accent-hover); }
.play-main:active { transform: scale(.96); }
.play-main .ic { width: 26px; height: 26px; fill: currentColor; stroke: none; }
.play[data-playing="0"] .play-main .ic { margin-left: 3px; } /* the triangle's weight, centred */
.play-btn {
  position: relative; display: grid; place-items: center; width: 52px; height: 52px; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer;
  transition: background-color var(--t-fast);
}
.play-btn:hover { background: var(--bg-sunken); }
.play-btn .ic { width: 28px; height: 28px; stroke-width: 1.8; }
.play-topbtn { width: 44px; height: 44px; }
.play-topbtn .ic { width: 22px; height: 22px; }
.play[data-panel="chat"] #play-chat, .play[data-panel="chapters"] #play-list, .play[data-panel="questions"] #play-list { background: var(--accent-soft); color: var(--accent-ink); }
.play-btn-n {
  position: absolute; inset: 0; display: grid; place-items: center; padding-top: 2px;
  font-size: var(--fs-badge); font-weight: 700; line-height: 1; pointer-events: none;
}
.play-speedbox { position: relative; flex: none; }
.play-speed {
  min-width: 56px; height: 44px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: transparent; color: var(--ink); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.play-speed:hover, .play-speed[aria-expanded="true"] { background: var(--bg-sunken); }
.play-menu {
  position: absolute; inset-block-end: calc(100% + 8px); left: 0; z-index: 5; width: 288px;
  display: grid; gap: 8px; padding: 12px; direction: rtl;
  background: var(--surface-raised); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-2);
  animation: play-in var(--t-fast) var(--ease);
}
.play-menu[hidden] { display: none; }
.play-menu-title { margin: 0; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.play-menu-hint { margin: 0; font-size: var(--fs-xs); color: var(--muted); line-height: 1.7; }
.play-rates { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.play-rate {
  min-height: 44px; border: 1px solid var(--line); border-radius: var(--r-sm); background: transparent; color: var(--ink);
  font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
.play-rate[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.play-switch {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 0 4px;
  border: 0; background: transparent; color: var(--ink); font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
.play-switch-track { position: relative; width: 40px; height: 24px; flex: none; border-radius: 12px; background: var(--line-strong); transition: background-color var(--t-fast); }
.play-switch-track i { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--knob); box-shadow: var(--shadow-1); transition: transform var(--t-fast) var(--ease); }
.play-switch[aria-checked="true"] .play-switch-track { background: var(--accent); }
.play-switch[aria-checked="true"] .play-switch-track i { transform: translateX(-16px); }
.play-pub { padding: 0 8px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600; }
.play-pub:hover { background: var(--bg-sunken); }
.play :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

@media (max-width: 400px) {
  .play-btns { gap: 4px; }
  .play-btn { width: 48px; height: 48px; }
  .play-pub .play-switch-label { font-size: var(--fs-xs); }
}

/* A phone on its side: the page takes the height; the controls fold into one row beside the time. */
@media (orientation: landscape) and (max-height: 520px) {
  .play-top { padding-block: 4px; }
  .play-titles h1 { font-size: var(--fs); }
  .play-sub, .play-pubnote { display: none; }
  .play-stage { padding: 6px; }
  .play-panel { height: 100%; width: min(380px, 50%); inset-inline-start: auto; border-radius: 0; }
  .play-bar { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 12px; padding-block: 2px; }
  .play-bar > * { max-width: none; }
  .play-where { display: none; }
  .play-btns { grid-row: 1; grid-column: 1; gap: 4px; }
  .play-seekrow { grid-row: 1; grid-column: 2; }
  .play-main { width: 46px; height: 46px; }
  .play-menu { gap: 4px; padding: 8px 12px; }
  .play-menu-title, .play-menu-hint { display: none; }
  .play-btn { width: 44px; height: 44px; }
}

/* Before the player: loading, an old link, not ready yet, not published. */
.play-msg {
  max-width: 420px; margin: 12vh auto 0; padding: 28px 24px;
  display: grid; justify-items: center; gap: 8px; text-align: center;
}
.play-msg h1 { margin: 4px 0 0; font-size: var(--fs-lg); }
.play-msg p { margin: 0; }
.play-msg-mark {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
}
.play-msg-mark .ic { width: 26px; height: 26px; }
.play-msg[data-kind="loading"] { box-shadow: none; background: none; }
.play-loading { color: var(--muted); }
@media (prefers-reduced-motion: reduce) {
  .play-main, .play-btn, .play-row, .play-switch-track, .play-switch-track i { transition: none; }
  .play-panel, .play-menu, .play-resume { animation: none; }
}

/* The class pages' recordings (classes.js): «پخش» opens the player. */
a.pg-play { text-decoration: none; }
.pg-rec-open { color: inherit; text-decoration: none; }
.pg-rec-open:hover b { text-decoration: underline; }
.class-recs h2 { margin: 0 0 6px; font-size: var(--fs-md); }
.class-recs-list { list-style: none; margin: 0 -8px; padding: 0; display: grid; gap: 2px; }
.class-rec {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 8px;
  border-radius: var(--r); color: inherit; text-decoration: none;
}
@media (hover: hover) { .class-rec:hover { background: var(--bg-sunken); } }
.class-rec-play {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
}
.class-rec-play svg { width: 18px; height: 18px; }
.class-rec-text { display: grid; min-width: 0; flex: 1; line-height: 1.5; }
.class-rec-text .hint { font-size: var(--fs-xs); margin: 0; }
.class-rec-len { color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.pg-pub { width: auto; min-height: 44px; margin-top: 2px; font-size: var(--fs-sm); font-weight: 500; color: var(--muted); }
.pg-pub[aria-checked="true"] { color: var(--ink-2); }
.play-dlbox { position: relative; }
.play-dlmenu { inset-block-end: auto; top: calc(100% + 8px); left: 0; width: 280px; }
.play-dlrow {
  display: flex; align-items: center; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: transparent; color: var(--ink); font: inherit; font-size: var(--fs-sm); text-decoration: none; cursor: pointer;
}
.play-dlrow:disabled { color: var(--muted); cursor: default; }
@media (hover: hover) { .play-dlrow:where(:not(:disabled)):hover { background: var(--bg-sunken); } }
.play-export {
  position: absolute; inset-block-start: 12px; inset-inline: 12px; z-index: 4; margin: 0 auto; max-width: 440px;
  display: grid; gap: 6px; padding: 12px 14px; border-radius: var(--r); background: var(--card); color: var(--ink); box-shadow: var(--shadow-2);
  font-size: var(--fs-sm);
}
.play-export[hidden] { display: none; }
.play-export .play-none { margin: 0; font-size: var(--fs-xs); }
.play-export-bar { display: block; height: 6px; border-radius: 3px; background: var(--bg-sunken); overflow: hidden; }
.play-export-bar i { display: block; height: 100%; width: 0; background: var(--accent); }
.play[data-exporting="1"] .play-bar, .play[data-exporting="1"] .play-acts > :not(.play-dlbox) { pointer-events: none; opacity: .5; }
