html {
    scroll-behavior: smooth;
}

body.history-page {
    background-color: #F5EFE6;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    transition: background-image 0.5s ease-in-out;
    margin: 0;
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
}

/* Overlay for readability */
body.history-page::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(245, 239, 230, 0.95);
    z-index: -1;
    transition: background-color 0.5s ease;
}

body.history-page.has-active-bg::before {
    background-color: rgba(0, 0, 0, 0.7);
}

.history-container {
    padding: 50px 0 0 0;
}

.history-timeline-wrapper {
    background-color: #1a1a1a;
}

.history-bottom-spacer {
    height: 10vh;
    background-color: #1a1a1a;
    width: 100%;
}

/* --- Navigation Styles (Added) --- */
.history-nav {
    position: fixed;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
}

.history-nav.visible {
    opacity: 1;
    visibility: visible;
}

.history-nav a {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.3);
    /* Inactive color: muted black/gray */
    font-weight: 900;
    font-size: 0.7rem;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    display: block;
    text-align: right;
    padding: 2px 0;
}

.history-nav a::before {
    content: '';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 2px;
    background-color: #EEE;
    transition: width 0.2s ease;
}

.history-nav a:hover,
.history-nav a.active {
    color: #EEE;
    /* red-500 */
    font-size: 0.9rem;
}

.history-nav a.active::before {
    width: 10px;
}

/* -------------------------------- */

.year-section {
    position: relative;
    height: 80vh;
    /* Fixed height for active and non-active */
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: all 0.6s ease;
    opacity: 0.65;
    /* Increased transparency to mix with background */
    filter: grayscale(100%) brightness(0.3);
    /* Brighter than black, looks grey */
    background-color: #1a1a1a;
    /* Dark grey base instead of pitch black */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Dim content/images separately when inactive */
.year-section:not(.active):not(.highlight) .year-content,
.year-section:not(.active):not(.highlight) .images-container {
    opacity: 0.1;
    transition: opacity 0.6s ease;
}

/* Subtle overlay for section background when active */
.year-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    /* Muted overlay for grey look */
    z-index: 2;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.year-section.active::before {
    opacity: 1;
}

.year-section.highlight,
.year-section.active {
    opacity: 0.9;
    filter: grayscale(85%) brightness(0.6);
    /* More grey, less color */
}

.year-section.active {
    border-bottom: none;
    opacity: 1;
    filter: grayscale(70%) brightness(0.7);
    /* Per user request: 'more grey' */
}

.year-section.highlight .year-title {
    transform: scale(1.05);
    color: #FFF;
}

/* Ensure content stays above section background overlay */
.year-content {
    z-index: 10;
    position: relative;
    padding: 0 20px;
}

.year-title {
    font-size: 3rem;
    font-weight: 900;
    color: #4A4A4A;
    transition: color 0.5s;
    margin-bottom: 0.5rem;
}

.year-desc {
    font-size: 1.1rem;
    color: #666;
    max-width: 600px;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease 0.2s;
    /* Delay text appearance */
}

.year-section.active .year-title {
    color: #FFF;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.year-section.active .year-desc {
    opacity: 1;
    transform: translateY(0);
    color: #EEE;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Floating Images */
.images-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    /* Above background overlay (z-2), below main text (z-10) */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s;
}

.year-section.active .images-container {
    opacity: 1;
    visibility: visible;
}

.floating-image {
    position: absolute;
    height: 250px;
    width: auto;
    border: 8px solid #FFF;
    border-bottom: 25px solid #FFF;
    /* Polaroid style */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    left: -300px;
    /* Start off-screen left */
}

/* Animation Keyframes */
/* Animation Keyframes: Float from Left to Right */
@keyframes floatRight {
    0% {
        transform: translateX(0) rotate(5deg) translateY(0);
    }

    25% {
        transform: translateX(35vw) rotate(-3deg) translateY(-20px);
    }

    50% {
        transform: translateX(70vw) rotate(3deg) translateY(0);
    }

    75% {
        transform: translateX(105vw) rotate(-3deg) translateY(20px);
    }

    100% {
        transform: translateX(140vw) rotate(5deg) translateY(0);
    }
}

/* Apply animation properties separately to avoid overriding duration */
.year-section.active .floating-image {
    animation-name: floatRight;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    animation-fill-mode: forwards;
}

/* Image Variations: Use NEGATIVE delay to show images immediately */
/* Image Variations: Spacing optimized */
/* Set 1 (Originals) */
.img-1 {
    top: 5%;
    animation-duration: 23s;
    animation-delay: 0s;
}

.img-2 {
    top: 28%;
    animation-duration: 30s;
    animation-delay: -5s;
}

.img-3 {
    top: 52%;
    /* Significantly raised from 70% to prevent bottom clipping */
    animation-duration: 20s;
    animation-delay: -10s;
}

.img-4 {
    top: 15%;
    animation-duration: 25s;
    animation-delay: -16s;
}

.img-5 {
    top: 40%;
    animation-duration: 28s;
    animation-delay: -21s;
}

/* Set 2 (Duplicates for loop) - Offset by approx 50% of duration */
.img-1.delay-set-2 {
    animation-delay: -11.5s;
}

.img-2.delay-set-2 {
    animation-delay: -20s;
}

.img-3.delay-set-2 {
    animation-delay: -20.5s;
}

.img-4.delay-set-2 {
    animation-delay: -3.3s;
}

.img-5.delay-set-2 {
    animation-delay: -7.3s;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .year-title {
        font-size: 2rem;
    }

    .floating-image {
        height: 150px;
    }

    .history-nav {
        transform: translateY(-50%) scale(0.70);
        transform-origin: right center;
        right: 5px;
    }

    .history-nav a {
        font-size: 1rem;
        padding: 1px 0;
    }

    .history-nav a.active {

        /* red-500 */
        font-size: 1.2rem;
    }
}