/* Basic Reset & Typography */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Define CSS Variables for Colors (Light Mode Defaults) */
:root {
    --bg-primary: #f5f8fc; /* Main background */
    --bg-secondary: #f3f9f9; /* Timeline background */
    --bg-card: #fff; /* Card/content background */
    --text-color: #444;
    --heading-color-main: #4a6f5d; /* Dark green */
    --heading-color-secondary: #77998a; /* Light green */
    --link-color: #77998a;
    --link-hover-color: #4a6f5d;
    --border-color: #e6f0f0;
    --shadow-color: rgba(0,0,0,0.08);
    --shadow-card: rgba(0,0,0,0.1);
    --timeline-line-color: #a7d9e8; /* Soft blue */
    --timeline-active-color: #4a6f5d; /* Dark green for active elements */
    --social-hover-bg: #e0f2ff; /* Soft blue */
    --footer-bg: #77998a; /* Light green */
    --modal-bg: rgba(0,0,0,0.85);
    --modal-close-color: #f5f5f5;
    --modal-caption-color: #f0f0f0;
}

/* Dark Mode Overrides - Presetsstore-inspired look */
body.dark-mode {
    --bg-primary: #121212; /* Very dark charcoal/almost black */
    --bg-secondary: #1e1e1e; /* Slightly lighter dark grey for timeline */
    --bg-card: #282828; /* Medium dark grey for cards/content boxes */
    --text-color: #eeeeee; /* Crisp light grey for text */
    --heading-color-main: #bb86fc; /* A subtle, modern purple for main headings */
    --heading-color-secondary: #03dac6; /* A clean teal for secondary headings */
    --link-color: #03dac6; /* Teal for links */
    --link-hover-color: #bb86fc; /* Purple on link hover */
    --border-color: #383838; /* Darker border for separation */
    --shadow-color: rgba(0,0,0,0.6); /* More prominent shadows in dark mode */
    --shadow-card: rgba(0,0,0,0.8);
    --timeline-line-color: #bb86fc; /* Purple for timeline line */
    --timeline-active-color: #03dac6; /* Teal for active timeline elements */
    --social-hover-bg: #383838; /* Dark grey hover for social links */
    --footer-bg: #0d0d0d; /* Even darker for footer */
    --modal-bg: rgba(0,0,0,0.98); /* Near black modal background */
    --modal-close-color: #cccccc;
    --modal-caption-color: #cccccc;
}


/* Global HTML/Body Styles */
html {
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    scroll-padding-top: 0px; /* Managed by CSS variables now */
    overflow-y: scroll;
}

body {
    font-family: 'Quicksand', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-primary);
    transition: background-color 0.5s ease, color 0.5s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

h1, h2, h3 {
    font-family: 'Comfortaa', cursive;
    font-weight: 700;
    margin-bottom: 1em;
    color: var(--heading-color-main);
    text-align: center;
    transition: color 0.5s ease;
}

h3 { color: var(--heading-color-secondary); }

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--link-hover-color);
}

/* Header */
.site-header {
    background-color: var(--bg-card);
    padding: 25px 0;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    box-shadow: 0 3px 8px var(--shadow-color);
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 100;
    transition: background-color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.site-header h1 {
    margin: 0;
    font-size: 2.5em;
    display: inline-block;
    vertical-align: middle;
}

/* Header Container Flex Layout */
.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Navigation Menu Styles */
.site-header nav {
    margin-left: 30px;
}

.site-header nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    gap: 25px;
}

.site-header nav ul li {
    display: inline-block;
}

.site-header nav ul li a {
    font-weight: 500;
    font-size: 1.2em;
    padding: 5px 0;
}

/* Dark Mode Toggle Button Styling */
.dark-mode-toggle {
    background: none;
    border: none;
    font-size: 1.8em;
    cursor: pointer;
    position: static;
    transform: none;
    color: var(--text-color);
    transition: color 0.3s ease, background-color 0.3s ease;
    padding: 5px;
    border-radius: 5px;
    outline: none;
    margin-left: 30px;
}

.dark-mode-toggle:hover {
    color: var(--link-hover-color);
    background-color: var(--border-color);
}


/* Main Content Sections */
.main-content {
    flex-grow: 1;
    position: relative;
    z-index: 1;
    background-color: transparent;
}

.main-content section {
    padding: 70px 0;
    text-align: center;
    background-color: var(--bg-card);
    position: relative;
    z-index: 1;
    transition: background-color 0.5s ease, color 0.5s ease;
    overflow: visible;
    scroll-snap-align: none;
    scroll-margin-top: 0; /* Remove scroll-margin-top from general sections */
}

.welcome-section {
    padding-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
    padding-top: 70px;
}

.welcome-section p {
    max-width: 800px;
    margin: 0 auto 1em auto;
    font-size: 1.1em;
}

/* Timeline Specific Styles */
.timeline-container {
    padding: 80px 0;
    position: relative;
    background-color: var(--bg-secondary);
    z-index: 1;
    transition: background-color 0.5s ease;

    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
}

.timeline-main-title {
    margin-bottom: 60px;
    text-align: center;
    padding-top: 0;
    margin-top: 0;
    scroll-snap-align: start;
    scroll-margin-top: 0px;
}

.timeline {
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

/* The vertical line */
.timeline::after {
    content: '';
    position: absolute;
    width: 6px;
    background-color: var(--timeline-line-color);
    top: 0;
    bottom: 0;
    left: 50%;
    margin-left: -3px;
    z-index: 2;
    transition: background-color 0.5s ease;
}

/* Individual timeline items */
.timeline-item {
    padding: 10px 0;
    position: relative;
    background-color: inherit;
    width: 50%;
    z-index: 1;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    scroll-snap-align: start;
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-margin-top: 0px;
}

/* When the 'hidden' class is removed, show and move the item */
.timeline-item.show {
    opacity: 1;
    transform: translateY(0);
}

/* The circles on the timeline */
.timeline-item::after {
    content: '';
    position: absolute;
    width: 25px;
    height: 25px;
    background-color: var(--timeline-line-color);
    border: 4px solid var(--bg-card);
    top: 25px;
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 2px 5px var(--shadow-color);
    transition: background-color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

/* Left side of the timeline */
.timeline-left {
    left: 0;
    padding-right: 60px;
}

.timeline-left::after {
    right: -17px;
}

/* Right side of the timeline */
.timeline-right {
    left: 50%;
    padding-left: 60px;
}

.timeline-right::after {
    left: -17px;
}

/* Content within timeline items */
.timeline-content {
    padding: 25px 30px;
    background-color: var(--bg-card);
    position: relative;
    border-radius: 12px;
    box-shadow: 0 5px 15px var(--shadow-card);
    text-align: left;
    height: auto;
    transition: background-color 0.5s ease, box-shadow 0.5s ease;
}

.timeline-content h3 {
    text-align: left;
    margin-bottom: 15px;
    font-size: 1.6em;
}

.timeline-content p {
    text-align: left;
    margin-bottom: 20px;
    font-size: 1em;
}


/* Images within timeline items */
.timeline-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    padding-top: 10px;
}

.timeline-images .gallery-item {
    box-shadow: 0 2px 8px var(--shadow-color);
    border-radius: 8px;
    transition: box-shadow 0.5s ease;
}

.timeline-images .gallery-item img {
    height: 150px;
    object-fit: cover;
}

.timeline-images .gallery-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px var(--shadow-card);
}

/* Arrows for timeline content boxes */
.timeline-left .timeline-content::before {
    content: " ";
    height: 0;
    position: absolute;
    top: 35px;
    width: 0;
    z-index: 1;
    right: -20px;
    border: medium solid var(--bg-card);
    border-width: 10px 0 10px 10px;
    transition: border-color 0.5s ease;
}

.timeline-right .timeline-content::before {
    content: " ";
    height: 0;
    position: absolute;
    top: 35px;
    width: 0;
    z-index: 1;
    left: -20px;
    border: medium solid var(--bg-card);
    border-width: 10px 10px 10px 0;
    transition: border-color 0.5s ease;
}

/* Add a class for active/highlighted timeline items */
.timeline-item.active .timeline-content {
    border: 2px solid var(--timeline-line-color);
    box-shadow: 0 8px 25px var(--shadow-card);
    transition: border-color 0.5s ease, box-shadow 0.5s ease;
}

.timeline-item.active .timeline-content h3 {
    color: var(--heading-color-main);
}

.timeline-item.active::after {
    background-color: var(--timeline-active-color);
    border-color: var(--bg-card);
    transform: scale(1.2);
    transition: all 0.3s ease, background-color 0.5s ease, border-color 0.5s ease;
}

/* About and Contact Sections */
.about-section, .contact-section {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.1em;
    padding-top: 70px;
    padding-bottom: 70px;
    background-color: var(--bg-card);
    position: relative;
    z-index: 1;
    transition: background-color 0.5s ease, color 0.5s ease;
    scroll-snap-align: none;
    scroll-margin-top: 0; /* Remove scroll-margin-top here */
}

.about-section p, .contact-section p {
    margin-bottom: 1.2em;
    text-align: center;
}

.social-links {
    margin-top: 30px;
}

.social-links a {
    display: inline-block;
    margin: 0 12px;
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    font-weight: 500;
}

.social-links a:hover {
    background-color: var(--social-hover-bg);
    color: var(--heading-color-main);
    border-color: var(--social-hover-bg);
}

/* Footer */
.site-footer {
    background-color: var(--footer-bg);
    color: var(--text-color);
    text-align: center;
    padding: 40px 0;
    font-size: 1em;
    position: relative;
    z-index: 1;
    transition: background-color 0.5s ease, color 0.5s ease;
    margin-top: auto;
    scroll-snap-align: none;
    scroll-margin-top: 0; /* Remove scroll-margin-top here */
}

/* Background Slideshow */
.background-slideshow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
    background-color: var(--bg-primary);
}

.background-slideshow img {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
    will-change: opacity;
}

.background-slideshow img.active {
    opacity: 0.1;
}

/* Modal/Lightbox Styles - Adjusted for centering and full visibility */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: var(--modal-bg);
    animation: fadeIn 0.3s;
    /* NEW: Use flexbox for robust vertical/horizontal centering */
    display: flex; /* Make the modal a flex container */
    align-items: center; /* Vertically center content */
    justify-content: center; /* Horizontally center content */
    flex-direction: column; /* Stack image and caption vertically */
    padding: 20px; /* Add some overall padding to prevent content hitting edges */
}

.modal-content {
    /* Removed margin:auto as flexbox handles centering */
    display: block;
    max-width: 95%; /* Give a bit more breathing room than 90% */
    max-height: 80vh; /* Leave room for caption and close button */
    object-fit: contain; /* Shrink to fit, maintain aspect ratio, show full image */
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.3);
    flex-shrink: 0; /* Prevent image from shrinking if caption is very long */
}

#caption {
    /* Removed margin:auto as flexbox handles centering */
    display: block;
    width: 95%; /* Match max-width of image */
    max-width: 800px; /* Limit caption width for readability */
    text-align: center;
    color: var(--modal-caption-color);
    padding: 15px 0;
    height: auto;
    font-size: 1.2em;
    font-family: 'Quicksand', sans-serif;
    flex-shrink: 0; /* Prevent caption from shrinking */
    margin-top: 10px; /* Space between image and caption */
}

.close-button {
    position: absolute;
    top: 20px;
    right: 40px;
    color: var(--modal-close-color);
    font-size: 45px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 10001; /* Ensure close button is always on top */
}

.close-button:hover,
.close-button:focus {
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

/* Animations */
@keyframes fadeIn {
    from {opacity: 0;}
    to {opacity: 1;}
}

/* Responsive Design */
@media (max-width: 768px) {
    .site-header .container {
        flex-direction: column;
        align-items: center;
        padding-top: 15px;
        padding-bottom: 15px;
    }

    .site-header h1 {
        font-size: 2.2em;
        margin-bottom: 10px;
    }

    .site-header nav {
        margin-left: 0;
        width: 100%;
        margin-bottom: 15px;
    }

    .site-header nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }

    .site-header nav ul li a {
        font-size: 1.1em;
    }

    .dark-mode-toggle {
        font-size: 1.5em;
        position: static;
        margin-left: 0;
        margin-top: 10px;
    }

    html {
        scroll-padding-top: 0px; /* Revert to 0 for mobile HTML */
    }
    .welcome-section {
        padding-top: 70px; /* Default padding for mobile */
    }

    /* Timeline Adjustments for Mobile */
    .timeline::after {
        left: 18px;
    }

    .timeline-item {
        width: 100%;
        padding-left: 60px;
        padding-right: 15px;
        min-height: 60vh;
        scroll-margin-top: 0px; /* No sticky header here, as timeline container has its own scroll */
    }

    .timeline-right {
        left: 0%;
    }

    .timeline-left::after,
    .timeline-right::after {
        left: 8px;
    }

    /* Remove arrows and shift content for mobile */
    .timeline-left .timeline-content::before,
    .timeline-right .timeline-content::before {
        border: none;
    }

    .timeline-images {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 10px;
    }

    .timeline-images .gallery-item img {
        height: 120px;
    }

    .close-button {
        font-size: 35px;
        top: 10px;
        right: 20px;
    }

    .modal-content {
        max-height: 70vh; /* Adjust for more consistent sizing on mobile */
    }

    .timeline-container {
        height: calc(100vh - 150px - 100px); /* Mobile header/footer adjustment */
    }
}

@media screen and (max-width: 480px) {
    .site-header h1 { font-size: 1.6em; }
    .site-header nav ul li a { font-size: 0.9em; }
    h2 { font-size: 1.5em; }
    h3 { font-size: 1.3em; }

    .main-content section {
        padding: 40px 0;
    }

    .timeline-images {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 8px;
    }

    .timeline-images .gallery-item img {
        height: 100px;
    }
}