/* jarchi before the class (ENTRY.md): the readiness check (ready.js), the waiting room (waiting.js) and the teacher's
   prep room (prep.js). Built on the kit in style.css: the tokens, the type and spacing scales, .card, .btn. Calm:
   warm grounds, colour only for meaning, never an alarming red ground. */

/* ---------- a small spinner (the kit's motion; still under reduced motion) ---------- */
.rd-spin {
  display: inline-block; flex: none;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-inline-end-color: transparent;
  opacity: .7; vertical-align: -3px;
  animation: rd-spin 900ms linear infinite;
}
@keyframes rd-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .rd-spin { animation: none; border-inline-end-color: currentColor; opacity: .35; } }
.btn .rd-spin { margin-inline-end: 2px; }

/* ---------- the first-time check in the join card ---------- */
/* One quiet line under the button; the rows open below it, flat (no inner card, no icon tiles). */
.rd-check { margin: var(--s2) 0 0; padding: 0; }
.rd-sum {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0;
  margin: 0; color: var(--muted); font-size: var(--fs-s);
}
.rd-more {
  display: inline-flex; align-items: center; gap: var(--s1); min-height: var(--tap); padding: 0 var(--s1);
  background: none; border: 0; color: inherit; font: inherit; cursor: pointer;
}
.rd-sum-ic { display: inline-grid; place-items: center; }
.rd-sum-ic .ic { width: 16px; height: 16px; color: var(--accent-ink); }
.rd-check[data-tone="warn"] .rd-sum-ic .ic { color: var(--hand-ink); }
.rd-sum-act { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s2); }
.rd-sum .btn.rd-link, .rd-check .btn.rd-link {
  width: auto; min-height: var(--tap); padding: 0 var(--s1); background: none; border: 0; box-shadow: none;
  color: var(--accent-ink); font-size: var(--fs-s); font-weight: var(--fw-b);
  text-decoration: underline; text-underline-offset: 3px;
}
.rd-link .ic { display: none; }
.rd-ask { display: inline-flex; align-items: center; gap: 0 var(--s1); }
.rd-body { margin: var(--s1) 0 0; text-align: start; }
.rd-check > .hint { margin: 0 0 var(--s2); font-size: var(--fs-s); }
.rd-rows { list-style: none; margin: 0; padding: 0; }
.rd-row {
  display: grid; grid-template-columns: auto minmax(0, auto) minmax(0, 1fr); align-items: center; gap: var(--s2) var(--s3);
  min-height: 48px; padding: var(--s1) 0; border-top: 1px solid var(--line);
}
.rd-row:first-child { border-top: 0; }
.rd-ic { display: grid; place-items: center; width: 32px; height: 32px; color: var(--muted); }
.rd-ic .ic { width: 18px; height: 18px; }
/* The signal bars never carry the "no network" cross here: the row's word is the result; weak dims the top bars. */
.rd-ic .sg-x { display: none; }
.rd-row[data-st="warn"] .rd-ic .sg-3, .rd-row[data-st="warn"] .rd-ic .sg-4 { opacity: .3; }
.rd-label { font-weight: var(--fw-b); font-size: var(--fs-sm); }
.rd-st {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s2);
  color: var(--muted); font-size: var(--fs-sm); text-align: end; min-width: 0;
}
.rd-st .ic { width: 18px; height: 18px; }
.rd-row[data-st="ok"] .rd-st { color: var(--ink-2); }
.rd-row[data-st="ok"] .rd-ic { color: var(--ink-2); }
.rd-row[data-st="warn"] .rd-st { color: var(--hand-ink); }
.rd-row[data-st="warn"] .rd-ic { color: var(--hand-ink); }
.rd-row .btn.tiny { min-height: var(--tap); }
.rd-tip { color: var(--ink-2); font-size: var(--fs-s); text-align: start; line-height: 1.6; }
@container (max-width: 380px) {
  .rd-row { grid-template-columns: auto minmax(0, 1fr); }
  .rd-st { grid-column: 1 / -1; justify-content: flex-start; padding-inline-start: 44px; }
}
form[data-ready="pending"] [data-enter] { cursor: progress; }

/* ---------- the red card: one problem, calmly ---------- */
.rd-red { text-align: center; padding-block: var(--s6) var(--s5); }
.rd-pic {
  display: inline-grid; place-items: center;
  width: 120px; height: 110px; margin: 0 auto var(--s2);
  color: var(--accent-ink); background: var(--accent-soft); border-radius: 28px;
}
.rd-pic svg { width: 60px; height: 60px; stroke-width: 1.5; } /* icons.js family, drawn large */
.rd-pic .ic-slash { stroke: var(--hand-ink); }
.rd-red h2 { font-size: var(--fs-lg); line-height: 1.5; font-weight: var(--fw-x); margin: 0 0 var(--s1); }
.rd-red > .hint { max-width: 40ch; margin: 0 auto var(--s3); }
.rd-steps {
  text-align: start; list-style: none; counter-reset: rd; margin: var(--s3) 0 0; padding: var(--s3) var(--s4) var(--s1);
  background: var(--bg); border-radius: var(--r-lg); font-size: var(--fs-sm);
}
.rd-steps li { counter-increment: rd; position: relative; padding-inline-start: 34px; margin-bottom: var(--s2); min-height: 24px; }
.rd-steps li::before {
  content: counter(rd, persian);
  position: absolute; inset-inline-start: 0; top: 1px;
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: var(--fw-x); font-size: var(--fs-s);
}
.rd-guide { text-align: start; margin-top: var(--s3); }
.rd-guide .pj-steps { background: var(--bg); border-radius: var(--r-lg); padding: var(--s3) var(--s4) var(--s1); }
.rd-red .pj-actions { margin-top: var(--s4); }
.rd-red #ready-retry { margin-top: var(--s3); }
.rd-again {
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  margin: var(--s4) 0 0; color: var(--muted); font-size: var(--fs-s);
}
.rd-code { margin: var(--s3) 0 0; color: var(--muted); font-size: var(--fs-s); }
.rd-code:empty { display: none; }
.rd-codenum { font-weight: var(--fw-b); color: var(--ink-2); letter-spacing: .08em; }

/* ---------- the waiting card (before the doors, and connected in the room) ---------- */
.wt { text-align: center; padding-block: var(--s6) var(--s5); }
.wt h1 { font-size: var(--fs-lg); line-height: 1.5; margin: var(--s3) 0 var(--s1); font-weight: var(--fw-x); }
.wt-mark { display: block; }
.wt-when { font-size: var(--fs-md); font-weight: var(--fw-b); color: var(--ink); margin: 0; }
.wt-notice {
  text-align: start; margin: var(--s4) 0 0; padding: var(--s3) var(--s4);
  border-radius: var(--r-lg); background: var(--hand-soft); border: 1px solid var(--hand-line); color: var(--ink);
}
.wt-notice-h { display: flex; align-items: center; gap: var(--s2); color: var(--hand-ink); font-weight: var(--fw-x); font-size: var(--fs-s); }
.wt-notice-h .ic { width: 18px; height: 18px; }
.wt-notice p { margin: var(--s1) 0 0; overflow-wrap: anywhere; white-space: pre-line; }
.wt-count, .wt-teacher {
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  margin: var(--s4) 0 0; color: var(--ink-2); font-size: var(--fs-sm);
}
.wt-teacher { margin-top: var(--s1); color: var(--muted); }
.wt-count .ic { width: 18px; height: 18px; color: var(--accent-ink); }
/* The amber line: calm, not an alarm (the page already adjusted). */
.wt-amber {
  display: flex; align-items: flex-start; justify-content: center; gap: var(--s2);
  margin: var(--s3) auto 0; max-width: 44ch; color: var(--ink-2); font-size: var(--fs-s); line-height: 1.7;
}
.wt-amber::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: .65em; border-radius: 50%; background: var(--hand-ink); }
.wt-tone { display: flex; flex-direction: column; align-items: center; gap: var(--s1); margin: var(--s2) 0 0; }
.wt-tone .btn { width: auto; }
.wt-tone .pj-said { margin: 0; }
.wt .pg-facts { margin-top: var(--s4); }
.wt-conn {
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  margin: var(--s4) 0 0; color: var(--muted); font-size: var(--fs-s);
}
.wt-conn[data-state="ok"] { color: var(--ink-2); }
.wt-conn .ic { width: 18px; height: 18px; flex: none; }
.wt-leave { margin: var(--s2) auto 0; display: flex; }
/* The card's quiet actions («صدا رو امتحان کن», «خروج»): text buttons, full tap height. */
.wt .btn.wt-link {
  width: auto; min-height: var(--tap); padding: 0 var(--s2); background: none; border: 0; box-shadow: none;
  color: var(--accent-ink); font-size: var(--fs-sm); font-weight: var(--fw-b);
}
.wt .btn.wt-link.wt-leave { color: var(--muted); }
.wt .btn.wt-link .ic { width: 18px; height: 18px; }
/* The classmates: up to four overlapping initials and «+N». */
.wt-faces { display: inline-flex; flex-direction: row; }
.wt-face {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink); border: 2px solid var(--surface);
  font-size: var(--fs-meta); font-weight: var(--fw-x); margin-inline-start: -8px;
}
.wt-face:first-child { margin-inline-start: 0; }
.wt-more { background: var(--bg-sunken); color: var(--ink-2); }
.wt .err { margin-top: var(--s3); }

/* ---------- in the class: the late joiner's line, the amber line, the support code ---------- */
.wt-toast {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s2) var(--s2) var(--s3);
  border-radius: var(--r-pop); background: var(--surface-raised); color: var(--ink);
  border: 1px solid var(--line); box-shadow: var(--shadow-2); font-size: var(--fs-sm);
  max-width: min(560px, 100%); pointer-events: auto;
}
.wt-toast > .ic { color: var(--accent-ink); }
.wt-toast > span { flex: 1; min-width: 0; }
#amber-line > .ic { color: var(--hand-ink); }
.conn-code { color: var(--muted); font-size: var(--fs-s); margin: var(--s2) 0 var(--s3); }
.conn-code bdi { color: var(--ink-2); font-weight: var(--fw-b); letter-spacing: .08em; }

/* ---------- the teacher's prep room ---------- */
/* One centred column (a phone's order everywhere): the title and the time on one line, then «شروع کلاس». */
.prep { max-width: 640px; margin-inline: auto; }
.prep-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin: 0 0 var(--s4); }
.prep-head .pg-title { margin: 0; flex: 0 1 auto; min-width: 0; }
.prep-bell {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 var(--s2); padding: 4px 12px;
  border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-ink);
  font-size: var(--fs-meta); font-weight: var(--fw-b);
}
.prep-bell .ic, .prep-bell svg { width: 16px; height: 16px; flex: none; }
.prep-bell[data-due="1"] { background: var(--hand-soft); color: var(--hand-ink); }
.prep-grid { display: flex; flex-direction: column; }
.prep-card h2 { display: flex; align-items: center; gap: var(--s2); }
.prep-card h2 .ic { color: var(--accent-ink); }
.prep-ask { display: flex; flex-direction: column; gap: var(--s3); margin: var(--s2) 0 var(--s1); }
.prep-live { margin: 0; }
.prep-live .pj-meter { height: 4px; }
.prep-livebar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 var(--s2); }
.prep-livebar .pj-status { margin: 0; }
.prep-prompt { margin: 0; color: var(--muted); font-size: var(--fs-s); }
.prep-ask { margin: 0; }
.prep .btn.prep-link {
  width: auto; min-height: var(--tap); padding: 0 var(--s2); background: none; border: 0; box-shadow: none;
  color: var(--accent-ink); font-size: var(--fs-sm); font-weight: var(--fw-b);
}
.prep .btn.prep-link .ic { width: 18px; height: 18px; }
.prep-mic[data-verdict="good"] .pj-bar { background: var(--speak); }
.prep-mic[data-verdict="low"] .pj-bar { background: var(--hand-ink); }
.prep-red-slot:empty { display: none; }
.prep-red-slot .rd-red { box-shadow: none; border-style: dashed; margin: var(--s2) 0 0; padding-block: var(--s4); }
.prep-red-slot .rd-pic { width: 96px; height: 88px; border-radius: 22px; }
.prep-red-slot .rd-pic svg { width: 48px; height: 48px; }
.prep-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s3); }
.prep-row .btn { width: auto; }
.prep-camwrap { display: flex; flex-direction: column; gap: var(--s2); }
.prep-cam { width: 240px; max-width: 100%; aspect-ratio: 16 / 9; border-radius: var(--r); background: var(--video-ground); object-fit: cover; }
.prep .pj-tip .ic { color: var(--accent-ink); width: 20px; height: 20px; flex: none; }
.prep-files { list-style: none; margin: var(--s3) 0 0; padding: 0; }
.prep-files:empty { display: none; }
.prep-files li {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; border-top: 1px solid var(--line);
}
.prep-files li:first-child { border-top: 0; }
.prep-files li > .ic { color: var(--muted); }
.prep-files li[data-state="ready"] > .ic { color: var(--accent-ink); }
.prep-files li[data-state="failed"] small { color: var(--hand-ink); }
.prep-file-name { display: flex; flex-direction: column; min-width: 0; }
.prep-file-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
.prep-file-name small { color: var(--muted); font-size: var(--fs-s); }
#prep-filecard .btn { width: auto; }
.prep-count { margin: 0 0 var(--s2); font-weight: var(--fw-b); }
.prep-count[data-n="0"] { font-weight: var(--fw); color: var(--muted); font-size: var(--fs-sm); }
.prep-count[data-n=""] { display: flex; align-items: center; gap: var(--s2); font-weight: var(--fw); color: var(--muted); font-size: var(--fs-sm); }
.prep-peoplecard { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.prep-peoplecard .prep-count { margin: 0; }
.prep-faces { display: inline-flex; align-items: center; }
.prep-faces:has(.prep-people:empty) { display: none; }
.prep-people { list-style: none; margin: 0; padding: 0; display: inline-flex; }
.prep-face {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink); border: 2px solid var(--surface);
  font-size: var(--fs-meta); font-weight: var(--fw-x); margin-inline-start: -8px;
}
.prep-people .prep-face:first-child { margin-inline-start: 0; }
.prep-face.warn { box-shadow: 0 0 0 2px var(--hand-ink); }
.prep-face.bad { box-shadow: 0 0 0 2px var(--danger-ink); }
.prep-more { background: var(--bg-sunken); color: var(--ink-2); }
/* Today's files: one compact row (the heading and «فایل امروز رو بذارید»), the list under it. */
#prep-filecard { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); }
#prep-filecard h2 { margin: 0; }
#prep-filecard > .hint:not(.prep-files-status) { display: none; }
#prep-filecard .prep-files, #prep-filecard .prep-files-status { flex-basis: 100%; }
#prep-filecard .prep-files-status:empty { display: none; }
.prep-label { display: block; color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--s1); }
#prep-notice {
  display: block; width: 100%; min-height: 72px; resize: vertical;
  padding: var(--s2) var(--s3); border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface);
}
.prep-said { margin: 0; }
.prep-said:empty { display: none; }
.prep-go { display: flex; flex-direction: column; gap: var(--s2); }
.prep-go .prep-row { margin-top: 0; }
.prep-startnote:empty { display: none; }
.prep-start { min-height: var(--tap-lg); font-size: var(--fs-md); width: 100%; }
.prep-startnote { margin: 0; }
.prep-go .err { margin: 0; }
.prep-go .err:empty { display: none; }
/* A phone on its side: a slimmer button. */
@media (max-height: 480px) and (orientation: landscape) {
  .prep-start { min-height: var(--tap); }
}

/* ---------- /ready: support reads a code ---------- */
.rd-rep .rd-rephead { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s3); }
.rd-rep .rd-verdict { font-weight: var(--fw-b); font-size: var(--fs-sm); }
.rd-rep[data-verdict="green"] .rd-verdict { color: var(--ink-2); }
.rd-rep[data-verdict="amber"] .rd-verdict { color: var(--hand-ink); }
.rd-rep[data-verdict="red"] .rd-verdict { color: var(--danger-ink); }
.rd-detail { overflow-x: auto; font-size: var(--fs-micro); background: var(--bg-sunken); border-radius: var(--r); padding: var(--s2) var(--s3); margin: var(--s2) 0 0; }
#rd-form input { display: block; width: 100%; min-height: 48px; margin: var(--s1) 0 var(--s3); padding: var(--s2) var(--s3); border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); }

/* the panel's class time */
.class-sched h2 { display: flex; align-items: center; gap: var(--s2); }
.class-sched h2 .pg-ic { color: var(--accent-ink); }
.class-sched-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.class-sched-row select, .class-sched-row input {
  min-height: var(--tap); padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); color: var(--ink);
}
.class-sched-row select { flex: 1 1 140px; }
.class-sched-row input { flex: 0 1 130px; }
.class-sched-row .btn { width: auto; }
.class-sched-said { margin: var(--s2) 0 0; }
.class-sched-said:empty { display: none; }
/* prejoin's optional mic test inside the first check */
.rd-check .rd-pj { margin: var(--s3) 0 0; background: var(--surface); }
.rd-check .rd-pj .pj-row:empty { display: none; }
/* prejoin's mic guide inside a red card: the card is the frame */
.rd-red .rd-guide { border: 0; background: transparent; padding: 0; box-shadow: none; }
/* The teacher's floor line on the stage (waiting.js): given → waiting for «آماده‌ام»; taken → «پایان صحبت». */
.floor-line .btn { flex: none; width: auto; }
.floor-line[data-floor="offered"] > .ic { color: var(--hand-ink); }
.floor-line[data-floor="live"] > .ic { color: var(--speak-ink); }
.rd-next { margin: 0 0 var(--s3); }
.err:empty:has(+ .rd-check) { display: none; } /* the line sits right under the button */
.prep-go .pj-said:empty { display: none; }

/* «ادامه از جلسه‌ی قبل»: one quiet row in today's files (prep.js) */
.prep-continue { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin: var(--s2) 0 var(--s3);
  padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--bg-sunken); }
.prep-continue > .ic { color: var(--muted); flex: none; }
.prep-continue[data-state="done"] > .ic { color: var(--accent-ink); }
.prep-continue-what { flex: 1 1 12rem; min-width: 0; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.prep-continue-what b { font-weight: 600; }
.prep-continue .btn { flex: none; }

/* «⋯» › «از جلسه‌ی قبل» (continue.js): the row opens in place to one row per file and the board */
.more-last { display: flex; flex-direction: column; gap: 2px; }
.more-last-list { display: flex; flex-direction: column; gap: 2px; }
.more-last-list .more-sub { margin-inline-start: 1.75rem; width: auto; font-size: var(--fs-sm); }
.more-last-list .more-sub > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
