/* ═══════════════════════════════════════
   AVATAR LAYERING SYSTEM CSS
   Split-Body Layering System with Z-Index Control
   ═══════════════════════════════════════ */

/* Avatar Canvas Container */
.avatar-canvas {
    position: relative !important;
    overflow: hidden !important;
    width: 100%;
    height: 100%;
}

/* All Avatar Layers - Force absolute positioning */
.avatar-canvas img,
.avatar-layer {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    pointer-events: none;
    image-rendering: auto;
    -webkit-user-select: none;
    user-select: none;
}

/* Permanent Body Parts - Always Visible */
.avatar-permanent {
    /* Permanent layers like body_under and body_head */
}

/* Specific Layer Classes for Debugging */
.avatar-layer-bg {
    /* Background layer - z-index: 0 */
}

.avatar-layer-aura {
    /* Aura layer - z-index: 1 */
}

.avatar-layer-body_under {
    /* Base body foundation - z-index: 2 (PERMANENT) */
}

.avatar-layer-pants,
.avatar-layer-shoes {
    /* Lower clothing - z-index: 3 */
}

.avatar-layer-robe {
    /* Upper clothing - z-index: 4 */
}

.avatar-layer-body_head {
    /* Head/face - z-index: 5 (PERMANENT - overlaps collar) */
}

.avatar-layer-hat,
.avatar-layer-weapon {
    /* Headwear and weapons - z-index: 6 */
}

.avatar-layer-effect {
    /* Top-level effects - z-index: 7 */
}

/* Avatar Canvas Variants */
.avatar-canvas-circle {
    border-radius: 50%;
}

.avatar-canvas-rounded {
    border-radius: 14px;
}

.avatar-canvas-square {
    border-radius: 0;
}

/* Responsive Sizing */
.avatar-canvas-sm {
    width: 100px;
    height: 100px;
}

.avatar-canvas-md {
    width: 200px;
    height: 200px;
}

.avatar-canvas-lg {
    width: 300px;
    height: 300px;
}

.avatar-canvas-xl {
    width: 500px;
    height: 500px;
}

/* Animation Support */
.avatar-canvas-animated .avatar-layer {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.avatar-canvas-animated:hover .avatar-layer {
    transform: scale(1.02);
}

/* Loading State */
.avatar-canvas-loading {
    background: linear-gradient(90deg, #1f2833 25%, #2a3441 50%, #1f2833 75%);
    background-size: 200% 100%;
    animation: avatarLoading 1.5s infinite;
}

@keyframes avatarLoading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Error State */
.avatar-canvas-error {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 70, 85, 0.1);
    border: 1px dashed rgba(255, 70, 85, 0.3);
    color: #ff4655;
    font-size: 12px;
    font-weight: 700;
}

.avatar-canvas-error::before {
    content: '⚠️ Avatar Error';
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    .avatar-layer {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .avatar-layer {
        image-rendering: -webkit-optimize-contrast;
    }
}
