/* 動效疊在 tianming.css 之後。只動現有版面，不改文案。
   捲動進度與進場只在支援 scroll/view timeline 的瀏覽器出現。 */

:root {
    --tm-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: no-preference) {
    .tm-hero-photo {
        animation-duration: 26s;
    }

    .tm-destiny-photo {
        animation-duration: 34s;
    }

    .tm-cta-photo {
        animation: tmKenBurnsSoft 36s ease-in-out infinite alternate;
    }

    .tm-lantern {
        transform-origin: 50% 0;
        animation: tmLanternSway 4.6s ease-in-out infinite;
    }

    .tm-lantern-r {
        animation-delay: -2.1s;
    }

    .tm-sec-title i {
        transform: scaleX(0);
        animation: tmLineDraw 1.05s var(--tm-ease) 0.12s forwards;
    }

    .tm-sec-title i:first-child {
        transform-origin: 100% 50%;
    }

    .tm-sec-title i:last-child {
        transform-origin: 0 50%;
        animation-delay: 0.28s;
    }

    .tm-service {
        animation-duration: 8s;
    }

    .tm-service:hover {
        animation: none;
        transform: translateY(-8px);
        border-color: rgba(232, 213, 163, 0.95);
        box-shadow:
            0 18px 34px rgba(0, 0, 0, 0.32),
            0 0 0 1px rgba(198, 161, 91, 0.28);
    }

    .tm-service:hover .tm-icon-wrap {
        animation: none;
        transform: translateY(-2px);
        box-shadow: 0 0 18px rgba(198, 161, 91, 0.42);
    }

    .tm-calc:hover,
    .tm-more:hover,
    .tm-btn-glow:hover {
        animation: tmBtnPulse 2.8s ease-in-out infinite;
        transform: translateY(-2px);
    }

    .tm-journal-grid img,
    .tm-know img {
        transition: transform 0.85s var(--tm-ease);
    }

    .tm-journal-grid a:hover img,
    .tm-know a:hover img {
        transform: scale(1.045);
    }

    .tm-journal-grid a,
    .tm-know,
    .tm-voice,
    .tm-topic-grid article,
    .tm-faq article {
        transition: transform 0.45s var(--tm-ease), border-color 0.45s ease, box-shadow 0.45s ease;
    }

    .tm-journal-grid a:hover,
    .tm-know:hover,
    .tm-voice:hover,
    .tm-topic-grid article:hover,
    .tm-faq article:hover {
        transform: translateY(-4px);
        border-color: rgba(198, 161, 91, 0.72);
        box-shadow: 0 16px 28px rgba(80, 40, 16, 0.1);
    }

    .tm-flow-ring {
        animation: tmRingIn 0.85s var(--tm-ease) both;
    }

    .tm-flow-steps > li:nth-child(3) .tm-flow-ring { animation-delay: 0.16s; }
    .tm-flow-steps > li:nth-child(5) .tm-flow-ring { animation-delay: 0.32s; }
    .tm-flow-steps > li:nth-child(7) .tm-flow-ring { animation-delay: 0.48s; }

    .tm-flow-arrow {
        animation: tmArrowNudge 2.6s ease-in-out infinite;
    }

    .tm-hero-verse,
    .tm-destiny-verse,
    .tm-side-verse {
        animation: tmVerseIn 1.5s var(--tm-ease) 0.35s both;
    }
}

@supports (animation-timeline: scroll()) {
    @media (prefers-reduced-motion: no-preference) {
        html::before {
            content: "";
            position: fixed;
            top: 0;
            left: 0;
            z-index: 80;
            width: 100%;
            height: 3px;
            transform: scaleX(0);
            transform-origin: 0 50%;
            background: linear-gradient(90deg, #8a1c24, #e8d5a3);
            pointer-events: none;
            animation: tmScrollProgress linear both;
            animation-timeline: scroll(root);
        }
    }
}

@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        .tm-journal-grid article,
        .tm-topic-grid article,
        .tm-voice,
        .tm-know,
        .tm-faq article {
            animation: tmRise linear both;
            animation-timeline: view();
            animation-range: entry 8% cover 32%;
        }

        .tm-service {
            animation: tmCardFloat 8s ease-in-out infinite, tmRise linear both;
            animation-timeline: auto, view();
            animation-range: normal, entry 8% cover 32%;
        }

        .tm-service:hover {
            animation: none;
        }
    }
}

@keyframes tmLanternSway {
    0%, 100% { rotate: -2.4deg; }
    50% { rotate: 2.4deg; }
}

@keyframes tmLineDraw {
    to { transform: scaleX(1); }
}

@keyframes tmRingIn {
    from { opacity: 0; transform: scale(0.88); }
    to { opacity: 1; transform: none; }
}

@keyframes tmArrowNudge {
    0%, 100% { transform: translateX(0); opacity: 0.45; }
    50% { transform: translateX(5px); opacity: 1; }
}

@keyframes tmVerseIn {
    from { opacity: 0; filter: blur(4px); }
    to { opacity: 1; filter: none; }
}

@keyframes tmRise {
    from { opacity: 0; translate: 0 18px; }
    to { opacity: 1; translate: 0 0; }
}

@keyframes tmScrollProgress {
    to { transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
    html::before {
        content: none;
    }
}
