/* Three independent layers: descent, rounded swoop, and leaf tumble. */
.autumn-background {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    user-select: none;
    isolation: isolate;
    contain: strict;
}

.container {
    position: relative;
    z-index: 1;
}

.autumn-background::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    background: rgb(20 21 20 / 48%);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.autumn-leaf {
    --leaf-color: #bb854e;
    --leaf-opacity: .3;
    --leaf-sway: 120px;
    --leaf-lift: 38px;
    --swoop-cycle: 7.2s;
    --swoop-phase: -1.6s;
    --tumble-cycle: 13s;
    --tumble-phase: -4s;
    --leaf-shape: polygon(50% 0, 59% 22%, 75% 10%, 72% 34%, 94% 26%, 84% 49%, 100% 53%, 78% 67%, 79% 80%, 59% 75%, 53% 88%, 55% 100%, 48% 100%, 47% 83%, 36% 77%, 20% 85%, 24% 64%, 3% 58%, 21% 45%, 10% 31%, 35% 35%, 30% 14%, 44% 24%);
    position: absolute;
    top: -130px;
    left: 6%;
    z-index: 1;
    width: 86px;
    height: 108px;
    opacity: 0;
    animation: autumn-descent 48s linear -11s infinite;
}

/* Transform fallback approximates the same rounded loop with eight segments. */
.autumn-leaf-sway {
    position: absolute;
    inset: 0;
    perspective: 650px;
    animation: autumn-swoop-fallback var(--swoop-cycle) linear var(--swoop-phase) infinite;
}

.autumn-leaf-sway::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--leaf-color);
    clip-path: var(--leaf-shape);
    transform-origin: 48% 63%;
    animation: autumn-tumble var(--tumble-cycle) ease-in-out var(--tumble-phase) infinite;
}

.autumn-leaf:nth-child(2) {
    --leaf-color: #99946a;
    --leaf-opacity: .27;
    --leaf-sway: 145px;
    --leaf-lift: 45px;
    --swoop-cycle: 8.6s;
    --swoop-phase: -5.2s;
    --tumble-cycle: 17s;
    --tumble-phase: -11s;
    left: 84%;
    width: 67px;
    height: 87px;
    animation-duration: 59s;
    animation-delay: -34s;
}

.autumn-leaf:nth-child(2) .autumn-leaf-sway,
.autumn-leaf:nth-child(2) .autumn-leaf-sway::before {
    animation-direction: reverse;
}

.autumn-leaf:nth-child(3) {
    --leaf-color: #a66a42;
    --leaf-opacity: .25;
    --leaf-sway: 165px;
    --leaf-lift: 50px;
    --swoop-cycle: 6.8s;
    --swoop-phase: -.8s;
    --tumble-cycle: 19s;
    --tumble-phase: -8s;
    --leaf-shape: polygon(50% 0, 70% 12%, 60% 20%, 82% 22%, 74% 34%, 96% 43%, 80% 49%, 86% 63%, 65% 66%, 54% 83%, 55% 100%, 47% 100%, 48% 83%, 33% 71%, 15% 75%, 20% 59%, 4% 51%, 24% 42%, 14% 28%, 38% 27%, 29% 14%);
    left: 24%;
    width: 106px;
    height: 124px;
    animation-duration: 55s;
    animation-delay: -26s;
}

.autumn-leaf:nth-child(4) {
    --leaf-color: #c19663;
    --leaf-opacity: .29;
    --leaf-sway: 125px;
    --leaf-lift: 42px;
    --swoop-cycle: 8.1s;
    --swoop-phase: -3.4s;
    --tumble-cycle: 15s;
    --tumble-phase: -2s;
    left: 71%;
    width: 78px;
    height: 100px;
    animation-duration: 44s;
    animation-delay: -5s;
}

.autumn-leaf:nth-child(4) .autumn-leaf-sway::before {
    animation-direction: reverse;
}

.autumn-leaf:nth-child(5) {
    --leaf-color: #a6a075;
    --leaf-opacity: .24;
    --leaf-sway: 110px;
    --leaf-lift: 36px;
    --swoop-cycle: 7.6s;
    --swoop-phase: -6.2s;
    --tumble-cycle: 21s;
    --tumble-phase: -16s;
    left: 43%;
    width: 61px;
    height: 80px;
    animation-duration: 64s;
    animation-delay: -51s;
}

.autumn-leaf:nth-child(5) .autumn-leaf-sway {
    animation-direction: reverse;
}

.autumn-leaf:nth-child(6) {
    --leaf-color: #af7447;
    --leaf-opacity: .28;
    --leaf-sway: 170px;
    --leaf-lift: 48px;
    --swoop-cycle: 9s;
    --swoop-phase: -2.7s;
    --tumble-cycle: 16s;
    --tumble-phase: -13s;
    left: 94%;
    width: 94px;
    height: 114px;
    animation-duration: 52s;
    animation-delay: -19s;
}

.autumn-leaf:nth-child(6) .autumn-leaf-sway::before {
    animation-direction: reverse;
}

/* The ellipse is a true curve: lateral speed eases at each turn, while its
   rising half briefly offsets the descent to give the leaf a small lift. */
@supports (offset-path: ellipse(80px 30px at 0px 0px)) {
    .autumn-leaf-sway {
        offset-path: ellipse(var(--leaf-sway) var(--leaf-lift) at 0px 0px);
        offset-anchor: center;
        offset-rotate: 0deg;
        animation-name: autumn-swoop;
    }
}

@keyframes autumn-descent {
    0% { transform: translate3d(0, -14vh, 0); opacity: 0; }
    8% { opacity: var(--leaf-opacity); }
    30% { transform: translate3d(0, 27vh, 0); }
    65% { transform: translate3d(0, 71vh, 0); }
    93% { opacity: var(--leaf-opacity); }
    100% { transform: translate3d(0, calc(100vh + 280px), 0); opacity: 0; }
}

@keyframes autumn-swoop {
    from { offset-distance: 0%; }
    to { offset-distance: 100%; }
}

@keyframes autumn-swoop-fallback {
    0%, 100% { transform: translate3d(var(--leaf-sway), 0, 0); }
    12.5% { transform: translate3d(calc(var(--leaf-sway) * .707), calc(var(--leaf-lift) * .707), 0); }
    25% { transform: translate3d(0, var(--leaf-lift), 0); }
    37.5% { transform: translate3d(calc(var(--leaf-sway) * -.707), calc(var(--leaf-lift) * .707), 0); }
    50% { transform: translate3d(calc(var(--leaf-sway) * -1), 0, 0); }
    62.5% { transform: translate3d(calc(var(--leaf-sway) * -.707), calc(var(--leaf-lift) * -.707), 0); }
    75% { transform: translate3d(0, calc(var(--leaf-lift) * -1), 0); }
    87.5% { transform: translate3d(calc(var(--leaf-sway) * .707), calc(var(--leaf-lift) * -.707), 0); }
}

@keyframes autumn-tumble {
    0% { transform: rotateX(15deg) rotateY(-25deg) rotateZ(-30deg); }
    22% { transform: rotateX(55deg) rotateY(70deg) rotateZ(15deg); }
    46% { transform: rotateX(-20deg) rotateY(145deg) rotateZ(102deg); }
    71% { transform: rotateX(40deg) rotateY(225deg) rotateZ(205deg); }
    100% { transform: rotateX(15deg) rotateY(335deg) rotateZ(330deg); }
}

@media (max-width: 760px) {
    .autumn-background::after {
        background: rgb(20 21 20 / 54%);
        -webkit-backdrop-filter: blur(16px);
        backdrop-filter: blur(16px);
    }

    .autumn-leaf {
        --leaf-opacity: .28;
        --leaf-sway: 68px;
        --leaf-lift: 25px;
        --swoop-cycle: 7.5s;
        left: 8%;
        width: 57px;
        height: 72px;
        animation-duration: 54s;
    }

    .autumn-leaf:nth-child(2) {
        --leaf-opacity: .25;
        --leaf-sway: 74px;
        --leaf-lift: 29px;
        --swoop-cycle: 8.7s;
        left: 73%;
        width: 48px;
        height: 63px;
        animation-duration: 61s;
    }

    .autumn-leaf:nth-child(3) {
        --leaf-opacity: .24;
        --leaf-sway: 80px;
        --leaf-lift: 30px;
        --swoop-cycle: 7s;
        left: 39%;
        width: 68px;
        height: 81px;
        animation-duration: 58s;
    }

    .autumn-leaf:nth-child(n + 4) { display: none; }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .autumn-leaf { filter: blur(18px); }
    .autumn-background::after { background: rgb(20 21 20 / 58%); }
}

@supports not (clip-path: polygon(0 0, 100% 0, 50% 100%)) {
    .autumn-background { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .autumn-background { display: none; }
    .autumn-leaf,
    .autumn-leaf-sway,
    .autumn-leaf-sway::before { animation: none !important; }
}
