/* Classes and Settings screens. Uses the tokens and components in styles.css;
   only rules these two screens need live here. */

/* ---------- All classes ---------- */
/* A board by grade: each grade is a column of its classes, so a school with one class a
   grade and a school with five both fill the page. The head and filters span the board. */
.main:has(> .grade-group) { grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); align-items: start; }
.main:has(> .grade-group) > :not(.grade-group) { grid-column: 1 / -1; }
.grade-group { display: grid; gap: var(--space-3); align-content: start; }
.grade-group > h2 { text-shadow: var(--ground-halo); }
.class-cards { display: grid; gap: var(--space-3); }
.class-card {
  display: grid; gap: var(--space-1); align-content: start; min-height: 96px; padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--edge); border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  color: var(--ink); text-decoration: none;
}
.class-card:hover { border-color: var(--edge-hover); color: var(--ink); box-shadow: var(--shadow-2); }
.class-card:active { box-shadow: var(--shadow-0); }
.class-card.is-archived { background: var(--surface-sunk); border-style: dashed; box-shadow: none; }
.class-card-name { font-weight: 700; font-size: var(--text-lg); line-height: 1.25; overflow-wrap: anywhere; }
.class-card-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--muted); }

.first-run { display: grid; gap: 14px; justify-items: start; }
.steps { list-style: decimal; padding-left: 22px; display: grid; gap: 8px; max-width: 62ch; }

/* ---------- One class ---------- */
.class-actions { justify-content: flex-end; }
.roster-table td { vertical-align: middle; }
.roster-table th:last-child, .roster-table td:last-child { text-align: right; }
.roster-name { font-weight: 700; overflow-wrap: anywhere; }
.roster-table tr.is-left td { color: var(--muted); }
.roster-table .pill { margin-left: 6px; }

/* ---------- Dialogs: add a child, paste a list, class, staff ---------- */
.choice-long { align-items: flex-start; }
.choice-long input { margin-top: 2px; flex: none; }
.range-inputs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.range-inputs label { font-weight: 600; font-size: 14px; }
.range-inputs input { width: 6.5em; }
.dialog-section { display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }

.dialog:has(.paste-dialog) { width: min(820px, calc(100vw - 24px)); }
.paste-text { min-height: 200px; font-family: var(--font-mono); font-size: 14px; }
.paste-preview {
  max-height: min(46vh, 420px); overflow: auto;
  border: 1px solid var(--line); border-radius: var(--radius-small);
}
.paste-preview .table th { position: sticky; top: 0; }
.paste-preview .table td { vertical-align: middle; }
.paste-skip td { color: var(--muted); }
.paste-error td { background: var(--alert-tint); }

/* ---------- Enter reading ranges ---------- */
.ranges-intro { display: grid; gap: 14px; }
.ranges-batch { display: flex; flex-wrap: wrap; align-items: start; gap: 16px 32px; }
.ranges-batch .field { flex: 0 1 220px; }

.ranges-table td { vertical-align: middle; }
.ranges-table input { width: 6.5em; }
.ranges-table:not(.show-ge) .rg-ge { display: none; }
.rg-name, .rg-now, .rg-msg, .rg-chart { display: block; }
.rg-name { font-weight: 700; overflow-wrap: anywhere; }
.rg-now { margin-top: 2px; font-size: 13px; color: var(--muted); }
.rg-msg { margin-top: 2px; font-size: 13px; color: var(--muted); }
.rg-msg:empty, .rg-chart:empty { display: none; }
.rg-chart { margin-top: 4px; font-size: 13px; color: var(--muted); white-space: nowrap; }

/* A changed row has a bar on its left edge as well as its words, so colour is never the only cue. */
.rg-changed > td:first-child { box-shadow: inset 4px 0 0 var(--brand); }
.rg-changed .rg-msg { color: var(--brand-dark); font-weight: 650; }
.rg-error > td { background: var(--alert-tint); }
.rg-error .rg-msg { color: var(--alert); font-weight: 650; }
.ranges-table input[aria-invalid="true"] { border-color: var(--alert); }

.ranges-bar {
  position: sticky; bottom: var(--space-3); z-index: 5;
  display: flex; flex-flow: row-reverse wrap; align-items: center; justify-content: flex-end; gap: var(--space-3) var(--space-5);
  padding: var(--space-3) var(--space-4); background: var(--surface);
  border: 1px solid var(--edge); border-radius: var(--radius-md); box-shadow: var(--shadow-2);
}
/* The buttons lead from the left, clear of Houston's floating button in the right corner. */
.ranges-bar .ranges-summary { flex: 1 1 240px; }
.ranges-summary { font-weight: 650; }

/* ---------- Settings ---------- */
.settings-layout {
  display: grid; gap: 20px; align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
}
.settings-form { max-width: 640px; }
.set-hawk { display: grid; gap: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.set-hawk legend { float: left; width: 100%; padding: 0 0 var(--space-1); font-weight: 700; font-size: var(--text-md); }
.set-hawk input { max-width: 160px; }
.set-stages-preview { display: grid; gap: var(--space-3); container-type: inline-size; }
.set-stages-text { font-size: var(--text-sm); font-weight: 650; }
/* The seven stages in a row: the picture in its frame, its name, the book count it starts at. */
.set-stages { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--space-2); }
/* Seven across where there is room, four and three where there is not; never six and one. */
@container (max-width: 470px) { .set-stages { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.set-stage {
  display: grid; justify-items: center; align-content: start; gap: var(--space-1); padding: var(--space-3) var(--space-1) var(--space-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-quiet); font-size: var(--text-2xs); line-height: 1.2; text-align: center;
}
.set-stage .hawk-pic { margin-bottom: 2px; }
.set-stage-name { color: var(--muted); font-weight: 700; }
.set-stage-at { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }
.staff-intro { margin-bottom: 4px; }
.staff-list { display: grid; }
.staff {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 16px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.staff:first-child { border-top: 0; }
.staff-who { display: grid; gap: 2px; min-width: 0; }
.staff-name { font-weight: 700; overflow-wrap: anywhere; }
.staff-email { font-size: var(--text-sm); color: var(--muted); overflow-wrap: anywhere; }
.staff-role { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.staff-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.staff.is-inactive .staff-name { color: var(--muted); }

/* Row buttons are small on a desk computer; on a touch screen they get the full tap height. */
@media (pointer: coarse) {
  .staff-actions .btn-small, .ranges-table .btn-small, .roster-table .btn-small { min-height: var(--tap); }
}

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .class-actions { justify-content: flex-start; }
  .class-actions .btn { flex: 1 1 auto; }
  .ranges-table th, .ranges-table td { padding: 8px 6px; }
  .ranges-table input { width: 4.8em; padding: 9px 8px; }
  .ranges-bar { padding: var(--space-3); padding-right: 72px; }
  .ranges-bar .row { flex: 1 1 100%; }
  .ranges-bar .btn { flex: 1 1 0; }
  .staff { grid-template-columns: 1fr; }
  .staff-role { justify-content: flex-start; }
}

/* ---------- Print: a class page prints as a plain class list ---------- */
@media print {
  .back, .class-actions, .ranges-bar, .notice { display: none !important; }
  .page-head p { color: #000; }
  .roster-table { font-size: 11pt; }
  .roster-table th, .roster-table td { padding: 6px 8px; }
  .roster-table th { background: none; color: #000; }
  .roster-table tr { break-inside: avoid; }
  .range { border-color: #000; }
}

/* A panel that opens with a bare heading (not a panel-head) needs air beneath it. */
.settings-layout .panel > h2:first-child, .settings-form > h2:first-child { margin-bottom: var(--space-4); }

@media (prefers-reduced-motion: no-preference) {
  .class-card { transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out); }
}
