/* ─── Sakura Falling Petals ─── */

/* 三層容器共用基礎 */
#sakura-back,
#sakura-front,
#sakura-stuck {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

#sakura-back  { z-index: 0;  } /* 70% 後方，烘贸2氛圍 */
#sakura-front { z-index: 10; } /* 20% 前方，増加景深 */
#sakura-stuck { z-index: 0;  } /* 10% 停留裝飾 */

/* 外層：純垂直下落 */
.sakura-wrap {
    position: absolute;
    top: -60px;
    animation-name: sakura-fall-y;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    will-change: transform, opacity;
}

@keyframes sakura-fall-y {
    0%   { transform: translate3d(0, 0, 0);       opacity: var(--o); }
    82%  {                                         opacity: var(--o); }
    100% { transform: translate3d(0, 116vh, 0);   opacity: 0; }
}

/* 內層：左右飄移 + 旋轉 */
.sakura-petal {
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation-name: sakura-sway;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    animation-direction: alternate;
    will-change: transform;
}

@keyframes sakura-sway {
    from {
        transform: translate3d(calc(var(--sway) * -1), 0, 0) rotate(var(--rot-a));
    }
    to {
        transform: translate3d(var(--sway), 0, 0) rotate(var(--rot-b));
    }
}

/* 停留花瓣：卡在邊角，輕微搖曳 */
.sakura-stuck {
    position: absolute;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation-name: sakura-stuck-sway;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    animation-direction: alternate;
    will-change: transform;
}

@keyframes sakura-stuck-sway {
    from { transform: rotate(var(--rot-a)); }
    to   { transform: rotate(var(--rot-b)); }
}

/* 無障礙：尊重使用者的減少動態設定 */
@media (prefers-reduced-motion: reduce) {
    #sakura-back, #sakura-front, #sakura-stuck { display: none; }
}
