/* Transformation Lab — tool-specific styles.
   Layout and component styles only; all colours come from main.css tokens. */

/* ── the two families, side by side ───────────────────────────────── */

.family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.family-card {
  border: 1px solid var(--app-border, #d6dfea);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 1rem 1.1rem;
  background: var(--app-bg, #f5f7fb);
}

/* The colour split is load-bearing: the same cue marks every shape-changing
   and scale-changing control elsewhere on the page. */
.family-card--shape { border-left-color: var(--app-accent, #2a7de1); }
.family-card--scale { border-left-color: var(--app-success, #2f9d58); }

.family-card h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.family-card p { margin: 0 0 0.5rem; font-size: 0.93rem; }
.family-card__formula { font-size: 1.05rem; color: var(--app-muted, #5f6b7a); }

.section-lede {
  color: var(--app-muted, #5f6b7a);
  max-width: 76ch;
  margin-top: 0;
}

.field-hint {
  font-size: 0.85rem;
  color: var(--app-muted, #5f6b7a);
  margin: 0.3rem 0 0;
  min-height: 1.1em;
}

/* ── diagnostics ──────────────────────────────────────────────────── */

.diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}

.diagnostic-plot { margin: 0; }

.diagnostic-plot figcaption {
  font-size: 0.85rem;
  color: var(--app-muted, #5f6b7a);
  text-align: center;
  margin-top: 0.35rem;
}

.plot-target {
  width: 100%;
  min-height: 260px;
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 8px;
  background: var(--app-card-bg, #fff);
}

.findings { display: grid; gap: 0.6rem; margin-bottom: 1.25rem; }

.finding {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--app-border, #d6dfea);
  background: var(--app-card-bg, #fff);
}

.finding--warn { border-left: 4px solid var(--app-warning, #f3b440); }
.finding--ok   { border-left: 4px solid var(--app-success, #2f9d58); }
.finding--info { border-left: 4px solid var(--app-muted, #5f6b7a); }

.finding__icon { font-size: 1.1rem; line-height: 1.4; }
.finding__headline { font-weight: 600; margin: 0 0 0.15rem; }
.finding__detail { margin: 0; font-size: 0.9rem; color: var(--app-muted, #5f6b7a); }

.recommendation {
  border: 1px solid var(--app-accent, #2a7de1);
  border-radius: 8px;
  padding: 1rem 1.15rem;
  background: rgba(42, 125, 225, 0.06);
}

.recommendation h3 { margin: 0 0 0.4rem; font-size: 1.1rem; }
.recommendation p { margin: 0 0 0.6rem; }
.recommendation--none { border-color: var(--app-success, #2f9d58); background: rgba(47, 157, 88, 0.07); }

.recommendation__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ── the ladder ───────────────────────────────────────────────────── */

.ladder-controls { margin-bottom: 1rem; }

.ladder-target {
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  display: inline-flex;
  gap: 1.25rem;
  align-items: center;
}

.ladder-target legend { padding: 0 0.4rem; font-size: 0.88rem; font-weight: 600; }

.ladder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 0.85rem;
}

.ladder-card {
  appearance: none;
  text-align: left;
  font: inherit;
  /* These are <button>s, which inherit the site's white button text and would
     otherwise render every label white-on-white. */
  color: var(--app-text, #1f2a37);
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 8px;
  background: var(--app-card-bg, #fff);
  padding: 0.6rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ladder-card:hover { border-color: var(--app-accent, #2a7de1); }

.ladder-card[aria-pressed="true"] {
  border-color: var(--app-accent, #2a7de1);
  box-shadow: 0 0 0 2px rgba(42, 125, 225, 0.25);
}

.ladder-card:focus-visible {
  outline: 2px solid var(--app-accent, #2a7de1);
  outline-offset: 2px;
}

.ladder-card--baseline { background: var(--app-bg, #f5f7fb); }

.ladder-card--blocked {
  opacity: 0.65;
  cursor: not-allowed;
  border-style: dashed;
}

.ladder-card__spark { width: 100%; height: 92px; }
.ladder-card__name { font-weight: 600; font-size: 0.88rem; }

.ladder-card__stat {
  font-size: 0.82rem;
  color: var(--app-muted, #5f6b7a);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.ladder-card__delta--up { color: var(--app-success, #2f9d58); font-weight: 600; }
.ladder-card__delta--down { color: var(--app-danger, #d64747); }
.ladder-card__blocked-why { font-size: 0.78rem; color: var(--app-danger, #d64747); }

.ladder-note { margin-top: 1rem; font-size: 0.88rem; }

/* ── comparison ───────────────────────────────────────────────────── */

.compare-header { margin-bottom: 0.75rem; }

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 1rem;
}

.compare-col { display: grid; gap: 0.6rem; }
.compare-col__title { margin: 0; font-size: 1rem; }

.metrics-table { width: 100%; border-collapse: collapse; margin: 1.25rem 0; }

.metrics-table th,
.metrics-table td {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--app-border, #d6dfea);
  text-align: right;
}

.metrics-table th:first-child,
.metrics-table td:first-child { text-align: left; }
.metrics-table thead th { background: var(--app-bg, #f5f7fb); }
.metrics-table .metric-better { color: var(--app-success, #2f9d58); font-weight: 600; }
.metrics-table .metric-worse { color: var(--app-danger, #d64747); }

.metrics-note {
  font-size: 0.85rem;
  color: var(--app-muted, #5f6b7a);
  margin: -0.75rem 0 1.25rem;
}

.interpretation {
  border-left: 4px solid var(--app-accent, #2a7de1);
  background: var(--app-bg, #f5f7fb);
  border-radius: 0 8px 8px 0;
  padding: 0.9rem 1.1rem;
}

.interpretation h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.interpretation p { margin: 0 0 0.5rem; }
.interpretation p:last-child { margin-bottom: 0; }

/* ── invariance proof ─────────────────────────────────────────────── */

.invariance-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.invariance-verdict {
  margin-top: 1rem;
  padding: 0.9rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--app-success, #2f9d58);
  background: rgba(47, 157, 88, 0.08);
}

.invariance-verdict h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.invariance-verdict p:last-child { margin-bottom: 0; }

.value-identical { color: var(--app-success, #2f9d58); font-weight: 600; }
.value-moved { color: var(--app-warning, #b8860b); font-weight: 600; }

/* ── receipt actions ──────────────────────────────────────────────── */

.receipt-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* ── "why would you change your data" opener ──────────────────────── */

.lede-big {
  font-size: 1.12rem;
  line-height: 1.55;
  max-width: 70ch;
}

.subhead {
  margin: 2rem 0 0.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--app-border, #d6dfea);
  font-size: 1.2rem;
}

.why-grid,
.reason-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.why-card {
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 8px;
  padding: 0.9rem 1.05rem;
  background: var(--app-bg, #f5f7fb);
}

.why-card h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.why-card p { margin: 0; font-size: 0.92rem; }

/* ── theory-driven vs diagnostic-driven ───────────────────────────── */

.reason-card {
  border: 1px solid var(--app-border, #d6dfea);
  border-top-width: 4px;
  border-radius: 8px;
  padding: 1rem 1.15rem;
  background: var(--app-card-bg, #fff);
}

.reason-card--theory { border-top-color: var(--app-success, #2f9d58); }
.reason-card--empirical { border-top-color: var(--app-accent, #2a7de1); }

.reason-card h4 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.reason-card p, .reason-card li { font-size: 0.92rem; }
.reason-card ul { padding-left: 1.15rem; margin: 0.5rem 0; }
.reason-card li { margin-bottom: 0.35rem; }

.reason-card__tag {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--app-muted, #5f6b7a);
  margin: 0 0 0.6rem;
  font-weight: 600;
}

.reason-card__verdict {
  margin: 0.6rem 0 0;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--app-border, #d6dfea);
  color: var(--app-muted, #5f6b7a);
}

.danger-card {
  border: 1px solid var(--app-danger, #d64747);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 1rem 1.2rem;
  margin: 1.5rem 0;
  background: rgba(214, 71, 71, 0.05);
  /* Anchor target for the in-page "p-hacking" links. */
  scroll-margin-top: 1rem;
}

.danger-card h4 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.danger-card ul { padding-left: 1.2rem; }
.danger-card li { margin-bottom: 0.45rem; }

.danger-card__fix {
  margin: 0.8rem 0 0;
  padding: 0.7rem 0.9rem;
  background: var(--app-card-bg, #fff);
  border-radius: 6px;
  border: 1px solid var(--app-border, #d6dfea);
}

.family-card__use {
  margin: 0.5rem 0 0;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--app-border, #d6dfea);
  color: var(--app-muted, #5f6b7a);
  font-size: 0.88rem;
}

/* ── fitted equations ─────────────────────────────────────────────── */

.equation-heading { margin: 1.5rem 0 0.6rem; font-size: 1.05rem; }

.equation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.equation-box {
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: var(--app-bg, #f5f7fb);
}

.equation-box__caption {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: var(--app-muted, #5f6b7a);
  margin-bottom: 0.2rem;
}

/* Long equations scroll rather than wrapping mid-term. */
.equation-box__body { overflow-x: auto; overflow-y: hidden; }

.equation-box__note {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--app-muted, #5f6b7a);
}

/* ── both-variables matrix ────────────────────────────────────────── */

.matrix-scroll { overflow-x: auto; margin: 0.5rem 0 0.75rem; }

.matrix-table { border-collapse: collapse; font-size: 0.85rem; min-width: 100%; }

.matrix-table th,
.matrix-table td {
  border: 1px solid var(--app-border, #d6dfea);
  padding: 0;
  text-align: center;
  white-space: nowrap;
}

.matrix-table thead th,
.matrix-table tbody th {
  padding: 0.4rem 0.6rem;
  background: var(--app-bg, #f5f7fb);
  font-weight: 600;
  font-size: 0.8rem;
}

.matrix-table tbody th { text-align: left; }

.matrix-cell__btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--app-text, #1f2a37);
  font: inherit;
  font-variant-numeric: tabular-nums;
  width: 100%;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
}

.matrix-cell__btn:hover { text-decoration: underline; }

.matrix-cell__btn:focus-visible {
  outline: 2px solid var(--app-accent, #2a7de1);
  outline-offset: -2px;
}

.matrix-cell__btn[aria-pressed="true"] {
  font-weight: 700;
  box-shadow: inset 0 0 0 2px var(--app-accent, #2a7de1);
}

.matrix-cell--blocked {
  color: var(--app-muted, #5f6b7a);
  padding: 0.45rem 0.6rem;
  background: repeating-linear-gradient(45deg, transparent, transparent 4px,
    rgba(95, 107, 122, 0.08) 4px, rgba(95, 107, 122, 0.08) 8px);
}

.matrix-cell--baseline { outline: 2px dashed var(--app-muted, #5f6b7a); outline-offset: -2px; }
.matrix-legend { font-size: 0.85rem; margin: 0.35rem 0; }

@media (max-width: 720px) {
  .matrix-table { font-size: 0.78rem; }
}

/* ── mode switch and Model mode ───────────────────────────────────── */

.mode-switch fieldset {
  border: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.mode-switch legend {
  font-weight: 600;
  margin-bottom: 0.4rem;
  padding: 0;
}

.mode-switch .radio-label {
  display: grid;
  grid-template-columns: 1.3rem 1fr;
  gap: 0.5rem;
  align-items: start;
  font-size: 0.93rem;
}

.model-outcome {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.predictor-table { width: 100%; border-collapse: collapse; }

.predictor-table th,
.predictor-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--app-border, #d6dfea);
  text-align: left;
  vertical-align: middle;
}

.predictor-table thead th { background: var(--app-bg, #f5f7fb); font-size: 0.88rem; }
.predictor-table select { width: 100%; max-width: 22rem; }
.predictor-table .skew-cell { font-variant-numeric: tabular-nums; color: var(--app-muted, #5f6b7a); }

.model-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 1.25rem 0;
}

.search-path {
  border-left: 4px solid var(--app-accent, #2a7de1);
  background: var(--app-bg, #f5f7fb);
  border-radius: 0 8px 8px 0;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.25rem;
}

.search-path h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.search-path ol { margin: 0 0 0.6rem; padding-left: 1.2rem; }
.search-path li { margin-bottom: 0.25rem; font-size: 0.92rem; }

.search-caveat {
  border-left: 4px solid var(--app-warning, #f3b440);
  background: rgba(243, 180, 64, 0.1);
  border-radius: 0 8px 8px 0;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
}

.fit-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.25rem;
}

.fit-stat {
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  background: var(--app-card-bg, #fff);
}

.fit-stat__label { font-size: 0.8rem; color: var(--app-muted, #5f6b7a); display: block; }
.fit-stat__value { font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.fit-stat--holdout { border-color: var(--app-accent, #2a7de1); }

.blocked-notice {
  border-left: 4px solid var(--app-danger, #d64747);
  background: rgba(214, 71, 71, 0.08);
  border-radius: 0 8px 8px 0;
  padding: 0.8rem 1rem;
  margin-bottom: 1.25rem;
}

.blocked-notice h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.blocked-notice ul { margin: 0; padding-left: 1.2rem; }

.vif-warn { color: var(--app-danger, #d64747); font-weight: 600; }

/* ── the live specification, under the variable pickers ───────────── */

.current-model {
  margin-top: 1rem;
  border: 1px solid var(--app-border, #d6dfea);
  border-left: 4px solid var(--app-accent, #2a7de1);
  border-radius: 0 8px 8px 0;
  background: var(--app-bg, #f5f7fb);
  padding: 0.85rem 1.1rem;
  color: var(--app-text, #1f2933);
}

.current-model__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.2rem;
}

.current-model__label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--app-muted, #5f6b7a);
}

.current-model__form {
  font-size: 0.8rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--app-card-bg, #fff);
  border: 1px solid var(--app-border, #d6dfea);
  color: var(--app-muted, #5f6b7a);
}

.current-model__form--changed {
  border-color: var(--app-accent, #2a7de1);
  color: var(--app-accent, #2a7de1);
  font-weight: 600;
}

.current-model__eq { overflow-x: auto; }
.current-model__note {
  margin: 0.2rem 0 0;
  font-size: 0.86rem;
  color: var(--app-muted, #5f6b7a);
}

/* ── per-plot reading guidance (step 1) ───────────────────────────── */

.plot-guide {
  margin-top: 0.5rem;
  border-top: 1px solid var(--app-border, #d6dfea);
  padding-top: 0.5rem;
  font-size: 0.84rem;
  color: var(--app-text, #1f2933);
}

.plot-guide p { margin: 0 0 0.4rem; }
.plot-guide p:last-child { margin-bottom: 0; }
.plot-guide strong { color: var(--app-text, #1f2933); }

.plot-guide__q {
  font-weight: 600;
  color: var(--app-accent, #2a7de1);
}

.plot-guide__why {
  margin: 0 0 1.25rem;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  background: var(--app-bg, #f5f7fb);
  font-size: 0.9rem;
}

/* ── what changed (step 3) ────────────────────────────────────────── */

.whatchanged {
  margin: 0.75rem 0 0.25rem;
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 8px;
  padding: 0.7rem 0.95rem;
  background: var(--app-card-bg, #fff);
}

.whatchanged__label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--app-muted, #5f6b7a);
}

.whatchanged__list {
  list-style: none;
  margin: 0.4rem 0 0.4rem;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.whatchanged__list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--app-muted, #5f6b7a);
}

.whatchanged--on { color: var(--app-text, #1f2933); }

.whatchanged__role {
  min-width: 108px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.whatchanged__name { font-weight: 600; }
.whatchanged__arrow { color: var(--app-muted, #5f6b7a); }
.whatchanged--on .whatchanged__to {
  font-weight: 600;
  color: var(--app-accent, #2a7de1);
}

.whatchanged__summary {
  margin: 0;
  font-size: 0.85rem;
  color: var(--app-muted, #5f6b7a);
}

/* ── interpretation + marginal effects ────────────────────────────── */

.interpretation__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
}

.interpretation__head h3 { margin: 0; }

.interpretation__form {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--app-card-bg, #fff);
  border: 1px solid var(--app-accent, #2a7de1);
  color: var(--app-accent, #2a7de1);
}

.interpretation__headline {
  font-size: 1.02rem;
  font-weight: 600;
}

.marginal {
  margin-top: 1rem;
  border-top: 1px solid var(--app-border, #d6dfea);
  padding-top: 0.85rem;
}

.marginal h4 { margin: 0 0 0.6rem; font-size: 0.95rem; }
.marginal__note { margin: 0.6rem 0 0; font-size: 0.89rem; }
.marginal__caveat {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
  color: var(--app-muted, #5f6b7a);
}

/* ── alternatives to transforming ─────────────────────────────────── */

.alt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.alt-card {
  border: 1px solid var(--app-border, #d6dfea);
  border-top: 3px solid var(--app-muted, #5f6b7a);
  border-radius: 8px;
  padding: 0.9rem 1.05rem;
  background: var(--app-card-bg, #fff);
}

.alt-card h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.alt-card p { margin: 0 0 0.6rem; font-size: 0.9rem; }
.alt-card__when { color: var(--app-text, #1f2933); }
.alt-card__cost { color: var(--app-muted, #5f6b7a); }

.alt-card__list {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.87rem;
  color: var(--app-muted, #5f6b7a);
}

.alt-card__list li { margin-bottom: 0.3rem; }

.alt-footer {
  margin: 0.5rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--app-bg, #f5f7fb);
  font-size: 0.92rem;
}

/* ── references ───────────────────────────────────────────────────── */

.ref-group__title {
  margin: 1.1rem 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--app-muted, #5f6b7a);
}

.ref-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.7rem;
}

.ref-list li { font-size: 0.89rem; line-height: 1.5; }
.ref-list a { word-break: break-word; }

.ref-list__why {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: var(--app-muted, #5f6b7a);
}

@media (max-width: 720px) {
  .ladder-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
  .plot-target { min-height: 220px; }
  .whatchanged__role { min-width: 0; }
}
