/* =====================================================
   textbook-quiz.css

   Styles for the end-of-chapter QUIZ + assignable TEXTBOOK WORK feature,
   plus the shared Timing Drill (no-feedback / test-conditions) UI.

   Three groups:
     A) Timing Drill runtime UI  (.td-*)  — the per-question pacing countdown,
        the mode badge, the end-of-drill pacing report + overlay. These were
        designed in the timing-drill proposal and are consumed by practice.js
        (and later results.html). Palette reuses the site's green/red review
        colors so it reads as part of the app.
     B) BoK reader "Quiz Me" + tutor "Assign this" affordances (.bok-quiz-*).
     C) quick-assign Textbook picker (.qa-tb-*).

   Everything here is additive — no existing selector is overridden. Loaded via
   an explicit <link> on practice.html, quick-assign.html and bok-reader.html.
   Each page also defines its own --* tokens; we fall back gracefully.
   ===================================================== */

/* ============================================================= */
/* A) TIMING DRILL — runtime UI                                  */
/* ============================================================= */

/* ---- Mode badge in the topbar (both flavors) ---- */
.td-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: #7a3e00;
  background: #fff2dd;
  border: 1.5px solid #ffce8a;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.td-badge.section { color: #1f4f8a; background: #e8f0fb; border-color: #b8d2f0; }

/* ---- Per-question pacing countdown (pacing flavor) ----
   Lives inside .timer, alongside the section clock display. */
.td-countdown {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 18px;
  color: var(--ink, #1a1a1a);
  transition: color .25s ease;
}
.td-countdown .td-cd-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #888);
  text-transform: uppercase;
  letter-spacing: .4px;
}
/* Soft nudge state — budget elapsed. Turn red + gentle pulse. NOT a lockout. */
.td-countdown.expired {
  color: #dc2626;
  animation: td-cd-pulse 1.1s ease-in-out infinite;
}
.td-countdown.expired .td-cd-label { color: #dc2626; }
.td-countdown .td-cd-nudge {
  font-size: 11px;
  font-weight: 700;
  color: #dc2626;
  margin-left: 4px;
}
/* Paused (idle / tab hidden): muted + a small "paused" hint so the student
   understands the clock froze on purpose. */
.td-countdown.paused-idle { color: var(--muted, #888); animation: none; }
.td-countdown.paused-idle::after {
  content: "⏸ paused";
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #888);
  margin-left: 6px;
}
@keyframes td-cd-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}

/* ---- End-of-drill pacing report ---- */
.td-report {
  max-width: 760px;
  margin: 0 auto;
  font-size: 14px;
  color: var(--ink, #1a1a1a);
}
.td-report .td-title { font-size: 22px; margin: 0 0 4px; }
.td-report .td-sub { color: var(--muted, #888); margin: 0 0 16px; line-height: 1.5; }
.td-empty { color: var(--muted, #888); }

.td-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.td-chip {
  flex: 1 1 110px;
  background: #f6f8fb;
  border: 1.5px solid #dbe3ee;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
}
.td-chip b { display: block; font-size: 22px; line-height: 1.1; }
.td-chip span { font-size: 11px; color: var(--muted, #888); text-transform: uppercase; letter-spacing: .4px; }
.td-chip.good   { background: #f0fdf4; border-color: #bbf7d0; }
.td-chip.good b { color: #16a34a; }
.td-chip.warn   { background: #fff7ed; border-color: #fed7aa; }
.td-chip.warn b { color: #c2410c; }
.td-chip.danger { background: #fef2f2; border-color: #fecaca; }
.td-chip.danger b { color: #dc2626; }

.td-callout {
  border: 1.5px solid #fecaca;
  background: #fef2f2;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.td-callout.ok { border-color: #bbf7d0; background: #f0fdf4; }
.td-callout-head { font-weight: 800; font-size: 15px; margin-bottom: 6px; color: #991b1b; }
.td-callout.ok .td-callout-head { color: #166534; }
.td-callout-body { color: #7f1d1d; line-height: 1.5; }
.td-callout.ok .td-callout-body { color: #14532d; }
.td-callout-list { margin: 10px 0 0; padding-left: 18px; }
.td-callout-list li { margin: 5px 0; color: #5b1414; line-height: 1.45; }
.td-over { color: #dc2626; font-weight: 700; }
.td-skill { color: var(--muted, #888); font-style: italic; }

/* per-question table */
.td-table {
  border: 1.5px solid var(--line, #ddd);
  border-radius: 10px;
  overflow: hidden;
}
.td-row {
  display: grid;
  grid-template-columns: 48px 56px 1fr 96px 44px;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft, #f0ede4);
}
.td-row:last-child { border-bottom: none; }
.td-row.td-head {
  background: #f6f8fb;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted, #888);
  font-weight: 700;
}
.td-row.flag { background: #fef2f2; }
.td-row.good { background: #f7fdf9; }
.td-c-q { font-weight: 700; }
.td-c-time { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.td-budget { color: var(--muted, #888); font-weight: 400; font-size: 12px; }
.td-c-res { text-align: center; }

.td-diff {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}
.td-diff.d1 { background: #e6f4ec; color: #1f7a3a; }
.td-diff.d2 { background: #fff2dd; color: #92600a; }
.td-diff.d3 { background: #fde8e8; color: #b42318; }

.td-res.right { color: #16a34a; font-weight: 800; }
.td-res.wrong { color: #dc2626; font-weight: 800; }
.td-res.na    { color: var(--muted, #888); }

/* mini bar: active fill + budget tick */
.td-bar {
  position: relative;
  height: 12px;
  background: #eef1f6;
  border-radius: 6px;
  overflow: hidden;
}
.td-bar-fill { position: absolute; top: 0; left: 0; bottom: 0; border-radius: 6px; }
.td-bar-fill.ok     { background: #93b3df; }
.td-bar-fill.banked { background: #6cc18c; }
.td-bar-fill.over   { background: #e88; }
.td-bar-budget {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: #334155;
  opacity: .7;
}

.td-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted, #888);
  align-items: center;
}
.td-legend i.td-sw {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  vertical-align: -1px;
  margin-right: 4px;
}
.td-sw.banked { background: #6cc18c; }
.td-sw.ok     { background: #93b3df; }
.td-sw.over   { background: #e88; }
.td-legend-tick { font-family: ui-monospace, monospace; }

/* ---- End-of-drill overlay shell (runner) ---- */
.td-overlay {
  position: fixed;
  inset: 0;
  background: rgba(245, 247, 250, 0.98);
  z-index: 700;
  display: none;
  overflow: auto;
  padding: 32px 20px 48px;
}
.td-overlay.open { display: block; }
.td-overlay-actions {
  max-width: 760px;
  margin: 22px auto 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============================================================= */
/* B) BoK READER — "Quiz Me" + tutor "Assign this"               */
/* ============================================================= */

/* The end-of-chapter QUIZ launch box. Distinct from the green Bluebook-launch
   ("practice these drills") box so a student understands this one is a
   real-test, no-feedback quiz. Amber/test palette. */
.bok-quiz-launch {
  margin: 20px 0 8px;
  padding: 16px 18px;
  border: 1.5px solid #ffce8a;
  background: #fff8ee;
  border-radius: 12px;
}
.bok-quiz-launch h3 {
  margin: 0 0 4px;
  font-size: 16px;
  color: #7a3e00;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bok-quiz-launch .bok-quiz-sub {
  margin: 0 0 12px;
  font-size: 13px;
  color: #8a5a1a;
  line-height: 1.5;
}
.bok-quiz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.bok-quiz-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #b45309;
  color: #fff;
  border: 1.5px solid #b45309;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.bok-quiz-btn:hover { background: #92400e; border-color: #92400e; }
.bok-quiz-btn.secondary {
  background: #fff;
  color: #b45309;
}
.bok-quiz-btn.secondary:hover { background: #fff3e0; }
.bok-quiz-count {
  font-size: 12px;
  color: #8a5a1a;
}

/* Tutor-only "Assign this chapter quiz" affordance (signed-in tutor only). */
.bok-assign-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #ffce8a;
}
.bok-assign-box .bok-assign-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #7a3e00;
  margin-bottom: 8px;
}
.bok-assign-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.bok-assign-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1f4f8a;
  color: #fff;
  border: 1.5px solid #1f4f8a;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.bok-assign-btn:hover { background: #173d6b; border-color: #173d6b; }
.bok-assign-btn.ghost {
  background: #fff;
  color: #1f4f8a;
}
.bok-assign-btn.ghost:hover { background: #eef4ff; }
.bok-assign-hint {
  font-size: 12px;
  color: #8a5a1a;
  flex-basis: 100%;
  margin-top: 4px;
}

/* ============================================================= */
/* C) quick-assign — Textbook picker                             */
/* ============================================================= */

.qa-tb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.qa-tb-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted, #888);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
.qa-tb-field select {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--line, #ddd);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.qa-tb-units {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qa-tb-unit {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--line, #ddd);
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
}
.qa-tb-unit:hover { background: #f6f8fb; }
.qa-tb-unit.checked { background: #eef5ff; border-color: #b8d2f0; }
.qa-tb-unit input[type="radio"] { margin: 0; }
.qa-tb-unit .qa-tb-unit-title { flex: 1; font-size: 14px; font-weight: 600; }
.qa-tb-unit .qa-tb-unit-meta {
  font-size: 12px;
  color: var(--muted, #888);
  white-space: nowrap;
}
.qa-tb-empty {
  font-size: 13px;
  color: var(--muted, #888);
  padding: 8px 2px;
}
