/* Compact Modern Lootbox Shop Styling */

#lootboxes-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: 16px;
    padding: 10px 0;
    min-width: 0;
    box-sizing: border-box;
    overflow: visible;
}

.lootbox-item {
    background: linear-gradient(145deg, #1a1d2e 0%, #16192b 100%);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    position: relative;
    backdrop-filter: blur(10px);
    height: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* Tooltips use position:absolute with z-index; card stays clipped but hovered card elevates */
.shop-item.lootbox-item { overflow: hidden; }
.shop-item.lootbox-item .item-info { overflow: visible; min-width: 0; }
.shop-item.lootbox-item .lootbox-contents { overflow: visible; }
.shop-item.lootbox-item .lootbox-contents-preview { overflow: visible; }
.shop-item.lootbox-item:hover { z-index: 10; overflow: visible; }

/* Shop layout wrapper (defined inline in shop.html) clips tooltips; unclip for lootboxes only */
#lootboxes-section .shop-section-layout { overflow: visible !important; }

@media (max-width: 768px) {
    /* Mobile/touch has no true hover; allow tooltip overflow without requiring :hover */
    #lootboxes-container {
        overflow: visible;
    }

    .shop-item.lootbox-item,
    .shop-item.lootbox-item .item-info,
    .shop-item.lootbox-item .lootbox-contents,
    .shop-item.lootbox-item .lootbox-contents-preview {
        overflow: visible !important;
    }
}


.lootbox-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(252, 157, 11, 0.5), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lootbox-item:hover::before {
    opacity: 1;
}

.lootbox-item:hover {
    transform: translateY(-5px) scale(1.01);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    border-color: rgba(252, 157, 11, 0.3);
}

/* Rarity-based borders */
.lootbox-item.lootbox-common {
    border-color: rgba(170, 170, 170, 0.4);
}

.lootbox-item.lootbox-common:hover {
    border-color: rgba(170, 170, 170, 0.8);
    box-shadow: 0 8px 20px rgba(170, 170, 170, 0.2);
}

.lootbox-item.lootbox-uncommon {
    border-color: rgba(76, 175, 80, 0.4);
}

.lootbox-item.lootbox-uncommon:hover {
    border-color: rgba(76, 175, 80, 0.8);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.2);
}

.lootbox-item.lootbox-rare {
    border-color: rgba(33, 150, 243, 0.4);
}

.lootbox-item.lootbox-rare:hover {
    border-color: rgba(33, 150, 243, 0.8);
    box-shadow: 0 8px 20px rgba(33, 150, 243, 0.2);
}

.lootbox-item.lootbox-epic {
    border-color: rgba(156, 39, 176, 0.4);
}

.lootbox-item.lootbox-epic:hover {
    border-color: rgba(156, 39, 176, 0.8);
    box-shadow: 0 8px 20px rgba(156, 39, 176, 0.2);
}

.lootbox-item.lootbox-legendary {
    border-color: rgba(255, 152, 0, 0.4);
    /* Animation only on hover for performance */
}

.lootbox-item.lootbox-legendary:hover {
    border-color: rgba(255, 152, 0, 0.9);
    box-shadow: 0 8px 25px rgba(255, 152, 0, 0.3);
    animation: legendary-pulse 2s ease-in-out infinite;
}

@keyframes legendary-pulse {
    0%, 100% {
        box-shadow: 0 0 5px rgba(255, 152, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 15px rgba(255, 152, 0, 0.6);
    }
}

/* Icon container - Compact */
.lootbox-item .lootbox-icon-container {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(30, 35, 50, 0.6) 0%, rgba(20, 25, 40, 0.9) 100%);
    position: relative;
    overflow: hidden;
}

.lootbox-item .lootbox-icon-container::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(252, 157, 11, 0.08) 0%, transparent 70%);
    /* animation removed for performance */
}

.lootbox-icon {
    font-size: 2.5rem;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

/* Rarity-specific icon colors */
.lootbox-icon.common { color: #aaaaaa; }
.lootbox-icon.uncommon { color: #4caf50; }
.lootbox-icon.rare { color: #2196f3; }
.lootbox-icon.epic { color: #9c27b0; }
.lootbox-icon.legendary {
    color: #ff9800;
    filter: drop-shadow(0 0 8px rgba(255, 152, 0, 0.6));
}

/* Rarity badge - Compact */
.lootbox-rarity-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.8px;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 2;
}

.lootbox-rarity-badge.common {
    background: rgba(170, 170, 170, 0.2);
    color: #bbb;
    border: 1px solid rgba(170, 170, 170, 0.4);
}
.lootbox-rarity-badge.uncommon {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.4);
}
.lootbox-rarity-badge.rare {
    background: rgba(33, 150, 243, 0.2);
    color: #2196f3;
    border: 1px solid rgba(33, 150, 243, 0.4);
}
.lootbox-rarity-badge.epic {
    background: rgba(156, 39, 176, 0.2);
    color: #c77dff;
    border: 1px solid rgba(156, 39, 176, 0.4);
}
.lootbox-rarity-badge.legendary {
    background: rgba(255, 152, 0, 0.2);
    color: #ffa726;
    border: 1px solid rgba(255, 152, 0, 0.4);
    /* Animation on hover only for performance */
}

.lootbox-item:hover .lootbox-rarity-badge.legendary {
    animation: legendary-badge-glow 2s ease-in-out infinite;
}

@keyframes legendary-badge-glow {
    0%, 100% { box-shadow: 0 2px 10px rgba(255, 152, 0, 0.3); }
    50% { box-shadow: 0 2px 20px rgba(255, 152, 0, 0.6); }
}

/* Item info section - Compact */
.lootbox-item .item-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    z-index: 2;
    min-width: 0;
    overflow: hidden;
}

.lootbox-item .item-info h3 {
    margin: 0;
    font-size: 1.05rem;
    color: #fff;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 0;
    min-width: 0;
}

.lootbox-item .item-description {
    color: #a8adb7;
    font-size: 0.8rem;
    line-height: 1.4;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    min-width: 0;
}

/* Lootbox stats section */
.lootbox-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin: 10px 0 8px 0;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    border: 1px solid rgba(252, 157, 11, 0.1);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px;
    text-align: center;
}

.stat-item i {
    font-size: 0.9rem;
    color: #fc9d0b;
    opacity: 0.8;
}

.stat-item span {
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.stat-item:hover i {
    opacity: 1;
    transform: scale(1.1);
    transition: all 0.2s ease;
}

/* Price and action section - Compact */
.item-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid rgba(252, 157, 11, 0.1);
    min-width: 0;
    gap: 6px;
    flex-wrap: wrap;
}

.price {
    font-weight: 700;
    font-size: 1.15rem;
    background: linear-gradient(135deg, #fc9d0b 0%, #e68a00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.buy-btn {
    padding: 7px 14px;
    background: linear-gradient(135deg, #fc9d0b 0%, #e68a00 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 3px 12px rgba(252, 157, 11, 0.3);
    position: relative;
    overflow: hidden;
}

.buy-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.buy-btn:hover::before {
    width: 300px;
    height: 300px;
}

.buy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(252, 157, 11, 0.5);
}

.buy-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(252, 157, 11, 0.4);
}

/* Contents preview - Rarity Cubes */
.lootbox-contents {
    margin-top: 8px;
    position: relative;
    z-index: 1;
}

.lootbox-contents h4 {
    font-size: 0.75rem;
    color: #a8adb7;
    margin: 0 0 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lootbox-contents-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
    position: relative;
    z-index: 20;
}

/* Ensure tooltips are not clipped by parent containers */
.lootbox-contents,
.lootbox-contents-preview {
  overflow: visible;
}

/* Elevate hovered card so tooltip layers above neighbors */
.shop-item.lootbox-item:hover {
  z-index: 10;
}


.rarity-cube {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: help;
    transition: all 0.2s ease;
    position: relative;
    border: 1.5px solid;
}

.rarity-cube:hover {
    transform: scale(1.15);
    z-index: 10;
}

/* Rarity-based cube colors */
.rarity-cube.common {
    background: rgba(170, 170, 170, 0.15);
    border-color: rgba(170, 170, 170, 0.4);
    color: #aaa;
}

.rarity-cube.uncommon {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.4);
    color: #4caf50;
}

.rarity-cube.rare {
    background: rgba(33, 150, 243, 0.15);
    border-color: rgba(33, 150, 243, 0.4);
    color: #2196f3;
}

.rarity-cube.epic {
    background: rgba(156, 39, 176, 0.15);
    border-color: rgba(156, 39, 176, 0.4);
    color: #9c27b0;
}

.rarity-cube.legendary {
    background: rgba(255, 152, 0, 0.15);
    border-color: rgba(255, 152, 0, 0.4);
    color: #ff9800;
    /* Animation on hover only for performance */
}

.rarity-cube.legendary:hover,
.lootbox-item:hover .rarity-cube.legendary {
    animation: legendary-cube-glow 2s ease-in-out infinite;
}

@keyframes legendary-cube-glow {
    0%, 100% { box-shadow: 0 0 4px rgba(255, 152, 0, 0.3); }
    50% { box-shadow: 0 0 10px rgba(255, 152, 0, 0.6); }
}

.rarity-cube.mythic {
    background: rgba(186, 85, 211, 0.25);
    border-color: rgba(186, 85, 211, 0.6);
    color: #ba55d3;
    /* Animation on hover only for performance */
}

.rarity-cube.mythic:hover,
.lootbox-item:hover .rarity-cube.mythic {
    animation: mythic-cube-glow 1.5s ease-in-out infinite;
}

@keyframes mythic-cube-glow {
    0%, 100% { box-shadow: 0 0 6px rgba(186, 85, 211, 0.5), inset 0 0 6px rgba(186, 85, 211, 0.2); }
    50% { box-shadow: 0 0 14px rgba(186, 85, 211, 0.8), inset 0 0 8px rgba(186, 85, 211, 0.4); }
}

.rarity-cube.ascendant {
    background: rgba(0, 212, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.6);
    color: #00d4ff;
    /* Animation on hover only for performance */
}

.rarity-cube.ascendant:hover,
.lootbox-item:hover .rarity-cube.ascendant {
    animation: ascendant-cube-glow 1.5s ease-in-out infinite;
}

@keyframes ascendant-cube-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(0, 212, 255, 0.5), inset 0 0 6px rgba(0, 255, 204, 0.2); }
    50% { box-shadow: 0 0 18px rgba(0, 212, 255, 0.9), inset 0 0 10px rgba(0, 255, 204, 0.4); }
}

.rarity-cube.transcendent {
    background: linear-gradient(135deg, rgba(255, 0, 255, 0.25), rgba(128, 0, 255, 0.2));
    border-color: rgba(255, 0, 255, 0.7);
    color: #ff00ff;
    /* Animation on hover only for performance */
}

.rarity-cube.transcendent:hover,
.lootbox-item:hover .rarity-cube.transcendent {
    animation: transcendent-cube-glow 1s ease-in-out infinite;
}

@keyframes transcendent-cube-glow {
    0%, 100% { 
        box-shadow: 0 0 10px rgba(255, 0, 255, 0.6), 0 0 20px rgba(128, 0, 255, 0.3), inset 0 0 8px rgba(255, 0, 255, 0.2);
        filter: hue-rotate(0deg);
    }
    50% { 
        box-shadow: 0 0 20px rgba(255, 0, 255, 1), 0 0 40px rgba(128, 0, 255, 0.6), inset 0 0 12px rgba(255, 0, 255, 0.4);
        filter: hue-rotate(30deg);
    }
}

/* Tooltip on hover - Fixed to appear on top */
.rarity-cube::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: rgba(15, 15, 25, 0.98);
    border: 1px solid rgba(252, 157, 11, 0.4);
    border-radius: 6px;
    font-size: 0.7rem;
    white-space: nowrap;
    color: #fff;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7);
}

.rarity-cube::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid rgba(252, 157, 11, 0.4);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 9999;
}

.rarity-cube:hover::after,
.rarity-cube:hover::before {
    opacity: 1;
}

@media (max-width: 768px) {
    /* On mobile, render tooltip as a fixed bottom sheet so it's never clipped */
    .rarity-cube::after,
    .rarity-cube[data-tooltip]:hover::after {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(14px + env(safe-area-inset-bottom));
        top: auto;
        transform: none;
        max-width: none;
        min-width: 0;
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
        padding: 10px 12px;
        font-size: 11px;
        line-height: 1.35;
        z-index: 2147483647;
    }

    .rarity-cube::before {
        display: none;
    }

    /* Show tooltip while pressing (touch) */
    .rarity-cube:active::after {
        opacity: 1;
    }
}

/* Tooltip for rarity-cube - force wrapping and larger box */
.rarity-cube[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    top: -44px;
    transform: translateX(-50%);
    background: rgba(30,30,40,0.98);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.85em;
    box-shadow: 0 4px 18px rgba(0,0,0,0.25);
    z-index: 9999;
    pointer-events: none;
    min-width: 180px;
    max-width: 340px;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    white-space: normal;
}

/* Stranger lootbox: show tooltips on hover only */
.lootbox-item.stranger-things-box:hover,
.lootbox-item.stranger-things-box:hover .lootbox-contents-preview {
    overflow: visible;
}

/* Old text-based content items - keep for backwards compatibility */
.content-item {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    background: rgba(30, 30, 30, 0.7);
}

.content-item.common { color: #aaa; }
.content-item.uncommon { color: #4caf50; }
.content-item.rare { color: #2196f3; }
.content-item.epic { color: #9c27b0; }
.content-item.legendary { color: #ff9800; }
.content-item.mythic { color: #ff3b30; }
.content-item.ascendant { color: #00d4ff; }
.content-item.transcendent { color: #ff00ff; }

/* Loading state */
.loading-spinner {
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 3px solid rgba(252, 157, 11, 0.2);
    border-radius: 50%;
    border-top-color: #fc9d0b;
    animation: spin 1s ease-in-out infinite;
    margin: 40px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive adjustments - Compact */
@media (max-width: 1024px) {
    #lootboxes-container {
        grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
        gap: 14px;
    }
}

@media (max-width: 768px) {
    #lootboxes-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .lootbox-item .lootbox-icon-container {
        height: 90px;
    }

    .lootbox-icon {
        font-size: 2.2rem;
    }

    .item-info {
        padding: 10px;
    }

    .item-info h3 {
        font-size: 0.95rem;
    }

    .item-description {
        font-size: 0.75rem;
        min-height: 28px;
    }

    .buy-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .price {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    #lootboxes-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 10px 0;
    }

    .lootbox-item .lootbox-icon-container {
        height: 85px;
    }

    .lootbox-icon {
        font-size: 2rem;
    }

    .lootbox-rarity-badge {
        font-size: 0.6rem;
        padding: 3px 8px;
    }
}
