/* ============================================================
   Page three: the card sort, and the class run in teacher mode
   ============================================================ */

.cs { margin-top: var(--sp-5); }
.cs-status { min-height: 2.6em; color: var(--text-2); max-width: none; }

.cs-tray {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px;
  margin-top: var(--sp-3);
  min-height: 48px;
  padding: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.cs.is-complete .cs-tray { display: none; }

.cs-card {
  font: inherit; font-size: var(--fs-2);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  text-align: left;
  cursor: grab;
  box-shadow: var(--shadow-sm);
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  display: flex; flex-direction: column; gap: 2px;
  transition: box-shadow var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
.cs-card--teacher { border-left-color: var(--accent-2); }
.cs-card:hover { box-shadow: var(--shadow-md); }
.cs-card.is-dragging { cursor: grabbing; z-index: 6; position: relative; box-shadow: var(--shadow-md); }
.cs-card.is-armed { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.cs-card.is-open { border-color: var(--accent); }
.cs-who { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.cs-card--teacher .cs-who { color: var(--accent-2); }
.cs-text { line-height: 1.35; }

/* the line */
.cs-line-wrap { margin-top: var(--sp-5); }
.cs-line { position: relative; }
.cs-field {
  position: relative;
  min-height: 250px;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--good) 16%, transparent), color-mix(in srgb, var(--check) 16%, transparent) 50%, color-mix(in srgb, var(--fab) 16%, transparent));
  border: 1px solid var(--border);
  transition: box-shadow var(--dur-fast) ease;
  padding-bottom: 10px;
}
.cs-field.is-over { box-shadow: 0 0 0 3px var(--accent); }
.cs-field::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: 10px; height: 3px;
  background: var(--border-strong); border-radius: 2px;
}
.cs-scale { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--font-mono); font-size: var(--fs-1); color: var(--muted); }
.cs-scale-l { color: var(--good); } .cs-scale-r { color: var(--fab); } .cs-scale-m { color: var(--check); }

/* placed cards sit on the line at --x, stacked upward by --row */
.cs-field .cs-card {
  position: absolute;
  left: clamp(82px, var(--x), calc(100% - 82px));
  bottom: calc(18px + var(--row, 0) * 58px);
  transform: translateX(-50%);
  width: 156px;
  font-size: 0.74rem;
  line-height: 1.25;
  padding: 5px 8px;
  gap: 0;
  z-index: calc(2 + var(--row, 0));
}
.cs-field .cs-card .cs-who { display: none; }
.cs-field .cs-card .cs-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.25;
}
.cs-field .cs-card::after {
  content: ''; position: absolute; left: 50%; top: 100%; width: 2px; height: 14px;
  background: var(--border-strong); transform: translateX(-50%);
}
.cs-field .cs-card[data-zone="fine"] { border-left-color: var(--good); }
.cs-field .cs-card[data-zone="depends"] { border-left-color: var(--check); }
.cs-field .cs-card[data-zone="cheating"] { border-left-color: var(--fab); }
.cs-field .cs-card.is-dragging { transform: translateX(-50%); }

.cs-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: var(--sp-3); }
.cs-picker[hidden], .cs-stage[hidden], .cs-consider[hidden] { display: none; }
.cs-picker-label { font-size: var(--fs-2); color: var(--text-2); }

.cs-consider {
  margin-top: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
}
.cs-consider-text { font-weight: 600; max-width: none; }
.cs-consider-note { margin-top: 6px; color: var(--text-2); max-width: none; }

.cs-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--sp-4); }
.cs-run { display: none; margin-left: auto; }
:root[data-mode="teacher"] .cs-run { display: inline-flex; }

/* ---------- the class run ---------- */
.cs-stage {
  margin-top: var(--sp-5);
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.cs-stage-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
.cs-stage-n { margin-top: var(--sp-4); font-family: var(--font-mono); font-size: var(--fs-1); color: var(--muted); }
.cs-big {
  margin-top: var(--sp-3);
  padding: var(--sp-5) var(--sp-6);
  border-radius: var(--radius-lg);
  background: var(--accent-bg);
  border-left: 8px solid var(--accent);
}
.cs-big--teacher { border-left-color: var(--accent-2); }
.cs-big-text { font-size: clamp(1.4rem, 3vw, 2.2rem); font-weight: 600; line-height: 1.25; max-width: none; margin-top: 4px; }
.cs-hands { margin-top: var(--sp-4); color: var(--text-2); max-width: none; }
.cs-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); margin-top: var(--sp-3); }
.cs-col {
  position: relative; overflow: hidden;
  font: inherit; color: var(--text);
  min-height: 200px;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px;
  padding: 12px;
}
.cs-col-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; transition: height var(--dur) var(--ease-out); opacity: 0.35; }
.cs-col--fine .cs-col-fill { background: var(--good); } .cs-col--depends .cs-col-fill { background: var(--check); } .cs-col--cheating .cs-col-fill { background: var(--fab); }
.cs-col--fine { border-color: var(--good); } .cs-col--depends { border-color: var(--check); } .cs-col--cheating { border-color: var(--fab); }
.cs-col-n { position: relative; font-family: var(--font-mono); font-size: clamp(2rem, 6vw, 3.6rem); font-weight: 500; line-height: 1; }
.cs-col-label { position: relative; font-weight: 600; }
.cs-col-minus {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer;
}
.cs-stage-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: var(--sp-4); }
.cs-stage-title { margin-top: var(--sp-4); }
.cs-board { display: grid; gap: 10px; margin-top: var(--sp-3); }
.cs-board-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 12px; align-items: center; }
.cs-board-text { font-size: var(--fs-2); }
.cs-board-bars { display: flex; height: 26px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.cs-seg { display: grid; place-items: center; font-family: var(--font-mono); font-size: 0.75rem; color: #fff; transition: width var(--dur) ease; }
.cs-seg--fine { background: var(--good); } .cs-seg--depends { background: var(--check); } .cs-seg--cheating { background: var(--fab); }

@media (max-width: 600px) {
  .cs-field { min-height: 300px; }
  .cs-field .cs-card { width: 120px; font-size: 0.68rem; bottom: calc(18px + var(--row, 0) * 52px); left: clamp(64px, var(--x), calc(100% - 64px)); }
  .cs-board-row { grid-template-columns: 1fr; gap: 4px; }
  .cs-col { min-height: 150px; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-card, .cs-field, .cs-col-fill, .cs-seg { transition: none; }
}

/* ---------- the citation builder ---------- */
.cite { margin-top: var(--sp-5); }
.cite-intro { color: var(--text-2); max-width: none; }
.cite-form { margin-top: var(--sp-4); display: grid; gap: var(--sp-4); }
.cite-group { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-4) var(--sp-5); margin: 0; background: var(--surface); }
.cite-legend { font-weight: 600; padding: 0 6px; }
.cite-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 14px; }
.cite-option { display: flex; align-items: baseline; gap: 8px; font-size: var(--fs-2); cursor: pointer; padding: 4px 0; }
.cite-option input { accent-color: var(--accent); }
.cite-row { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(160px, 1fr); gap: var(--sp-3); align-items: end; }
.cite-select, .cite-field input {
  font: inherit; font-size: var(--fs-2);
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; min-height: 40px; width: 100%;
}
.cite-field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-1); color: var(--muted); }
.cite-field--wide { margin-top: var(--sp-3); }
.cite-hint { color: var(--muted); font-size: var(--fs-1); }
.cite-other { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-3); }
.cite-other[hidden] { display: none; }

.cite-out { margin-top: var(--sp-5); display: grid; gap: var(--sp-3); }
.cite-lead { color: var(--text-2); max-width: none; }
.cite-block {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-5);
  padding-right: 96px;
}
.cite-block--credit { border-left-color: var(--accent-2); }
.cite-block--note { border-left-color: var(--check); }
.cite-block--comment { border-left-color: var(--good); }
.cite-block-label { font-family: var(--font-mono); font-size: var(--fs-1); color: var(--muted); margin-bottom: 6px; max-width: none; }
.cite-block-text { max-width: none; line-height: 1.6; }
.cite-hanging { padding-left: 2em; text-indent: -2em; }
.cite-copy { position: absolute; right: var(--sp-4); top: var(--sp-4); }
.cite-why { margin-top: var(--sp-2); padding: var(--sp-3) var(--sp-4); background: color-mix(in srgb, var(--accent-bg) 70%, transparent); border-radius: var(--radius); }
.cite-why-label { font-family: var(--font-mono); font-size: var(--fs-1); color: var(--accent); margin-bottom: 4px; }
.cite-why-text { color: var(--text-2); max-width: none; font-size: var(--fs-2); }
.cite-why-text + .cite-why-text { margin-top: 6px; }
.cite-foot { margin-top: var(--sp-4); font-size: var(--fs-1); color: var(--muted); max-width: none; }
@media (max-width: 700px) {
  .cite-row { grid-template-columns: 1fr; }
  .cite-block { padding-right: var(--sp-5); padding-bottom: 56px; }
  .cite-copy { top: auto; bottom: var(--sp-3); right: var(--sp-4); }
}

/* ---------- three cases from a teacher ---------- */
.cases { margin-top: var(--sp-5); }
.cases-intro { color: var(--text-2); max-width: none; }
.cases-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--sp-4); }
.cases-tab {
  font: inherit; font-size: var(--fs-2); font-weight: 500;
  color: var(--text-2); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 8px 14px; cursor: pointer; text-align: left;
}
.cases-tab.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.case {
  margin-top: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5) var(--sp-6);
  scroll-margin-top: 80px;
}
.case[hidden] { display: none; }
.case-title { margin-bottom: var(--sp-4); }
.case-part + .case-part { margin-top: var(--sp-5); }
.case-label { font-family: var(--font-mono); font-size: var(--fs-1); color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--sp-2); }
.case-p { max-width: none; }
.case-p + .case-p { margin-top: 0.8em; }
.case-why { margin: 0; padding-left: 1.2em; }
.case-why li + li { margin-top: 0.5em; }
.case-ask { margin-top: var(--sp-5); padding: var(--sp-4) var(--sp-5); background: var(--accent-bg); border-radius: var(--radius); }
.case-options { display: flex; flex-wrap: wrap; gap: 8px; }
.case-words {
  display: block; width: 100%; margin-top: var(--sp-3);
  font: inherit; font-size: var(--fs-2); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; resize: vertical;
}
.case-ask .tp-btn--play { margin-top: var(--sp-3); }
.case-push { margin-top: var(--sp-5); border-top: 1px solid var(--border); padding-top: var(--sp-4); }
.case-push[hidden] { display: none; }
.case-pb { padding: var(--sp-3) 0; }
.case-pb + .case-pb { border-top: 1px dashed var(--border); }
.case-pb-q { font-weight: 600; max-width: none; }
.case-pb-a { margin-top: 6px; color: var(--text-2); max-width: none; }
.case-pb-alabel { font-family: var(--font-mono); font-size: var(--fs-1); color: var(--accent-2); text-transform: uppercase; letter-spacing: 0.05em; }
.case-next { margin-top: var(--sp-3); }
.cases-done { margin-top: var(--sp-4); color: var(--accent); font-weight: 600; max-width: none; }
@media (max-width: 600px) { .case { padding: var(--sp-4); } }
