/**
 * POE Item Icon Display with Sockets
 * Based on The-Settle/Echo-Shop pattern: img + absolute overlay
 */

/* === Sprite sheet constants === */
:root {
    --tileW: 38px;      /* largeur d'une tuile sprite */
    --tileH: 35px;      /* hauteur d'une tuile sprite */
    --sheetW: 190px;    /* 5 * 38 */
    --sheetH: 175px;    /* 5 * 35 */
}

/* Container for item icon - use native image size */
.poe-icon {
    --cell: 47px; /* 1 inventory cell = 47px (for socket positioning) */
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    /* Container size will be determined by image natural size */
}

.poe-icon > img {
    position: relative;
    display: block;
    /* Use natural image size (no scaling) */
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
}

/* Sockets overlay container */
.poe-sockets {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

/* Sockets (cercle) */
.poe-socket {
    position: absolute;
    width: var(--tileH);
    height: var(--tileH);
    background-image: url('/app/assets/socket.png');
    background-repeat: no-repeat;
    background-size: var(--sheetW) var(--sheetH);
}

/* Mapping des couleurs - positions du sprite POE officiel */
.poe-socket--red {
    /* Str socket - position officielle: -140px 0px */
    background-position: -140px 0px;
}

.poe-socket--green {
    /* Dex socket - position officielle: -35px -105px */
    background-position: -35px -105px;
}

.poe-socket--blue {
    /* Int socket - position officielle: -105px 0px */
    background-position: -105px 0px;
}

.poe-socket--white {
    /* Gen socket (white) - position officielle: -140px -35px */
    background-position: -140px -35px;
}

.poe-socket--abyss {
    /* Abyss socket - position officielle: 0px -70px */
    background-position: 0px -70px;
}

/* Liens - utilise le sprite socket.png */
.poe-link {
    position: absolute;
    background-image: url('/app/assets/socket.png');
    background-repeat: no-repeat;
    background-size: var(--sheetW) var(--sheetH);
}

.poe-link--h {
    /* Lien horizontal - position officielle: -70px -140px */
    width: 38px;
    height: 15px;
    background-position: -70px -140px;
}

.poe-link--v {
    /* Lien vertical - position officielle: -175px 0px */
    width: 15px;
    height: 38px;
    background-position: -175px 0px;
}

/* Scale up in modal for better visibility */
.poe-icon--large {
    --cell: 70px;
}

/* Évite de changer background-size dans .poe-icon--large
   → on scale l'overlay, pas la sprite */
.poe-icon--large .poe-sockets {
    transform-origin: top left;
    transform: scale(calc(var(--cell) / 47)); /* 47 = cell par défaut */
}

/* Responsive scaling for smaller screens */
@media (max-width: 640px) {
    .poe-icon {
        --cell: 40px;
    }
    
    .poe-socket {
        width: 14px;
        height: 14px;
    }
    
    .poe-icon--large {
        --cell: 50px;
    }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .poe-socket {
        border-color: rgba(255, 255, 255, 0.3);
    }
}

/* === Hover-only sockets in cards === */
/* Hide sockets by default in cards, show only on hover */
.item-card .poe-sockets {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.item-card:hover .poe-sockets {
    opacity: 1;
}

/* Always show sockets in modal (no hover needed) */
#modal-root .poe-sockets {
    opacity: 1 !important;
}
