/*
 * EC Shop City - 動畫效果樣式表
 * 版本: 2.0
 * 更新日期: 2026-02-06
 */

/* ========================================
   基礎動畫關鍵幀
======================================== */

/* 淡入 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 淡入上移 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 淡入下移 */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 淡入左移 */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 淡入右移 */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 縮放淡入 */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 彈跳 */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-15px);
    }
    60% {
        transform: translateY(-7px);
    }
}

/* 脈動 */
@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 15px rgba(37, 211, 102, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

/* 搖晃 */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* 旋轉 */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* 浮動 */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* 閃爍 */
@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* 滑入展開 */
@keyframes slideExpand {
    from {
        max-height: 0;
        opacity: 0;
    }
    to {
        max-height: 500px;
        opacity: 1;
    }
}

/* 波紋效果 */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* 打字效果 */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

/* 光標閃爍 */
@keyframes cursorBlink {
    0%, 100% {
        border-color: transparent;
    }
    50% {
        border-color: var(--color-primary);
    }
}

/* 漸變背景動畫 */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* 光暈效果 */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(92, 197, 250, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(92, 197, 250, 0.8), 0 0 30px rgba(92, 197, 250, 0.6);
    }
}

/* 數字計數 */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   滾動觸發動畫類
======================================== */

/* 初始狀態 (等待觸發) */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

/* 不同方向的滾動動畫 */
.animate-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-left.animated {
    opacity: 1;
    transform: translateX(0);
}

.animate-right {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-right.animated {
    opacity: 1;
    transform: translateX(0);
}

.animate-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-scale.animated {
    opacity: 1;
    transform: scale(1);
}

/* 延遲動畫 */
.delay-100 { transition-delay: 0.1s; }
.delay-200 { transition-delay: 0.2s; }
.delay-300 { transition-delay: 0.3s; }
.delay-400 { transition-delay: 0.4s; }
.delay-500 { transition-delay: 0.5s; }
.delay-600 { transition-delay: 0.6s; }
.delay-700 { transition-delay: 0.7s; }
.delay-800 { transition-delay: 0.8s; }

/* ========================================
   即時動畫類
======================================== */
.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.fade-in-up {
    animation: fadeInUp 0.6s ease forwards;
}

.fade-in-down {
    animation: fadeInDown 0.6s ease forwards;
}

.fade-in-left {
    animation: fadeInLeft 0.6s ease forwards;
}

.fade-in-right {
    animation: fadeInRight 0.6s ease forwards;
}

.scale-in {
    animation: scaleIn 0.5s ease forwards;
}

.bounce {
    animation: bounce 1s ease;
}

.float {
    animation: float 3s ease-in-out infinite;
}

.rotate {
    animation: rotate 2s linear infinite;
}

/* ========================================
   WhatsApp 按鈕脈動效果
======================================== */
.whatsapp-btn {
    animation: pulse 2s infinite;
}

.whatsapp-btn:hover {
    animation: none;
}

/* ========================================
   Hero 區域動畫
======================================== */
.hero-content {
    animation: fadeInUp 0.8s ease 0.2s forwards;
    opacity: 0;
}

.hero-title {
    animation: fadeInUp 0.8s ease 0.3s forwards;
    opacity: 0;
}

.hero-subtitle {
    animation: fadeInUp 0.8s ease 0.4s forwards;
    opacity: 0;
}

.hero-buttons {
    animation: fadeInUp 0.8s ease 0.5s forwards;
    opacity: 0;
}

.hero-stats {
    animation: fadeInUp 0.8s ease 0.6s forwards;
    opacity: 0;
}

.hero-image {
    animation: fadeInRight 1s ease 0.5s forwards;
    opacity: 0;
}

/* ========================================
   卡片懸停效果
======================================== */
.card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
}

.card .card-icon {
    transition: transform 0.3s ease, background 0.3s ease;
}

.card:hover .card-icon {
    transform: scale(1.1);
    background: var(--gradient-primary);
}

.card:hover .card-icon svg,
.card:hover .card-icon img {
    filter: brightness(0) invert(1);
}

/* 價格卡片特殊效果 */
.price-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.price-card:hover {
    transform: translateY(-10px) scale(1.02);
    border-color: var(--color-primary);
    box-shadow: 0 20px 50px rgba(92, 197, 250, 0.2);
}

/* ========================================
   按鈕動畫效果
======================================== */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* 波紋效果 */
.btn::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    transform: scale(0);
    opacity: 0;
    transition: transform 0.5s ease, opacity 0.5s ease;
}

.btn:active::after {
    transform: scale(2);
    opacity: 1;
    transition: 0s;
}

/* 按鈕懸停上移 */
.btn-primary:hover,
.btn-secondary:hover {
    transform: translateY(-3px);
}

.btn-primary:active,
.btn-secondary:active {
    transform: translateY(-1px);
}

/* ========================================
   導航動畫
======================================== */
/* 下拉菜單動畫 */
.nav-dropdown {
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

.dropdown-link {
    transition: background 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
}

.dropdown-link:hover {
    padding-left: 25px;
}

/* 漢堡菜單動畫 */
.hamburger span {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* 手機菜單滑入動畫 */
.main-nav {
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 導航遮罩淡入 */
.nav-overlay {
    transition: opacity 0.3s ease;
}

/* ========================================
   滾動 Header 效果
======================================== */
.header {
    transition: background 0.3s ease, box-shadow 0.3s ease, height 0.3s ease;
}

.header.scrolled {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.header.scrolled .header-inner {
    height: 70px;
}

.header.scrolled .logo img {
    height: 38px;
}

/* ========================================
   表單動畫
======================================== */
.form-input,
.form-textarea,
.form-select {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(92, 197, 250, 0.15);
}

/* 表單標籤動畫 (浮動標籤效果) */
.form-floating .form-label {
    position: absolute;
    top: 14px;
    left: 18px;
    font-size: 15px;
    color: var(--color-text-light);
    pointer-events: none;
    transition: all 0.2s ease;
}

.form-floating .form-input:focus ~ .form-label,
.form-floating .form-input:not(:placeholder-shown) ~ .form-label {
    top: -10px;
    left: 14px;
    font-size: 12px;
    color: var(--color-primary);
    background: var(--color-white);
    padding: 0 4px;
}

/* ========================================
   FAQ 手風琴動畫
======================================== */
.faq-answer {
    transition: max-height 0.4s ease, padding 0.4s ease, opacity 0.3s ease;
    opacity: 0;
}

.faq-item.active .faq-answer {
    opacity: 1;
}

.faq-icon {
    transition: transform 0.3s ease;
}

.faq-item.active .faq-icon {
    transform: rotate(180deg);
}

.faq-question {
    transition: color 0.2s ease, background 0.2s ease;
}

.faq-question:hover {
    background: rgba(92, 197, 250, 0.05);
}

/* ========================================
   客戶 Logo 動畫
======================================== */
.client-logo {
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.client-logo:hover {
    transform: translateY(-5px);
}

.client-logo img {
    transition: filter 0.3s ease, opacity 0.3s ease;
}

/* ========================================
   統計數字動畫
======================================== */
.stats-number {
    display: inline-block;
}

.stats-number.counting {
    animation: countUp 0.5s ease forwards;
}

/* ========================================
   圖片載入動畫
======================================== */
.img-lazy {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.img-lazy.loaded {
    opacity: 1;
}

/* 圖片懸停縮放 */
.img-zoom {
    overflow: hidden;
}

.img-zoom img {
    transition: transform 0.5s ease;
}

.img-zoom:hover img {
    transform: scale(1.1);
}

/* ========================================
   頁面載入動畫
======================================== */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-white);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--color-bg-light);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

/* ========================================
   滾動進度條
======================================== */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--gradient-primary);
    z-index: 1001;
    width: 0%;
    transition: width 0.1s linear;
}

/* ========================================
   工具提示動畫
======================================== */
.tooltip {
    position: relative;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    padding: 8px 12px;
    background: var(--color-bg-dark);
    color: var(--color-white);
    font-size: 13px;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.tooltip:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

/* ========================================
   返回頂部按鈕
======================================== */
.back-to-top {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 45px;
    height: 45px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-white);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 998;
    cursor: pointer;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-primary);
}

/* ========================================
   文字打字效果
======================================== */
.typing-text {
    overflow: hidden;
    white-space: nowrap;
    border-right: 3px solid var(--color-primary);
    animation: 
        typing 3s steps(30, end),
        cursorBlink 0.75s step-end infinite;
}

/* ========================================
   漸變背景動畫
======================================== */
.animated-gradient {
    background: linear-gradient(-45deg, #5CC5FA, #3E99CA, #2d7aa3, #5CC5FA);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
}

/* ========================================
   光暈按鈕效果
======================================== */
.btn-glow {
    animation: glow 2s ease-in-out infinite;
}

.btn-glow:hover {
    animation: none;
    box-shadow: 0 0 20px rgba(92, 197, 250, 0.8);
}

/* ========================================
   錯開動畫 (用於列表項目)
======================================== */
.stagger-animation > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.6s; }
.stagger-animation > *:nth-child(7) { animation-delay: 0.7s; }
.stagger-animation > *:nth-child(8) { animation-delay: 0.8s; }

/* ========================================
   減少動畫模式支援
======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .animate-on-scroll,
    .animate-left,
    .animate-right,
    .animate-scale {
        opacity: 1;
        transform: none;
    }

    .whatsapp-btn {
        animation: none;
    }

    .hero-content,
    .hero-title,
    .hero-subtitle,
    .hero-buttons,
    .hero-stats,
    .hero-image {
        opacity: 1;
        animation: none;
    }
}
