/* Answer controls: stars, choice chips, the 1 to 10 bar, text fields and buttons.
   Every control is a native radio or field; the styling reads its state with :has(). */

/* Stars */

.stars {
  --star-size: 1.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-s);
  /* Line the first star up with the text above it, not with its tap area. */
  margin-inline-start: calc((var(--star-size) - max(var(--tap-size), var(--star-size) + 0.5rem)) / 2);
}

.stars-row { display: flex; }

.star {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  inline-size: max(var(--tap-size), var(--star-size) + 0.5rem);
  block-size: max(var(--tap-size), var(--star-size) + 0.5rem);
  border-radius: 50%;
  cursor: pointer;
}

.star svg {
  inline-size: var(--star-size);
  block-size: var(--star-size);
  fill: transparent;
  stroke: var(--line-strong);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

/* The chosen star and every star before it. :where() keeps the weight low so hover can win. */
.star:where(:has(:checked), :has(~ .star :checked)) svg {
  fill: var(--star);
  stroke: var(--star-edge);
}

.star:has(:focus-visible) {
  outline: 2px solid var(--forest);
  outline-offset: -2px;
}

.star:active svg { transform: scale(0.92); }

@media (hover: hover) and (pointer: fine) {
  .stars-row:hover .star svg {
    fill: color-mix(in oklch, var(--star) 55%, white);
    stroke: var(--star-edge);
  }

  .stars-row .star:hover ~ .star svg {
    fill: transparent;
    stroke: var(--line-strong);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .star svg { transition: transform 140ms var(--ease-out); }
}

.stars-readout {
  min-inline-size: 10ch;
  font-weight: 600;
  color: var(--forest);
}

.question-lead .stars {
  --star-size: clamp(2.25rem, 1.5rem + 4vw, 3.25rem);
  flex-direction: column;
  gap: var(--space-xs);
  margin-inline-start: 0;
}

.question-lead .stars-readout {
  min-block-size: 1lh;
  font-size: var(--step-1);
  text-align: center;
}

.question-lead .stars-readout:empty::before {
  content: "1 ster is slecht, 5 sterren is uitstekend";
  font-size: var(--step--1);
  font-weight: 400;
  color: var(--ink-soft);
}

/* A question split into parts: label on one side, stars on the other, wrapping when tight. */

.question-body:has(.part) {
  display: flex;
  flex-direction: column;
}

.part {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 var(--space-s);
  padding-block: var(--space-xs);
}

.part + .part { border-block-start: 1px solid var(--line); }

.part-label {
  flex: 1 1 8rem;
  font-weight: 500;
}

.part .stars-readout { display: none; }

/* Choice chips */

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.chip {
  position: relative;
  cursor: pointer;
}

.chip-label {
  display: flex;
  align-items: center;
  min-block-size: var(--tap-size);
  padding-inline: 1.1em;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.chip:has(:checked) .chip-label {
  border-color: var(--forest);
  background: var(--forest);
  color: var(--on-dark);
}

.chip:has(:focus-visible) .chip-label {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

.chip:active .chip-label { transform: scale(0.97); }

.choice-other { margin-block-start: var(--space-s); }

/* The 1 to 10 bar */

.scale {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: clip;
}

.scale-step {
  position: relative;
  display: grid;
  place-items: center;
  min-block-size: 3rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.scale-step + .scale-step { border-inline-start: 1px solid var(--line); }

.scale-step:where(:has(:checked), :has(~ .scale-step :checked)) {
  border-color: color-mix(in oklch, var(--forest), white 20%);
  background: var(--forest);
  color: var(--on-dark);
}

.scale-step:has(:focus-visible) {
  outline: 2px solid var(--mint);
  outline-offset: -4px;
}

.scale-step:active { background: var(--forest-soft); }

.scale-ends {
  display: flex;
  justify-content: space-between;
  gap: var(--space-s);
  margin-block-start: var(--space-xs);
  font-size: var(--step--1);
  color: var(--ink-soft);
}

/* As the first question the bar takes the full width of the card, with taller steps. */

.question-lead .question-body:has(.scale) { align-self: stretch; }

.question-lead .scale-step {
  min-block-size: 3.5rem;
  font-size: var(--step-1);
}

@media (hover: hover) and (pointer: fine) {
  .chip:hover:not(:has(:checked)) .chip-label,
  .scale-step:hover:not(:has(:checked), :has(~ .scale-step :checked)) { background: var(--forest-soft); }
}

@media (prefers-reduced-motion: no-preference) {
  .chip-label {
    transition:
      background-color 140ms var(--ease-out),
      color 140ms var(--ease-out),
      transform 140ms var(--ease-out);
  }
}

/* Text fields */

.textarea,
.text-input {
  display: block;
  inline-size: 100%;
  padding: 0.7em 0.9em;
  border: 1.5px solid var(--line-strong);
  border-radius: calc(var(--radius) - 0.25rem);
  background: var(--surface);
}

.textarea {
  field-sizing: content;
  min-height: 3lh;
  max-height: 12lh;
  resize: none;
  text-wrap: stable;
}

.textarea:focus-visible,
.text-input:focus-visible {
  border-color: var(--forest);
  outline: 2px solid var(--forest);
  outline-offset: 0;
}

/* Buttons */

.button {
  inline-size: min(100%, 20rem);
  padding: 0.85em 2em;
  border: 0;
  border-radius: var(--radius-pill);
  font-size: max(1.2rem, var(--step-1));
  font-weight: 700;
  background: var(--brand);
  color: var(--on-brand);
  cursor: pointer;
  transition: background-color 160ms var(--ease-out);
}

a.button {
  display: inline-block;
  text-decoration: none;
}

.button-follow {
  inline-size: auto;
  font-size: calc(1.1 * var(--step-0));
}

.button-secondary {
  inline-size: auto;
  padding-inline: 1.5em;
  font-size: var(--step-0);
  box-shadow: inset 0 0 0 2px var(--brand);
  background: transparent;
  color: var(--ink);
}

.button-icon {
  display: inline-grid;
  place-items: center;
  inline-size: 3rem;
  block-size: 3rem;
  padding: 0;
  box-shadow: inset 0 0 0 2px var(--brand);
  background: transparent;
  color: var(--ink);
}

a.button-icon { display: inline-grid; }

.button-icon svg {
  inline-size: 1.5rem;
  block-size: 1.5rem;
}

.button:focus-visible { outline-color: var(--brand); }

.button:active {
  background: var(--brand-pressed);
  transform: scale(0.97);
}

.link-button {
  padding: 0;
  border: 0;
  font-weight: 600;
  text-decoration: underline;
  background: none;
  cursor: pointer;
}

.link-button:active { opacity: 0.7; }

@media (hover: hover) and (pointer: fine) {
  .button:hover { background: var(--brand-pressed); }
  .button-secondary:hover,
  .button-icon:hover { background: color-mix(in oklch, var(--brand) 14%, transparent); }
}

@media (prefers-reduced-motion: no-preference) {
  .button {
    transition:
      background-color 160ms var(--ease-out),
      transform 160ms var(--ease-out);
  }
}
