/**
 * STAR StackArena - Advanced Motion Design System
 * arena-motion.css
 */

/* ==========================================================================
   1. ACCESSIBILITY / REDUCED MOTION SAFEGUARDS
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .arena-particle-canvas {
        display: none !important;
    }
}

/* ==========================================================================
   2. CINEMATIC PVP MATCH REVEAL (4.1)
   ========================================================================== */
.arena-pvp-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, rgba(15, 18, 30, 0.96) 0%, rgba(5, 6, 12, 0.99) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    perspective: 1200px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.arena-pvp-overlay.active {
    opacity: 1;
}

.arena-pvp-bg-grid {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background-image: 
        linear-gradient(rgba(0, 242, 254, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 242, 254, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    transform: perspective(600px) rotateX(60deg) translateY(0);
    animation: gridScroll 15s linear infinite;
    pointer-events: none;
}

@keyframes gridScroll {
    0% { transform: perspective(600px) rotateX(60deg) translateY(0); }
    100% { transform: perspective(600px) rotateX(60deg) translateY(40px); }
}

.arena-pvp-top-bar {
    position: absolute;
    top: 24px;
    width: 90%;
    max-width: 1000px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

.arena-pvp-match-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.arena-pvp-skip-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--text-muted, #94a3b8);
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.arena-pvp-skip-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.35);
}

.arena-pvp-arena {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 92%;
    max-width: 1050px;
    position: relative;
    z-index: 5;
}

/* Opposing 3D Player Cards */
.arena-pvp-player-card {
    flex: 1;
    max-width: 420px;
    background: linear-gradient(145deg, rgba(22, 25, 42, 0.85) 0%, rgba(12, 14, 25, 0.92) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    transform-style: preserve-3d;
    will-change: transform, opacity;
}

.arena-pvp-player-card.team-a {
    border-left: 4px solid #00f2fe;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 242, 254, 0.15);
    transform: perspective(1000px) translateX(-100px) rotateY(18deg);
    opacity: 0;
    animation: pvpCardLeftEnter 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.15s;
}

.arena-pvp-player-card.team-b {
    border-right: 4px solid #ff4081;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 64, 129, 0.15);
    transform: perspective(1000px) translateX(100px) rotateY(-18deg);
    opacity: 0;
    animation: pvpCardRightEnter 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.25s;
}

@keyframes pvpCardLeftEnter {
    to {
        transform: perspective(1000px) translateX(0) rotateY(8deg);
        opacity: 1;
    }
}

@keyframes pvpCardRightEnter {
    to {
        transform: perspective(1000px) translateX(0) rotateY(-8deg);
        opacity: 1;
    }
}

.arena-pvp-avatar-wrap {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    margin-bottom: 14px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border: 3px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.arena-pvp-avatar-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.team-a .arena-pvp-avatar-wrap {
    border-color: #00f2fe;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.4);
}

.team-b .arena-pvp-avatar-wrap {
    border-color: #ff4081;
    box-shadow: 0 0 20px rgba(255, 64, 129, 0.4);
}

.arena-pvp-tag {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 4px;
    font-family: var(--font-heading, 'Outfit', sans-serif);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
}

.arena-pvp-role {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 14px;
}

.arena-pvp-stats-grid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
    opacity: 0;
    animation: pvpStatsFade 0.45s ease forwards 0.8s;
}

@keyframes pvpStatsFade {
    to { opacity: 1; transform: translateY(0); }
}

/* Central VS Impact Shockwave */
.arena-vs-clash-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 15;
    flex-shrink: 0;
}

.arena-vs-impact {
    font-family: var(--font-heading, 'Black Ops One', sans-serif);
    font-size: 3.4rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 
        0 0 20px rgba(255, 75, 43, 0.8),
        0 0 40px rgba(0, 229, 255, 0.6),
        0 4px 15px rgba(0, 0, 0, 0.8);
    transform: scale(3.5);
    opacity: 0;
    animation: vsClashImpact 0.5s cubic-bezier(0.19, 1, 0.22, 1) forwards 0.65s;
    user-select: none;
}

@keyframes vsClashImpact {
    0% { transform: scale(3.5); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.arena-vs-shockwave-ring {
    position: absolute;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 3px solid rgba(255, 215, 0, 0.8);
    opacity: 0;
    pointer-events: none;
    animation: shockwaveExpand 0.75s ease-out forwards 0.7s;
}

@keyframes shockwaveExpand {
    0% { transform: scale(0.3); opacity: 1; border-color: #ffd700; }
    100% { transform: scale(2.8); opacity: 0; border-color: #00f2fe; }
}

.arena-pvp-cta-bottom {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    opacity: 0;
    animation: pvpBottomFade 0.4s ease forwards 1.2s;
}

@keyframes pvpBottomFade {
    to { opacity: 1; }
}

/* ==========================================================================
   3. BRACKET PROGRESSION & ENERGY PATH ILLUMINATION (4.2)
   ========================================================================== */
.bracket-match-wrapper.is-winner-node {
    border-color: #00f2fe !important;
}

.bracket-energy-beam {
    position: absolute;
    background: linear-gradient(90deg, #00f2fe, #ffd700);
    box-shadow: 0 0 12px #00f2fe, 0 0 24px rgba(0, 242, 254, 0.5);
    pointer-events: none;
    z-index: 5;
    border-radius: 4px;
}

@keyframes beamTravelHorizontal {
    0% { width: 0; opacity: 1; }
    80% { opacity: 1; }
    100% { width: 100%; opacity: 0.9; }
}

@keyframes cardProgressionPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 rgba(0, 242, 254, 0); }
    50% { transform: scale(1.03); box-shadow: 0 0 25px rgba(0, 242, 254, 0.7); }
    100% { transform: scale(1); box-shadow: 0 0 12px rgba(0, 242, 254, 0.3); }
}

.card-progression-active {
    animation: cardProgressionPulse 1.2s ease-in-out;
}

/* ==========================================================================
   4. CINEMATIC VICTORY & DEFEAT PRESENTATION (4.3)
   ========================================================================== */
.settlement-presentation-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    padding: 32px 24px;
    margin-bottom: 24px;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.6);
}

.settlement-presentation-wrapper.is-victory {
    background: radial-gradient(circle at 50% 20%, rgba(255, 215, 0, 0.15) 0%, rgba(14, 18, 30, 0.95) 75%);
    border: 1px solid rgba(255, 215, 0, 0.4);
}

.settlement-presentation-wrapper.is-defeat {
    background: radial-gradient(circle at 50% 20%, rgba(239, 68, 68, 0.1) 0%, rgba(14, 18, 30, 0.95) 75%);
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.settlement-emblem-drop {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
    transform: translateY(-40px) scale(0.6);
    opacity: 0;
    animation: emblemBounceIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards 0.2s;
}

@keyframes emblemBounceIn {
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.settlement-victory-title {
    font-family: var(--font-heading, 'Outfit', sans-serif);
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #fff;
    margin: 0;
    text-align: center;
    background: linear-gradient(180deg, #ffffff 30%, #ffd700 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 12px rgba(255, 215, 0, 0.3));
}

.settlement-defeat-title {
    font-family: var(--font-heading, 'Outfit', sans-serif);
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #fff;
    margin: 0;
    text-align: center;
    color: #f87171;
    filter: drop-shadow(0 4px 12px rgba(239, 68, 68, 0.25));
}

/* ==========================================================================
   5. STAGED RANK-UP MODAL (4.4)
   ========================================================================== */
.rankup-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 5, 10, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.rankup-modal-overlay.active {
    opacity: 1;
}

.rankup-modal-card {
    background: linear-gradient(145deg, rgba(22, 26, 44, 0.95), rgba(12, 14, 26, 0.98));
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 24px;
    padding: 36px 30px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    position: relative;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(255, 215, 0, 0.2);
    transform: scale(0.85);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.rankup-modal-overlay.active .rankup-modal-card {
    transform: scale(1);
}

.rankup-emblem-box {
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    position: relative;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.2) 0%, rgba(0, 0, 0, 0.5) 70%);
    border: 3px solid #ffd700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
    animation: emblemPulse 2s infinite alternate ease-in-out;
}

@keyframes emblemPulse {
    0% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 215, 0, 0.4); }
    100% { transform: scale(1.06); box-shadow: 0 0 40px rgba(255, 215, 0, 0.8); }
}

/* ==========================================================================
   6. 3D POINTER-AWARE TILT & INTERACTION (4.7)
   ========================================================================== */
.arena-tilt-target {
    transform-style: preserve-3d;
    transition: transform 0.15s ease-out, box-shadow 0.25s ease;
    will-change: transform;
}

.arena-tilt-target:hover {
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 242, 254, 0.15);
}

/* Fullscreen Particle Canvas */
.arena-particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 99998;
}

/* ==========================================================================
   7. RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 768px) {
    .arena-pvp-arena {
        flex-direction: column;
        gap: 16px;
    }
    .arena-pvp-player-card {
        max-width: 100%;
        width: 100%;
        padding: 20px;
    }
    .arena-pvp-player-card.team-a,
    .arena-pvp-player-card.team-b {
        transform: perspective(600px) translateY(0);
        animation: none;
        opacity: 1;
    }
    .arena-vs-impact {
        font-size: 2.2rem;
    }
    .settlement-victory-title {
        font-size: 1.7rem;
    }
}
