/*
 * SEARCH (header from 48rem on, see HeaderSearch.js, mobile the search form is part of the hamburger navigation)
 * Disclosure of the search button with the search form (pill, see .navigation__search in layout.css), a <div> with
 * the hidden attribute (see Components/Disclosure.js).
 *
 * Opens like the accessibility settings (see AccessibilitySettings.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 form is next to the button, as high as the button. The button is filled while the panel is open.
 *
 * Colors follow --color--primary/--color--secondary like the header, so the panel is inverted in the contrast mode.
 */

#navigation__service--search {
    position: relative;
}

#navigation__service--search > button[aria-expanded="true"] {
    z-index: 3;
    background-color: var(--header--text);
    color: var(--color--primary);
}

#navigation__search__menu {
    --panel--padding : var(--space--s);
    --panel--border  : var(--border-width--default);
    /*
     * At most the width left of the button within the page: right of the button are the accessibility button, the
     * language switch and the hamburger button (about 14rem incl. the gaps, in rem as they grow with the font size)
     */
    --panel--right   : 14rem;
    --panel--width   : min(36rem, calc(100cqi - 2 * var(--page-pad) - var(--panel--right)));
    --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) - var(--panel--border));
    right: calc(0px - var(--panel--padding) - var(--panel--border));
    margin: 0;

    width: var(--panel--width);
    max-width: none;

    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);
    /* Space of the button right of the form */
    padding-right: calc(var(--panel--padding) + var(--target) + var(--layout--gap--small));

    font-size: var(--font-size--text-small);

    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: hidden for all (display none after the transition), the author display above overrides the UA rule */
#navigation__search__menu[hidden] {
    display: none;
}

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

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

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

/* As high as the search button next to it (the pill's border is part of the height) */
#navigation__search__form input {
    min-height: calc(var(--target) - 4px);
}

#navigation__search__form button {
    width: calc(var(--target) - 4px);
    height: calc(var(--target) - 4px);
}
