/* style.css */
/* This file contains all the styling for the CoffeeSpill website. */

body {
    background-color: #3d2c22;
    color: #f5f5f5;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Changed from center to allow scrolling from top */
    min-height: 100vh;
    text-align: center;
    overflow-y: auto; /* Allow vertical scrolling */
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

.header {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.header h1 {
    font-size: 2.5rem;
    color: #e0cda9;
    margin: 0;
    line-height: 1;
}

.header-icon {
    height: 100px;
    vertical-align: middle;
}

.header p {
    font-size: 1.2rem;
    color: #c5b59a;
}

.image-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 900px;
}

.hidden {
    display: none !important;
}


.image-wrapper {
    width: 45%;
    max-width: 400px;
    aspect-ratio: 3 / 4;
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    background-color: #2a1d15;
    transition: transform 0.3s ease;
    will-change: transform, opacity;
}

.image-wrapper:hover {
    transform: scale(1.03);
}

.image-wrapper.chosen {
    animation: chosen-pop-bounce 0.6s ease-out forwards;
}

.image-wrapper.not-chosen {
    animation: unchosen-fade-dim 0.6s ease-out forwards;
}

@keyframes chosen-pop-bounce {
    0% { transform: scale(1) rotate(0deg); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4); }
    30% { transform: scale(1.15) rotate(2deg); box-shadow: 0 8px 60px rgba(224, 205, 169, 1); }
    60% { transform: scale(1.05) rotate(-1deg); box-shadow: 0 8px 45px rgba(224, 205, 169, 0.7); }
    100% { transform: scale(1) rotate(0deg); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4); }
}

@keyframes unchosen-fade-dim {
    0% { filter: brightness(1); transform: scale(1) rotate(0deg); opacity: 1; }
    30% { filter: brightness(0.5); transform: scale(0.95) rotate(-1deg); opacity: 0.8; }
    100% { filter: brightness(0.8); transform: scale(0.98) rotate(0deg); opacity: 0.5; }
}


.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #e0cda9;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 50px auto;
}

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

.button-container {
    display: flex;
    gap: 20px; /* Space between buttons */
    margin-top: 30px;
}

.app-button {
    background-color: #e0cda9;
    color: #3d2c22;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: background-color 0.3s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-button:hover {
    background-color: #d2b78d;
    transform: translateY(-2px);
}

.app-button i {
    font-size: 1.2rem;
}


.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background-color: #3d2c22;
    margin: auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 900px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content > .close-button {
    color: #e0cda9;
    font-size: 35px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px;
    cursor: pointer;
    transition: color 0.3s ease;
}

.modal-content > .close-button:hover,
.modal-content > .close-button:focus {
    color: #c5b59a;
    text-decoration: none;
}

.modal-content h2 {
    color: #e0cda9;
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: 20px;
}

.leaderboard-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #5a4b3d;
}

.leaderboard-tab {
    background-color: transparent;
    border: none;
    color: #c5b59a;
    padding: 10px 20px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    margin: 0 5px;
}

.leaderboard-tab:hover {
    color: #f5f5f5;
    background-color: rgba(224, 205, 169, 0.1);
    border-radius: 5px 5px 0 0;
}

.leaderboard-tab.active {
    color: #e0cda9;
    border-bottom-color: #e0cda9;
    font-weight: bold;
}

#leaderboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 20px;
    padding: 10px;
    max-height: 60vh;
    overflow-y: auto;
    background-color: #2a1d15;
    border-radius: 10px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

.leaderboard-item {
    background-color: #4a382e;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, background-color 0.2s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.leaderboard-item:hover {
    transform: translateY(-5px);
    background-color: #5a4b3d;
}

.rank-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: #e0cda9;
    color: #3d2c22;
    padding: 5px 10px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

.leaderboard-thumbnail-wrapper {
    position: relative;
    width: 100%;
    max-width: 150px;
    height: 150px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 3px solid #c5b59a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    background-color: #5a4b3d;
    overflow: hidden;
}

.leaderboard-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 8px;
}

.rank-icon-container {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background-color: #3d2c22;
    border: 2px solid #e0cda9;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.rank-icon-image {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.leaderboard-info {
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
}

.leaderboard-info p {
    margin: 5px 0;
    color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.leaderboard-info .elo-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #e0cda9;
    margin-bottom: 8px;
}

.inline-rank-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    vertical-align: middle;
}

#no-data-message {
    color: #c5b59a;
    margin-top: 30px;
    font-size: 1.1rem;
    text-align: center;
    width: 100%;
}

.elo-display {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: #e0cda9;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 1.3rem;
    font-weight: bold;
    z-index: 1;
    opacity: 0;
    min-width: 80px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.elo-display.elo-fade-in {
    animation: eloFadeIn 0.6s ease-out forwards;
}

@keyframes eloFadeIn {
    0% { opacity: 0; transform: translate(-50%, 20px); }
    50% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 1; transform: translate(-50%, 0); }
}

.elo-number-animated {
    font-size: 1.3rem;
    font-weight: bold;
    color: #e0cda9;
}

.elo-rank-info {
    display: flex;
    align-items: center;
    gap: 5px;
}

.rank-icon-container-elo {
    background-color: #3d2c22;
    border: 1px solid #e0cda9;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.rank-icon-image-elo {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.rank-name-elo {
    font-size: 0.8rem;
    color: #f5f5f5;
}

.image-display-content {
    background-color: transparent;
    padding: 15px;
    max-width: 80vw;
    max-height: 80vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-wrapper-for-modal {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

#displayed-image {
    max-width: 70vw;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.image-wrapper-for-modal > .close-button {
    color: #f5f5f5;
    font-size: 24px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    transition: color 0.3s ease, background-color 0.3s ease;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.image-wrapper-for-modal > .close-button:hover,
.image-wrapper-for-modal > .close-button:focus {
    color: #e0cda9;
    background-color: rgba(0, 0, 0, 0.9);
    text-decoration: none;
}

/* Rank Track specific styles */
.rank-track-content {
    max-width: 90%; /* Allow more width for horizontal scroll */
    padding: 20px;
}

.rank-track-content .base-elo-info {
    font-size: 0.9rem; /* Smaller font size for base ELO info */
    color: #c5b59a; /* Slightly muted color */
    margin-top: -10px; /* Pull it closer to the title */
    margin-bottom: 20px;
}

#rank-track-grid {
    display: flex; /* Changed to flex for horizontal layout */
    flex-direction: row; /* Horizontal direction */
    gap: 0; /* No initial gap, will be set dynamically */
    margin-top: 20px;
    padding: 20px; /* Increased padding for the "road" effect */
    max-height: 60vh; /* Keep vertical constraint */
    overflow-x: auto; /* Enable horizontal scrolling */
    overflow-y: hidden; /* Hide vertical overflow */
    background-color: #2a1d15;
    border-radius: 10px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
    position: relative; /* For pseudo-element line */
    align-items: center; /* Vertically align items in the road */
    justify-content: flex-start; /* Start items from the left */
    scroll-behavior: smooth; /* Smooth scrolling */
}

/* The "trophy road" line */
#rank-track-grid::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 8px; /* Thickness of the road line */
    background: linear-gradient(to right, #c5b59a, #e0cda9, #c5b59a); /* Gradient for the road */
    border-radius: 4px;
    transform: translateY(-50%);
    z-index: 0; /* Behind the rank items */
}


.rank-track-item {
    display: flex;
    flex-direction: column; /* Stack icon and info vertically */
    align-items: center;
    background-color: #4a382e;
    border-radius: 15px; /* More rounded for trophy look */
    padding: 15px 20px; /* Increased padding */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s ease, background-color 0.2s ease;
    min-width: 150px; /* Ensure minimum width for each rank */
    flex-shrink: 0; /* Prevent shrinking */
    position: relative; /* For z-index to be above the road line */
    z-index: 1; /* Above the road line */
    border: 2px solid #e0cda9; /* Border for emphasis */
    margin-right: var(--rank-spacing, 30px); /* Dynamic spacing */
}

.rank-track-item:hover {
    transform: translateY(-8px); /* More pronounced lift on hover */
    background-color: #5a4b3d;
}

.rank-track-icon-container {
    background-color: #3d2c22;
    border: 3px solid #e0cda9; /* Thicker border for icon */
    border-radius: 50%;
    width: 80px; /* Larger icon */
    height: 80px; /* Larger icon */
    min-width: 80px;
    min-height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
    margin-bottom: 10px; /* Space between icon and info */
}

.rank-track-icon-image {
    width: 60px; /* Larger icon image */
    height: 60px;
    object-fit: contain;
}

.rank-track-info {
    text-align: center; /* Center text within the item */
}

.rank-track-info h3 {
    margin: 0;
    color: #e0cda9;
    font-size: 1.4rem; /* Larger font for rank name */
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

.rank-track-info p {
    margin: 5px 0 0;
    color: #f5f5f5;
    font-size: 1rem; /* Clearer font for ELO */
    font-weight: bold;
}

/* Styles for Leaderboard Circles on Rank Track */
.elo-group-marker-container {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 5px; /* Space between multiple circles at the same spot */
    z-index: 2; /* Above the rank track items */
    left: calc(100% - 25px); /* Position at the end of the rank item */
}

.elo-group-marker {
    width: 40px;
    height: 40px;
    background-color: #e0cda9;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s ease, background-color 0.2s ease;
    border: 2px solid #3d2c22;
    flex-shrink: 0;
}

.elo-group-marker:hover {
    transform: scale(1.1);
    background-color: #d2b78d;
}

.elo-group-marker img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
}

.elo-group-marker span {
    color: #3d2c22;
    font-weight: bold;
    font-size: 1rem;
}

/* Styles for the new Rank Elo Detail Modal */
.rank-elo-detail-content {
    max-width: 900px;
    padding: 30px;
}

.rank-elo-detail-content h2 {
    margin-bottom: 25px;
}

.rank-elo-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    max-height: 50vh;
    overflow-y: auto;
    padding: 10px;
    background-color: #2a1d15;
    border-radius: 10px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

.rank-elo-detail-item {
    background-color: #4a382e;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, background-color 0.2s ease;
    cursor: pointer;
}

.rank-elo-detail-item:hover {
    transform: translateY(-5px);
    background-color: #5a4b3d;
}

.rank-elo-detail-thumbnail {
    width: 100%;
    max-width: 150px;
    height: 150px;
    border-radius: 8px;
    margin-bottom: 10px;
    object-fit: cover;
    border: 3px solid #c5b59a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.rank-elo-detail-info {
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
}

.rank-elo-detail-info p {
    margin: 5px 0;
    color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.rank-elo-detail-info .elo-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #e0cda9;
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    .image-container {
        flex-direction: column;
        gap: 25px;
    }

    .image-wrapper {
        width: 80%;
        max-width: 350px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .header-icon {
        width: 40px;
        height: 40px;
    }

    .header p {
        font-size: 1rem;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }

    .modal-content h2 {
        font-size: 1.6rem;
    }

    .leaderboard-tab {
        font-size: 1rem;
        padding: 8px 15px;
    }

    #leaderboard-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
        padding: 5px;
    }

    .leaderboard-thumbnail {
        width: 100%;
        max-width: 120px;
        height: 120px;
    }

    .leaderboard-info {
        font-size: 0.8rem;
    }

    .leaderboard-info .elo-value {
        font-size: 1.1rem;
    }

    .elo-display {
        font-size: 1.1rem;
        padding: 4px 8px;
        bottom: 5px;
    }

    .image-display-content {
        padding: 10px;
    }

    .image-wrapper-for-modal > .close-button {
        font-size: 20px;
        width: 35px;
        height: 35px;
        top: 5px;
        right: 5px;
    }

    .button-container {
        flex-direction: column;
        gap: 15px;
    }

    .app-button {
        width: 80%;
        max-width: 250px;
        justify-content: center;
    }

    .rank-track-content {
        width: 95%;
        padding: 15px;
    }

    #rank-track-grid {
        padding: 15px;
        gap: 20px;
    }

    .rank-track-icon-container {
        width: 60px; /* Adjusted for mobile */
        height: 60px;
        min-width: 60px;
        min-height: 60px;
        margin-bottom: 8px;
    }

    .rank-track-icon-image {
        width: 45px;
        height: 45px;
    }

    .rank-track-info h3 {
        font-size: 1.2rem;
    }

    .rank-track-info p {
        font-size: 0.9rem;
    }

    .elo-group-marker {
        width: 35px;
        height: 35px;
    }

    .elo-group-marker img {
        width: 30px;
        height: 30px;
    }

    .elo-group-marker span {
        font-size: 0.9rem;
    }

    .rank-elo-detail-content {
        padding: 20px;
    }

    .rank-elo-detail-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
    }

    .rank-elo-detail-thumbnail {
        max-width: 120px;
        height: 120px;
    }
}
