/* static/css/home.css */

/* CSS Variables for Maintainability */
:root {
    --primary-green: #1a3c34; /* Cricket field green */
    --secondary-green: #2e6b4e;
    --cricket-red: #a11212; /* Cricket ball red */
    --cricket-gold: #ffeb3b; /* Trophy gold */
    --navy-blue: #001f3f;
    --orange-accent: #FFA500;
    --text-white: #ffffff;
    --text-muted: #cccccc;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --border-radius: 12px;
}

/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--navy-blue);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 400px;
    background-color: var(--navy-blue);
    border-radius: var(--border-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 800px;
    max-height: 90vh;
    box-shadow: var(--shadow);
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary-green), var(--secondary-green));
    color: var(--text-white);
    text-align: center;
    padding: 12px;
}

.app-header h1 {
    font-size: 1.8em;
    font-weight: 700;
    letter-spacing: 1px;
}

/* Main Content */
.app-main {
    flex-grow: 1;
    padding: 15px;
    color: var(--text-white);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--orange-accent) var(--navy-blue);
}

/* Hero Section */
.hero-section {
    text-align: center;
}

.hero-image {
    width: 50%;
    max-width: 160px;
    margin: 15px auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 15px 0;
}

.btn {
    padding: 12px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1em;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    color: var(--text-white);
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover, .btn:focus {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn:focus {
    outline: 2px solid var(--cricket-gold);
    outline-offset: 2px;
}

.btn-play {
    background: linear-gradient(135deg, var(--primary-green), var(--secondary-green));
}

.btn-join {
    background: linear-gradient(135deg, var(--orange-accent), #ff8c00);
}

/* Tournament Banner */
.tournament-banner {
    background: linear-gradient(45deg, var(--cricket-gold), #d4a017);
    color: var(--navy-blue);
    padding: 15px;
    border-radius: var(--border-radius);
    text-align: center;
    margin: 15px 0;
    box-shadow: var(--shadow);
}

.banner-icon {
    font-size: 2em;
    color: var(--text-white);
}

.tournament-banner h3 {
    margin: 8px 0;
    font-size: 1.2em;
    color: var(--text-white);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.tournament-banner p {
    margin: 0 0 10px 0;
    font-size: 0.9em;
}

.countdown-timer {
    background: rgba(0, 0, 0, 0.2);
    padding: 6px 10px;
    border-radius: 8px;
    display: inline-block;
}

#tournament-countdown {
    font-size: 1em;
    font-weight: 600;
    color: var(--text-white);
}

/* Leaderboard Preview */
.leaderboard-preview-section {
    margin-top: 20px;
    padding: 0 10px;
}

.leaderboard-preview-section h2 {
    text-align: center;
    font-size: 1.1em;
    color: var(--cricket-gold);
    margin-bottom: 12px;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#leaderboard-preview-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.leaderboard-preview-entry {
    background: rgba(255, 255, 255, 0.15);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.leaderboard-preview-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.leaderboard-preview-rank {
    font-size: 1.1em;
    font-weight: bold;
}

.leaderboard-preview-rank[data-rank="1"] { color: var(--cricket-gold); }
.leaderboard-preview-rank[data-rank="2"] { color: #c0c0c0; }
.leaderboard-preview-rank[data-rank="3"] { color: #cd7f32; }

.leaderboard-preview-name {
    font-weight: 500;
    font-size: 0.9em;
}

.leaderboard-preview-score {
    font-weight: bold;
    color: var(--secondary-green);
    display: flex;
    align-items: center;
    gap: 5px;
}

.leaderboard-preview-score .fa-coins {
    color: var(--cricket-gold);
    font-size: 0.9em;
}

.view-full-leaderboard {
    display: block;
    text-align: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85em;
    margin-top: 12px;
    transition: color 0.2s ease;
}

.view-full-leaderboard:hover, .view-full-leaderboard:focus {
    color: var(--text-white);
}

.view-full-leaderboard:focus {
    outline: 2px solid var(--cricket-gold);
    outline-offset: 2px;
}

/* Bottom Navigation */
.app-nav {
    display: flex;
    justify-content: space-around;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.8em;
    transition: color 0.2s ease, transform 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--orange-accent);
    transform: scale(1.05);
}

.nav-link:focus {
    outline: 2px solid var(--cricket-gold);
    outline-offset: 2px;
}

.nav-link i {
    font-size: 1.3em;
}

/* Spin Wheel Link */
.spin-wheel-link {
    padding: 8px 12px;
    background: linear-gradient(135deg, var(--primary-green), var(--secondary-green));
    color: var(--text-white);
    border-radius: var(--border-radius);
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    box-shadow: var(--shadow);
    transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.spin-wheel-link:hover {
    background: linear-gradient(135deg, var(--cricket-red), #d32f2f);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.spin-wheel-link:focus {
    outline: 2px solid var(--cricket-gold);
    outline-offset: 2px;
}

.spin-wheel-link.active {
    background: linear-gradient(135deg, var(--cricket-gold), #d4a017);
    color: var(--navy-blue);
}

.spin-icon {
    width: 16px;
    height: 16px;
    color: var(--text-white);
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        max-width: 100%;
        border-radius: 0;
    }

    .app-header h1 {
        font-size: 1.5em;
    }

    .hero-image {
        max-width: 140px;
    }

    .btn {
        padding: 10px;
        font-size: 1em;
    }

    .tournament-banner {
        padding: 12px;
    }

    .tournament-banner h3 {
        font-size: 1.1em;
    }

    .spin-wheel-link {
        padding: 6px 10px;
        font-size: 0.75em;
    }

    .spin-icon {
        width: 14px;
        height: 14px;
    }
}

/* Accessibility: High Contrast Mode */
@media (prefers-contrast: high) {
    .app-container {
        background: #000;
        border: 2px solid #fff;
    }

    .app-header {
        background: #000;
        border-bottom: 2px solid #fff;
    }

    .btn, .spin-wheel-link {
        border: 2px solid #fff;
    }

    .spin-wheel-link {
        background: var(--primary-green);
    }

    .spin-wheel-link:hover {
        background: var(--cricket-red);
    }
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}