/**
 * AD213 Financial Accounting PWA - Knowledge Check Styles
 * Active retrieval / checkpoint component designed with clean editorial layout.
 * Eliminates chunky cards, panel boxes, neon buttons, and glaring dark mode inputs.
 * Strictly adheres to inverted ink typography and quiet, borderless actions.
 */

.knowledge-check-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ==========================================================================
   Header & Progress (Clean Typographic Flow, Zero Box Borders)
   ========================================================================== */

.kc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 18px;
  margin: 0;
}

.kc-title-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.kc-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.kc-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.kc-kicker {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-text);
}

.kc-title {
  font-family: var(--font-sans);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
}

.kc-checkpoint-subtitle {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

/* Borderless Ghost Action for Viewing Slide */
.kc-view-slide-btn {
  height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.kc-view-slide-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.kc-view-slide-btn .icon {
  width: 14px;
  height: 14px;
  opacity: 0.85;
}

.kc-progress-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}

.kc-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.kc-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--border-strong);
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.kc-dot.active {
  background-color: var(--text-primary);
  transform: scale(1.25);
}

.kc-dot.correct {
  background-color: var(--debit-color);
}

.kc-dot.completed {
  background-color: var(--accent-primary);
}

.kc-dot.incorrect {
  background-color: var(--credit-color);
}

.kc-mastered-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--debit-color);
}

/* ==========================================================================
   Question Content Container
   ========================================================================== */

.kc-question-container {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.kc-question-prompt {
  font-family: var(--font-sans);
  font-size: 1.08rem;
  line-height: 1.6;
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.kc-question-prompt p {
  margin: 0 0 8px 0;
}

.kc-question-prompt p:last-child {
  margin-bottom: 0;
}

.kc-code-callout {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  background-color: var(--callout-bg);
  border-left: 2px solid var(--border-strong);
  padding: 10px 14px;
  margin: 12px 0;
  display: block;
  overflow-x: auto;
  border-radius: 0 4px 4px 0;
}

/* ==========================================================================
   Multiple Choice Options (Calm List Rows, No Thick Box Panels)
   ========================================================================== */

.kc-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kc-option-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 5px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.94rem;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.kc-option-btn:hover:not(:disabled) {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
}

.kc-option-btn.selected {
  border-color: var(--text-primary);
  background-color: var(--bg-hover);
}

.kc-option-btn.disabled {
  opacity: 0.65;
  cursor: default;
}

.kc-option-btn.correct {
  border-color: var(--debit-color) !important;
  background-color: var(--debit-bg) !important;
  color: var(--text-primary);
}

.kc-option-btn.incorrect {
  border-color: var(--credit-color) !important;
  background-color: var(--credit-bg) !important;
  color: var(--text-primary);
}

.kc-option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--text-secondary);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.kc-option-btn:hover:not(:disabled) .kc-option-letter {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.kc-option-btn.selected .kc-option-letter {
  background-color: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--bg-surface);
}

.kc-option-btn.correct .kc-option-letter {
  background-color: var(--debit-color);
  border-color: var(--debit-color);
  color: #FFFFFF;
}

.kc-option-btn.incorrect .kc-option-letter {
  background-color: var(--credit-color);
  border-color: var(--credit-color);
  color: #FFFFFF;
}

.kc-option-text {
  flex: 1;
}

/* ==========================================================================
   Text / Numeric / Rubric Input (Zero Glare Dark Mode Writing)
   ========================================================================== */

.kc-input-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.kc-text-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  caret-color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease;
}

.kc-text-input:focus {
  border-color: var(--text-secondary);
}

/* Rubric Free-Text Explanation Area (Never Glaring in Dark Mode) */
.kc-rubric-textarea {
  width: 100%;
  min-height: 110px;
  padding: 14px 16px;
  border-radius: 4px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.94rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  caret-color: var(--text-primary);
  transition: border-color 0.15s ease;
}

.kc-rubric-textarea:focus {
  border-color: var(--text-secondary);
}

.kc-rubric-textarea::placeholder {
  color: var(--text-tertiary);
  opacity: 0.8;
}

/* Primary Check & Submit Button: Inverted Ink (Zero Candy Neon) */
.kc-check-btn {
  padding: 9px 18px;
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: none;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.kc-check-btn:hover:not(:disabled) {
  opacity: 0.88;
}

.kc-check-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Rubric Self-Check Comparison (Pure Typographic Flow, Not a Card) */
.kc-rubric-card {
  background: transparent;
  border: none;
  border-left: 2px solid var(--border-strong);
  padding: 8px 0 8px 16px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kc-rubric-title {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.kc-rubric-model {
  font-family: var(--font-serif);
  font-size: 0.96rem;
  line-height: 1.65;
  color: var(--text-primary);
  font-style: italic;
}

.kc-rubric-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

.kc-rubric-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1.5;
}

.kc-rubric-item input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--text-primary);
}

/* ==========================================================================
   DR/CR Reflex Classifier (Clean Segmented Comparison)
   ========================================================================== */

.kc-drcr-group {
  display: flex;
  gap: 12px;
}

.kc-drcr-btn {
  flex: 1;
  padding: 14px 18px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  font-family: var(--font-sans);
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
}

.kc-drcr-btn.dr {
  color: var(--debit-color);
}

.kc-drcr-btn.cr {
  color: var(--credit-color);
}

.kc-drcr-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
}

.kc-drcr-btn.selected-dr {
  background-color: var(--debit-bg);
  border-color: var(--debit-color);
}

.kc-drcr-btn.selected-cr {
  background-color: var(--credit-bg);
  border-color: var(--credit-color);
}

/* ==========================================================================
   Educational Feedback Block (Minimal Left-Rule Callout)
   ========================================================================== */

.kc-feedback-box {
  border-radius: 0 4px 4px 0;
  padding: 14px 18px;
  background-color: var(--callout-bg);
  border-left: 2.5px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: kcSlideIn 0.18s ease-out;
}

.kc-feedback-box.success {
  background-color: var(--debit-bg);
  border-left-color: var(--debit-color);
}

.kc-feedback-box.failure {
  background-color: var(--credit-bg);
  border-left-color: var(--credit-color);
}

.kc-feedback-box.note {
  background-color: var(--callout-bg);
  border-left-color: var(--accent-primary);
}

@keyframes kcSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.kc-feedback-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
}

.kc-feedback-box.success .kc-feedback-header {
  color: var(--debit-color);
}

.kc-feedback-box.failure .kc-feedback-header {
  color: var(--credit-color);
}

.kc-feedback-box.note .kc-feedback-header {
  color: var(--text-primary);
}

.kc-explanation-text {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.kc-explanation-text p {
  margin: 0 0 6px 0;
}

.kc-explanation-text p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   Knowledge Check Action Footer (Zero Panel Sandwich, Borderless Actions)
   ========================================================================== */

.kc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.kc-footer-left,
.kc-footer-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Back Link: Quiet Editorial Breadcrumb */
.kc-btn-secondary {
  padding: 6px 0;
  background: transparent;
  border: none;
  border-radius: 0;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s ease;
}

.kc-btn-secondary:hover {
  background: transparent;
  color: var(--text-primary);
  border: none;
}

.kc-btn-secondary .icon {
  width: 13px;
  height: 13px;
  opacity: 0.85;
}

/* Primary Next Button: Inverted Ink (Zero Neon Blue) */
.kc-btn-primary {
  padding: 8px 18px;
  background-color: var(--btn-primary-bg);
  border: none;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--btn-primary-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s ease;
}

.kc-btn-primary:hover {
  opacity: 0.88;
}

.kc-btn-primary .icon {
  width: 14px;
  height: 14px;
}

/* Skip Actions: Borderless Muted Text Buttons */
.kc-btn-skip {
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: 0;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.15s ease;
}

.kc-btn-skip:hover {
  color: var(--text-primary);
  background: transparent;
  border: none;
}

/* ==========================================================================
   Modern Interactive Table-Fill & Spreadsheet Worksheet Styles
   ========================================================================== */

.kc-table-section {
  margin: 18px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kc-table-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.kc-table-card:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.kc-table-card-header {
  padding: 12px 16px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kc-table-card-kicker {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.kc-table-card-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.kc-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background-color: var(--bg-surface);
  max-width: 100%;
}

/* Thin clean scrollbar for horizontal overflow */
.kc-table-wrapper::-webkit-scrollbar {
  height: 6px;
}
.kc-table-wrapper::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}
.kc-table-wrapper::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.kc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  color: var(--text-primary);
  text-align: left;
}

.kc-table th {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 9px 8px;
  border-bottom: 1.5px solid var(--border-color);
  white-space: nowrap;
  vertical-align: middle;
  text-align: center;
}

.kc-table th.num-col {
  text-align: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.kc-table th.kc-row-header-col {
  text-align: left;
  padding-left: 14px;
  width: 95px;
}

.kc-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  background-color: var(--bg-surface);
  transition: background-color 0.12s ease;
}

.kc-table tbody tr:hover td {
  background-color: color-mix(in srgb, var(--accent-primary) 3%, var(--bg-surface));
}

.kc-table tbody tr:last-child td {
  border-bottom: none;
}

/* Row Label Column Badge */
.kc-table td.kc-row-label-col {
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-primary);
  width: 95px;
  padding-left: 14px;
}

.kc-row-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  padding: 3px 8px;
  border-radius: 4px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
}

/* Operator columns (=, +, -) */
.kc-table th.operator-col {
  width: 22px;
  min-width: 20px;
  max-width: 24px;
  padding: 9px 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-tertiary);
  background-color: var(--bg-secondary);
}

.kc-table td.operator-col {
  width: 22px;
  min-width: 20px;
  max-width: 24px;
  padding: 8px 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-tertiary);
  user-select: none;
}

/* Plain Non-Input Numbers (e.g. 0) */
.kc-table td.kc-plain-num {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-primary);
  padding: 8px 6px;
  font-variant-numeric: tabular-nums;
}

/* Input Cell & Wrapper */
.kc-table td.kc-table-input-cell {
  padding: 5px 6px;
  min-width: 95px;
  max-width: 135px;
}

.kc-table-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
  width: 100%;
}

.kc-table-input {
  width: 100%;
  height: 35px;
  padding: 4px 10px;
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.94rem;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all 0.15s ease-in-out;
}

.kc-table-input::placeholder {
  color: var(--text-tertiary);
  opacity: 0.55;
  font-weight: 500;
}

.kc-table-input:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.kc-table-input:focus {
  border-color: var(--accent-primary);
  background-color: var(--bg-surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 18%, transparent), inset 0 1px 2px rgba(0,0,0,0.02);
}

/* Correct Answer State */
.kc-table-input.correct {
  border-color: var(--debit-color);
  background-color: color-mix(in srgb, var(--debit-color) 8%, var(--bg-surface));
  color: var(--debit-color);
  font-weight: 700;
}

/* Incorrect Answer State */
.kc-table-input.incorrect {
  border-color: var(--credit-color);
  background-color: color-mix(in srgb, var(--credit-color) 8%, var(--bg-surface));
  color: var(--credit-color);
  font-weight: 700;
}

/* Expected Answer Micro-Pill */
.kc-table-expected-pill {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--credit-color);
  background-color: color-mix(in srgb, var(--credit-color) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--credit-color) 25%, transparent);
  padding: 2px 6px;
  border-radius: 4px;
  align-self: flex-end;
  white-space: nowrap;
}

.kc-table-expected-pill span {
  opacity: 0.8;
}

.kc-table-expected-pill strong {
  font-weight: 700;
}

/* Table Actions & Button */
.kc-table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
}

.kc-check-table-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 18px;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--btn-primary-text);
  background-color: var(--btn-primary-bg);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.kc-check-table-btn:hover:not(:disabled) {
  opacity: 0.88;
}

.kc-check-table-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Score Badge */
.kc-table-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: var(--font-sans);
}

.kc-table-score-badge.perfect {
  background-color: color-mix(in srgb, var(--debit-color) 12%, transparent);
  color: var(--debit-color);
  border: 1px solid color-mix(in srgb, var(--debit-color) 30%, transparent);
}

.kc-table-score-badge.partial {
  background-color: color-mix(in srgb, var(--warning-color, #E65100) 12%, transparent);
  color: var(--warning-color, #E65100);
  border: 1px solid color-mix(in srgb, var(--warning-color, #E65100) 30%, transparent);
}
