/* 全站共用：小頭像／縮圖 hover 放大 + 點擊燈箱（cm_image_lightbox） */

.cm-avatar-thumb:not(.cm-avatar-thumb--initial) {
    cursor: zoom-in;
}

.cm-avatar-thumb:not(.cm-avatar-thumb--initial):hover {
    border-color: #93c5fd;
    box-shadow: 0 0 0 2px rgba(147, 197, 253, 0.28);
}

.cm-avatar-thumb--initial {
    cursor: default;
}

.cm-avatar-thumb--initial:hover {
    border-color: rgba(147, 197, 253, 0.55);
    box-shadow: 0 0 0 2px rgba(147, 197, 253, 0.18);
}

img.cm-avatar-thumb {
    cursor: zoom-in;
    box-sizing: border-box;
}

img.cm-avatar-thumb:hover {
    border-color: #93c5fd;
    box-shadow: 0 0 0 2px rgba(147, 197, 253, 0.28);
}

#cmAvatarHoverPreview.cm-avatar-hover-preview {
    display: none;
    position: fixed;
    /* 須高於 es-modal (28000)、一般燈箱 (30000)；點擊開燈箱前 JS 會 hidePreview */
    z-index: 2147483646;
    pointer-events: none;
    padding: 6px;
    box-sizing: border-box;
    background: #161b22;
    border: 1px solid #484f58;
    border-radius: 10px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.72);
    flex-direction: column;
    align-items: center;
    gap: 6px;
    /* 獨立合成層，避免被 YouTube iframe（OOPIF）蓋住 */
    transform: translateZ(0);
    isolation: isolate;
}

#cmAvatarHoverPreview.cm-avatar-hover-preview--visible,
#cmAvatarHoverPreview.cm-avatar-hover-preview--visible[hidden] {
    display: flex !important;
}

.cm-avatar-hover-preview__media {
    position: relative;
    line-height: 0;
}

#cmAvatarHoverPreview img {
    display: block;
    width: 140px;
    height: 168px;
    object-fit: cover;
    border-radius: 8px;
}

#cmAvatarHoverPreview.cm-avatar-hover-preview--wide img {
    width: 220px;
    height: 165px;
    object-fit: contain;
    background: #0f172a;
}

#cmAvatarHoverPreview.cm-avatar-hover-preview--round img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
}

.cm-avatar-hover-preview__initial {
    display: none;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    color: #ecfeff;
    background: linear-gradient(135deg, #0ea5e9, #065f46);
    font-weight: 800;
    font-size: 2.4rem;
    line-height: 1;
    user-select: none;
}

#cmAvatarHoverPreview.cm-avatar-hover-preview--initial .cm-avatar-hover-preview__initial {
    display: flex;
}

#cmAvatarHoverPreview.cm-avatar-hover-preview--initial img {
    display: none;
}

.cm-avatar-hover-preview__caption {
    margin: 0;
    padding: 0 4px 2px;
    max-width: 140px;
    color: #f1f5f9;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
    word-break: break-word;
}

#cmAvatarHoverPreview.cm-avatar-hover-preview--wide .cm-avatar-hover-preview__caption {
    max-width: 220px;
}

#cmAvatarHoverPreview img,
#cmAvatarHoverPreview video {
    display: block;
    width: 140px;
    height: 168px;
    object-fit: cover;
    border-radius: 8px;
}

#cmAvatarHoverPreview img[hidden],
#cmAvatarHoverPreview video[hidden] {
    display: none !important;
}

#cmAvatarHoverPreview.cm-avatar-hover-preview--scaled img,
#cmAvatarHoverPreview.cm-avatar-hover-preview--scaled video {
    max-width: none;
    object-fit: contain;
    background: transparent;
}

#cmAvatarHoverPreview.cm-avatar-hover-preview--scaled .cm-avatar-hover-preview__caption {
    max-width: none;
}

.cm-avatar-hover-preview__caption:empty {
    display: none;
}

.cm-avatar-video-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483645;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.88);
    padding: 24px;
    box-sizing: border-box;
}

.cm-avatar-video-overlay[hidden] {
    display: none !important;
}

.cm-avatar-video-overlay__el {
    max-width: min(92vw, 1100px);
    max-height: min(86vh, 92vw);
    background: #000;
    border-radius: 10px;
}

.cm-avatar-video-overlay__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.85);
    color: #f8fafc;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.cm-avatar-video-overlay__close:hover {
    background: #1e293b;
}

@media print {
    #cmAvatarHoverPreview,
    #cmAvatarVideoOverlay {
        display: none !important;
    }
}
