/* General styles for races page */
.races-section {
    padding-top: 35px; /* Padding to avoid overlap with header */
    background-color: var(--color-background);
    display: flex;
    flex-direction: column;
    box-sizing: border-box; /* Include padding in height calculation */
    overflow: hidden; /* Ensure no overflow */
}

/* Flexbox layout for slideshow and details */
.races-content {
    display: flex;
    flex: 1;
    gap: 30px;
    align-items: stretch; /* Ensure children stretch to the same height */
    overflow: hidden; /* Prevent scrollbars from appearing */
}

/* Slideshow styles */
.races-slideshow {
    flex: 1;
    position: relative;
    max-width: 100%; /* Take full width of its container */
    box-sizing: border-box; /* Include padding in height calculation */
    height: calc(100vh - 225px); /* Adjust height to fit within the viewport minus padding and header/footer space */
}

.slideshow-container {
    display: flex;
    overflow: hidden;
    border-radius: 10px;
    height: 100%; /* Full height of its container */
    box-sizing: border-box; /* Include border and padding in height calculation */
}

.slideshow-container .slide {
    display: none; /* Hide all slides by default */
}

.slideshow-container .slide.active {
    display: flex; /* Show only the active slide */
}

.slide {
    min-width: 100%;
    height: 100%; /* Full height of its container */
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ensure the image covers the container and is cropped */
    border-radius: 10px;
}

/* Navigation arrows */
.prev, .next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -22px;
    color: white;
    font-weight: bold;
    font-size: 18px;
    transition: 0.6s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    background-color: rgba(0, 0, 0, 0.5);
}

.next {
    right: 0; /* Align to the right border */
    border-radius: 3px 0 0 3px;
}

.prev:hover, .next:hover {
    background-color: rgba(0,0,0,0.8);
}

/* Details styles */
.races-details {
    flex: 1;
    max-width: 100%; /* Take full width of its container */
}

.races-list {
    margin-bottom: 20px;
    padding: 0 15px; /* Add padding to prevent items from touching the container's edges */
    overflow: hidden; /* Ensure content doesn't overflow the container */
}

.races-list h3 {
    font-size: 2em;
    color: var(--color-primary);
    margin-bottom: 10px;
}

.races-list ul {
    list-style: none;
    padding: 0;
    font-size: 1.1em;
    margin-top: 0; /* Set top margin to 0 */
}

.races-list li {
    margin-bottom: 10px;
    padding: 15px;
    background-color: var(--list-item-background, #444); /* Use a variable for list item background */
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* Slightly darker shadow for better contrast */
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
}

/* Apply hover effects only on devices that support hover */
@media (hover: hover) {
    .races-list li:hover {
        background-color: var(--color-hover);
        border-radius: 8px;
        transform: scale(1.02);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); /* Darker shadow on hover */
    }
}

.races-list li b {
    font-size: 1.1em;
    color: var(--color-primary);
    font-weight: bold;
}

.races-list li .race-details p {
    font-size: 1em;
    color: var(--color-text);
}

.races-list li .race-details p strong {
    font-weight: bold; /* Make only the definition part bold */
}

/* Status labels with distinct colors */
.label-completed {
    background-color: var(--label-completed-bg, rgba(0, 128, 0, 0.2)); /* Use a variable for background */
    color: var(--label-completed-text, #00ff00); /* Use a variable for text color */
}

.label-in-progress {
    background-color: var(--label-in-progress-bg, rgba(255, 165, 0, 0.2)); /* Use a variable for background */
    color: var(--label-in-progress-text, #ffcc00); /* Use a variable for text color */
}

.label-upcoming {
    background-color: var(--label-upcoming-bg, rgba(0, 0, 255, 0.2)); /* Use a variable for background */
    color: var(--label-upcoming-text, #3399ff); /* Use a variable for text color */
}

.label-completed, .label-in-progress, .label-upcoming {
    font-size: 0.8em; /* Smaller font size */
    padding: 2px 4px; /* Smaller padding */
    border-radius: 3px;
    margin-right: 5px; /* Space between label and race name */
}

.date-badge {
    background-color: var(--date-badge-bg, rgba(0, 123, 255, 0.2)); /* Use a variable for background */
    color: var(--date-badge-text, var(--color-primary)); /* Use a variable for text color */
    font-size: 0.8em; /* Smaller font size */
    padding: 2px 4px; /* Smaller padding */
    border-radius: 3px;
    margin-left: 5px; /* Space between race name and date badge */
}

/* Responsive Design */
@media (max-width: 768px) {
    .races-section {
        padding-top: 20px;
    }

    .races-content {
        flex-direction: column;
        align-items: center;
        gap: 0px;
    }

    .races-slideshow, .races-details {
        max-width: 100%;
        height: auto; /* Let the content determine the height */
        padding: 0px 0px 15px 0px;
    }

    .races-list {
        padding: 0;
    }

    .prev, .next {
        font-size: 16px;
    }

    .section-title {
        font-size: 2em;
    }

    /* Apply 4:3 aspect ratio only to regular slideshow images */
    .slideshow-container .slide img {
        width: 100%;
        height: auto;
        aspect-ratio: 4 / 3; /* Maintain a 4:3 aspect ratio */
        object-fit: cover; /* Ensure the image covers the container */
    }
}

/* Fullscreen slideshow styles */
.fullscreen-slideshow {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.fullscreen-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.fullscreen-content .slide {
    display: none; /* Hide all fullscreen slides by default */
    width: 100%;
    height: 100%;
    justify-content: center;
    align-items: center;
}

.fullscreen-content .slide.active {
    display: flex; /* Show only the active fullscreen slide */
}

.fullscreen-content img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.close-fullscreen {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
}

.fullscreen-slideshow .prev,
.fullscreen-slideshow .next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    padding: 16px;
    color: white;
    font-weight: bold;
    font-size: 30px;
    transition: 0.6s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10000;
}

.fullscreen-slideshow .prev {
    left: 20px;
}

.fullscreen-slideshow .next {
    right: 20px;
    border-radius: 3px 0 0 3px;
}

.fullscreen-slideshow .prev:hover,
.fullscreen-slideshow .next:hover,
.close-fullscreen:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.race-details {
    display: none; /* Hide by default */
    padding: 10px;
    border-radius: 5px;
    transition: max-height 0.3s ease-out;
}

.races-list li.expanded .race-details {
    display: block; /* Show when expanded */
}

.thumbnail-gallery {
    display: flex;
    flex-wrap: wrap; /* Allow thumbnails to wrap to a new line */
    gap: 5px;
    margin-top: 10px;
}

.thumbnail {
    width: 50px; /* Adjust size as needed */
    height: 50px;
    object-fit: cover;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s;
}

.thumbnail:hover {
    transform: scale(1.1);
}

#total-km-counter {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--color-primary);
    background-color: var(--list-item-background);
    padding: 15px;
    margin: 0 0 20px 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
}

#total-km-counter::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--color-primary);
    opacity: 0.2;
}

#total-km-counter i {
    font-size: 1.2em;
    color: var(--color-primary);
    opacity: 0.9;
}

#km-value {
    font-weight: bold;
    color: var(--color-primary);
}

.youtube-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: var(--color-text);
    background-color: var(--list-item-background, #444);
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.youtube-link i {
    color: #FF0000;  /* YouTube's red color */
    margin-right: 8px;
    font-size: 1.2em;
}

.youtube-link:hover {
    background-color: var(--color-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border-color: var(--color-primary);
}

@media (max-width: 768px) {
    #total-km-counter {
        font-size: 1em;
        padding: 15px;
        margin: 0 0 15px 0;
    }
    
    #total-km-counter::after {
        bottom: -7px;
        height: 2px;
    }
}
