.button {
    position: relative;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    border-radius: var(--border-radius-xs);
    background: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    transition:
        background-color 0.3s ease,
        opacity 0.3s ease,
        color 0.3s ease;
    border: var(--border-width-sm) solid transparent;
    font-family: var(--font-decorative), monospace;
    text-transform: uppercase;
    font-weight: var(--font-weight-regular);
    line-height: var(--line-height-xs);
    --spinner-color: var(--color-text-primary);
}

.button:hover {
    opacity: 0.85;
}

.primary,
.primary:hover,
.primary:focus,
.primary:active,
.primary:visited {
    background-color: var(--color-bg-fill-primary);
    color: var(--color-text-primary-inverted);
    --spinner-color: var(--color-text-primary-inverted);
}

.primary-invert,
.primary-invert:hover,
.primary-invert:focus,
.primary-invert:active,
.primary-invert:visited {
    background-color: var(--color-bg-fill-brand-inverse);
    color: var(--color-text-primary);
    --spinner-color: var(--color-text-primary);
}

.secondary,
.secondary:hover,
.secondary:focus,
.secondary:active,
.secondary:visited {
    background-color: var(--color-bg-fill-brand-solar);
    color: var(--color-text-primary);
    --spinner-color: var(--color-text-primary);
}

.tertiary,
.tertiary:hover,
.tertiary:focus,
.tertiary:active,
.tertiary:visited {
    background-color: var(--color-bg-fill-brand-indigo);
    color: var(--color-text-primary);
    --spinner-color: var(--color-text-primary);
}

.muted,
.muted:focus,
.muted:active,
.muted:visited {
    background-color: transparent;
    color: var(--color-text-primary);
    border-color: var(--border-color-alpha-black-20);
    --spinner-color: var(--color-text-primary);
}

.muted.muted:hover {
    background-color: var(--color-bg-fill-primary);
    border-color: var(--color-bg-fill-primary);
    color: var(--color-text-primary-inverted);
    --spinner-color: var(--color-text-primary-inverted);
}

.muted-invert,
.muted-invert:focus,
.muted-invert:active,
.muted-invert:visited {
    background-color: transparent;
    color: var(--color-text-primary-inverted);
    border-color: var(--border-color-invert);
    --spinner-color: var(--color-text-primary-inverted);
}

.muted-invert.muted-invert:hover {
    background-color: var(--color-bg-fill-brand-inverse);
    border-color: var(--border-color-invert);
    color: var(--color-text-primary);
    --spinner-color: var(--color-text-primary);
}

.ghost,
.ghost:hover,
.ghost:focus,
.ghost:active,
.ghost:visited {
    background-color: transparent;
    color: var(--color-text-primary);
    --spinner-color: var(--color-text-primary);
}

.xs {
    min-width: 40px;
    min-height: 32px;
    padding: 0 var(--spacing-12);
    border-radius: var(--border-radius-xxs);
    font-size: var(--font-size-xxs);
    letter-spacing: var(--letter-spacing-xxl);
}

.sm {
    min-width: 40px;
    min-height: 40px;
    padding: 0 var(--spacing-16);
    border-radius: var(--border-radius-xxs);
    font-size: var(--font-size-xs);
    letter-spacing: var(--letter-spacing-xxl);
}

.md {
    min-width: 48px;
    min-height: 48px;
    padding: 0 var(--spacing-16);
    font-size: var(--font-size-sm);
    letter-spacing: var(--letter-spacing-xxl);
}

.lg {
    min-width: 56px;
    min-height: 56px;
    padding: 0 var(--spacing-20);
    font-size: var(--font-size-sm);
    letter-spacing: var(--letter-spacing-xxl);
}

.disabled:hover,
.disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.button,
.button:focus,
.button:active,
.button:hover {
    text-decoration: none;
}

.content {
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    flex-wrap: nowrap;
    gap: var(--spacing-8);
    z-index: 1;
}

.xs .content,
.sm .content {
    gap: var(--spacing-4);
}

.iconWrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    min-width: 20px;
    max-width: 20px;
    height: 20px;
    max-height: 20px;
    overflow: hidden;

    & > * {
        width: 100%;
        height: 100%;
    }
}

.xs .iconWrap {
    width: 14px;
    min-width: 14px;
    max-width: 14px;
    height: 14px;
    max-height: 14px;
}

.sm .iconWrap {
    width: 16px;
    min-width: 16px;
    max-width: 16px;
    height: 16px;
    max-height: 16px;
}

.button[data-loading='true'] {
    &, &:disabled, &:focus {
        color: transparent;
        pointer-events: none;
        cursor: default;
    }

    &:after {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        display: block;
        width: 1.5em;
        height: 1.5em;
        border-radius: 50%;
        border: var(--border-width-md) solid var(--spinner-color);
        border-bottom-color: transparent;
        opacity: 0.6;
        animation: button-loading-spinner 1s ease infinite;
        margin: auto;
    }
}

@keyframes button-loading-spinner {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}
