:root {
    --messages-offset: 50px; /* Offset for message positioning */
}

.carousel {
    position: relative;
    width: 100%;
    height: 93vh;
    overflow: hidden;
    z-index: 0;
    background-color: var(--Dark); /* Fallback background */
}

.carousel-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    background-color: var(--Dark); /* Ensure no white background shows */
    transition: transform 0.6s ease-in-out; /* Container moves as one unit */
}

.carousel-slide {
    position: relative; /* Changed from absolute to relative */
    width: 100vw; /* Use viewport width instead of percentage */
    height: 100%;
    background-size: cover;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0; /* Prevent slides from shrinking */
    pointer-events: auto; /* Always allow interaction with visible slide */
    z-index: 1;
}

/* Container-based movement - slides are positioned relatively in a row */

.carousel-slide img {
    max-width: 100%;
    max-height: 100%;
}

.carousel-message {
    position: absolute;
    height: 100%;
    transform: translateY(30px);
    opacity: 0;
    transition: opacity 0.5s ease 0.3s, transform 0.5s ease 0.3s;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Changed from center to flex-start */
    padding-top: 30vh; /* Position text between upper third and center (25% from top) */
    max-width: 600px; /* Prevent text from stretching too wide */
}

/* Position variants */
.carousel-message-left {
    left: var(--messages-offset);
    align-items: flex-start;
    text-align: left;
}

.carousel-message-middle {
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
    text-align: center;
}

.carousel-message-right {
    right: calc(var(--messages-offset) + 50px); /* Add extra offset to balance the right-aligned text */
    align-items: flex-end;
    text-align: right;
}

.carousel-message div {
    background-color: var(--Accent-transparent);
    color: var(--light);
    padding: 0.5em;
    border-radius: 5px; 
    font-size: 2em;
    text-shadow: 1px 1px 1px var(--Accent-dark);
    display: block; /* Ensure consistent display for both linked and non-linked content */
    width: 100%; /* Full width of the message container */
}

.carousel-message h1 {
    font-size: 1.5em;
    margin: 0.2em 0;
    text-align: left;
    width: auto;
}

.carousel-message a {
    text-decoration: none;
    color: var(--light);
    transition: color var(--transition-length);
}

.carousel-message a:hover {
    color: var(--Contrast);
}

.carousel-link {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: all var(--transition-length);
    width: 100%; /* Ensure link takes full width */
}

.carousel-link:hover {
    transform: scale(1.02);
}

.carousel-link:hover div {
    /* Keep original colors, only apply scale animation */
    background-color: var(--Accent-transparent);
    color: var(--light);
}



/* Message visibility based on current slide - only active slide shows message */
.carousel-slide .carousel-message {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1.2s ease, transform 1.2s ease;
}

.carousel-slide .carousel-message-middle {
    opacity: 0;
    transform: translateX(-50%) translateY(30px);
    transition: opacity 1.2s ease, transform 1.2s ease;
}

.carousel-slide.active .carousel-message {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease 0.3s, transform 0.5s ease 0.3s;
}

.carousel-slide.active .carousel-message-middle {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    transition: opacity 0.5s ease 0.3s, transform 0.5s ease 0.3s;
}

/* Hide messages during container transitions for smoother infinite loop */
.carousel-container.transitioning .carousel-message {
    opacity: 0 !important;
    transition: opacity 0.2s ease !important;
}

/* Carousel Navigation Buttons */
.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: transparent;
    color: var(--light-transparent);
    border: none;
    padding: 1rem 0.8rem;
    margin: 0;
    font-size: 4em;
    cursor: pointer;
    transition: all var(--transition-length);
    z-index: 10;
    user-select: none;
}

.carousel-btn:hover {
    color: var(--light);
    background-color: transparent;
    transform: translateY(-50%) scale(1.1);
    text-shadow: 0 4px 8px var(--Dark-accent);
}

.carousel-prev {
    left: 20px;
}

.carousel-next {
    right: 20px;
}

/* Carousel Dot Indicators */
.carousel-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.carousel-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--light-transparent);
    cursor: pointer;
    transition: all var(--transition-length);
    border: 2px solid transparent;
    user-select: none; /* Prevent text selection cursor */
}

.carousel-dot:hover {
    background-color: var(--light);
    transform: scale(1.2);
}

.carousel-dot.active {
    background-color: var(--light-transparent);
    border-color: var(--light);
    transform: scale(1.3);
}

/* Mobile Responsive */
@media screen and (max-width: 768px) {
    .carousel-btn {
        /* Keep buttons the same size on mobile for better usability */
        padding: 1rem 0.8rem;
        font-size: 4em;
    }
    
    .carousel-prev {
        left: 10px;
    }
    
    .carousel-next {
        right: 10px;
    }
    
    .carousel-dots {
        bottom: 15px;
        gap: 8px;
    }
    
    .carousel-dot {
        width: 10px;
        height: 10px;
    }
    
    /* Adjust carousel message positioning on mobile */
    .carousel-message {
        max-width: calc(100% - 40px); /* Account for side padding */
    }

    .carousel-message-left, 
    .carousel-message-right, 
    .carousel-message-middle {
        right: auto !important; /* Reset right positioning */
        left: 50% !important; /* Center horizontally */
        transform: translateX(-50%) !important; /* Center the element */
        align-items: center !important; /* Center content alignment */
        text-align: center !important; /* Center text alignment */
    }
    
    /* Override animation states for mobile to maintain centering */
    .carousel-slide .carousel-message-left,
    .carousel-slide .carousel-message-right,
    .carousel-slide .carousel-message-middle {
        transform: translateX(-50%) translateY(30px) !important;
    }
    
    .carousel-slide.active .carousel-message-left,
    .carousel-slide.active .carousel-message-right,
    .carousel-slide.active .carousel-message-middle {
        transform: translateX(-50%) translateY(0) !important;
    }
    
    .carousel-message div {
        font-size: 1.5em; /* Smaller text on mobile */
        padding: 0.4em;
        word-wrap: break-word; /* Allow long words to break */
        overflow-wrap: break-word; /* Better browser support */
        hyphens: auto; /* Add hyphenation for better text flow */
    }
}

