/*
 * ACCESSIBILITY SETTINGS (header, see AccessibilitySettings.js)
 * Panel (disclosure, a <div> with the hidden attribute, see Components/Disclosure.js) of the accessibility button with the contrast mode and the font size (100%, 150%, 200%).
 *
 * Opens like the program filter (see ProgramFilter.css): anchored to the top right corner of the button (the button
 * sits in the panel's padding corner, above it) and unfolds from there to the left and downwards. The button is
 * filled while the panel is open.
 *
 * Mobile (header below 48rem) the panel reaches to the right page padding and covers the hamburger button right of
 * the accessibility button, so it can use the full width at large font sizes. From 48rem on it is anchored to the
 * button like the filter, there is enough space left of it.
 *
 * Colors follow --color--primary/--color--secondary like the header, so the panel is inverted in the contrast mode.
 * The height is limited to the viewport (scrollable), so the panel stays usable at 200% font size and zoom.
 */

#navigation__service--accessibility {
    position: relative;
}

/* Above the hamburger button (z-index 1) only while open, otherwise the open hamburger navigation covers it */
#navigation__service--accessibility > button[aria-expanded="true"] {
    z-index: 3;
    background-color: var(--header--text);
    color: var(--color--primary);
}

#navigation__accessibility__menu {
    /* Space right of the button up to the page padding: the hamburger button (mobile) */
    --panel--offset  : calc(var(--target) + var(--layout--gap--small));
    /* Padding limited on narrow headers, it would take too much space from the text at large font sizes */
    --panel--padding : min(var(--space--s), 4cqi);
    --panel--border  : var(--border-width--default);
    /* At most the page width, the panel reaches as far into the page padding on the left as on the right */
    --panel--width   : min(30rem, calc(100cqi - 2 * var(--page-pad) + var(--panel--padding) + 2 * var(--panel--border)));
    --panel--radius  : var(--border-radius--default);
    --panel--duration: .3s;

    /* Collapsed into the top right corner */
    --panel--clip--closed: inset(0 0 100% 100% round var(--panel--radius));
    --panel--clip--open  : inset(0 round var(--panel--radius));

    position: absolute;
    inset: auto;
    top  : calc(0px - var(--panel--padding) / 2 - var(--panel--border));
    right: calc(0px - var(--panel--padding) / 2 - var(--panel--border) - var(--panel--offset));
    margin: 0;

    width: var(--panel--width);
    max-height: calc(100dvh - var(--header-height));
    overflow-y: auto;
    overscroll-behavior: contain;

    background: var(--color--primary);
    color: var(--color--secondary);

    border: var(--panel--border) solid var(--color--secondary);
    border-radius: var(--panel--radius);
    padding: var(--panel--padding);

    font-size: var(--font-size--text-large);
    line-height: var(--line-height--text);
    hyphens: auto;
    overflow-wrap: break-word;

    z-index: 2;

    display: block;
    clip-path: var(--panel--clip--closed);
    transition:
        clip-path var(--panel--duration) ease-in-out,
        display   var(--panel--duration) allow-discrete;
}

/* Closed: display none after the transition, the author display above overrides the UA rule */
#navigation__accessibility__menu[hidden] {
    display: none;
}

#navigation__accessibility__menu:not([hidden]) {
    clip-path: var(--panel--clip--open);
}

@starting-style {
    #navigation__accessibility__menu:not([hidden]) {
        clip-path: var(--panel--clip--closed);
    }
}

@media (prefers-reduced-motion: reduce) {
    #navigation__accessibility__menu {
        transition: none;
    }
}

@container header (min-width: 48rem) {
    #navigation__accessibility__menu {
        --panel--offset: 0px;
    }
}


.accessibility__form {
    container: accessibility / inline-size;
}

/* Title next to the button, it keeps the space of the button (and of the covered hamburger button) free */
.accessibility__title {
    min-height: var(--target);
    padding-right: calc(var(--target) + var(--panel--offset) + var(--layout--gap--default));
    font-family: var(--font-family--headline);
    font-size: var(--font-size--h3);
    line-height: var(--line-height--sub-headline);
}

/* Narrow panel (large font sizes on phones): title below the button, next to it there is too little space */
@container accessibility (max-width: 20rem) {
    .accessibility__title {
        padding-top: calc(var(--target) + var(--layout--gap--small));
        padding-right: 0;
    }
}

.accessibility__options {
    display: flex;
    flex-direction: column;
    gap: var(--layout--gap--large);
    margin-top: var(--layout--gap--default);
}

.accessibility__options fieldset {
    display: flex;
    flex-wrap: wrap;
    column-gap: var(--layout--gap--large);
    border: unset;
}

/* The rendered legend doesn't take part in the flex layout of the fieldset, it stays above the options */
.accessibility__options legend {
    font-weight: var(--font-weight--bold);
    font-size: var(--font-size--badge);
}


/*
 * Options: radio as circle in front of the label (like the program filter), filled when checked. The native radio
 * lies invisible above the circle, so it stays focusable, clickable and is announced by screen readers.
 */
.accessibility__option {
    --option--size: calc(var(--target) / 2);

    position: relative;
    display: flex;
    align-items: center;
    min-height: var(--target);
}

.accessibility__option input {
    position: absolute;
    left: 0;
    width: var(--option--size);
    height: var(--option--size);
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.accessibility__option label {
    display: flex;
    align-items: center;
    gap: var(--space--xs);
    cursor: pointer;
}

.accessibility__option label::before {
    content: "";
    flex-shrink: 0;
    width: var(--option--size);
    height: var(--option--size);
    border: var(--border-width--default) solid currentColor;
    border-radius: var(--border-radius--round);
}

.accessibility__option input:checked + label::before {
    background-color: currentColor;
    box-shadow: inset 0 0 0 .1875rem var(--color--primary);
}

.accessibility__option input:focus-visible + label::before {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.accessibility__option label:hover {
    text-decoration: underline;
    text-decoration-thickness: var(--text-decoration-thickness--regular);
    text-underline-offset: .15em;
}

/* Backgrounds are replaced in forced colors mode, keep the checked circle filled in the highlight color */
@media (forced-colors: active) {
    .accessibility__option input:checked + label::before {
        forced-color-adjust: none;
        border-color: Highlight;
        background-color: Highlight;
        box-shadow: inset 0 0 0 .1875rem Canvas;
    }
}


.accessibility__footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--layout--gap--default);

    margin-top: var(--layout--gap--large);
    padding-top: var(--layout--gap--large);
    border-top: 1px solid var(--color--secondary);
}
