/* Keep the flag outside the filtered page sections. */
html.rp-mourning-monochrome body > :not(.rp-condolence, script, style, link, noscript),
html.rp-mourning-monochrome body::before,
html.rp-mourning-monochrome body::after,
html.rp-mourning-monochrome :is(dialog:modal, :fullscreen),
html.rp-mourning-monochrome dialog::backdrop {
    filter: grayscale(1);
}

html.rp-mourning-monochrome body {
    background: #f7f7f7 !important;
}

html.rp-mourning-monochrome[data-theme="dark"] body:is(.light-theme, .guide-page) {
    background: #131313 !important;
}

@media (prefers-color-scheme: dark) {
    html.rp-mourning-monochrome:not([data-theme]) body {
        background: #131313 !important;
    }
}

/* The header's filter changes the containing block of its mobile backdrop. */
html.rp-mourning-monochrome .rp-header.rp-menu-is-open .rp-menu-backdrop {
    position: absolute;
    inset: 100% 0 auto;
    height: calc(100vh - var(--rp-header-height));
    height: calc(100dvh - var(--rp-header-height));
}

.rp-condolence {
    display: none;
    border-bottom: 1px solid #393939;
    background: #171717;
    color: #f5f5f5;
    font-size: .875rem;
    line-height: 1.45;
}

html.rp-mourning .rp-condolence {
    display: block;
}

.rp-condolence__inner {
    display: grid;
    grid-template-columns: auto minmax(0, auto) auto;
    grid-template-areas: "label copy toggle";
    align-items: center;
    justify-content: center;
    gap: .5rem 1rem;
    max-inline-size: 76rem;
    margin-inline: auto;
    padding: .625rem 1rem;
}

.rp-condolence__label {
    grid-area: label;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding-inline-end: 1rem;
    border-inline-end: 1px solid #666;
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.rp-condolence__flag {
    box-sizing: border-box;
    display: inline-block;
    flex: none;
    width: 1.6rem;
    aspect-ratio: 8 / 5;
    border: 1px solid #aaa;
    background: linear-gradient(to bottom, #fff 50%, #dc143c 50%);
}

.rp-condolence__copy {
    grid-area: copy;
    min-width: 0;
}

.rp-condolence__copy p {
    margin: 0;
}

.rp-condolence__copy .rp-condolence__mode {
    margin-block-start: .125rem;
    color: #cecece;
    font-size: .8125rem;
}

.rp-condolence .rp-condolence__toggle {
    grid-area: toggle;
    justify-self: end;
    min-height: 44px;
    padding: .375rem .75rem;
    border: 1px solid #a8a8a8;
    border-radius: .35rem;
    background: #242424;
    color: #fff;
    font: inherit;
    font-size: .8125rem;
    font-weight: 650;
    line-height: 1.2;
    cursor: pointer;
}

.rp-condolence .rp-condolence__toggle:hover {
    background: #3a3a3a;
}

.rp-condolence .rp-condolence__toggle:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

html.rp-mourning-monochrome .rp-condolence [data-rp-color],
html:not(.rp-mourning-monochrome) .rp-condolence [data-rp-mono] {
    display: none;
}

@media (max-width: 740px) {
    .rp-condolence__inner {
        grid-template-columns: minmax(0, 1fr) minmax(0, auto);
        grid-template-areas: "label toggle" "copy copy";
        gap: .5rem .75rem;
    }

    .rp-condolence__label {
        padding-inline-end: 0;
        border-inline-end: 0;
    }
}
