/*
 * Veri laboratuvarı (plan 106 A6), the `data` investigation drawn by lab-find-data.js. Colours come only from tokens.css
 * (chart-1..6 for categories and groups); no color-mix(). Each grade fits one screen of the explorer dialog at 1366×768
 * and 1280×720: two columns (plot | task panel), one column on phones. Motion is the JS drop-in (transform and opacity)
 * plus the button transitions, both off under body.reduced-motion.
 */
#catalogueExploreDialog:has(.cl-lab[data-exploration-type="data"]) { width: min(1240px, 96vw); }
.cl-lab[data-exploration-type="data"] { display: grid; gap: 14px; color: var(--ink); }
.cl-lab[data-exploration-type="data"] [hidden] { display: none !important; }
.cl-lab[data-exploration-type="data"] p { margin: 0; }
.cl-lab[data-exploration-type="data"] .button { min-height: 46px; padding: 8px 16px; }
.cl-lab[data-exploration-type="data"] :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.cl-lab[data-exploration-type="data"] button { font-family: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.cl-lab[data-exploration-type="data"] .button[aria-pressed="true"] { color: var(--on-brand); background: var(--brand); border-color: transparent; }
html:not([data-input="touch"]) .cl-lab[data-exploration-type="data"] .button[aria-pressed="true"]:hover:where(:not(:disabled)) { color: var(--on-brand); background: var(--brand); }

/* ---- Head: data source · title and size · next preset ---------------------------------------------------------- */
.fd-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.fd-source { display: flex; gap: 6px; }
.fd-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; flex: 1 1 260px; min-width: 0; font-size: 19px; line-height: 1.25; }
.fd-n { color: var(--ink-2); font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---- Main: plot | side panel ----------------------------------------------------------------------------------- */
.fd-main { display: grid; gap: 18px 24px; align-items: start; }
.fd-main--g5 { grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr); }
.fd-main--g6 { grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); }
.fd-main--g7 { grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr); }
.fd-main--g8 { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
.fd-side { display: grid; gap: 12px; align-content: start; min-width: 0; }
.fd-task { font-size: 17px; font-weight: 650; line-height: 1.35; }
.fd-left { display: inline-block; margin-left: 6px; color: var(--ink-2); font-weight: 600; }
.fd-note { color: var(--ink-2); font-size: 15px; line-height: 1.4; }
.fd-choices, .fd-cards { display: flex; flex-wrap: wrap; gap: 8px; }
.fd-stat { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- Grade 5: bar chart built from cards --------------------------------------------------------------------- */
.fd-chart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 12px; padding: 4px 0 0; }
.fd-col { display: grid; justify-items: stretch; gap: 6px; min-width: 0; }
.fd-count { align-self: center; padding-bottom: 4px; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.fd-bar-track { display: flex; flex-direction: column; justify-content: flex-end; height: 208px; border-bottom: 3px solid var(--line-strong); }
/* No border or padding: the bar's height is exactly count × unit. Each card is one segment. */
.fd-bar { display: flex; flex-direction: column-reverse; width: 100%; background: var(--fd-color); border-radius: 8px 8px 0 0; overflow: hidden; }
.fd-bar i { flex: 1 1 0; box-shadow: inset 0 2px 0 var(--surface); }
.fd-bar i:last-child { box-shadow: none; }
.fd-col-button { width: 100%; padding-inline: 6px; overflow-wrap: anywhere; }
.fd-col-button::before { content: ""; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--fd-color); }
.fd-card { min-width: 92px; }
.fd-card[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--focus); }

/* ---- Grade 6: dot plot, median line, towers ------------------------------------------------------------------ */
.fd-tasks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.fd-sides { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fd-sides span { display: grid; justify-items: center; gap: 2px; padding: 6px 4px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); font-size: 15px; font-weight: 650; }
.fd-sides b { color: var(--ink); font-size: 24px; font-variant-numeric: tabular-nums; }
.fd-sides [data-data-side="on"] b { color: var(--brand-ink); }
/* Every column is a tap target of at least 44 px; when a wide class poll does not fit a phone, the plot scrolls
   sideways inside its own box. */
.fd-plot { padding-top: 34px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; }
.fd-columns { position: relative; display: grid; }
.fd-column { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; height: 216px; padding: 0; color: var(--ink); background: transparent; border: 0; border-radius: 10px 10px 0 0; cursor: pointer; transition: background var(--dur-fast) ease; }
html:not([data-input="touch"]) .fd-column:hover { background: var(--surface-2); }
.fd-column[aria-pressed="true"] { background: var(--brand-tint); }
.fd-dots { display: flex; flex-direction: column-reverse; align-items: center; gap: 4px; }
.fd-dots i { display: block; width: var(--fd-dot); height: var(--fd-dot); border-radius: 50%; background: var(--chart-1); }
.fd-tick { font-size: 18px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.2; }
/* In the dot plot the tick row sits under the axis, so the median line never covers a number. */
.fd-column .fd-tick { align-self: stretch; box-sizing: border-box; height: 30px; padding-top: 3px; text-align: center; border-top: 3px solid var(--line-strong); }
/* The median line: a 44 px wide slider over the plot, with its value in a grip above the columns. */
.fd-line { position: absolute; top: -34px; bottom: 27px; z-index: 1; display: flex; justify-content: center; width: 44px; cursor: ew-resize; touch-action: none; border-radius: 10px; }
.fd-line__bar { width: 4px; height: 100%; background: var(--red-ink); border-radius: 2px; }
.fd-line__grip { position: absolute; top: 0; left: 50%; min-width: 44px; padding: 3px 8px; transform: translateX(-50%); color: var(--on-brand); background: var(--red-ink); border-radius: 8px; font-size: 16px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.fd-line.is-dragging .fd-line__bar { width: 6px; }
.fd-towers { display: flex; align-items: flex-end; justify-content: center; gap: 10px; min-height: 250px; padding-top: 8px; border-bottom: 3px solid var(--line-strong); }
.fd-tower { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; min-width: 52px; min-height: 52px; padding: 4px 4px 6px; color: var(--ink); background: transparent; border: 0; border-radius: 10px 10px 0 0; cursor: pointer; transition: background var(--dur-fast) ease; }
html:not([data-input="touch"]) .fd-tower:hover { background: var(--surface-2); }
.fd-tower[aria-pressed="true"] { background: var(--brand-tint); box-shadow: inset 0 0 0 3px var(--focus); }
.fd-blocks { display: flex; flex-direction: column-reverse; gap: 2px; }
.fd-blocks i { display: block; width: 40px; height: calc(var(--fd-block) - 2px); background: var(--chart-2); border-radius: 4px; }

/* ---- Grade 7: two groups on one axis, points are sliders ------------------------------------------------------ */
.fd-groups { display: grid; gap: 12px; min-width: 0; }
.fd-group { display: grid; gap: 4px; padding: 10px 28px 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.fd-group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin: 0 -14px; font-size: 16px; font-variant-numeric: tabular-nums; }
.fd-group-head strong { font-size: 18px; }
.fd-group-head strong::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border-radius: 50%; background: var(--fd-color); }
.fd-group-head span { color: var(--ink-2); font-weight: 650; }
.fd-track { position: relative; height: 108px; border-bottom: 3px solid var(--line-strong); }
.fd-mean-mark { position: absolute; top: 0; bottom: 0; width: 0; margin-left: -1.5px; border-left: 3px dashed var(--ink-2); }
.fd-point { position: absolute; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; cursor: ew-resize; touch-action: none; }
.fd-point::before { content: ""; width: 24px; height: 24px; border-radius: 50%; background: var(--fd-color); box-shadow: 0 0 0 2px var(--surface); transition: transform var(--dur-fast) ease; }
.fd-point.is-dragging { z-index: 1; }
.fd-point.is-dragging::before { transform: scale(1.2); }
.fd-axis { position: relative; height: 22px; color: var(--ink-2); font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.fd-axis span { position: absolute; top: 2px; transform: translateX(-50%); white-space: nowrap; }
.fd-axis span::before { content: ""; position: absolute; top: -6px; left: 50%; height: 6px; border-left: 2px solid var(--line-strong); }
.fd-reasons { display: grid; gap: 4px; margin: 0; padding: 0; border: 0; }
.fd-reasons legend { padding: 0 0 4px; font-size: 16px; font-weight: 700; }
.fd-reasons label { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border-radius: 10px; background: var(--surface-2); font-size: 16px; cursor: pointer; }
.fd-reasons input { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--brand); }

/* ---- Grade 8: pie chart with ±15° steppers -------------------------------------------------------------------- */
.fd-pie { display: grid; justify-items: center; gap: 8px; margin: 0; }
.fd-pie-svg { display: block; width: clamp(200px, 38vh, 300px); height: auto; }
.fd-pie-empty { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1.5; stroke-dasharray: 4 4; }
.fd-slice { stroke: var(--surface); stroke-width: 2; }
.fd-pie-svg text { fill: var(--on-brand); font-size: 13px; font-weight: 800; paint-order: stroke; stroke: var(--inverse); stroke-width: 2.5px; stroke-linejoin: round; }
.fd-pie figcaption { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fd-pie figcaption.fd-over { color: var(--red-ink); }
.fd-slices { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.fd-slices th, .fd-slices td { padding: 3px 6px; text-align: left; border: 0; }
.fd-slices thead th { color: var(--ink-2); font-size: 14px; font-weight: 700; }
.fd-slices tbody th { font-size: 17px; white-space: nowrap; }
.fd-slices tbody tr + tr > * { border-top: 1px solid var(--line); }
.fd-swatch { display: inline-block; width: 14px; height: 14px; margin-right: 8px; border-radius: 4px; background: var(--fd-color); vertical-align: -1px; }
.fd-freq { font-size: 16px; white-space: nowrap; }
.fd-stepper { display: flex; align-items: center; gap: 6px; }
.fd-stepper .button { min-width: 64px; padding-inline: 8px; }
.fd-stepper output { min-width: 52px; font-size: 19px; font-weight: 800; text-align: center; }
.fd-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 900; }
.fd-mark--ok { color: var(--green-ink); background: var(--green-tint); }
.fd-mark--no { color: var(--red-ink); background: var(--red-tint); }

/* ---- Class poll: one key per allowed answer ------------------------------------------------------------------- */
.fd-poll { display: grid; gap: 14px; }
.fd-keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.fd-keys--numbers { grid-template-columns: repeat(11, minmax(0, 1fr)); }
.fd-key { flex-direction: column; gap: 0; min-height: 64px; font-size: 19px; }
.fd-key small { min-height: 18px; color: var(--ink-2); font-size: 14px; font-weight: 700; }
.fd-poll-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.fd-poll-count { margin-right: auto; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Short boards (1280×720): the band and body give back some padding so every grade fits without a scroll. */
@media (max-height: 780px) {
  #catalogueExploreDialog:has(.cl-lab[data-exploration-type="data"]) #catalogueExploreBody { padding-block: 12px; }
  .cl-lab[data-exploration-type="data"] { gap: 10px; }
}

/* Phones: one column; the page scrolls vertically, nothing scrolls sideways. */
@media (max-width: 760px) {
  .fd-main--g5, .fd-main--g6, .fd-main--g7, .fd-main--g8 { grid-template-columns: minmax(0, 1fr); }
  .fd-source { flex-wrap: wrap; }
  .fd-chart { gap: 6px; }
  .fd-tick { font-size: 15px; }
  .fd-keys { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fd-keys--numbers { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  /* Each table row becomes two lines: name, frequency and mark, then the stepper. */
  .fd-slices thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .fd-slices tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 10px; padding: 6px 0; }
  .fd-slices tbody tr + tr { border-top: 1px solid var(--line); }
  .fd-slices tbody tr + tr > * { border-top: 0; }
  .fd-slices tbody td:nth-child(3) { grid-row: 2; grid-column: 1 / -1; }
  .fd-slices tbody td:nth-child(4) { grid-row: 1; grid-column: 3; }
  .fd-slices th, .fd-slices td { padding: 0; }
  .fd-stepper .button { flex: 1 1 0; }
  .fd-group { padding-inline: 24px; }
}
