/* ===================================
   IMAGE STYLES
   =================================== */

/* General Image Styles */
.wiki-image {
    display: block;
    max-width: 100%;
    height: auto;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.wiki-image.loading {
    opacity: 0;
    transform: scale(0.95);
}

.wiki-image.loaded {
    opacity: 1;
    transform: scale(1);
}

.wiki-image.error {
    opacity: 0.5;
    filter: grayscale(1);
}

/* Boss Images */
.boss-hero-banner {
    width: 100%;
    height: 400px;
    margin: -40px -40px 40px -40px;
    position: relative;
    overflow: hidden;
    background: var(--bg-secondary);
    border-radius: 8px 8px 0 0;
}

.boss-hero-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

.boss-portrait {
    width: 300px;
    height: 300px;
    margin: -150px auto 30px;
    position: relative;
    z-index: 10;
    border-radius: 50%;
    overflow: hidden;
    border: 5px solid var(--ds-gold);
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.5);
    background: var(--bg-card);
}

.boss-portrait-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Weapon Images */
.weapon-icon-container {
    width: 128px;
    height: 128px;
    margin: 0 auto 20px;
    padding: 20px;
    background: rgba(212, 175, 55, 0.1);
    border: 2px solid var(--ds-gold);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.weapon-icon {
    max-width: 100%;
    max-height: 100%;
    filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.5));
}

.weapon-full-render {
    max-width: 800px;
    margin: 30px auto;
    padding: 40px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.05), transparent);
    border-radius: 8px;
    text-align: center;
}

.weapon-full-image {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5));
}

/* Item Images */
.item-icon-container {
    width: 200px;
    height: 200px;
    margin: 0 auto 30px;
    padding: 30px;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.2), transparent);
    border: 3px solid var(--ds-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.item-icon-container::before {
    content: '';
    position: absolute;
    inset: -10px;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 50%;
    animation: rotate-slow 20s linear infinite;
}

@keyframes rotate-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.item-icon {
    max-width: 100%;
    max-height: 100%;
    filter: drop-shadow(0 0 20px rgba(212, 175, 55, 0.6));
}

.item-full-image {
    max-width: 600px;
    margin: 30px auto;
    text-align: center;
    padding: 30px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.item-full-image img {
    max-width: 100%;
    height: auto;
}

/* Area Images */
.area-banner {
    width: 100%;
    height: 400px;
    margin: -40px -40px 40px -40px;
    position: relative;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
}

.area-banner-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.8);
}

.area-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 40px 0;
}

.area-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition-base);
}

.area-gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
    border-color: var(--ds-gold);
}

.area-gallery-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.area-gallery-item:hover .area-gallery-image {
    transform: scale(1.1);
}

/* Thumbnail Images for Listings */
.item-thumbnail {
    width: 100%;
    height: 150px;
    object-fit: contain;
    object-position: center;
    margin-bottom: 20px;
    border-radius: 4px;
    background: radial-gradient(ellipse at center, rgba(212, 175, 55, 0.1), var(--bg-secondary));
    padding: 15px;
    position: relative;
    image-rendering: auto;
    min-height: 150px; /* Ensure minimum height */
    display: block; /* Ensure block display */
}

/* Weapon-specific thumbnail styles */
.weapons-thumbnail {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.05), var(--bg-secondary));
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

/* Special handling for weapon thumbnails that are wider */
.equipment-thumbnail.item-thumbnail {
    max-width: 90%;
    height: auto;
    max-height: 130px;
}

/* Ensure weapon thumbnail containers center properly */
.item-card[href*="equipment/weapons"] .item-thumbnail-container {
    padding: 10px;
}

/* Boss thumbnail enhancement */
.bosses-thumbnail {
    filter: brightness(1.1) contrast(1.1);
}

/* NPC thumbnail enhancement */
.npcs-thumbnail {
    filter: sepia(0.1) brightness(1.05);
}

/* Add blur backdrop for small images */
.item-thumbnail-container {
    position: relative;
    width: 100%;
    height: 150px;
    margin-bottom: 20px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-thumbnail-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(212, 175, 55, 0.1), transparent);
    z-index: 1;
}

.item-thumbnail-container .item-thumbnail {
    position: relative;
    z-index: 2;
    margin-bottom: 0;
}

.boss-thumbnail {
    width: 100%;
    height: 250px;
    object-fit: cover;
    margin-bottom: 20px;
    border-radius: 4px;
    filter: brightness(0.9);
    transition: filter var(--transition-base);
}

.item-card:hover .boss-thumbnail {
    filter: brightness(1.1);
}

/* Loading Animation for Images */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.image-loading-placeholder {
    background: linear-gradient(
        90deg,
        var(--bg-card) 0%,
        var(--bg-secondary) 50%,
        var(--bg-card) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
}

/* Responsive Images */
@media (max-width: 768px) {
    .boss-hero-banner {
        height: 250px;
    }
    
    .boss-portrait {
        width: 200px;
        height: 200px;
        margin-top: -100px;
    }
    
    .weapon-full-render,
    .item-full-image {
        padding: 20px;
    }
    
    .area-gallery {
        grid-template-columns: 1fr;
    }
}

/* Lightbox for Full Images */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.image-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    filter: drop-shadow(0 0 50px rgba(0, 0, 0, 0.8));
}

.lightbox-close {
    position: absolute;
    top: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--bg-card);
    border: 2px solid var(--ds-gold);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.lightbox-close:hover {
    transform: rotate(90deg);
    background: var(--ds-gold);
}

.lightbox-close::before,
.lightbox-close::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
}

.lightbox-close::before {
    transform: rotate(45deg);
}

.lightbox-close::after {
    transform: rotate(-45deg);
}