/* PrepMora — step-by-step Math explanations (assets/js/walkthrough.js).

   This one lives on two screens with opposite palettes: the white Bluebook
   exam (practice.html, which defines --e-*) and the dark site shell
   (test-answers.html, which defines the app tokens). So every colour is read
   through a local token that falls back from one set to the other — the
   fallback only kicks in when the first name is genuinely undefined, which is
   exactly the difference between the two pages.

   The Desmos calculator itself always renders light; that is Desmos's own
   chrome and is left alone. */

.wt {
  --wt-bg: var(--e-bg, var(--surface, #ffffff));
  --wt-panel: var(--e-panel, var(--surface-2, #f7f8fa));
  --wt-line: var(--e-line, var(--line, #d6dae0));
  --wt-line-soft: var(--e-line-soft, var(--line-soft, #e7eaee));
  --wt-ink: var(--e-ink, var(--text, #1a1c1f));
  --wt-ink-2: var(--e-ink-2, var(--text-2, #4a5058));
  --wt-ink-3: var(--e-ink-3, var(--text-3, #767d87));
  --wt-accent: var(--e-accent, var(--accent, #1668c4));
  --wt-accent-soft: var(--e-accent-soft, var(--accent-wash, #e8f1fc));
  --wt-sans: var(--e-sans, var(--font-body, "Segoe UI", system-ui, sans-serif));
  --wt-serif: var(--e-serif, var(--font-body, Georgia, "Times New Roman", serif));

  margin-top: 4px;
}

/* Component classes below set display, which beats the UA rule for [hidden]. */
[hidden] {
  display: none !important;
}

/* --- Step bar ----------------------------------------------------------- */

.wt-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
}

.wt-nav,
.wt-all {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--wt-line);
  background: transparent;
  font-family: var(--wt-sans);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--wt-ink);
  cursor: pointer;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.wt-all {
  margin-left: auto;
  border-color: var(--wt-accent);
  color: var(--wt-accent);
}

.wt-nav:disabled,
.wt-all:disabled {
  opacity: 0.4;
  cursor: default;
}

@media (hover: hover) {
  .wt-nav:not(:disabled):hover,
  .wt-all:not(:disabled):hover {
    background: var(--wt-panel);
  }
}

.wt-nav:focus-visible,
.wt-all:focus-visible {
  outline: 2px solid var(--wt-accent);
  outline-offset: 2px;
}

.wt-pos {
  font-family: var(--wt-sans);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--wt-ink-2);
  font-variant-numeric: tabular-nums;
}

/* --- Stage -------------------------------------------------------------- */

.wt-stage {
  position: relative;
}

/* The calculator gets one fixed box and stays in it. Its height never depends
   on how many expressions a step adds — the graph shifting between steps is
   the whole thing this layout exists to prevent. */
.wt-calc {
  position: relative;
  height: 430px;
  border: 1px solid var(--wt-line);
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
}

.wt-calc-host {
  position: absolute;
  inset: 0;
}

.wt-fallback {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  overflow-y: auto;
  background: var(--wt-bg);
}

.wt-calc.is-failed {
  background: var(--wt-bg);
}

.wt-calc.is-failed .wt-fallback {
  display: flex;
}

.wt-fallback-note {
  margin: 0;
  font-family: var(--wt-sans);
  font-size: 13.5px;
  color: var(--wt-ink-3);
}

/* Board walkthroughs (geometry): the current step's figure, offline. */
.wt-fallback-fig {
  display: block;
  flex: none;
  width: min(100%, 420px);
  height: auto;
  margin: 0 auto;
  padding: 10px;
  border-radius: 8px;
  background: #ffffff;
}

/* --- Step notes --------------------------------------------------------- */
/* The offline list inside the calculator box, and the whole explanation for
   questions that never open a calculator. */

.wt-fallback-steps,
.wt-notes {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: wt-step;
}

.wt-fallback-steps li,
.wt-notes li {
  counter-increment: wt-step;
  position: relative;
  padding: 10px 0 10px 34px;
  border-top: 1px solid var(--wt-line-soft);
  font-family: var(--wt-serif);
  font-size: 16px;
  line-height: 1.6;
  color: var(--wt-ink-2);
}

.wt-fallback-steps li:first-child,
.wt-notes li:first-child {
  border-top: none;
}

.wt-fallback-steps li::before,
.wt-notes li::before {
  content: counter(wt-step);
  position: absolute;
  left: 0;
  top: 11px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--wt-panel);
  color: var(--wt-ink-3);
  font-family: var(--wt-sans);
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
}

.wt-fallback-steps li.is-current,
.wt-notes li.is-current {
  color: var(--wt-ink);
}

.wt-fallback-steps li.is-current::before,
.wt-notes li.is-current::before {
  background: var(--wt-accent-soft);
  color: var(--wt-accent);
}

/* --- No-calculator layout ----------------------------------------------- */

.wt-stage.has-figure {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 300px);
  gap: 20px;
  align-items: start;
}

.wt-figure img {
  display: block;
  width: 100%;
  border: 1px solid var(--wt-line);
  border-radius: 8px;
  background: #ffffff;
}

@media (max-width: 900px) {
  .wt-calc {
    height: 340px;
  }

  .wt-stage.has-figure {
    grid-template-columns: minmax(0, 1fr);
  }

  .wt-figure {
    max-width: 320px;
  }
}
