/*
 * Simple theme crossfade.
 * Browsers with the View Transitions API fade the complete page snapshot.
 */
html.theme-crossfade::view-transition-group(root) {
    animation-duration: 1760ms;
}

html.theme-crossfade::view-transition-old(root),
html.theme-crossfade::view-transition-new(root) {
    mix-blend-mode: normal;
}

html.theme-crossfade::view-transition-old(root) {
    animation: theme-fade-out 1760ms cubic-bezier(.45, 0, .2, 1) both;
}

html.theme-crossfade::view-transition-new(root) {
    animation: theme-fade-in 1760ms cubic-bezier(.25, .1, .15, 1) both;
}

html[data-theme="light"].theme-crossfade::view-transition-new(root) {
    animation-name: theme-sunrise-in;
}

html[data-theme="dark"].theme-crossfade::view-transition-new(root) {
    animation-name: theme-sunset-in;
}

@keyframes theme-fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes theme-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes theme-sunrise-in {
    from {
        opacity: 0;
        filter: brightness(.88);
    }
    to {
        opacity: 1;
        filter: brightness(1);
    }
}

@keyframes theme-sunset-in {
    from {
        opacity: 0;
        filter: brightness(1.08);
    }
    to {
        opacity: 1;
        filter: brightness(1);
    }
}

/*
 * Firefox and other browsers without the View Transitions API smoothly
 * interpolate the theme-dependent visual properties in place.
 */
html.theme-color-transition,
html.theme-color-transition *,
html.theme-color-transition *::before,
html.theme-color-transition *::after {
    transition-property:
        background-color,
        color,
        border-color,
        outline-color,
        box-shadow,
        fill,
        stroke,
        filter !important;
    transition-duration: 1760ms !important;
    transition-timing-function: cubic-bezier(.25, .1, .15, 1) !important;
    transition-delay: 0ms !important;
}

html[data-motion="reduce"].theme-crossfade::view-transition-group(root),
html[data-motion="reduce"].theme-crossfade::view-transition-old(root),
html[data-motion="reduce"].theme-crossfade::view-transition-new(root) {
    animation-duration: 1ms;
}
