// 1. Reset button styles for individual link variants.
// 2. Generate link colors for all link states.
// 3. Links in headings always have the default decoration, even those with `.link-underlined`.
// 4. Allow link underline everywhere, except for headings in default state.
// 5. Allow link to obtain the visited state style
// 6. Disable pointer and text decoration changes for "disabled" links (intended for link-like `<button>` elements).
// 7. Allow link stretching over the closest element with `position: relative`.
// 8. Disable link underline everywhere.

@use 'sass:map';
@use '@tokens' as tokens;
@use '../../settings/cursors';
@use '../../settings/dictionaries' as dictionaries-settings;
@use '../../settings/links' as links-settings;
@use '../../tools/dictionaries';
@use '../../tools/links' as links-tools;

// 1.
@include dictionaries.prepare-button-links(links-settings.$colors);

// 2.
@include dictionaries.generate-link-colors($selector: '.link', $dictionary-values: links-settings.$colors);

// 3.
[class*='typography-heading'] a {
    text-decoration: links-settings.$text-decoration-default;
}

// 4.
.link-underlined,
[class*='typography-heading'] a:hover,
[class*='typography-heading'] a:active {
    text-decoration: links-settings.$text-decoration-hover;
}

// 5.
.link-allow-visited-style:visited {
    color: tokens.$link-state-visited;
}

// 6.
// stylelint-disable selector-no-qualifying-type -- Increase specificity to override button variant styles.
:is(.link-disabled, button.link-disabled),
:is(.link-disabled, button.link-disabled):is(:hover, :focus, :active, :visited) {
    color: tokens.$disabled-content;
    cursor: cursors.$disabled;
}

// 6.
:is(.link-disabled, button.link-disabled):not(.link-underlined) {
    text-decoration: links-settings.$text-decoration-default;
}
// stylelint-enable selector-no-qualifying-type

// 7.
.link-stretched {
    @include links-tools.stretch();
}

// 8.
// stylelint-disable selector-no-qualifying-type -- Increase specificity to override button variant styles.
:is(.link-not-underlined, button.link-not-underlined),
:is(.link-not-underlined, button.link-not-underlined):is(:hover, :focus, :active) {
    text-decoration: links-settings.$text-decoration-default;
}
// stylelint-enable selector-no-qualifying-type
