/* Hiệu ứng cuộn (đi cùng fx.js) */
.fx { --ease-fx: cubic-bezier(.2, .8, .2, 1); transition: opacity 1s var(--ease-fx), transform 1.1s var(--ease-fx), filter 1s ease, clip-path 1.3s var(--ease-fx), letter-spacing 1.2s var(--ease-fx); }
.fx:not(.fx-in) { opacity: 0; }
.fx.fx-in { opacity: 1; }

.fx-up:not(.fx-in) { transform: translateY(28px); }
.fx-left:not(.fx-in) { transform: translateX(-48px); }
.fx-right:not(.fx-in) { transform: translateX(48px); }
.fx-zoom:not(.fx-in) { transform: scale(.7); }
.fx-drop:not(.fx-in) { transform: translateY(-40px) scale(1.08); }
.fx-blur:not(.fx-in) { filter: blur(12px); letter-spacing: .12em; }
.fx-pop.fx-in { animation: fxpop .8s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes fxpop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.fx-bounce.fx-in { animation: fxbounce 1.1s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes fxbounce { 0% { transform: translateY(-70px) scale(.8); opacity: 0; } 60% { transform: translateY(8px) scale(1.03); opacity: 1; } 100% { transform: none; } }
.fx-spin:not(.fx-in) { transform: rotate(-120deg) scale(.4); }

/* Lau chữ từ trái / phải như bút viết */
.fx-wipe, .fx-wipe-r { opacity: 1 !important; }
.fx-wipe:not(.fx-in) { clip-path: inset(-20% 100% -20% 0); }
.fx-wipe-r:not(.fx-in) { clip-path: inset(-20% 0 -20% 100%); }
.fx-wipe.fx-in, .fx-wipe-r.fx-in { clip-path: inset(-20% -5% -20% -5%); transition-duration: 1.8s; }

/* Chữ gõ máy */
.fx-type { opacity: 1 !important; }
.fx-type:not(.fx-in) { clip-path: inset(0 100% 0 0); }
.fx-type.fx-in { clip-path: inset(0 0 0 0); transition: clip-path 1.6s steps(22, end); }

/* Polaroid đung đưa bay vào từ hai bên */
.fx-swing-l:not(.fx-in) { transform: translate(-60px, -30px) rotate(-14deg); }
.fx-swing-r:not(.fx-in) { transform: translate(60px, -30px) rotate(14deg); }
.fx-swing-l.fx-in, .fx-swing-r.fx-in { transition-duration: 1.3s; transition-timing-function: cubic-bezier(.3, 1.35, .5, 1); }
.fx-swing-r { transition-delay: .18s; }

/* Hai đường kẻ vàng của câu trích dẫn chạy ra từ giữa */
.fx-lines { opacity: 1 !important; border-color: transparent !important; position: relative; }
.fx-lines::before, .fx-lines::after { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: rgba(239, 210, 124, .6); transform: scaleX(0); transition: transform 1.4s var(--ease-fx); }
.fx-lines::before { top: 0; } .fx-lines::after { bottom: 0; transition-delay: .3s; }
.fx-lines.fx-in::before, .fx-lines.fx-in::after { transform: scaleX(1); }
.quote-text.fx-blur:not(.fx-in), .quote-text p.fx-blur:not(.fx-in) { transition-delay: .4s; }

/* Ô đếm ngược lật lần lượt */
.fx-flip { opacity: 1 !important; perspective: 600px; }
.fx-flip .cd-unit { transition: transform .8s cubic-bezier(.3, 1.3, .5, 1) var(--fx-d, 0s), opacity .6s ease var(--fx-d, 0s); transform-origin: 50% 0; }
.fx-flip:not(.fx-in) .cd-unit { transform: rotateX(-95deg); opacity: 0; }

/* Ngày trên lịch hiện lan dần */
.fx-ripple { opacity: 1 !important; }
.fx-ripple td { transition: opacity .5s ease var(--fx-d, 0s), transform .5s var(--ease-fx) var(--fx-d, 0s); }
.fx-ripple:not(.fx-in) td { opacity: 0 !important; transform: scale(.5); }

/* Lời cảm ơn mở ra như lá thư, các đoạn hiện lần lượt */
.fx-unfold { transform-origin: 50% 0; }
.fx-unfold:not(.fx-in) { transform: perspective(900px) rotateX(-70deg); }
.fx-unfold.fx-in { transition-duration: 1.4s; }
.fx-stagger-up { opacity: 1 !important; }
.fx-stagger-up p { transition: opacity .9s ease calc(.5s + var(--fx-d, 0s)), transform .9s var(--ease-fx) calc(.5s + var(--fx-d, 0s)); }
.fx-stagger-up:not(.fx-in) p { opacity: 0; transform: translateY(16px); }

@media (prefers-reduced-motion: reduce) { .fx, .fx * { transition: none !important; animation: none !important; opacity: 1 !important; transform: none !important; clip-path: none !important; filter: none !important; } }
/* hiện nhanh hơn: vừa vào màn hình là chạy, thời gian ngắn lại */
.fx { transition-duration: .75s, .8s, .7s, 1s, .8s; }
.quote-text.fx-blur:not(.fx-in), .quote-text p.fx-blur:not(.fx-in) { transition-delay: 0s; }
.fx-blur:not(.fx-in) { filter: blur(8px); }
.tw-word { white-space: nowrap; }
.letter-body.tw-ready .tw { opacity: 0; transition: opacity .12s linear; }
.letter-body.tw-ready .tw.on { opacity: 1; }
.thanks .letter-body p { opacity: 1 !important; transform: none !important; }
