/**
 * Competition Mode Styles - Tournament & Versus UI
 * TSI Wildlife Call Training Application
 * Phase 7: Competition & Tournaments
 */

/* =========================================================================
   CSS VARIABLES
   ========================================================================= */

:root {
    /* Competition Colors */
    --comp-bg-dark: #0a0a0f;
    --comp-bg-medium: #12121a;
    --comp-bg-card: rgba(255, 255, 255, 0.05);
    --comp-glass: rgba(255, 255, 255, 0.08);
    --comp-border: rgba(255, 255, 255, 0.1);

    /* Rank Colors */
    --rank-rookie: #6b7280;
    --rank-apprentice: #cd7f32;
    --rank-competitor: #c0c0c0;
    --rank-challenger: #ffd700;
    --rank-expert: #4ade80;
    --rank-master: #3b82f6;
    --rank-champion: #a855f7;
    --rank-legend: #ef4444;
    --rank-hof: #f59e0b;

    /* Action Colors */
    --win-color: #22c55e;
    --loss-color: #ef4444;
    --draw-color: #f59e0b;

    /* Typography */
    --font-display: 'Rajdhani', 'Segoe UI', sans-serif;
    --font-body: 'Inter', -apple-system, sans-serif;
}

/* =========================================================================
   BASE STYLES
   ========================================================================= */

.competition-page {
    min-height: 100vh;
    background: var(--comp-bg-dark);
    color: #fff;
    font-family: var(--font-body);
}

.competition-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.comp-section {
    margin-bottom: 3rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-icon {
    font-size: 1.5rem;
}

/* =========================================================================
   RANK DISPLAY
   ========================================================================= */

.rank-card {
    background: linear-gradient(135deg, var(--comp-bg-medium), var(--comp-bg-dark));
    border: 1px solid var(--comp-border);
    border-radius: 16px;
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.rank-badge {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    position: relative;
}

.rank-badge::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--rank-expert), var(--rank-champion), var(--rank-expert));
    z-index: -1;
    animation: rank-glow 3s linear infinite;
}

@keyframes rank-glow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.rank-info {
    flex: 1;
}

.rank-tier {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rank-points {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 0.25rem;
}

.rank-progress {
    margin-top: 1rem;
}

.rank-progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.rank-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--rank-expert), var(--rank-champion));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.rank-progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.5rem;
}

.rank-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    text-align: center;
}

.rank-stat {
    padding: 1rem;
    background: var(--comp-glass);
    border-radius: 12px;
}

.rank-stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
}

.rank-stat-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* =========================================================================
   COMPETITION CARDS
   ========================================================================= */

.comp-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.comp-card {
    background: var(--comp-bg-card);
    border: 1px solid var(--comp-border);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.comp-card:hover {
    transform: translateY(-4px);
    border-color: var(--rank-expert);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.comp-card-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.comp-card-icon {
    font-size: 2.5rem;
}

.comp-card-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
}

.comp-card-subtitle {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
}

.comp-card-body {
    padding: 1.5rem;
}

.comp-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
}

.comp-card-action {
    padding: 1rem 1.5rem;
    background: var(--rank-expert);
    color: #000;
    text-align: center;
    font-family: var(--font-display);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: background 0.2s;
}

.comp-card-action:hover {
    background: var(--rank-champion);
    color: #fff;
}

/* =========================================================================
   LEADERBOARD
   ========================================================================= */

.leaderboard {
    background: var(--comp-bg-card);
    border: 1px solid var(--comp-border);
    border-radius: 16px;
    overflow: hidden;
}

.leaderboard-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(255,255,255,0.08), transparent);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.leaderboard-tabs {
    display: flex;
    gap: 0.5rem;
}

.leaderboard-tab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--comp-border);
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.leaderboard-tab:hover,
.leaderboard-tab.active {
    background: var(--comp-glass);
    border-color: var(--rank-expert);
    color: #fff;
}

.leaderboard-body {
    max-height: 500px;
    overflow-y: auto;
}

.leaderboard-entry {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--comp-border);
    transition: background 0.2s;
}

.leaderboard-entry:hover {
    background: rgba(255, 255, 255, 0.03);
}

.leaderboard-entry.current-player {
    background: rgba(74, 222, 128, 0.1);
    border-left: 3px solid var(--rank-expert);
}

.leaderboard-entry:last-child {
    border-bottom: none;
}

.entry-rank {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
}

.entry-rank.top-3 {
    font-size: 1.5rem;
}

.entry-rank.first { color: #ffd700; }
.entry-rank.second { color: #c0c0c0; }
.entry-rank.third { color: #cd7f32; }

.entry-player {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.entry-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--comp-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.entry-name {
    font-weight: 500;
}

.entry-tier {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.entry-value {
    text-align: right;
}

.entry-score {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
}

.entry-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
}

.entry-change {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.entry-change.up { color: var(--win-color); }
.entry-change.down { color: var(--loss-color); }

/* =========================================================================
   VERSUS SCREEN
   ========================================================================= */

.versus-container {
    position: fixed;
    inset: 0;
    background: var(--comp-bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.versus-players {
    display: flex;
    align-items: center;
    gap: 4rem;
    margin-bottom: 3rem;
}

.versus-player {
    text-align: center;
}

.versus-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--comp-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    margin-bottom: 1rem;
    border: 3px solid var(--comp-border);
}

.versus-avatar.player1 {
    border-color: var(--rank-expert);
}

.versus-avatar.player2 {
    border-color: var(--rank-champion);
}

.versus-name {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
}

.versus-rank {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
}

.versus-badge {
    font-family: var(--font-display);
    font-size: 4rem;
    font-weight: 700;
    color: var(--rank-legend);
    text-shadow: 0 0 30px rgba(239, 68, 68, 0.5);
    animation: versus-pulse 1s ease-in-out infinite;
}

@keyframes versus-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.versus-info {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
}

/* =========================================================================
   MATCH INTERFACE
   ========================================================================= */

.match-container {
    position: fixed;
    inset: 0;
    background: var(--comp-bg-dark);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: var(--comp-bg-medium);
    border-bottom: 1px solid var(--comp-border);
}

.match-players {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.match-player {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.match-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--comp-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.match-player-info {
    text-align: left;
}

.match-player-name {
    font-weight: 600;
}

.match-player-score {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--rank-expert);
}

.match-vs {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.3);
}

.match-timer {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 700;
    text-align: center;
}

.match-round {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.match-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.match-prompt {
    text-align: center;
    margin-bottom: 2rem;
}

.prompt-text {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 0.5rem;
}

.prompt-call {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    color: var(--rank-expert);
}

.match-record-btn {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 4px solid var(--rank-expert);
    background: radial-gradient(circle at 30% 30%, rgba(74, 222, 128, 0.2), transparent);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.match-record-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(74, 222, 128, 0.3);
}

.match-record-btn.recording {
    border-color: var(--loss-color);
    background: radial-gradient(circle at 30% 30%, rgba(239, 68, 68, 0.3), transparent);
    animation: recording-pulse 1s ease-in-out infinite;
}

@keyframes recording-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* =========================================================================
   TOURNAMENT BRACKET
   ========================================================================= */

.bracket-container {
    overflow-x: auto;
    padding: 2rem;
}

.bracket {
    display: flex;
    gap: 3rem;
    min-width: max-content;
}

.bracket-round {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: space-around;
}

.round-title {
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    margin-bottom: 1rem;
}

.bracket-match {
    background: var(--comp-bg-card);
    border: 1px solid var(--comp-border);
    border-radius: 8px;
    width: 200px;
    overflow: hidden;
}

.bracket-player {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--comp-border);
}

.bracket-player:last-child {
    border-bottom: none;
}

.bracket-player.winner {
    background: rgba(34, 197, 94, 0.1);
}

.bracket-player.loser {
    opacity: 0.5;
}

.bracket-player-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.bracket-seed {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    min-width: 20px;
}

.bracket-score {
    font-family: var(--font-display);
    font-weight: 600;
}

/* Bracket connectors */
.bracket-connector {
    position: absolute;
    border: 1px solid var(--comp-border);
    border-left: none;
}

/* =========================================================================
   SPONSORED EVENT THEMING
   ========================================================================= */

.sponsored-event {
    background: var(--sponsor-bg, var(--comp-bg-dark));
}

.sponsored-header {
    position: relative;
    height: 200px;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: flex-end;
    padding: 2rem;
}

.sponsored-header-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
}

.sponsored-logo {
    height: 60px;
    position: relative;
    z-index: 1;
}

.sponsored-title {
    position: relative;
    z-index: 1;
    margin-left: 1.5rem;
}

.sponsored-prize-pool {
    text-align: center;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--sponsor-accent, var(--rank-expert));
}

.prize-pool-value {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 700;
    color: var(--sponsor-accent, var(--rank-expert));
}

.prize-pool-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* =========================================================================
   QR SCANNER
   ========================================================================= */

.qr-scanner-container {
    position: fixed;
    inset: 0;
    background: #000;
    display: flex;
    flex-direction: column;
    z-index: 2000;
}

.qr-video {
    flex: 1;
    object-fit: cover;
}

.qr-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.qr-frame {
    width: 250px;
    height: 250px;
    border: 3px solid var(--rank-expert);
    border-radius: 16px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
}

.qr-instructions {
    margin-top: 2rem;
    text-align: center;
    color: #fff;
    font-size: 1rem;
}

.qr-result {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem;
    background: var(--comp-bg-medium);
    border-top: 1px solid var(--comp-border);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.qr-result.show {
    transform: translateY(0);
}

.qr-result-success {
    border-top-color: var(--win-color);
}

.qr-result-error {
    border-top-color: var(--loss-color);
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

@media (max-width: 768px) {
    .competition-container {
        padding: 1rem;
    }

    .rank-card {
        flex-direction: column;
        text-align: center;
    }

    .rank-stats {
        width: 100%;
    }

    .versus-players {
        flex-direction: column;
        gap: 2rem;
    }

    .versus-badge {
        font-size: 3rem;
    }

    .match-header {
        flex-direction: column;
        gap: 1rem;
    }

    .bracket-container {
        padding: 1rem;
    }

    .comp-card-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================================================
   ANIMATIONS
   ========================================================================= */

@keyframes slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.animate-slide-up {
    animation: slide-up 0.5s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-fade-in {
    animation: fade-in 0.3s ease-out;
}

/* =========================================================================
   ACCESSIBILITY
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
    .rank-badge::before,
    .versus-badge,
    .match-record-btn.recording {
        animation: none;
    }

    * {
        transition-duration: 0.01ms !important;
    }
}

.comp-card:focus,
.leaderboard-tab:focus,
.match-record-btn:focus {
    outline: 2px solid var(--rank-expert);
    outline-offset: 2px;
}
