/* Probability simulator: the controls, last result, tally table and the relative-frequency chart.
   Builds on the shared .explorer, .btn and .cx styles in styles.css. */
.probability-sim { min-width: 0; }

/* Last result (and the wheel next to it) above the buttons. */
.ps-top { display: flex; flex-wrap: wrap; gap: 0.8rem 1.2rem; align-items: center; margin-bottom: 0.6rem; }
.ps-wheel { flex: none; width: 136px; height: 136px; }
/* the sector fills (.ps-slice, .ps-slice--N) are shared with the spinner figure: styles/figures/maths.css */
.ps-slice.is-last { stroke: var(--text); stroke-width: 4; stroke-linejoin: round; }
.ps-slice-name { font-size: 14px; /* 136 px for 160 units: about 12 px on the page */ font-weight: 700; fill: var(--text); pointer-events: none; }

.ps-last { display: flex; flex-direction: column; gap: 0.15rem; min-width: 5.5rem; }
.ps-last-title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.ps-result { display: grid; place-items: center; min-width: 4rem; min-height: 3.4rem; padding: 0.2rem 0.8rem; border: 2px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.ps-face { font-size: 1.6rem; font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; text-align: center; }
@media (prefers-reduced-motion: no-preference) {
  .ps-face { animation: ps-pop 0.18s ease-out; }
}
@keyframes ps-pop { from { transform: scale(0.8); opacity: 0.5; } to { transform: none; opacity: 1; } }

.ps-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; flex: 1 1 14rem; }
.ps-step { min-width: 56px; min-height: 44px; font-variant-numeric: tabular-nums; }
.ps-reset { min-height: 44px; }

/* The announcement is also on screen: it is the readout of the last run. */
.ps-readout { margin: 0 0 0.8rem; min-height: 1.5em; padding: 0.5rem 0.7rem; border-radius: 10px; background: var(--accent-soft); font-weight: 600; overflow-wrap: anywhere; }

/* Tally table. At large text it can be wider than the card: it scrolls inside its own box (focusable, so the keyboard can scroll it). */
.ps-table-box { --box-padding: min(1.2rem, 19.2px); overflow-x: auto; margin-inline: calc(-1 * var(--box-padding)); padding-inline: var(--box-padding); } /* reaches into the card's side padding (as the table did before it had a box), so a table that is a few pixels too wide at 320 px is not cut off; the shadows at its edges reach over the padding too (see styles.css) */
.ps-table-box:focus-visible { outline-offset: -3px; }
/* The box's side padding is two grid columns that give way before the box would overflow (see styles.css), so at the default size a table that
   just fits the card keeps its place. When the table is wider than the box (large text) there is nothing to give: the table gets the inset as its own margin,
   so the heading lines up with the widget's and the focus ring does not run over the text. The width is the table's width (about 16.8rem) plus a little. */
@supports (animation-timeline: scroll()) {
  @container (width < 16.5rem) { .explorer .ps-table-box > .ps-table { margin-inline: var(--box-padding); width: auto; } }
}
.ps-table { width: 100%; border-collapse: collapse; margin: 0 0 0.9rem; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.ps-table caption { text-align: left; font-weight: 700; padding-bottom: 0.3rem; overflow-wrap: anywhere; }
.ps-table th, .ps-table td { border: 1px solid var(--border); padding: 0.3rem 0.4rem; text-align: left; }
.ps-table tbody th { overflow-wrap: anywhere; } /* a long sector name may break; the column headings never do */
.ps-table thead th { background: var(--surface-2); font-size: 0.78rem; vertical-align: bottom; }
.ps-table tbody th, .ps-table tfoot th { font-weight: 600; }
.ps-table .ps-num { text-align: right; }
.ps-table tr.is-tracked th, .ps-table tr.is-tracked td { background: var(--accent-soft); font-weight: 700; }
.ps-table tfoot th, .ps-table tfoot td { background: var(--surface-2); font-weight: 600; }

/* Chart. */
.ps-follow { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; margin-bottom: 0.5rem; font-weight: 600; }
.ps-select { font: inherit; min-height: 44px; padding: 0.3rem 0.6rem; border: 1.5px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); max-width: 100%; }
.ps-chart-wrap { max-width: 460px; border-radius: 10px; }
.ps-grid { stroke: var(--grid); stroke-width: 1; }
.ps-tick { font-size: 11px; }
.ps-frequency { fill: none; stroke: var(--user-line); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.ps-end { fill: var(--user-line); stroke: var(--surface); stroke-width: 2; }
.ps-theory { stroke: var(--line); stroke-width: 2.25; stroke-dasharray: 7 4; }

/* The legend says the same as the colours, with a solid and a dashed sample. */
.ps-legend { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.88rem; color: var(--muted); }
.ps-legend li { display: flex; align-items: center; gap: 0.5rem; overflow-wrap: anywhere; }
.ps-legend li::before { content: ''; flex: none; width: 1.8rem; border-top: 3px solid; }
.ps-legend .ps-legend-frequency::before { border-color: var(--user-line); }
.ps-legend .ps-legend-theory::before { border-color: var(--line); border-top-style: dashed; }
