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

/* Health, Mana and Status Indicators */
.health-indicator, .mana-indicator {
    position: absolute;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    border-radius: 50%;
    z-index: 10;
    box-shadow: 0 0 8px rgba(238, 219, 241, 0.5);
    border: 2px solid rgba(238, 219, 241, 0.7);
    backdrop-filter: blur(3px);
    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: 253px; /* 10% larger (230px * 1.1) */
    height: 189px; /* 10% larger (172px * 1.1) */
    border-radius: 60px 60px 12px 12px; /* 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: 12px solid #8B4513; /* Thicker border */
    z-index: 10;
    /* Enhanced outer and inner shadows for stronger 3D effect */
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.5),
        /* Inner shadow to create 3D frame effect */
        inset 0 0 12px 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(-2px);
    box-shadow: 
        0 6px 12px rgba(238, 219, 241, 0.6),
        inset 0 0 12px 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: 50px 50px 8px 8px; /* Extremely rounded top inner corners, less rounded bottom inner corners */
    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: 50px 50px 8px 8px; /* Extremely rounded top inner corners, less rounded bottom inner corners */
    box-shadow: 
        inset 3px 3px 6px rgba(255, 255, 255, 0.3),
        inset -4px -4px 8px rgba(0, 0, 0, 0.5),
        inset 0 0 10px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 2;
}

#player-portrait {
    /* Bottom right corner positioning */
    position: fixed;
    bottom: 50px; /* Lifted up from bottom */
    right: 20px;
    /* 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: 50px; /* Lowered from top */
    right: 20px;
    /* 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 - 50% larger */
.health-indicator, .mana-indicator {
    width: 59px !important; /* 40% smaller (98px * 0.6) */
    height: 59px !important; /* 40% smaller (98px * 0.6) */
    min-width: 59px !important; /* Ensure minimum size */
    min-height: 59px !important; /* Ensure minimum size */
    border-radius: 50%;
    border: none; /* Removed purple border */
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.5), inset 0 0 6px 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 3px black, 0 0 5px rgba(0, 0, 0, 0.5) !important;
    font-size: 29px !important; /* 40% smaller font size (48px * 0.6) */
}

/* 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.png');
    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.png');
    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.png');
    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: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    z-index: 20; /* Increased z-index to ensure visibility */
}

#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: 0; /* Aligned with the bottom edge */
    right: 30%; /* Balanced position between hands and 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: 0; /* Aligned with the top edge */
    right: 30%; /* Balanced position between hands and edge */
    z-index: 5;
    overflow: visible;
    /* Removed negative margin that was causing cutoff */
}

/* Media queries for responsiveness - matching card media queries exactly */
@media screen and (min-width: 768px) {
    .health-indicator, .mana-indicator {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .deck-visual,
    #player-deck,
    #opponent-deck {
        width: 60px; /* Matches card size at this breakpoint */
        height: 88px; /* Matches card size at this breakpoint */
    }

    .deck-count {
        width: 22px;
        height: 22px;
        font-size: 12px;
    }
}

@media screen and (min-width: 1200px) {
    .health-indicator, .mana-indicator {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }

    .deck-visual,
    #player-deck,
    #opponent-deck {
        width: 70px; /* Matches card size at this breakpoint */
        height: 102px; /* Matches card size at this breakpoint */
    }

    .deck-count {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }
}
