/**
 * Poke Royale - Base Styles
 * Section 2: CSS Variables & Base Styles
 * Contains: CSS custom properties, body layout, arena styling, torches, ambient animations
 */

@import url('https://fonts.googleapis.com/css2?family=Bangers&family=Rubik:wght@400;600;700;900&display=swap');

/* ===== CSS Custom Properties ===== */
:root {
    --pokemon-red: #CC0000;
    --pokemon-blue: #3B4CCA;
    --pokemon-yellow: #FFDE00;
    --pokemon-gold: #B3A125;
}

/* ===== Reset & Base ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Rubik', sans-serif;
    background: #0a0a12;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    padding: 20px 0;
}

/* ===== Game Container ===== */
#game-container {
    position: relative;
    width: 100%;
    max-width: 414px;
    height: calc(100vh - 40px);
    max-height: 700px;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 0 40px rgba(0,0,0,0.8);
}

/* ===== Arena ===== */
#arena {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100% - 140px);
    background: 
        /* Grid pattern overlay */
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 30px,
            rgba(0,0,0,0.05) 30px,
            rgba(0,0,0,0.05) 31px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 30px,
            rgba(0,0,0,0.05) 30px,
            rgba(0,0,0,0.05) 31px
        ),
        /* Team zones with rich colors */
        linear-gradient(180deg, 
            #8b2942 0%,
            #a63d58 3%,
            #2d5a3d 8%,
            #3a7a52 18%,
            #4a9a68 35%,
            #3a8a5a 42%,
            #2563eb 46%,
            #3b82f6 48%,
            #60a5fa 50%,
            #3b82f6 52%,
            #2563eb 54%,
            #3a8a5a 58%,
            #4a9a68 65%,
            #3a7a52 82%,
            #2d5a3d 92%,
            #1e4b6e 97%,
            #2563eb 100%
        );
    overflow: hidden;
    /* 3D perspective for depth */
    perspective: 1000px;
    transform-style: preserve-3d;
    /* Premium vignette and inner glow */
    box-shadow: 
        inset 0 0 120px rgba(0,0,0,0.4),
        inset 0 -50px 80px rgba(37, 99, 235, 0.15),
        inset 0 50px 80px rgba(139, 41, 66, 0.15);
    border: 4px solid #1a1a2e;
    border-radius: 8px 8px 0 0;
}

/* Arena outer frame */
#arena-frame {
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: 132px;
    border: 8px solid;
    border-image: linear-gradient(180deg, #4a3a2a 0%, #2a2a1a 50%, #3a3a2a 100%) 1;
    pointer-events: none;
    z-index: 200;
    border-radius: 12px;
}

/* 3D tilt effect on units */
.pokemon {
    transform-style: preserve-3d;
}

/* Scale units based on Y position for perspective */
.pokemon .pokemon-sprite {
    transition: transform 0.08s linear;
}

/* ===== Decorative Torches ===== */
.arena-torch {
    position: absolute;
    width: 24px;
    height: 40px;
    z-index: 50;
    pointer-events: none;
}

.arena-torch::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 24px;
    background: linear-gradient(180deg, #5a4a3a 0%, #3a2a1a 100%);
    border-radius: 2px;
}

.arena-torch::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 20px;
    background: radial-gradient(ellipse at 50% 70%, #ff6b35 0%, #ff4500 40%, #dc2626 70%, transparent 100%);
    border-radius: 50% 50% 30% 30%;
    animation: torch-flicker 0.3s ease-in-out infinite;
    box-shadow: 0 0 20px #ff6b35, 0 0 40px #ff4500, 0 -10px 30px rgba(255, 107, 53, 0.5);
}

.arena-torch.left-top { top: 5%; left: 5px; }
.arena-torch.right-top { top: 5%; right: 5px; }
.arena-torch.left-mid { top: 40%; left: 5px; }
.arena-torch.right-mid { top: 40%; right: 5px; }
.arena-torch.left-bottom { bottom: 15%; left: 5px; }
.arena-torch.right-bottom { bottom: 15%; right: 5px; }

@keyframes torch-flicker {
    0%, 100% { transform: translateX(-50%) scaleY(1) scaleX(1); opacity: 1; }
    25% { transform: translateX(-50%) scaleY(1.1) scaleX(0.9); opacity: 0.9; }
    50% { transform: translateX(-50%) scaleY(0.95) scaleX(1.05); opacity: 1; }
    75% { transform: translateX(-50%) scaleY(1.05) scaleX(0.95); opacity: 0.95; }
}

/* ===== Grass Texture & Ambient Effects ===== */
#arena::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 24px,
            rgba(0,0,0,0.03) 24px,
            rgba(0,0,0,0.03) 48px
        );
    pointer-events: none;
    animation: grass-sway 8s ease-in-out infinite;
}

@keyframes grass-sway {
    0%, 100% { background-position: 0 0; }
    50% { background-position: 5px 0; }
}

/* Attack burst effect */
@keyframes attack-burst {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

/* Dynamic arena lighting */
#arena::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(ellipse at 50% 30%, rgba(255,255,200,0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 20% 80%, rgba(100,200,100,0.05) 0%, transparent 40%),
                radial-gradient(ellipse at 80% 80%, rgba(100,200,100,0.05) 0%, transparent 40%);
    pointer-events: none;
    animation: arena-ambience 10s ease-in-out infinite alternate;
}

@keyframes arena-ambience {
    0% { opacity: 0.8; }
    100% { opacity: 1; }
}

/* ===== Animated Particles ===== */
.arena-particles {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 3;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 200, 0.6);
    border-radius: 50%;
    animation: float-particle 15s linear infinite;
}

@keyframes float-particle {
    0% { transform: translateY(100%) translateX(0); opacity: 0; }
    10% { opacity: 0.8; }
    90% { opacity: 0.8; }
    100% { transform: translateY(-100%) translateX(100px); opacity: 0; }
}

/* ===== River & Bridges ===== */
.river-overlay {
    position: absolute;
    top: 45%;
    left: 0;
    width: 100%;
    height: 10%;
    background: linear-gradient(90deg, 
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.15) 25%,
        rgba(255,255,255,0.25) 50%,
        rgba(255,255,255,0.15) 75%,
        rgba(255,255,255,0) 100%
    );
    animation: shimmer 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes shimmer {
    0%, 100% { transform: translateX(-100%); opacity: 0.5; }
    50% { transform: translateX(100%); opacity: 1; }
}

/* Bridges - wooden with detail */
.bridge {
    position: absolute;
    top: 43%;
    width: 75px;
    height: 14%;
    background: 
        repeating-linear-gradient(
            90deg,
            #7a6245 0px,
            #7a6245 12px,
            #6b5344 12px,
            #6b5344 14px
        ),
        linear-gradient(180deg, #9a8060 0%, #8B7355 20%, #7a6245 80%, #6b5344 100%);
    border: 3px solid #5a4535;
    border-radius: 4px;
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 2px 0 rgba(255,255,255,0.15);
}

.bridge.left { left: 25px; }
.bridge.right { right: 25px; }

.bridge::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 10px,
        rgba(0,0,0,0.12) 10px,
        rgba(0,0,0,0.12) 12px
    );
    border-radius: 2px;
}

.bridge::after {
    content: '';
    position: absolute;
    left: -4px; right: -4px;
    height: 6px;
    background: linear-gradient(90deg, #5a4535, #8B7355, #5a4535);
    border-radius: 3px;
    top: -3px;
}

/* ===== Base/Goal Areas ===== */
.base-area {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 60px;
    border-radius: 30px;
    pointer-events: none;
    z-index: 1;
}

.base-area.enemy {
    top: 0;
    background: radial-gradient(ellipse at 50% 100%, rgba(239, 68, 68, 0.15) 0%, transparent 70%);
    border-bottom: 2px dashed rgba(239, 68, 68, 0.3);
}

.base-area.player {
    bottom: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(59, 130, 246, 0.15) 0%, transparent 70%);
    border-top: 2px dashed rgba(59, 130, 246, 0.3);
}

/* Grass patches for depth */
.grass-patch {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(34, 197, 94, 0.2) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
}
