/* ============================================================
   头像框系统样式 (oy_avatar)
   ============================================================ */

/* ---- 全局头像框 overlay（以 avatar-wrap 为定位基准） ----
   头像框通常比头像大一圈，设置为 130% 并反向偏移 15% 让框图完整覆盖并外扩 */
.oy-avatar-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 130%;
    height: 130%;
    max-width: none;
    box-sizing: border-box;
    aspect-ratio: 1 / 1;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 2;
    object-fit: fill;
    image-rendering: auto;
}

/* 与 XIUNOX 站点头像设置保持一致：
   rounded=圆角方形、circle=圆形、square=直角方形。
   头像框为头像的 130%，圆角值按同一比例由头像的 6px 放大至约 8px。 */
.oy-avatar-overlay.oy-avatar-shape-rounded {
    border-radius: 8px;
}
.oy-avatar-overlay.oy-avatar-shape-circle {
    border-radius: 50%;
}
.oy-avatar-overlay.oy-avatar-shape-square {
    border-radius: 0;
}

/* 仅对佩戴头像框的 avatar-wrap 生效，避免影响无框用户的头像显示 */
.avatar-wrap.has-frame {
    position: relative;
    overflow: visible;
    padding: 6%;
    margin: -6%;
}

/* 头像框墙预览使用明确的正方形基准。
   模板同时带有 Bootstrap .d-inline-block（display:...!important），因此不再依赖
   inline-flex 的内容尺寸推导，避免浏览器缩放时宽高分别取整造成圆框变形。 */
.oy-avatar-preview {
    position: relative;
    display: inline-block !important;
    flex: 0 0 auto;
    overflow: visible;
    line-height: 0;
    vertical-align: middle;
    box-sizing: content-box;
    aspect-ratio: 1 / 1;
}
.oy-avatar-preview-lg {
    width: 52px;
    height: 52px;
}
.oy-avatar-preview-xl {
    width: 96px;
    height: 96px;
}
.oy-avatar-preview .oy-avatar-overlay {
    z-index: 3;
}

/* ---- 卡片交互 ---- */
.oy-avatar-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.oy-avatar-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08);
}
.oy-avatar-card.is-wearing {
    border-color: var(--bs-primary, #0d6efd);
    box-shadow: 0 0 0 0.125rem rgba(13, 110, 253, 0.25);
}

/* ---- 稀有度标签（游戏化配色：普通灰 / 稀有青 / 史诗紫 / 传说金） ---- */
/* 用实色背景 + !important 覆盖 Bootstrap .badge 的 color:#fff */
.badge.oy-avatar-rarity-1 {
    background-color: #868e96;
    color: #fff !important;
}
.badge.oy-avatar-rarity-2 {
    background-color: #20c997;
    color: #fff !important;
}
.badge.oy-avatar-rarity-3 {
    background-color: #7c3aed;
    color: #fff !important;
}
.badge.oy-avatar-rarity-4 {
    background-color: #f59e0b;
    color: #fff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ---- 倒计时 ---- */
.oy-avatar-countdown {
    font-size: 0.75rem;
    color: #6c757d;
}
.oy-avatar-countdown.urgent {
    color: #dc3545;
    font-weight: 600;
    animation: oyAvatarPulse 2s ease-in-out infinite;
}
@keyframes oyAvatarPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ---- 空状态 ---- */
.oy-avatar-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: #6c757d;
}
.oy-avatar-empty i {
    font-size: 3rem;
    opacity: 0.4;
    margin-bottom: 0.5rem;
}

/* ---- 拥有/未获得 Tab 内容 ---- */
.oy-avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

/* ---- 按钮微调 ---- */
.oy-avatar-card .btn-group .btn {
    font-size: 0.8rem;
    line-height: 1.4;
}

/* ---- 后台管理页面样式 ---- */
.oy-avatar-admin-preview {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 2px;
    background: #fff;
}
.oy-avatar-admin-preview-lg {
    width: 96px;
    height: 96px;
    object-fit: contain;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 2px;
    background: #fff;
}

/* ---- 移动端适配 ---- */
@media (max-width: 575.98px) {
    .oy-avatar-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    .oy-avatar-card .card-body {
        padding: 0.75rem;
    }
    .oy-avatar-card .fw-medium {
        font-size: 0.8rem;
    }
}

/* ---- 图片加载失败兜底 ---- */
.oy-avatar-overlay[src=""],
.oy-avatar-overlay:not([src]) {
    display: none;
}
