@use 'libs/components/theme/src/lib/styles/variables' as *;
@use 'libs/components/theme/src/lib/styles/compat-tokens-mixins' as compatMixins;

@include compatMixins.sky-default-overrides('.sky-radio-group') {
  --sky-override-radio-group-content-space: #{$sky-space-sm};
  --sky-override-radio-group-content-with-hint-text-space: #{$sky-space-md};
  --sky-override-radio-group-hint-text-space: #{$sky-space-xs};

  .sky-radio-group-legend {
    .sky-radio-group-heading-text {
      line-height: 1.1;
    }
  }
}

@include compatMixins.sky-modern-overrides('.sky-radio-group') {
  .sky-radio-group-legend {
    .sky-radio-group-heading-text {
      line-height: 1.1;
    }
  }
}

:host {
  &.sky-field-group-stacked,
  &.sky-form-field-stacked {
    display: block;
  }
}

.sky-radio-group-legend {
  h3,
  h4,
  h5 {
    margin: 0;
    display: inline-block;
  }
}

.sky-radio-group {
  &:has(.sky-radio-group-legend:not(.sky-screen-reader-only)) {
    &:not(:has(.sky-radio-group-hint-text)) {
      .sky-radio-group-content {
        margin-top: var(
          --sky-override-radio-group-content-space,
          var(--sky-space-gap-form-s)
        );
      }
    }

    .sky-radio-group-hint-text {
      margin-top: var(
        --sky-override-radio-group-hint-text-space,
        var(--sky-space-gap-stacked_supplemental-s)
      );
    }
  }

  &:has(.sky-radio-group-hint-text) {
    .sky-radio-group-content {
      margin-top: var(
        --sky-override-radio-group-content-with-hint-text-space,
        var(--sky-space-gap-form-l)
      );
    }
  }
}
