/* The failed-midterm article's own widget styles.
 *
 * Every rule is scoped to .post-page and to this article's failure-* class names, so nothing can
 * reach another page. Colours come from the token set in styles.css, which means light, dark and
 * the Auto setting all follow without a second palette. Pass and fail are always written out in
 * text as well as coloured; the ungraded final uses a striped pattern, not a zero-length bar.
 */

/* ---------------------------------------------------------------- 1. The 100-point gradebook */

.post-page .failure-gradebook { overflow: hidden; }
.post-page .failure-gradebook-bar {
  position: relative;
  display: flex;
  height: 24px;
  margin: 4px 0 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--border);
}
.post-page .failure-band {
  position: relative;
  display: block;
  min-width: 2px;
  height: 100%;
  border-right: 1px solid var(--bg);
}
.post-page .failure-band:last-of-type { border-right: 0; }
.post-page .failure-band-fill {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  border-radius: 0 3px 3px 0;
}
.post-page .failure-band-midterm { background: var(--accent); }
.post-page .failure-band-midterm .failure-band-fill { background: var(--highlight); }
.post-page .failure-band-assignments { background: var(--accent); }
.post-page .failure-band-assignments .failure-band-fill { background: var(--primary); }
.post-page .failure-band-quizzes { background: var(--accent); }
.post-page .failure-band-quizzes .failure-band-fill { background: var(--muted); }
.post-page .failure-band-final {
  border-left: 2px dashed var(--muted);
  background: repeating-linear-gradient(
    135deg,
    transparent 0,
    transparent 6px,
    var(--border) 6px,
    var(--border) 10px
  );
}
.post-page .failure-pass-mark {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 50%;
  width: 2px;
  background: var(--text);
  box-shadow: 0 0 0 2px var(--bg);
}
.post-page .failure-gradebook-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 0 0 18px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
}
.post-page .failure-gradebook-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.post-page .failure-key {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
}
.post-page .failure-key-earned { background: var(--highlight); }
.post-page .failure-key-open {
  border: 1px dashed var(--muted);
  background: repeating-linear-gradient(
    135deg,
    transparent 0,
    transparent 3px,
    var(--muted) 3px,
    var(--muted) 4px
  );
}
.post-page .failure-pass-label { font-weight: 700; color: var(--text); }
.post-page .failure-grade-head,
.post-page .failure-grade-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(48px, 0.55fr) minmax(0, 0.95fr);
  gap: 12px;
  align-items: center;
}
.post-page .failure-grade-head {
  padding: 0 12px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.post-page .failure-grade-head span:last-child { text-align: right; }
.post-page .failure-grade-rows { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.post-page .failure-grade-row {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
}
.post-page .failure-grade-row[hidden] { display: none; }
.post-page .failure-grade-row-midterm {
  border-left: 4px solid var(--highlight);
  background: var(--accent);
}
.post-page .failure-grade-row-final {
  border-style: dashed;
  background: var(--bg);
}
.post-page .failure-grade-what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.post-page .failure-grade-what strong { font-size: 0.95rem; }
.post-page .failure-grade-sub { font-size: 0.78rem; color: var(--muted); }
.post-page .failure-grade-row-final .failure-grade-sub {
  align-self: flex-start;
  padding: 1px 8px;
  border: 1px dashed var(--muted);
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.post-page .failure-grade-weight { font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.post-page .failure-grade-points {
  font-size: 0.9rem;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.post-page .failure-gradebook-summary {
  margin: 18px 0 0;
  padding: 14px 16px;
  border-left: 4px solid var(--highlight);
  border-radius: 0 10px 10px 0;
  background: var(--accent);
  font-size: 0.95rem;
  line-height: 1.55;
}
.post-page .failure-gradebook-summary strong { color: var(--text); }
.post-page .failure-live { margin: 12px 0 0; font-size: 0.86rem; line-height: 1.55; color: var(--muted); }
.post-page .failure-live:empty { display: none; }
.post-page .failure-reveal { margin-top: 16px; min-height: 44px; }
.post-page .failure-reveal[hidden] { display: none; }

/* ---------------------------------------------------------------- 2. The final-score switch */

.post-page .failure-slider-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 8px;
  font-weight: 600;
}
.post-page .failure-slider-label output {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--highlight);
  font-variant-numeric: tabular-nums;
}
.post-page .failure-presets { margin-top: 12px; }
.post-page .failure-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin: 14px 0 18px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}
.post-page .failure-switch:focus-within { outline: 2px solid var(--highlight); outline-offset: 2px; }
.post-page .failure-switch input {
  width: 20px;
  height: 20px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--highlight);
  cursor: pointer;
}
.post-page .failure-final-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.post-page .failure-final-stat {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--accent);
}
.post-page .failure-final-label { display: block; font-size: 0.78rem; color: var(--muted); }
.post-page .failure-final-stat strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.post-page .failure-verdict {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: 0 10px 10px 0;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.5;
}
.post-page .failure-verdict[data-state="pass"] {
  border-color: var(--ok-border);
  border-left-color: var(--ok-text);
  background: var(--ok-bg);
  color: var(--ok-text);
}
.post-page .failure-verdict[data-state="fail"] {
  border-color: var(--danger-border);
  border-left-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}
.post-page .failure-hurdle {
  margin: 10px 0 0;
  padding: 11px 14px;
  border-left: 4px dashed var(--danger);
  border-radius: 0 10px 10px 0;
  background: var(--danger-bg);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text);
}
.post-page .failure-hurdle[hidden] { display: none; }
.post-page .failure-hurdle[data-state="met"] {
  border-left-style: solid;
  border-left-color: var(--ok-text);
  background: var(--ok-bg);
}

/* ---------------------------------------------------------------- 3. The mistake cards */

.post-page .failure-mistake-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.post-page .failure-mistake-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  transition: border-color 180ms ease, background 180ms ease, opacity 180ms ease;
}
.post-page .failure-mistake-card.is-active {
  border-color: var(--highlight);
  border-left-width: 4px;
  background: var(--accent);
}
.post-page .failure-mistake-card.is-dimmed { opacity: 0.75; }
.post-page .failure-mistake-tag {
  margin: 0 0 6px;
  padding-left: 8px;
  border-left: 3px solid var(--highlight);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text);
}
.post-page .failure-mistake-action { margin: 0; font-size: 0.9rem; line-height: 1.5; }

/* ---------------------------------------------------------------- Responsive and motion */

@media (max-width: 760px) {
  .post-page .failure-final-grid,
  .post-page .failure-mistake-cards { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 520px) {
  .post-page .failure-grade-head { display: none; }
  .post-page .failure-grade-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
  }
  .post-page .failure-grade-weight { text-align: right; }
  .post-page .failure-grade-weight::before {
    content: "Weight ";
    font-weight: 600;
    color: var(--muted);
  }
  .post-page .failure-grade-points {
    grid-column: 1 / -1;
    text-align: left;
    padding-top: 2px;
  }
  .post-page .failure-grade-points::before {
    content: "Course points: ";
    font-weight: 600;
    color: var(--muted);
  }
  .post-page .failure-gradebook-summary { padding: 12px 14px; }
  .post-page .failure-switch { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .post-page .failure-mistake-card { transition: none; }
}

