/* Game Indicators for Health, Mana and Deck */

/* Health, Mana and Status Indicators */
.health-indicator,
.mana-indicator {
    width: 9.4vmin;
    height: 9.4vmin;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 4.6vmin;
    color: #fff;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 20;
    position: relative;
    transition: all 0.3s ease;
}

.health-indicator {
    background-color: rgba(180, 0, 0, 0.7);
    color: #fff;
}

.mana-indicator {
    background-color: rgba(0, 60, 180, 0.7);
    color: #eedbf1;
}

/* Portrait positioning */
/* 3D player portrait with rounded wooden frame - even wider */
.player-portrait {
    position: absolute;
    width: 31vmin;
    /* Slightly smaller portrait width */
    height: 23vmin;
    /* Slightly smaller portrait height */
    border-radius: 8.76vmin 8.76vmin 1.75vmin 1.75vmin;
    /* Extremely rounded top corners, less rounded bottom corners */
    background-size: cover;
    background-position: center top;
    /* Crop from bottom by positioning at top */
    /* Fix for image rendering issues at small sizes */
    image-rendering: auto;
    /* Standard rendering */
    transform: translateZ(0);
    /* Force GPU acceleration */
    -webkit-backface-visibility: hidden;
    /* Fix for Safari */
    -moz-backface-visibility: hidden;
    backface-visibility: hidden;
    filter: none;
    /* Remove filters that might cause issues */
    /* Wooden frame border */
    border: 1.11vmin solid #8B4513;
    /* Thicker border (12px -> 1.11vmin) */
    z-index: 10;
    /* Enhanced outer and inner shadows for stronger 3D effect */
    box-shadow:
        0 0.37vmin 0.74vmin rgba(0, 0, 0, 0.5),
        /* Inner shadow to create 3D frame effect */
        inset 0 0 1.11vmin rgba(0, 0, 0, 0.7);

    /* Position settings */
    position: relative;
    overflow: hidden;
    /* Keep the image within the rounded corners */
    transition: all 0.3s ease;
    /* Ensure visibility */
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    /* Fix positioning issues */
    position: absolute !important;
    margin: 0 !important;
}

/* Portrait shake animation with variable amplitude */
@keyframes portrait-shake {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    15% {
        transform: translate(calc(var(--portrait-shake-amp, 6px) * -1), calc(var(--portrait-shake-amp, 6px) * -0.3)) rotate(-1deg);
    }

    30% {
        transform: translate(calc(var(--portrait-shake-amp, 6px) * 0.8), calc(var(--portrait-shake-amp, 6px) * 0.4)) rotate(1deg);
    }

    45% {
        transform: translate(calc(var(--portrait-shake-amp, 6px) * -0.6), calc(var(--portrait-shake-amp, 6px) * 0.6)) rotate(-0.8deg);
    }

    60% {
        transform: translate(calc(var(--portrait-shake-amp, 6px) * 0.5), calc(var(--portrait-shake-amp, 6px) * -0.4)) rotate(0.8deg);
    }

    75% {
        transform: translate(calc(var(--portrait-shake-amp, 6px) * -0.3), calc(var(--portrait-shake-amp, 6px) * 0.3)) rotate(-0.5deg);
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

.player-portrait.portrait-shake {
    animation: portrait-shake 500ms ease-in-out;
    will-change: transform;
}

/* Tint overlay for damage/heal on portraits */
/* Removed portrait tint overlays (red/green flashes) */



/* Enlarged invisible hitbox for easier drag-and-drop */
.portrait-hitbox {
    position: fixed;
    background: transparent;
    pointer-events: auto;
    /* Must capture drag events */
}

/* Hover effect with purple haze and enhanced shadows */
.player-portrait:hover {
    transform: translateY(-0.2vmin);
    box-shadow:
        0 0.56vmin 1.11vmin rgba(238, 219, 241, 0.6),
        inset 0 0 1.11vmin rgba(0, 0, 0, 0.7);
}

/* Purple haze effect on hover */
.player-portrait::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, rgba(238, 219, 241, 0.2) 0%, rgba(238, 219, 241, 0) 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border-radius: 7.65vmin 7.65vmin 0.64vmin 0.64vmin;
    /* Calculated inner radius: 8.76 - 1.11 = 7.65, 1.75 - 1.11 = 0.64 */
    z-index: 3;
    /* Above the inner shadow */
}

.player-portrait:hover::after {
    opacity: 1;
}

/* Enhanced inner frame shadow overlay for stronger 3D effect */
.player-portrait::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 7.65vmin 7.65vmin 0.64vmin 0.64vmin;
    /* Calculated inner radius */
    box-shadow:
        inset 0.28vmin 0.28vmin 0.56vmin rgba(255, 255, 255, 0.3),
        inset -0.37vmin -0.37vmin 0.74vmin rgba(0, 0, 0, 0.5),
        inset 0 0 0.93vmin rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 2;
}

#player-portrait {
    /* Bottom right corner positioning */
    position: fixed;
    bottom: 3vmin;
    /* Lifted up from bottom, scales with viewport */
    right: 3vmin;
    /* Ensure visibility */
    opacity: 1;
    visibility: visible;
    /* Important: Do NOT clip indicators */
    overflow: visible;
    z-index: 15;
    /* Higher z-index to ensure visibility */
}

#opponent-portrait {
    /* Top right corner positioning */
    position: fixed;
    top: 3vmin;
    /* Offset from top, scales with viewport */
    right: 3vmin;
    /* Ensure visibility */
    opacity: 1;
    visibility: visible;
    /* Important: Do NOT clip indicators */
    overflow: visible;
    z-index: 15;
    /* Higher z-index to ensure visibility */
}

/* Player area positioning */
.player-area {
    position: relative;
    z-index: 10;
    overflow: visible !important;
    /* Ensure indicators can stick out */
}

/* Portrait container positioning - corners of the screen */
.portrait-container {
    position: fixed;
    z-index: 15;
    display: flex;
    justify-content: center;
    align-items: center;
}

#player-portrait-container {
    bottom: 20px;
    right: 20px;
}

#opponent-portrait-container {
    top: 20px;
    right: 20px;
}

/* Health and mana indicators base styling */
.health-indicator,
.mana-indicator {
    width: 9.4vmin !important;
    /* Slightly smaller indicators */
    height: 9.4vmin !important;
    min-width: 9.4vmin !important;
    min-height: 9.4vmin !important;
    border-radius: 50%;
    border: none;
    /* Removed purple border */
    box-shadow: 0 0 1.11vmin rgba(0, 0, 0, 0.5), inset 0 0 0.56vmin rgba(255, 255, 255, 0.2);
    z-index: 20;
    /* Higher than portraits to be visible when sticking out */
    /* Ensure indicators are styled correctly */
    position: absolute !important;
    margin: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    font-weight: bold !important;
    color: white !important;
    text-shadow: 0 0 0.28vmin black, 0 0 0.46vmin rgba(0, 0, 0, 0.5) !important;
    font-size: 4.6vmin !important;
}

/* Health indicator specific styling */
.health-indicator {
    background-color: rgba(180, 0, 0, 0.7) !important;
    /* Red background for health */
}

/* Mana indicator specific styling */
.mana-indicator {
    background-color: rgba(0, 60, 180, 0.7) !important;
    /* Blue background for mana */
}

/* Position for player health indicator - adjusted for larger size */
#player-health-indicator {
    bottom: 5px;
    /* Adjusted for larger indicator */
    right: 5px;
    /* Adjusted for larger indicator */
    transform: translate(50%, 50%);
    /* Position half outside */
}

/* Position for opponent health indicator - adjusted for larger size */
#opponent-health-indicator {
    bottom: 5px;
    /* Adjusted for larger indicator */
    right: 5px;
    /* Adjusted for larger indicator */
    transform: translate(50%, 50%);
    /* Position half outside */
}

/* Position for player mana indicator - adjusted for larger size */
#player-mana-indicator {
    bottom: 5px;
    /* Adjusted for larger indicator */
    left: 5px;
    /* Adjusted for larger indicator */
    transform: translate(-50%, 50%);
    /* Position half outside */
    position: absolute !important;
}

/* Position for opponent mana indicator - adjusted for larger size */
#opponent-mana-indicator {
    bottom: 5px;
    /* Adjusted for larger indicator */
    left: 5px;
    /* Adjusted for larger indicator */
    transform: translate(-50%, 50%);
    /* Position half outside */
    position: absolute !important;
}

/* Deck Visualization */
.deck-visual,
#player-deck,
#opponent-deck {
    position: relative;
    width: var(--card-width);
    /* Match card width */
    height: var(--card-height);
    /* Match card height */
    background-image: url('../assets/images/cardback.webp');
    background-size: cover;
    background-position: center;
    border-radius: 0;
    box-shadow: 0 0 8px rgba(238, 219, 241, 0.5);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(238, 219, 241, 0.3);
    z-index: 10;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: visible;
    margin: 0 20px;
}

/* Ensure parent containers don't clip content */
#player-area,
#opponent-area,
.player-area,
.opponent-area,
.board-container,
.hand-container,
#game-view {
    overflow: visible;
}

/* Stacked card effect with pseudo-elements */
.deck-visual::before,
#player-deck::before,
#opponent-deck::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    width: 100%;
    height: 100%;
    background-image: url('../assets/images/cardback.webp');
    background-size: cover;
    background-position: center;
    border-radius: 0;
    border: 1px solid rgba(238, 219, 241, 0.3);
    z-index: -1;
    /* Behind main element */
    box-sizing: border-box;
}

.deck-visual::after,
#player-deck::after,
#opponent-deck::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    width: 100%;
    height: 100%;
    background-image: url('../assets/images/cardback.webp');
    background-size: cover;
    background-position: center;
    border-radius: 0;
    border: 1px solid rgba(238, 219, 241, 0.3);
    z-index: -2;
    /* Behind ::before */
    box-sizing: border-box;
}

.deck-visual:hover,
#player-deck:hover,
#opponent-deck:hover {
    box-shadow: 0 0 12px rgba(238, 219, 241, 0.8);
    transform: rotate(-5deg) translateY(-3px);
}

/* Ensure pseudo-elements (stacked cards) stay put during hover */
/* Ensure pseudo-elements (stacked cards) stay put during hover */
.deck-visual:hover::before,
#player-deck:hover::before,
#opponent-deck:hover::before,
.deck-visual:hover::after,
#player-deck:hover::after,
#opponent-deck:hover::after {
    transform: rotate(0) translateY(0);
}

.deck-count {
    position: absolute;
    bottom: -8px;
    right: -8px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #eedbf1;
    border: 1px solid rgba(238, 219, 241, 0.5);
    border-radius: 50%;
    width: 6.74vmin;
    height: 6.74vmin;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3.57vmin;
    font-weight: bold;
    z-index: 20;
    /* Increased z-index to ensure visibility */
}

/* Position player's deck count at the top so it's visible when deck is cut off */
#player-deck .deck-count {
    top: -1.59vmin;
    bottom: auto;
}

#player-deck,
#opponent-deck {
    /* Ensure decks are visually above hand containers for drop events */
    z-index: 15;
    position: relative;
    /* z-index requires a position other than static */
}

/* Player/Opponent deck wrapper positioning - balanced distance from hands */
#player-deck-wrapper {
    position: absolute;
    bottom: -8.91vmin;
    /* Aligned with the bottom edge, cut off like cards */
    right: 21%;
    /* Slightly closer to the right edge */
    z-index: 5;
    overflow: visible;
    /* Removed negative margin that was causing cutoff */
}

/* Completely remove wrapper height constraints and let content determine size */
#opponent-deck-wrapper {
    position: absolute;
    top: -8.91vmin;
    /* Aligned with the top edge, cut off like cards */
    right: 21%;
    /* Slightly closer to the right edge */
    z-index: 5;
    overflow: visible;
    /* Removed negative margin that was causing cutoff */
}