/* A hidden screen reader texts for readers, focus elements for
   vision impaired and other useful a11y CSS hacks. */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

/* Hide on mouse focus (can't be focused via mouse when invisible) */
.screen-reader-text:focus {
    opacity: 0;
}

/* Visible on keyboard focus - critical for skip links */
.screen-reader-text:focus-visible {
    background-color: var(--color-white);
    border-radius: 4px;
    box-shadow: 0 0 2px 2px rgba(22, 22, 22, 0.6);
    clip: auto;
    clip-path: none;
    display: block;
    font-size: 1rem;
    font-weight: 600;
    height: auto;
    left: 0.5rem;
    line-height: normal;
    opacity: 1;
    padding: 1rem 1.5rem;
    text-decoration: none;
    top: 0.5rem;
    width: auto;
    z-index: 100001; /* Above everything including mobile menu */
    color: var(--color-black);
}

/* Skip link specific styling */
.skip-link:focus-visible {
    background-color: lightgray;
    color: var(--color-black);
    font-weight: 600;
}

/* Visually distinct focus color on keyboard */
a:focus,
input:focus,
button:focus,
select:focus,
textarea:focus,
div[tabindex]:focus {
    /* Make sure every focusable element has opacity 100% */
    opacity: 1;

    /* Make sure it's not glued to the element */
    outline-offset: 0.5rem;
}

/* Main content scroll offset for sticky header */
#content {
    /* Account for sticky header on mobile */
    scroll-margin-top: calc(var(--primary-menu-height) + 20px);
}

@media (min-width: 1024px) {
    #content {
        /* Account for both primary and secondary nav on desktop */
        scroll-margin-top: calc(
            var(--secondary-menu-height) + var(--primary-menu-height) + 20px
        );
    }
}

/* Text meant only for screen readers. */
.sr-only {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    /* doiuse-disable */
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    /* Many screen reader and browser combinations announce broken words as they would appear visually. */
    /* stylelint-disable-next-line declaration-no-important, max-line-length */
    word-wrap: normal !important;
}

/* Focused on mouse (it never can be focused via mouse, because it's already invisible) */
.sr-only:focus {
    opacity: 0;
}

/* Focused on keyboard */
.sr-only:focus-visible {
    background-color: var(--color-white);
    border-radius: 0;
    box-shadow: 0 0 2px 2px rgb(22 22 22 / 0.6);
    clip: auto;
    clip-path: none;
    display: block;
    font-size: 1.7rem;
    font-weight: var(--font-weight-bold);
    height: auto;
    left: 0.5rem;
    line-height: normal;
    opacity: 1;
    padding: 1.5rem 2.3rem 1.4rem;
    text-decoration: none;
    top: 0.5rem;
    width: auto;
    z-index: 100000; /* Above WP toolbar. */
}

.skip-to-content {
    margin: 0.5rem;
}

/* Visually distinct focus color on keyboard */
a:focus,
input:focus,
button:focus,
select:focus,
textarea:focus,
div[tabindex]:focus {
    /* Make sure every focusable element has opacity 100% */
    opacity: 1;

    /* Make sure it's not glued to the element */
    outline-offset: 0.5rem;
}

/* Make focus a little more engaging
     @source https://twitter.com/argyleink/status/1387072095159406596
     @link https://codepen.io/argyleink/pen/JjEzeLp */
@media (prefers-reduced-motion: no-preference) {
    *:focus {
        transition: outline-offset 0.25s ease;
    }
}

/* External link icon */
.external-link-icon {
    margin-left: 0.7rem;
    margin-right: 0.2rem;
    display: none;
}

@media (max-width: 768px) {
    /* Replaced $container-mobile with a typical mobile breakpoint */
    .external-link-icon {
        height: 1.2rem;
        margin-left: 0.4rem;
        transform: translateY(1px);
        width: 1.2rem;
    }
}
