/* -- Survey Question (website · Account & States) -------------------------
   Presents one question with its response controls - a single choice as cards, several choices, an agreement scale, or a written answer. */

@layer components {
  /* every box in the block measures border-box - the same on any page */
  :where(.mk-survey-question, .mk-survey-question *, .mk-survey-question ::before, .mk-survey-question ::after) {
    box-sizing: border-box;
  }

  .mk-survey-question {
    display: grid;
    gap: 1.25rem;
    width: 100%;
    max-width: 36rem;
    padding: 1.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--card);
    color: var(--card-foreground);
    & fieldset {
      display: grid;
      gap: 0.625rem;
      margin: 0;
      padding: 0;
      border: 0;
      min-width: 0;
    }
    & legend {
      margin-block-end: 0.375rem;
      padding: 0;
      font-size: 1.25rem;
      font-weight: 600;
      letter-spacing: -0.01em;
      text-wrap: balance;
    }
  }
  .mk-survey-question-meta {
    display: grid;
    gap: 0.5rem;
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    font-weight: 500;
    & progress {
      width: 100%;
      height: 0.375rem;
    }
  }
  .mk-survey-question-hint {
    margin: 0 0 0.375rem;
    color: var(--muted-foreground);
    font-size: 0.875rem;
  }
  .mk-survey-question-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    cursor: pointer;

    & input {
      flex: none;
      accent-color: var(--primary);
    }
    &:hover {
      border-color: color-mix(in oklch, var(--foreground) 30%, var(--border));
    }
    &:has(:checked) {
      border-color: var(--primary);
      background: color-mix(in oklch, var(--primary) 6%, transparent);
    }
  }
  .mk-survey-question-actions {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .mk-survey-question[data-variant="scale"] {
    & .mk-survey-question-scale {
      display: grid;
      grid-template-columns: repeat(5, minmax(0, 1fr));
      gap: 0.375rem;
    }
    & .mk-survey-question-option {
      flex-direction: column;
      justify-content: center;
      gap: 0.375rem;
      padding: 0.75rem 0.25rem;
      font-size: 0.75rem;
      line-height: 1.25;
      text-align: center;
    }
  }
  .mk-survey-question[data-variant="text"] .textarea {
    min-height: 6rem;
  }

  /* -- Accessibility ------------------------------------------- */
  @media (forced-colors: active) {
    .mk-survey-question-option:has(:checked) {
      border-color: Highlight;
    }
  }
}
