import { css } from 'lit';
import componentStyles from '../../styles/component.styles.mjs';

const styles = css`
  ${componentStyles}

  :host {
    display: inline-block;
    --radio-color: var(--flow-ui-checkbox-color, var(--flow-ui-color-primary-500));
  }

  :host(:focus-visible) {
    outline: 0px;
  }

  .radio {
    width: 100%;
    display: inline-flex;
    align-items: top;
    font-family: var(--flow-ui-control-font-family);
    font-size: var(--flow-ui-control-font-size-medium);
    font-weight: var(--flow-ui-control-font-weight);
    color: var(--flow-ui-control-label-color);
    vertical-align: middle;
    cursor: pointer;
  }

  /* Alternative 'reverse' style */
  .radio--reverse {
    flex-direction: row-reverse;
  }

  .radio--reverse .radio__label {
    margin-left: 0;
    margin-right: 0.5em;
  }

  .radio--small {
    --toggle-size: var(--flow-ui-toggle-size-small);
    font-size: var(--flow-ui-control-font-size-small);
  }

  .radio--medium {
    --toggle-size: var(--flow-ui-toggle-size-medium);
    font-size: var(--flow-ui-control-font-size-medium);
  }

  .radio--large {
    --toggle-size: var(--flow-ui-toggle-size-large);
    font-size: var(--flow-ui-control-font-size-large);
  }

  .radio__checked-icon {
    display: inline-flex;
    width: var(--toggle-size);
    height: var(--toggle-size);
  }

  .radio__control {
    flex: 0 0 auto;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--toggle-size);
    height: var(--toggle-size);
    border: solid var(--flow-ui-control-border-width) var(--flow-ui-control-border-color);
    border-radius: 50%;
    background-color: var(--flow-ui-control-background-color);
    color: transparent;
    transition:
      var(--flow-ui-transition-fast) border-color,
      var(--flow-ui-transition-fast) background-color,
      var(--flow-ui-transition-fast) color,
      var(--flow-ui-transition-fast) box-shadow;
  }

  .radio__input {
    position: absolute;
    opacity: 0;
    padding: 0;
    margin: 0;
    pointer-events: none;
  }

  /* Checked */
  .radio--checked .radio__control {
    color: var(--flow-ui-color-background);
    border-color: var(--radio-color);
    background-color: var(--radio-color);
  }

  /* Checked + focus */
  :host(:focus-visible) .radio__control {
    outline: var(--flow-ui-focus-ring);
    outline-offset: var(--flow-ui-focus-ring-offset);
  }

  /* Disabled */
  .radio--disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  /* When the control isn't checked, hide the circle for Windows High Contrast mode a11y */
  .radio:not(.radio--checked) svg circle {
    opacity: 0;
  }

  .radio__label {
    flex: 1;
    display: inline-block;
    color: var(--flow-ui-control-label-color);
    line-height: var(--toggle-size);
    margin-inline-start: 0.5em;
    user-select: none;
  }
`;

export { styles as default };
