/**
 * VECTOR Game v2.0 - Piece Styles
 * Piece rendering, state indicators, and animations
 */

/* ============================================
   PIECE CONTAINER
   ============================================ */
.piece {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: calc(var(--square-size) - 8px);
    height: calc(var(--square-size) - 8px);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform var(--transition-fast),
                box-shadow var(--transition-fast),
                filter var(--transition-fast);
    z-index: 10;
    user-select: none;
}

.piece:hover {
    transform: scale(1.05);
}

/* ============================================
   WHITE PIECES
   ============================================ */
.piece.white {
    background: linear-gradient(135deg, 
        rgba(74, 158, 255, 0.3) 0%, 
        rgba(74, 158, 255, 0.15) 100%);
    border: 2px solid var(--accent-blue);
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.2);
}

.piece.white:hover {
    box-shadow: var(--shadow-glow-blue);
}

/* ============================================
   BLACK PIECES
   ============================================ */
.piece.black {
    background: linear-gradient(135deg, 
        rgba(255, 107, 107, 0.3) 0%, 
        rgba(255, 107, 107, 0.15) 100%);
    border: 2px solid var(--accent-red);
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.2);
}

.piece.black:hover {
    box-shadow: var(--shadow-glow-red);
}

/* ============================================
   PIECE ICON
   ============================================ */
.piece-icon {
    width: 60%;
    height: 60%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.piece-icon svg {
    width: 100%;
    height: 100%;
}

.piece.white .piece-icon svg {
    fill: var(--accent-blue);
    stroke: var(--accent-blue);
}

.piece.black .piece-icon svg {
    fill: var(--accent-red);
    stroke: var(--accent-red);
}

/* ============================================
   PIECE TYPE LABEL
   ============================================ */
.piece-type {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.piece.white .piece-type {
    color: var(--accent-blue);
}

.piece.black .piece-type {
    color: var(--accent-red);
}

/* ============================================
   STATE BADGE (M/I)
   ============================================ */
.piece-state {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    font-weight: 700;
    border-radius: 50%;
    border: 1px solid;
}

/* Material state */
.piece-state.material {
    background: var(--bg-primary);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

/* Influence state */
.piece-state.influence {
    background: rgba(167, 139, 250, 0.3);
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

/* ============================================
   BLADE MODE INDICATOR (LANCE)
   ============================================ */
.piece-blade-mode {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
}

.blade-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-purple);
    opacity: 0.7;
}

/* ============================================
   SELECTED PIECE
   ============================================ */
.piece.selected {
    transform: scale(1.08);
    z-index: 20;
}

.piece.white.selected {
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.5),
                var(--shadow-glow-blue);
}

.piece.black.selected {
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.5),
                var(--shadow-glow-red);
}

/* ============================================
   MOVING PIECE
   ============================================ */
.piece.moving {
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1),
                left 300ms cubic-bezier(0.4, 0, 0.2, 1),
                top 300ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

/* ============================================
   COLLAPSING PIECE
   ============================================ */
.piece.collapsing {
    animation: collapsePiece 400ms ease-out forwards;
}

@keyframes collapsePiece {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    30% {
        transform: scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* ============================================
   PHASE SHIFTING PIECE
   ============================================ */
.piece.phase-shifting {
    animation: phaseShift 500ms ease-out;
}

@keyframes phaseShift {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    30% {
        transform: scale(1.15);
        filter: brightness(1.3);
    }
    60% {
        transform: scale(0.95);
        filter: brightness(1.5) hue-rotate(30deg);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

/* ============================================
   PIECE ENTRANCE ANIMATION
   ============================================ */
.piece.entering {
    animation: pieceEnter 300ms ease-out;
}

@keyframes pieceEnter {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* ============================================
   PIECE TYPES - SPECIFIC STYLING
   ============================================ */

/* Core - Special styling for the most important piece */
.piece.core .piece-icon svg {
    stroke-width: 2;
}

/* Guardian */
.piece.guardian {
    /* Slightly different border */
    border-width: 3px;
}

/* Field */
.piece.field .piece-icon {
    opacity: 0.9;
}

/* Lance */
.piece.lance .piece-icon svg {
    stroke-width: 1.5;
}

/* Drone */
.piece.drone {
    /* Smaller visual presence */
    opacity: 0.95;
}

/* ============================================
   THREAT INDICATOR
   ============================================ */
.piece-threat {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 0.5rem;
    font-weight: 700;
    color: var(--accent-red);
    text-shadow: 0 0 4px rgba(255, 107, 107, 0.5);
}

/* ============================================
   GHOST PIECE (for drag preview)
   ============================================ */
.piece.ghost {
    opacity: 0.5;
    pointer-events: none;
}

/* ============================================
   PROMOTED PIECE INDICATOR
   ============================================ */
.piece.promoted::after {
    content: '★';
    position: absolute;
    top: -6px;
    left: -6px;
    font-size: 0.625rem;
    color: var(--accent-gold);
    text-shadow: 0 0 4px rgba(255, 200, 87, 0.5);
}

/* ============================================
   PIECE INFLUENCE LINES (optional visualization)
   ============================================ */
.influence-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.influence-line {
    position: absolute;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(74, 158, 255, 0.3) 50%, 
        transparent 100%);
    height: 2px;
    transform-origin: left center;
}

.piece.black ~ .influence-line {
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 107, 107, 0.3) 50%, 
        transparent 100%);
}

/* ============================================
   RESPONSIVE PIECE SIZING
   ============================================ */
@media (max-width: 768px) {
    .piece {
        width: calc(var(--square-size) - 6px);
        height: calc(var(--square-size) - 6px);
    }
    
    .piece-type {
        font-size: 0.5rem;
    }
    
    .piece-state {
        width: 14px;
        height: 14px;
        font-size: 0.4rem;
    }
}

@media (max-width: 480px) {
    .piece {
        width: calc(var(--square-size) - 4px);
        height: calc(var(--square-size) - 4px);
        border-width: 1px;
    }
    
    .piece-type {
        display: none;
    }
    
    .piece-state {
        width: 12px;
        height: 12px;
        top: -2px;
        right: -2px;
    }
}

/* ============================================
   PIECE SVG ICONS (inline definitions)
   ============================================ */

/* Core Icon - Hexagon with center dot */
.icon-core {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Guardian Icon - Shield shape */
.icon-guardian {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Field Icon - Diamond with cross */
.icon-field {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Lance Icon - Arrow/spear */
.icon-lance {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Drone Icon - Simple dot or circle */
.icon-drone {
    fill: none;
    stroke-width: 2;
}