/* =========================================================================
   Epistemology Lens Switch — tool-specific styling
   -------------------------------------------------------------------------
   Shared page furniture comes from components/tool-kit.css. What is
   particular here: the lens chooser, the collapsible decision list in the
   controls column, and the pinned study specification.
   ========================================================================= */

/* Grid children default to a min-content minimum width, which a wide table
   would push past the viewport. Both columns must be allowed to shrink. */
#lens-switch .interactive__controls,
#lens-switch .interactive__stage {
  min-width: 0;
}

/* The stage is a grid, and a grid item's automatic minimum size is its
   min-content width - so a wide table inside a .table-scroll still widens
   the whole track and pushes the stage past a narrow viewport, even though
   the scroller itself would have coped. Every direct child of the stage has
   to opt out of that minimum, not just the stage. */
#lens-switch .interactive__stage > * {
  min-width: 0;
}

@media (min-width: 52em) {
  #lens-switch .interactive__body {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (min-width: 76em) {
  #lens-switch .interactive__body {
    grid-template-columns: minmax(0, 28rem) minmax(0, 1fr);
  }
}

/* -------------------------------------------------------------------------
   The case
   ---------------------------------------------------------------------- */

.case-facts {
  padding-left: 1.1rem;
  font-size: var(--text-sm);
}

.case-facts > li + li {
  margin-top: var(--space-3);
}

/* -------------------------------------------------------------------------
   Lens chooser
   ---------------------------------------------------------------------- */

.lens-option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: var(--space-3);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-md);
  background-color: var(--colour-surface-raised);
  cursor: pointer;
  min-height: 2.75rem;
}

.lens-option + .lens-option {
  margin-top: var(--space-2);
}

.lens-option:has(input:checked) {
  border-color: var(--colour-accent);
  background-color: var(--colour-accent-soft);
}

.lens-option input {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.2rem;
  flex: none;
  accent-color: var(--colour-accent);
}

.lens-option__body {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.lens-option__name {
  font-size: var(--text-sm);
  font-weight: 650;
}

.lens-option__object {
  font-size: var(--text-xs);
  color: var(--colour-text-muted);
}

/* -------------------------------------------------------------------------
   Decisions
   -------------------------------------------------------------------------
   Only one decision is expanded at a time; the others collapse to a summary
   button carrying the choice already made. Collapsing is done by toggling
   `hidden` rather than rebuilding, so keyboard focus survives.
   ---------------------------------------------------------------------- */

.decisions {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-2);
  counter-reset: none;
}

.decision-item {
  margin-top: 0;
}

.decision__summary {
  display: grid;
  gap: 0.1rem;
  width: 100%;
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font: inherit;
  color: var(--colour-text);
  background-color: var(--colour-surface-raised);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.decision__summary:hover {
  border-color: var(--colour-border-strong);
}

.decision__summary-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--colour-text-muted);
}

.decision__summary-value {
  font-size: var(--text-sm);
  line-height: 1.35;
}

.decision__summary-action {
  flex: none;
  font-weight: 650;
  color: var(--colour-accent);
}

.decision {
  margin: 0;
  padding: var(--space-3);
  border: 1px solid var(--colour-border-strong);
  border-left: 4px solid var(--colour-accent);
  border-radius: var(--radius-md);
  background-color: var(--colour-surface-raised);
}

/* A <legend> is painted on the fieldset's top border, so a long one that
   wraps spills out of the box. Floating it makes it lay out as a block while
   leaving the element - and so its announcement with each radio - unchanged. */
.decision__legend {
  float: left;
  width: 100%;
  padding: 0;
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: normal;
  text-transform: none;
  color: var(--colour-text);
}

.decision__hint {
  clear: both;
  margin: 0.35rem 0 var(--space-2);
  font-size: var(--text-xs);
  color: var(--colour-text-muted);
}

.decision__option {
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.35rem 0;
  font-size: var(--text-sm);
  line-height: 1.4;
  min-height: 2.75rem;
  cursor: pointer;
}

.decision__option input {
  margin-top: 0.25rem;
}

.decision__nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.decision__nav .button {
  min-height: 2.75rem;
}

/* -------------------------------------------------------------------------
   The specification
   ---------------------------------------------------------------------- */

.spec__case {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--colour-text-muted);
}

.spec td {
  font-variant-numeric: normal;
}

.spec td[data-empty="yes"] {
  color: var(--colour-text-muted);
  font-style: italic;
}

/* Inline, so the flag joins the last line of the choice instead of taking a
   line of its own in every row: five rows of two lines each is most of the
   pinned block's height. */
.spec__text {
  font-size: var(--text-sm);
  line-height: 1.4;
}

/* The state is always written out in words, so the tint is redundant. */
.spec__flag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--colour-border-strong);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 650;
}

.spec__flag[data-state="ok"] {
  border-color: var(--colour-neuropsychology);
  color: var(--colour-neuropsychology);
}

.spec__flag[data-state="tension"] {
  border-color: var(--colour-social-critical-psychology);
  color: var(--colour-social-critical-psychology);
}

.spec__coherence {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-left: 4px solid var(--colour-border-strong);
  border-radius: var(--radius-sm);
  background-color: var(--colour-surface);
  font-size: var(--text-sm);
}

.spec__coherence[data-state="ok"] {
  border-left-color: var(--colour-neuropsychology);
}

.spec__coherence[data-state="tension"] {
  border-left-color: var(--colour-social-critical-psychology);
}

/* -------------------------------------------------------------------------
   Challenge results
   ---------------------------------------------------------------------- */

.claims__results {
  margin: var(--space-3) 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: var(--space-3);
}

.claims__results > li {
  margin-top: 0;
}

.claims__result-head {
  margin: 0 0 var(--space-1);
}

.claims__results > li[data-agreed="no"] {
  padding-left: var(--space-3);
  border-left: 3px solid var(--colour-social-critical-psychology);
}

.claims__results > li[data-agreed="yes"] {
  padding-left: var(--space-3);
  border-left: 3px solid var(--colour-neuropsychology);
}

/* -------------------------------------------------------------------------
   Forced colours
   ---------------------------------------------------------------------- */

@media (forced-colors: active) {
  .lens-option,
  .decision,
  .decision__summary,
  .spec__flag {
    border: 1px solid CanvasText;
  }

  .lens-option:has(input:checked) {
    border: 2px solid Highlight;
  }

  .spec__flag[data-state="ok"],
  .spec__flag[data-state="tension"] {
    color: CanvasText;
  }

  .spec__coherence,
  .claims__results > li[data-agreed="no"],
  .claims__results > li[data-agreed="yes"] {
    border-left: 4px solid CanvasText;
  }
}
