/* Interactive lessons: controls and widgets. Loaded only by lesson pages; uses the site's tokens. */

.lesson .step { scroll-margin-top: 1.5rem; }
.lesson .step + .step { margin-top: var(--section); }
.lesson .step h2:focus { outline: none; }

/* Buttons */

.lesson button { font: inherit; color: inherit; cursor: pointer; }
.lesson button[aria-disabled="true"] { cursor: default; }

.btn {
  min-height: 44px;
  padding: 0.55rem 1rem;
  border: 1px solid var(--text);
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg) !important;
  font-weight: 500;
}
.btn:hover { opacity: 0.88; }
.btn.ghost { background: transparent; color: var(--text) !important; }
.btn.ghost:hover { background: var(--hover); opacity: 1; }
.btn[aria-disabled="true"] { opacity: 0.45; }
.btn.next { display: block; margin-top: 1.75rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0; min-height: 44px; }

/* Predictions */

.predict { margin: 1.5rem 0; }
.predict .q { font-weight: 500; color: var(--text); }

.prose .choices, .prose .summary { list-style: none; padding: 0; margin-left: 0; }
.choices { margin: 0.75rem 0 0; display: grid; gap: 0.5rem; }
.choices li { margin: 0; }
.choice {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.9rem;
  text-align: left;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: transparent;
}
.choice:hover:not([aria-disabled="true"]) { background: var(--hover); border-color: var(--muted); }
.choice[aria-disabled="true"]:not([aria-pressed="true"]) { opacity: 0.5; }
.choice[aria-pressed="true"] { border-color: var(--text); background: var(--hover); font-weight: 500; }
.choice[aria-pressed="true"]::after { content: "  · your answer"; font-weight: 400; color: var(--muted); }

.feedback {
  margin: 0.9rem 0 0;
  padding-left: 0.9rem;
  border-left: 2px solid var(--muted);
}
.feedback.right { border-left-color: var(--chart); }

.status { min-height: 1.6em; margin: 1rem 0 0.75rem; }
.note { font-size: var(--step-small); color: var(--muted); margin-top: 0.5rem; }
.feedback .you-said { color: var(--muted); }
.panel-h { font-weight: 500; margin: 0 0 0.5rem; }

/* Three doors */

.doors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; max-width: 26rem; }
.door {
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.25rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--hover);
  transition: background 0.25s ease, border-color 0.25s ease;
}
.door .n { font-family: var(--display); font-size: 1.6rem; line-height: 1; }
.door .behind { font-size: var(--step-small); min-height: 1.3em; }
.door:hover:not([aria-disabled="true"]) { border-color: var(--text); }
.door.picked { border: 2px solid var(--text); }
.door.open { background: transparent; border-style: dashed; }
.door.open.car { border-style: solid; border-color: var(--chart); }
.door.picked.open { border: 2px solid var(--muted); }
.door.picked.open.car { border-color: var(--chart); }
.door.car .behind { color: var(--chart); font-weight: 600; }
.door.goat .behind { color: var(--muted); }
.door.final { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }

.tally { max-width: 20rem; margin-top: 0.5rem; }
.prose .tally td, .prose .tally th { text-align: right; }
.prose .tally th:first-child { text-align: left; }

/* Bars */

.bars { display: grid; gap: 0.5rem; margin: 1rem 0 0.25rem; }
.bar-row { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: 0.2rem 0.75rem; align-items: center; }
.bar-row .label { font-weight: 500; }
.bar-row .track { height: 0.7rem; border-radius: 0 4px 4px 0; background: var(--rule); overflow: hidden; }
.bar-row .fill { display: block; height: 100%; width: 0; background: var(--chart); border-radius: 0 4px 4px 0; }
.bar-row .value { grid-column: 2; font-size: var(--step-small); color: var(--muted); font-variant-numeric: tabular-nums; }

/* Slider and stacked mix bars */

.range-label { display: block; font-weight: 500; margin-top: 1rem; }
.range-label output { font-variant-numeric: tabular-nums; }
.lesson input[type="range"] { width: 100%; max-width: 28rem; min-height: 44px; accent-color: var(--text); }
.mixes { display: grid; gap: 0.5rem; margin: 0.25rem 0 0.5rem; }
.stack { display: flex; gap: 2px; height: 0.7rem; }
.seg { display: block; flex-basis: 0; min-width: 0; }
.seg.mild, .key.mild { background: var(--chart); }
.seg.severe, .key.severe { background: var(--muted); }
.seg.mild { border-radius: 0; }
.seg.severe { border-radius: 0 4px 4px 0; }
.legend { font-size: var(--step-small); color: var(--muted); margin-bottom: 1.25rem; }
.key { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 2px; vertical-align: -0.05em; }
.key.severe { margin-left: 0.75rem; }

/* Compare panels (side by side when there's room) */

.compare { display: grid; gap: 1rem; margin-top: 1rem; }
@media (min-width: 40rem) { .compare { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.panel, .tile-group { padding: 1rem; border: 1px solid var(--rule); border-radius: var(--radius); }

.controls { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem; }
.toggle { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: center; }
.toggle legend { float: left; margin-right: 0.5rem; font-weight: 500; }
.toggle label { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 44px; cursor: pointer; }
.toggle input { accent-color: var(--text); width: 1.1rem; height: 1.1rem; }

/* Thirty games */

.tiles { display: flex; flex-wrap: wrap; gap: 4px; }
.tile { width: 16px; height: 16px; border-radius: 3px; }
.tile.win { background: var(--chart); }
.tile.lose { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }

.formula {
  font-family: var(--mono);
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow-x: auto;
}

/* A hundred doors */

.grid100 { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; max-width: 28rem; }
.cell {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  font-size: 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--hover);
  font-variant-numeric: tabular-nums;
  transition: opacity 0.2s ease;
}
.cell:hover:not([aria-disabled="true"]) { border-color: var(--text); }
.cell.open { opacity: 0.18; }
.cell.picked { border: 2px solid var(--text); }
.cell.car { background: var(--chart); color: var(--bg); border-color: var(--chart); opacity: 1; }
.cell.final { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }

/* Figures drawn in SVG (√2) */

.lesson-figure { margin: 1.5rem 0; }
.lesson-figure svg { display: block; width: 100%; max-width: 15rem; height: auto; }
.lesson-figure figcaption { margin-top: 0.6rem; font-size: var(--step-small); color: var(--muted); }
.lesson-figure path, .lesson-figure rect { vector-effect: non-scaling-stroke; }
.lesson-figure .tilt { fill: var(--chart); fill-opacity: 0.22; }
.lesson-figure .grid-line { fill: none; stroke: var(--muted); stroke-width: 1; }
.lesson-figure .edge { fill: none; stroke: var(--chart); stroke-width: 2; }
.lesson-figure .small { fill: var(--chart); fill-opacity: 0.3; stroke: var(--chart); stroke-width: 1.5; }
.lesson-figure .corner { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 3; }
.lesson-figure .big { fill: none; stroke: var(--text); stroke-width: 2; }
.chain { font-family: var(--mono); font-size: 0.9rem; white-space: pre-wrap; }

/* Summary */

.summary { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.summary li { display: grid; gap: 0.1rem; padding-left: 0.9rem; border-left: 2px solid var(--muted); }
.summary li.right { border-left-color: var(--chart); }
.summary li span { font-size: var(--step-small); color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .door, .cell { transition: none; }
}
