/* ===========================================================================
 * mc-grid.css — McItem grid-in input mode visual.
 * ===========================================================================
 * Applies when McItem is mounted with features.format === 'grid'. Renders a
 * numeric/free-text input + a Submit button instead of choice rows. Same
 * stem/figure/hint/why chrome as MC mode; only the input area differs.
 *
 * Shared rules (not surface-scoped); see migration-defaults.md "Components
 * ship their own structural CSS" principle.
 * ========================================================================= */

.mc-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 14px;
}

/* The field and its sign key sit on one row (study A-45 / B-05): the iOS
   numeric pad has no minus, so the sign is a control of the app's own beside
   the box it changes. */
.mc-grid-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.mc-grid-sign {
  flex: 0 0 auto;
  min-width: 56px;
  min-height: 44px;
  font-family: var(--font-ui, inherit);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink, #18130E);
  background: var(--bg-card, var(--surface, #fff));
  border: 2px solid var(--ink-30, rgba(0, 0, 0, 0.16));
  border-radius: var(--radius, 14px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--dur-quick, 120ms), background var(--dur-quick, 120ms);
}
/* Pressed = the value currently carries a leading minus. Accent border, not an
   accent FILL: this is a modifier on the answer, not the answer. */
.mc-grid-sign[aria-pressed="true"] {
  border-color: var(--accent-coral, #C96F4A);
  color: var(--accent-coral, #C96F4A);
}
.mc-grid-sign:focus-visible {
  outline: 2px solid var(--accent-coral);
  outline-offset: 2px;
}
/* The sealed paper's keyboard dismissal (study B-06). Quiet: it is a way out,
   not the action — there is no action, the value is already recorded. */
.mc-grid-done {
  align-self: flex-end;
  padding: 11px 18px;
  min-height: 44px;
  font-family: var(--font-ui, inherit);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink, #18130E);
  background: var(--bg-card, var(--surface, #fff));
  border: 1px solid var(--ink-30, rgba(0, 0, 0, 0.16));
  border-radius: var(--radius, 14px);
  cursor: pointer;
}
.mc-grid-done:focus-visible {
  outline: 2px solid var(--accent-coral);
  outline-offset: 2px;
}

.mc-grid-input {
  width: 100%;
  flex: 1 1 auto;
  min-width: 0;
  padding: 16px 18px;
  font-family: ui-serif, Georgia, serif;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border: 2px solid var(--ink-30, rgba(0, 0, 0, 0.16));
  border-radius: var(--radius, 14px);
  background: var(--bg-elevated, var(--surface, #fff));
  color: var(--ink, #18130E);
  outline: none;
  box-sizing: border-box;
  /* Sanctioned durations only (study D5) — reduced motion zeroes them. */
  transition: border-color var(--dur-quick, 120ms);
}
.mc-grid-input:focus-visible {
  border-color: var(--accent-coral);
  outline: 2px solid var(--accent-coral);
  outline-offset: 2px;
}
.mc-grid-input.is-correct {
  border-color: var(--accent-sage, #5B7A4A);
  color: var(--accent-sage-ink, var(--ink));
  background: var(--accent-sage-tint, rgba(91, 122, 74, 0.08));
}
.mc-grid-input.is-wrong {
  border-color: var(--danger, #A0412E);
  color: var(--danger, #A0412E);
  background: var(--danger-bg, #EED7CF);
}
/* SI-22 — THE STUDENT'S OWN CORRECT ANSWER MUST NOT READ AS DISABLED. The
 * input is `disabled` after Submit so the value can't be edited, and WebKit
 * paints a disabled control's text with its own `-webkit-text-fill-color`,
 * which OVERRIDES `color` — so the answer the student got right rendered in a
 * light grey inside the success-tinted box. Inherit the colour the .is-correct
 * / .is-wrong rules above set instead. */
.mc-grid-input:disabled {
  cursor: default;
  -webkit-text-fill-color: currentColor;
  opacity: 1;
}
/* SI-33 — THE PLACEHOLDER IS CHROME, NOT AN ANSWER. The field is set in the
 * reading serif because the VALUE is a number the student typed and a numeric
 * answer is legitimately serif; "Your answer" is a UI label and every other
 * placeholder in the app is the UI sans. */
/* B-18 — an EMPTY field is left-aligned, so the caret sits before the
 * placeholder instead of inside the middle of the word. The moment there is a
 * value the field centres again. */
.mc-grid-input.is-empty { text-align: left; }
.mc-grid-input::placeholder {
  font-family: var(--font-ui, inherit);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-soft, var(--ink-70));
  opacity: 1;
}

.mc-grid-submit {
  align-self: stretch;
  padding: 12px 18px;
  font-family: var(--font-ui, inherit);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--accent-coral, #C96F4A);
  border: none;
  border-radius: var(--radius, 14px);
  cursor: pointer;
  transition: opacity var(--dur-quick, 120ms), background var(--dur-quick, 120ms);
  -webkit-tap-highlight-color: transparent;
}
.mc-grid-submit:hover:not(:disabled) { opacity: 0.92; }
.mc-grid-submit:disabled {
  background: var(--ink-10, rgba(0, 0, 0, 0.08));
  color: var(--ink-30, rgba(0, 0, 0, 0.3));
  cursor: default;
}
.mc-grid-submit:focus-visible {
  outline: 2px solid var(--accent-coral);
  outline-offset: 2px;
}

/* Reveal-block scoping (when the why-panel is preceded by an expected-value
 * line for grid wrong answers). The why block becomes a card. */
.mc-why-block {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius, 14px);
  border: 1px solid var(--ink-10, rgba(0, 0, 0, 0.08));
  background: var(--bg-muted, var(--surface));
}
.mc-why-block.is-correct {
  background: var(--accent-sage-tint, rgba(91, 122, 74, 0.10));
  border-color: var(--accent-sage, #5B7A4A);
}
.mc-why-block.is-wrong {
  background: var(--bg-muted, var(--surface));
  border-color: var(--ink-30, rgba(0, 0, 0, 0.16));
}

.mc-grid-expected {
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink, #18130E);
  margin-bottom: 6px;
}
.mc-grid-expected b {
  color: var(--accent-sage-ink, #3F5732);
  font-weight: 700;
}
