/* views.css — styles specific to individual screens. */

/* Boot guard (file:// help screen) */

.boot-help {
  max-width: 60ch;
  margin: var(--sp-6) auto;
  padding: var(--sp-5);
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  border-radius: var(--r-lg);
}
.boot-help__note { font-size: .875rem; color: var(--ink-faint); }

/* Dashboard */

.dash-hero {
  padding: var(--sp-5);
  margin-bottom: var(--sp-5);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.dash-hero h1 { margin-bottom: var(--sp-2); }
.dash-hero p { max-width: 60ch; color: var(--ink-soft); }
.dash-hero__actions { margin-top: var(--sp-4); }

.clocks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-5);
  padding: var(--sp-4);
  background: var(--paper-3);
  border-radius: var(--r-md);
}
.clock__zone {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.clock__time {
  font-size: 1.25rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.clock__delta { font-size: .8125rem; color: var(--ink-soft); }

/* Data screen */

.data-panel + .data-panel { margin-top: var(--sp-4); }

.data-panel__body { display: flex; flex-direction: column; gap: var(--sp-3); }

.json-peek {
  max-height: 260px;
  overflow: auto;
  font-size: .8125rem;
  line-height: 1.45;
  background: var(--paper-2);
  border: 1px solid var(--line);
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-1) var(--sp-4);
  margin: 0;
  font-size: .9375rem;
}
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.danger-zone { border-color: var(--danger-line); }

/* Self-test panel (#/selftest) */

.selftest-verdict {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.selftest-verdict.is-pass { background: var(--good-soft); border-left: 4px solid var(--good); }
.selftest-verdict.is-fail { background: var(--danger-soft); border-left: 4px solid var(--danger); }
.selftest-verdict__mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  font-size: 1.5rem;
  font-weight: 700;
  border-radius: 50%;
  background: var(--paper);
}
.selftest-verdict.is-pass .selftest-verdict__mark { color: var(--good); }
.selftest-verdict.is-fail .selftest-verdict__mark { color: var(--danger); }
.selftest-verdict__headline { margin: 0 0 2px; font-size: 1.25rem; }

/* The headline example: one instant, two clocks */

.selftest-example { margin-bottom: var(--sp-5); }
.selftest-example__grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) 0 var(--sp-3);
}
.selftest-example__side {
  flex: 1 1 180px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--paper-3);
  border-radius: var(--r-md);
}
.selftest-example__eq { flex: none; font-size: 1.5rem; color: var(--ink-faint); }
.selftest-example__weekday { font-size: 1.0625rem; font-weight: 650; }
.selftest-example__time {
  font-size: 1.75rem;
  font-weight: 680;
  line-height: 1.15;
  letter-spacing: -.02em;
}

/* Grouped results */

.selftest-group { margin-bottom: var(--sp-5); }
.selftest-group__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-1);
}
.selftest-group__head h2 { margin: 0; font-size: 1.0625rem; }

.selftest-list { margin: var(--sp-3) 0 0; padding: 0; list-style: none; }
.selftest-list > li + li { margin-top: var(--sp-1); }

.selftest-row {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.selftest-row[open] { box-shadow: var(--shadow); }

.selftest-row__summary {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-3);
  cursor: pointer;
  list-style: none;
}
.selftest-row__summary::-webkit-details-marker { display: none; }
.selftest-row__summary:hover { background: var(--paper-2); border-radius: var(--r-md); }

.selftest-row__mark { flex: none; width: 1.1em; font-weight: 700; text-align: center; }
.selftest-row__mark.is-pass { color: var(--good); }
.selftest-row__mark.is-fail { color: var(--danger); }
.selftest-row__title { font-size: .9375rem; }

.selftest-row__detail {
  padding: 0 var(--sp-3) var(--sp-3) calc(var(--sp-3) + 1.1em + var(--sp-3));
  border-top: 1px solid var(--line);
  padding-top: var(--sp-3);
}
.selftest-row__detail .kv { margin-top: var(--sp-2); }
.selftest-row__value {
  font-family: var(--mono);
  font-size: .8125rem;
  overflow-wrap: anywhere;
}
.selftest-row__value.is-wrong { color: var(--danger); font-weight: 600; }

.selftest-footnote { margin-top: var(--sp-5); }

@media (max-width: 700px) {
  .selftest-example__eq { display: none; }
  .selftest-row__detail { padding-left: var(--sp-3); }
}

/* ------------------------------------------------------------------ *
 * Class chat
 *
 * One thread per class. Sized for a phone first: the log scrolls inside
 * itself so the composer stays put, and a bubble may run the full width
 * rather than the narrow column a desktop chat uses — a student reading a
 * homework note should not read it three words to a line.
 * ------------------------------------------------------------------ */

.msg-head { margin-bottom: var(--sp-4); }

.msg-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }

.msg-row__btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3);
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
}

.msg-row__btn:hover { background: var(--paper-2); }

.msg-row__main { display: grid; gap: 2px; min-width: 0; }
.msg-row__name { font-weight: 600; }

.msg-row__preview {
  color: var(--ink-faint);
  font-size: .875rem;
  /* One line, ellipsised: a preview that wraps stops being a list. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-row__meta {
  display: grid;
  gap: 4px;
  justify-items: end;
  flex: none;
  text-align: right;
}

.msg-badge {
  padding: 1px 8px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  font-size: .8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.nav__badge {
  display: inline-block;
  margin-inline-start: 6px;
  min-width: 18px;
  padding: 0 5px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

/* ── One thread ─────────────────────────────────────────────────── */

.thread__head { margin-bottom: var(--sp-3); }
.thread__nav { margin-bottom: var(--sp-2); }

.thread__members {
  padding: var(--sp-3);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-3);
}

.thread__members h2 { margin: 0; }

.member-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: var(--sp-2) 0;
}

.member {
  display: inline-grid;
  padding: 4px 10px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: .875rem;
}

.member__name { font-weight: 600; }
.member__role { color: var(--ink-faint); font-size: .75rem; }

/* The coordinator's chip is outlined, because the panel's claim — an adult is
   always here — is the one a parent is reading the panel to check. */
.member--admin { border-color: var(--accent); background: var(--accent-soft); }
.member--maybe { color: var(--ink-faint); border-style: dashed; align-content: center; }

.thread__local { margin: 0 0 var(--sp-2); }

.thread__log {
  display: grid;
  gap: var(--sp-3);
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--sp-2) 0;
  border-block: 1px solid var(--line);
}

.thread__day { display: grid; gap: var(--sp-2); }

.thread__date {
  margin: 0;
  text-align: center;
  font-size: .8125rem;
  color: var(--ink-faint);
}

.bubble {
  max-width: 90%;
  padding: var(--sp-2) var(--sp-3);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

/* Own messages sit right, as every chat does. Colour is not the only cue —
   the name reads "You" — so it survives a colour-blind reader. */
.bubble--mine { margin-inline-start: auto; background: var(--accent-soft); border-color: var(--accent); }
.bubble--gone { max-width: 100%; background: none; border-style: dashed; text-align: center; }

.bubble__who {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-2);
  margin: 0 0 2px;
}

.bubble__name { font-weight: 600; font-size: .875rem; }
.bubble__role, .bubble__time { color: var(--ink-faint); font-size: .75rem; }

.bubble__body {
  margin: 0;
  /* Volunteers type newlines and expect them to survive. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble .btn { margin-top: var(--sp-1); }

.empty--thread { padding-block: var(--sp-6); }

/* ── The composer ───────────────────────────────────────────────── */

.composer { display: grid; gap: var(--sp-2); padding-top: var(--sp-3); }

.composer__box {
  width: 100%;
  min-height: 44px;
  padding: var(--sp-2);
  font: inherit;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  resize: vertical;
}

.composer__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.composer__foot p { margin: 0; flex: 1; }

@media (max-width: 30rem) {
  .composer__foot { flex-direction: column; align-items: stretch; }
  .composer__foot .btn { width: 100%; }
  .bubble { max-width: 100%; }
}

/* ------------------------------------------------------------------ *
 * Sign-in and accounts
 * ------------------------------------------------------------------ */

.signin { max-width: 24rem; margin: 0 auto; padding-top: var(--sp-5); }
.signin h1 { margin-bottom: var(--sp-1); }
.signin__form { display: grid; gap: var(--sp-4); margin: var(--sp-5) 0 var(--sp-4); }
.signin__caveat { margin-top: var(--sp-4); }

.field { display: grid; gap: 4px; }
.field__label { font-weight: 600; font-size: .9375rem; }

.field__input {
  width: 100%;
  min-height: 44px;
  padding: var(--sp-2);
  font: inherit;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.field__hint { margin: 0; }
.field__error { margin: 0; color: var(--danger-ink); font-weight: 600; }

.session__who { font-weight: 600; font-size: .9375rem; }

.invite-list { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: grid; gap: var(--sp-2); }

.invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--paper-2);
  border-radius: var(--r-sm);
}

/* The one-time code. Fixed and centred because it must not scroll away or
   time out while somebody is reading it into WeChat. */
.code-card {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  width: min(24rem, calc(100vw - 2rem));
  padding: var(--sp-5);
  background: var(--paper);
  border: 2px solid var(--accent);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

.code-card h2 { margin: 0 0 var(--sp-2); }
.code-card__pair { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-2) var(--sp-3); margin: var(--sp-3) 0; }
.code-card__pair dt { color: var(--ink-faint); font-size: .875rem; }
.code-card__pair dd { margin: 0; font-weight: 600; }
.code-card__code { font-size: 1.5rem; letter-spacing: .08em; }
.code-card .btn { width: 100%; margin-top: var(--sp-3); }

.mono { font-family: var(--mono); }
.is-muted { opacity: .55; }

/* The approval queue. Stacks on a phone: a select and two buttons on one
   line at 375px would put every target under the 44px minimum. */
.invite-row--pending { flex-direction: column; align-items: stretch; gap: var(--sp-2); }
.pending-name { font-weight: 600; }
.pending-act { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.pending-act .field__input { flex: 1 1 10rem; min-width: 0; }

.tag--warn { background: var(--warn-soft); color: var(--warn); }

/* Name, role and any tags on one line with real gaps — they used to run
   together as "TutorWaiting". */
.who-cell { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.pending-who { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2); }
