/* THE CHOICE COMPONENT — page kit, C.58c.
 *
 * Three modes of one control: cards, an inline row, icon chips. The
 * differences between them are what the reader is choosing BETWEEN — a
 * set of drawings, a yes or a no, an alignment — and nothing else: one
 * explanation line, one focus treatment, one chosen state, one rhythm.
 *
 * NOT ONE LENGTH IS WRITTEN HERE. Every distance, size, radius and
 * colour is a token from abbundo.css's `:root`, and the kit-tokens gate
 * refuses a value written any other way. The only bare numbers allowed
 * are `0` and the one-pixel hairline a border is.
 *
 * The radio inputs stay real and stay focusable in all three modes. In
 * icon mode the input is laid over its own chip at zero opacity rather
 * than removed from the layout, because a control that is not rendered
 * is not focusable — and the browser's own arrow-key behaviour inside a
 * named radio group is the whole of this component's keyboard law. No
 * script re-implements it.
 */

/* THE GROUP CARRIES ITS OWN AIR AND ITS OWN WIDTH, because a page that
 * has to remember to give it either will one day not.
 *
 * The air above is `--rhythm-heading`: the legend IS the group's
 * heading, and page design law 1 gives a heading the air that separates
 * one group of things from another. The first build had none, and the
 * bench showed what that costs — the line explaining the chosen answer
 * stood as close to the NEXT group's heading as to the controls it
 * belongs to, which is the proximity defect the rhythm tokens exist to
 * prevent, arriving through a component instead of through a page.
 *
 * The width is `--measure`: a choice group left to fill its container
 * spread three cards across a 1280 px window, each of them a third of
 * the screen wide with four words in it. A control is read at the same
 * measure as a sentence. */
.kit-choice {
  border: 0;
  margin: var(--rhythm-heading) 0 0;
  padding: 0;
  max-width: var(--measure);
}

.kit-choice-legend {
  padding: 0;
  font-weight: 650;
}

.kit-choice-options {
  display: grid;
  gap: var(--s3);
  margin-top: var(--rhythm-within);
}

/* A group whose legend is hidden belongs to the heading or label above
 * it: the distance of what belongs, and no room for a legend that is
 * not drawn (C.58j: the settings popup's view set stood 48 px under its
 * own section heading). */
.kit-choice.kit-choice-unheaded {
  margin-top: var(--rhythm-within);
}

.kit-choice-unheaded .kit-choice-options {
  margin-top: 0;
}

/* -- cards --------------------------------------------------------- */

.kit-choice-card .kit-choice-options {
  grid-template-columns: repeat(auto-fit, minmax(var(--kit-card-min), 1fr));
}

.kit-choice-card .kit-choice-option {
  display: flex;
  align-items: flex-start;
  gap: var(--gap-icon-label);
  padding: var(--s3);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  min-height: var(--tap);
}

/* The chosen state is stated twice on purpose. `:has(input:checked)` is
 * what a reader with no script sees, and it is true the moment the dot
 * moves; `.is-chosen` is what kit/choice.js maintains, for a browser
 * that does not know `:has` yet. Neither can be dropped: the first keeps
 * the component honest without a script, the second keeps it honest
 * without a modern selector engine. */
.kit-choice-card .kit-choice-option:has(input:checked),
.kit-choice-card .kit-choice-option.is-chosen,
.kit-choice-inline .kit-choice-option:has(input:checked),
.kit-choice-inline .kit-choice-option.is-chosen {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* THE RING IS THE SITE'S RING, not one of the kit's own. abbundo.css's
 * `:focus-visible` rule paints a 3px outline at a 2px offset on every
 * focusable thing on this site; a card and a chip take exactly that, so
 * a keyboard reader meets one ring everywhere. The kit-tokens gate reads
 * those two numbers out of that rule and refuses any other value here,
 * which is why they are typed rather than tokenised: the source of truth
 * is the rule, and the gate follows it. */
.kit-choice-card .kit-choice-option:has(input:focus-visible),
.kit-choice-inline .kit-choice-option:has(input:focus-visible) {
  outline: var(--focus-ring-width) solid var(--accent);
  outline-offset: var(--focus-ring-offset);
}

/* -- inline -------------------------------------------------------- */

.kit-choice-inline .kit-choice-options {
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  justify-content: start;
}

.kit-choice-inline .kit-choice-option {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-icon-label);
  padding: var(--s2) var(--s3);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  cursor: pointer;
  min-height: var(--tap);
}

/* 35rem is 560 px: page design law 2's one width, where a group's grid
 * drops from two columns to one. It is the only breakpoint the kit
 * states, in any of its four stylesheets, and the kit-tokens gate holds
 * that — a media query cannot read a custom property, so the one number
 * CSS cannot tokenise is kept to one number. */
@media (max-width: 35rem) {
  .kit-choice-inline .kit-choice-options {
    grid-auto-flow: row;
    grid-auto-columns: auto;
  }
}

/* -- segments (card redesign 01.11.2026, CARD_REDESIGN D2, CR10) ---- */

/* A SEGMENTED CHOICE: the answers stand side by side in ONE track, the
 * chosen one filled, no radio dot. Each answer draws a hairline on its
 * leading side and its top; the track clips the lines of the first column
 * and the first row away under its own border, so the dividers stand only
 * between answers that are shown, in one row or in two. The answers lie in one
 * row while their words fit the track's room, else two to a row
 * (kit/choice.js measures it and writes `data-kit-segment-rows`); a word
 * never wraps inside its answer. The dot stays a real radio under its
 * answer at zero opacity, so the arrows move the choice as the browser
 * moves it, and the keyboard ring is drawn round the whole track. */
.kit-choice-segment .kit-choice-options {
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  justify-content: start;
  gap: 0;
  border: var(--hairline) solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: max-content;
  max-width: 100%;
}

.kit-choice-segment[data-kit-segment-rows="2"] .kit-choice-options {
  grid-auto-flow: row;
  grid-template-columns: 1fr 1fr;
  width: auto;
}

.kit-choice-segment .kit-choice-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--s3);
  min-height: var(--tap);
  white-space: nowrap;
  background: transparent;
  box-shadow: calc(-1 * var(--hairline)) 0 0 var(--line-strong),
    0 calc(-1 * var(--hairline)) 0 var(--line-strong);
  cursor: pointer;
}

.kit-choice-segment .kit-choice-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.kit-choice-segment .kit-choice-option:has(input:checked),
.kit-choice-segment .kit-choice-option.is-chosen {
  background: var(--accent-soft);
  color: var(--accent);
}

.kit-choice-segment .kit-choice-options:has(input:focus-visible) {
  outline: var(--focus-ring-width) solid var(--accent);
  outline-offset: var(--focus-ring-offset);
}

/* An option's picture beside its word (owner 13.11.2026, the panel with
 * its grain on „Maserung längs / quer"): the kit's icon in the word's own
 * colour, so it follows the theme and the chosen state with the word. */
.kit-choice-label-pic {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
}

.kit-choice-pic {
  flex: none;
}

/* -- icon chips ---------------------------------------------------- */

.kit-choice-icon .kit-choice-options {
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  justify-content: start;
  gap: 0;
  border: var(--hairline) solid var(--line-strong);
  border-radius: var(--radius-sm);
  width: max-content;
}

/* The chips are joined into one control, so the run's outer corners are
 * rounded and its inner ones are not. Done on the chips rather than by
 * clipping the row, because a clipped row would cut the focus ring off
 * the first and the last chip — the very two a keyboard reader reaches
 * first. */
.kit-choice-icon .kit-choice-option:first-child .kit-choice-chip {
  border-start-start-radius: var(--radius-sm);
  border-end-start-radius: var(--radius-sm);
}

.kit-choice-icon .kit-choice-option:last-child .kit-choice-chip {
  border-start-end-radius: var(--radius-sm);
  border-end-end-radius: var(--radius-sm);
}

.kit-choice-icon .kit-choice-option {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.kit-choice-icon .kit-choice-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.kit-choice-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  background: var(--panel);
  color: var(--ink-soft);
}

.kit-choice-icon .kit-choice-option:has(input:checked) .kit-choice-chip,
.kit-choice-icon .kit-choice-option.is-chosen .kit-choice-chip {
  background: var(--accent-soft);
  color: var(--accent);
}

/* The input lies over its chip at zero opacity, so the ring the browser
 * would draw on it is invisible. It is drawn on the chip instead, with
 * the site's own two numbers. */
.kit-choice-icon .kit-choice-option input:focus-visible ~ .kit-choice-chip {
  outline: var(--focus-ring-width) solid var(--accent);
  outline-offset: var(--focus-ring-offset);
}

/* The glyph is drawn out of the chip's own colour, so a chip needs no
 * picture file and inherits the theme with everything else. Three bars
 * whose widths say where the text sits. */
.kit-choice-glyph {
  display: block;
  width: var(--s5);
  height: var(--s3);
  background:
    linear-gradient(currentcolor, currentcolor) no-repeat,
    linear-gradient(currentcolor, currentcolor) no-repeat,
    linear-gradient(currentcolor, currentcolor) no-repeat;
  background-size: 100% var(--hairline), 60% var(--hairline),
    100% var(--hairline);
  background-position: left top, left center, left bottom;
}

.kit-choice-glyph.kit-glyph-center,
.kit-choice-glyph.kit-glyph-centre {
  background-position: center top, center center, center bottom;
}

.kit-choice-glyph.kit-glyph-right {
  background-position: right top, right center, right bottom;
}

/* -- the one line, about the chosen value -------------------------- */

.kit-choice-help:empty {
  display: none;
}

/* -- an answer's own words (C.58j) --------------------------------- */

/* A card whose answer carries words of its own - the declaration the
 * prepare form's first answer gives - stands its label over them, both
 * beside the dot; the words are read before the answer is chosen. */
.kit-choice-text {
  display: flex;
  flex-direction: column;
  gap: var(--gap-icon-label);
  min-width: 0;
}

.kit-choice-detail {
  color: var(--ink-soft);
  font-size: var(--fs-small);
}
