/* 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 ---------- */
.rd-check {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s3) var(--s4); margin: 0 0 var(--s4);
}
.rd-check h3 { font-size: var(--fs); font-weight: var(--fw-x); margin: 0; }
.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; border-radius: 10px;
  background: var(--card); color: var(--muted); border: 1px solid var(--line);
}
.rd-ic .ic { width: 18px; height: 18px; }
.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(--ok-ink); }
.rd-row[data-st="ok"] .rd-ic { color: var(--ok-ink); background: var(--ok-soft); border-color: transparent; }
.rd-row[data-st="warn"] .rd-st { color: var(--warn); }
.rd-row[data-st="warn"] .rd-ic { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.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); background: var(--accent-soft); border-radius: 28px;
}
.rd-pic svg { width: 96px; height: 88px; }
.rd-pic .rd-x { stroke: var(--warn-solid); }
.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); 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(--faint); 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-left {
  display: inline-block; margin: var(--s2) 0 0; padding: 2px var(--s3);
  border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-strong);
  font-weight: var(--fw-x); font-size: var(--fs-sm);
}
.wt-notice {
  text-align: start; margin: var(--s4) 0 0; padding: var(--s3) var(--s4);
  border-radius: var(--r-lg); background: var(--hand); 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); }
.wt-amber {
  margin: var(--s3) auto 0; max-width: 44ch; padding: var(--s2) var(--s3);
  border-radius: var(--r); background: var(--warn-soft); color: var(--warn); font-size: var(--fs-s); font-weight: var(--fw-m);
}
.wt-tone { display: flex; flex-direction: column; align-items: center; gap: var(--s1); margin: var(--s4) 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(--ok-ink); }
.wt-conn .ic { width: 18px; height: 18px; flex: none; }
.wt-leave { margin: var(--s3) auto 0; display: flex; }
.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(--card-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); }
.wt-toast > span { flex: 1; min-width: 0; }
#amber-line > .ic { color: var(--warn); }
.conn-code { color: var(--faint); 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 ---------- */
body.in-prep { padding-bottom: 0; }
.prep { padding-bottom: 120px; }
.prep-head { margin: 0 0 var(--s4); }
.prep-head .pg-title { margin-bottom: var(--s1); }
.prep-head .pg-lede { margin: 0; max-width: 60ch; }
.prep-grid { display: grid; gap: 0 var(--s5); }
.prep-card h2 { display: flex; align-items: center; gap: var(--s2); }
.prep-card h2 .ic { color: var(--accent); }
.prep-ask { display: flex; flex-direction: column; gap: var(--s3); margin: var(--s2) 0 var(--s1); }
.prep-why {
  display: flex; align-items: flex-start; gap: var(--s2); margin: 0;
  padding: var(--s3); border-radius: var(--r); background: var(--accent-soft); color: var(--ink); font-size: var(--fs-sm);
}
.prep-why .ic { color: var(--accent); margin-top: 3px; }
.prep-live { margin: var(--s2) 0 var(--s1); }
.prep-live .pj-meter { height: 14px; }
.prep-mic[data-verdict="good"] .pj-bar { background: var(--speak); }
.prep-mic[data-verdict="low"] .pj-bar { background: var(--warn-solid); }
.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: 76px; height: 70px; }
.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: #000; object-fit: cover; }
.prep .pj-tip .ic { color: var(--accent); 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); }
.prep-files li[data-state="failed"] small { color: var(--warn); }
.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-people { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.prep-people li { display: flex; align-items: center; gap: var(--s3); min-height: 44px; border-top: 1px solid var(--line); }
.prep-people li:first-child { border-top: 0; }
.prep-people .avatar {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong); font-weight: var(--fw-x); font-size: var(--fs-sm);
}
.prep-pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); font-weight: var(--fw-m); }
.prep-ready { color: var(--muted); font-size: var(--fs-s); white-space: nowrap; }
.prep-ready.ok { color: var(--ok-ink); }
.prep-ready.warn { color: var(--warn); }
.prep-ready.bad { color: var(--danger-ink); }
.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(--card);
}
.prep-said { margin: 0; }
.prep-said:empty { display: none; }
.prep-bar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  padding: var(--s3) max(var(--s4), env(safe-area-inset-left)) max(var(--s3), env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.prep-barin { max-width: 1120px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); }
.prep-start { min-height: var(--tap-lg); font-size: var(--fs-md); width: auto; min-width: 240px; flex: 0 0 auto; margin-inline-start: auto; }
.prep-startnote { margin: 0; flex: 1 1 260px; }
.prep-bar .err { flex-basis: 100%; margin: 0; }
.prep-bar .err:empty { display: none; }
@container (min-width: 860px) {
  .prep-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
}
@media (max-width: 600px) {
  .prep-start { width: 100%; min-width: 0; }
  .prep-startnote { flex-basis: 100%; font-size: var(--fs-s); }
  .prep { padding-bottom: 150px; }
}
/* A phone on its side: the start bar stays one slim row. */
@media (max-height: 480px) and (orientation: landscape) {
  .prep-startnote { display: none; }
  .prep-start { min-height: var(--tap); }
  .prep { padding-bottom: 90px; }
}

/* ---------- /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(--ok-ink); }
.rd-rep[data-verdict="amber"] .rd-verdict { color: var(--warn); }
.rd-rep[data-verdict="red"] .rd-verdict { color: var(--danger-ink); }
.rd-detail { overflow-x: auto; font-size: 12px; 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(--card); }

/* the panel's class time */
.class-sched h2 { display: flex; align-items: center; gap: var(--s2); }
.class-sched h2 .pg-ic { color: var(--accent); }
.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(--card); 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(--card); }
.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; }
