/* 動態頭像動畫系統 CSS */

/* 頭像容器基礎樣式 */
.avatar-container {
    position: relative;
    display: inline-block;
}

/* 靜態頭像樣式 */
.avatar-static {
    position: relative;
    z-index: 0;
    border-radius: 50%;
    object-fit: cover;
    /* 確保靜態頭像始終可見 */
    display: block;
    width: 100%;
    height: 100%;
    /* 確保靜態頭像與容器尺寸完全一致 */
    box-sizing: border-box;
}

/* 當沒有動畫時，確保靜態頭像正常顯示 */
.avatar-container:not(.has-animation) .avatar-static {
    z-index: 1;
}

/* 當有動畫時，靜態頭像作為背景 */
.avatar-container.has-animation .avatar-static {
    z-index: 0;
}

/* 動畫覆蓋層 */
.avatar-animation-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    z-index: 1;
    /* 確保覆蓋層與容器尺寸完全一致 */
    box-sizing: border-box;
}

/* 動畫視頻樣式 */
.avatar-video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 改為 cover 以填滿整個容器 */
    object-position: center; /* 確保視頻居中 */
    border-radius: 50%;
    background: #000; /* 添加黑色背景以填充空白區域 */
    /* 確保視頻與容器尺寸完全一致 */
    box-sizing: border-box;
}

/* 動畫控制按鈕（預設隱藏） */
.avatar-animation-controls {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    width: 75px;
    height: 75px;
    display: none !important; /* 預設隱藏播放按鈕 */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 36px;
    z-index: 2;
    transition: all 0.3s ease;
}

.avatar-animation-controls:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* 頭像編輯覆蓋層 */
.avatar-overlay {
    position: absolute;
    bottom: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    color: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 3;
}

.avatar-overlay:hover {
    background: rgba(0,0,0,0.9);
    transform: scale(1.1);
}

/* 不同尺寸的頭像容器 */
.avatar-container.small {
    width: 50px;
    height: 50px;
}

.avatar-container.medium {
    width: 80px;
    height: 80px;
}

.avatar-container.large {
    width: 120px;
    height: 120px;
}

.avatar-container.xlarge {
    width: 150px;
    height: 150px;
}

.avatar-container.xxlarge {
    width: 240px;
    height: 240px;
}

.avatar-container.xxxlarge {
    width: 360px;
    height: 360px;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .avatar-animation-controls {
        width: 50px;
        height: 50px;
        font-size: 24px;
        bottom: 10px;
        right: 10px;
    }

    .avatar-overlay {
        width: 25px;
        height: 25px;
        font-size: 12px;
    }
}

/* 動畫載入狀態 */
.avatar-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.8);
    font-size: 24px;
    z-index: 2;
}

/* 動畫錯誤狀態 */
.avatar-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 0, 0, 0.8);
    font-size: 20px;
    z-index: 2;
}

/* 動畫播放指示器 */
.avatar-play-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.9);
    font-size: 32px;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.avatar-container:hover .avatar-play-indicator {
    opacity: 1;
}

/* 動畫邊框效果 */
.avatar-animation-border {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid transparent;
    border-radius: 50%;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4, #feca57);
    background-size: 300% 300%;
    animation: gradient-border 3s ease infinite;
    z-index: -1;
}

@keyframes gradient-border {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 動畫脈衝效果 */
.avatar-pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
