@use 'design-system' as *;

.cta {
    position: relative;
    display: inline-block;
}

a.cta,
.cta a,
.cta button {
    display: flex;
    justify-content: center;
    align-items: center;
    width: $spacing-size-10;
    height: $spacing-size-10;
    border-radius: var(--radius-sm);
    transition:
        color $transition-default-timing,
        background-color $transition-default-timing;
    cursor: pointer;

    &:hover {
        background-color: var(--color-util-brand-100);
    }

    &:focus-visible {
        outline: none;
        box-shadow:
            0 0 0 $spacing-size-1 var(--color-button-primary-shadow-focus),
            var(--shadow-xs);
    }

    svg {
        --icon-size: 1.25em;

        fill: var(--color-link);
        transform: translate(1px, 0.75px);
        transition: fill $transition-default-timing;
    }

    li:first-child & svg {
        --icon-size: 1.35em;
    }

    #{$selector-darkmode} & {
        &:hover {
            background-color: var(--color-util-brand-50);
        }
    }
}

// Hide button (CodeSandbox & Plunker) CTA items for Mobile Safari only
@supports (-webkit-touch-callout: none) {
    .cta button {
        display: none;
    }
}

.tooltip {
    --tooltip-background: var(--color-fg-primary);

    position: absolute;
    display: block;
    color: var(--color-bg-primary);
    top: -44px;
    left: 50%;
    padding: $spacing-size-1 $spacing-size-4;
    white-space: nowrap;
    font-weight: 600;
    background-color: var(--tooltip-background);
    border-radius: 6px;
    transform: translate(-50%, $spacing-size-1);
    opacity: 0;
    pointer-events: none;
    transition-delay: 0;
    transition:
        opacity 0.165s ease-in,
        transform 0.165s ease-in;
    z-index: 1;

    &::before {
        $pointer-size: 8px;

        content: '';
        position: absolute;
        background-color: var(--tooltip-background);
        width: $pointer-size * 2;
        height: $pointer-size * 2;
        transform: rotate(45deg);
        bottom: -7px;
        left: calc(50% - $pointer-size);
        border-radius: 3px;
        z-index: -1;
    }

    .cta:hover & {
        opacity: 1;
        transform: translate(-50%, 0);
        transition:
            opacity 0.33s ease-in,
            transform 0.33s ease-in;
        transition-delay: 0.165s;
    }

    #{$selector-darkmode} & {
        --tooltip-background: var(--color-bg-secondary);

        color: var(--color-fg-primary);
        box-shadow: 0 -4px 16px 0 rgba(0, 0, 0, 0.4);
    }
}
