/* public/style.css */

:root {
    --bg-color: #0b0813;
    --surface-color: rgba(22, 18, 38, 0.7);
    --surface-solid: #161226;
    --surface-hover: rgba(32, 28, 54, 0.85);
    
    --primary: #8b5cf6;       /* Violet */
    --primary-glow: rgba(139, 92, 246, 0.35);
    --secondary: #ec4899;     /* Pink */
    --secondary-glow: rgba(236, 72, 153, 0.35);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(139, 92, 246, 0.4);
    
    --success: #10b981;
    --error: #ef4444;
    
    --font-header: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-body);
    height: 100vh;
    height: 100svh;
    display: flex;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Background glowing blur points */
.glow-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: -1;
    background: 
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.12) 0%, transparent 40%);
}

.container {
    width: 100%;
    max-width: 1200px;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    flex-wrap: nowrap;
    gap: 20px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

header h1 {
    font-family: var(--font-header);
    font-weight: 800;
    font-size: 24px;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #ffffff, #d8b4fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 400;
}

.nav-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.nav-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-header);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s ease;
}

.nav-tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

.nav-tab.active {
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    box-shadow: 0 4px 15px var(--primary-glow);
}

/* Category Pills */
.category-scroll-container {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    margin-bottom: 24px;
    padding-bottom: 4px;
}

.category-scroll-container::-webkit-scrollbar {
    display: none; /* Safari and Chrome */
}

.category-pills {
    display: flex;
    gap: 10px;
    width: max-content;
}

.pill {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.pill:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.15);
}

.pill.active {
    background: rgba(139, 92, 246, 0.12);
    border-color: var(--primary);
    color: #ffffff;
    box-shadow: inset 0 0 10px rgba(139, 92, 246, 0.1);
}

#view-vote {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
}

/* Matchup Arena */
.arena-wrapper {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 450px;
    perspective: 1000px;
}

.arena {
    display: flex;
    width: 100%;
    align-items: stretch;
    justify-content: space-between;
    gap: 20px;
}

.card-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents overflow in flex layouts */
}

.card {
    background: var(--surface-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 40px 32px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 380px;
    position: relative;
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1),
                border-color 0.3s ease,
                box-shadow 0.3s ease;
    user-select: none;
}

.card:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 4px;
}

.card-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), 
                                rgba(255, 255, 255, 0.05) 0%, 
                                transparent 60%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

@media (hover: hover) {
    .card:hover {
        transform: translateY(-8px) scale(1.02);
        border-color: var(--border-highlight);
        background: var(--surface-hover);
    }
    
    .card:hover .card-glow {
        opacity: 1;
    }
    
    /* Color theme mappings for left vs right card */
    #card-left-container .card:hover {
        box-shadow: 0 15px 40px var(--primary-glow);
        border-color: rgba(139, 92, 246, 0.5);
    }
    
    #card-right-container .card:hover {
        box-shadow: 0 15px 40px var(--secondary-glow);
        border-color: rgba(236, 72, 153, 0.5);
    }
}

/* Card details styling */
.card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    width: 100%;
}

.card-badge {
    align-self: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--primary);
    background: rgba(139, 92, 246, 0.12);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

#card-right-container .card-badge {
    color: var(--secondary);
    background: rgba(236, 72, 153, 0.12);
    border-color: rgba(236, 72, 153, 0.2);
}

.card-title {
    font-family: var(--font-header);
    font-size: 32px;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    background: linear-gradient(135deg, #ffffff, #e2e8f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-desc {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-muted);
    text-align: center;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 24px;
    width: 100%;
}

.keyboard-key {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-weight: bold;
    color: var(--text-muted);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}

/* VS Divider */
.vs-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 5;
    position: relative;
    width: 60px;
}

.vs-line {
    flex-grow: 1;
    width: 1px;
    background: linear-gradient(to bottom, transparent, var(--border-color), transparent);
}

.vs-circle {
    width: 44px;
    height: 44px;
    background: var(--surface-solid);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-header);
    font-weight: 800;
    font-size: 13px;
    color: var(--text-muted);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

/* Animations for card voting swipe */
@keyframes swipeLeft {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    100% { transform: translate(-300px, 50px) rotate(-15deg); opacity: 0; }
}

@keyframes swipeRight {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    100% { transform: translate(300px, 50px) rotate(15deg); opacity: 0; }
}

@keyframes scaleUp {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.anim-swipe-left {
    animation: swipeLeft 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.anim-swipe-right {
    animation: swipeRight 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.anim-fade-in {
    animation: scaleUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.touch-instructions {
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    margin-top: 24px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Leaderboard Page */
.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.leaderboard-header h2 {
    font-family: var(--font-header);
    font-weight: 800;
}

.leaderboard-filters {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

#rank-search {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: 10px;
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
    width: 240px;
    transition: all 0.2s ease;
}

#rank-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    background: rgba(255, 255, 255, 0.06);
}

#rank-limit {
    background: var(--surface-solid);
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: 10px;
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

#rank-limit:focus {
    border-color: var(--primary);
}

/* Top 3 Podium */
.podium-section {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 20px;
    margin: 40px auto 48px;
    max-width: 800px;
    padding: 0 20px;
}

.podium-card {
    flex: 1;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px 16px;
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.podium-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-weight: 800;
    font-family: var(--font-header);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.podium-card.gold {
    height: 180px;
    order: 2; /* Gold in center */
    border-color: rgba(245, 158, 11, 0.4);
    box-shadow: 0 15px 35px rgba(245, 158, 11, 0.15);
    background: linear-gradient(to top, rgba(22, 18, 38, 0.9), rgba(245, 158, 11, 0.05));
}
.podium-card.gold .podium-badge {
    background: #f59e0b;
    color: #000;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.6);
}

.podium-card.silver {
    height: 150px;
    order: 1; /* Silver on left */
    border-color: rgba(156, 163, 175, 0.4);
    background: linear-gradient(to top, rgba(22, 18, 38, 0.9), rgba(156, 163, 175, 0.05));
}
.podium-card.silver .podium-badge {
    background: #9ca3af;
    color: #000;
    box-shadow: 0 0 15px rgba(156, 163, 175, 0.4);
}

.podium-card.bronze {
    height: 135px;
    order: 3; /* Bronze on right */
    border-color: rgba(180, 83, 9, 0.4);
    background: linear-gradient(to top, rgba(22, 18, 38, 0.9), rgba(180, 83, 9, 0.05));
}
.podium-card.bronze .podium-badge {
    background: #b45309;
    color: #fff;
    box-shadow: 0 0 15px rgba(180, 83, 9, 0.4);
}

.podium-details {
    width: 100%;
}

.podium-category {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    display: block;
    margin-bottom: 4px;
}

.podium-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.podium-stats {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-elo {
    font-weight: bold;
    font-size: 14px;
    color: var(--text-main);
}
.stat-winrate {
    font-size: 11px;
    color: var(--text-muted);
}

/* Leaderboard Table */
.table-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 16px 24px;
    font-size: 14px;
}

th {
    background: rgba(255, 255, 255, 0.02);
    font-family: var(--font-header);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.15s ease;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.table-rank {
    font-family: var(--font-header);
    font-weight: 800;
    font-size: 16px;
    color: var(--text-muted);
}

.table-rank-1 { color: #f59e0b; }
.table-rank-2 { color: #9ca3af; }
.table-rank-3 { color: #b45309; }

.table-name {
    font-weight: 600;
    color: #ffffff;
}

.table-desc-dim {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 400;
    display: block;
    margin-top: 2px;
}

.table-category-tag {
    font-size: 11px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 12px;
    color: var(--text-muted);
}

.table-num {
    font-family: monospace;
    font-size: 14px;
}

.table-elo-val {
    font-family: monospace;
    font-size: 14px;
    font-weight: bold;
    color: #d8b4fe;
}

/* Footer */
footer {
    margin-top: auto;
    padding: 32px 0 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-dim);
    font-size: 12px;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-stats {
    display: flex;
    gap: 8px;
}

/* Loader / Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 8, 19, 0.95);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

.spinner-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(139, 92, 246, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-text {
    font-family: var(--font-header);
    font-weight: 600;
    color: var(--text-muted);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(22, 18, 38, 0.9);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    z-index: 200;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.toast.active {
    transform: translateX(-50%) translateY(0);
}

.toast.toast-error {
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.15);
}

/* Responsive adjustments */
@media (max-width: 850px) {
    .podium-section {
        flex-direction: column;
        align-items: center;
        gap: 16px;
    }
    .podium-card {
        width: 100%;
        max-width: 400px;
    }
    .podium-card.gold, .podium-card.silver, .podium-card.bronze {
        height: auto;
        order: initial;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 12px 16px;
    }

    header {
        margin-bottom: 12px;
        padding-bottom: 12px;
        justify-content: center;
        text-align: center;
    }

    .logo-area {
        flex-direction: column;
        gap: 2px;
    }

    header h1 {
        font-size: 20px;
    }

    .arena-wrapper {
        min-height: 0;
    }

    .arena {
        flex-direction: column;
        height: 100%;
        gap: 4px;
    }
    
    .card-container {
        flex: 1;
        min-height: 0;
    }

    .card {
        flex: 1;
        min-height: 0;
        padding: 16px 20px;
        border-radius: 16px;
    }
    
    .card-title {
        font-size: 22px;
    }

    .card-badge {
        font-size: 9px;
        padding: 4px 10px;
    }

    .card-footer {
        font-size: 10px;
        margin-top: 12px;
    }

    .vs-divider {
        width: 100%;
        height: 36px;
        flex-direction: row;
        gap: 4px;
    }
    
    .vs-line {
        height: 1px;
        width: 100%;
        background: linear-gradient(to right, transparent, var(--border-color), transparent);
    }

    .vs-circle {
        width: 32px;
        height: 32px;
        font-size: 10px;
    }

    .touch-instructions {
        margin-top: 12px;
        font-size: 10px;
    }

    footer {
        padding: 12px 0 4px;
        margin-top: 12px;
    }
}
