/* --- Basic Reset & Variables --- */
:root {
    --bg-html: #1a1a1a;
    --bg-body: #000000;
    --text-main: #e0e0e0;
    --border-main: #333;
    --shadow-color: rgba(255, 255, 255, 0.05);
    --bg-footer: #111;
    --bg-carousel: #000;
    --bg-burger: rgba(30, 30, 30, 0.9);
    --bg-caption: rgba(0,0,0,0.7);
    --bg-marker-transparent: rgba(0, 0, 0, 0);
    --bg-marker-bar: rgba(0, 0, 0, 0.15);
    --bg-marker-border: rgba(0, 0, 0, 0.8);
}

body.light-theme {
    --bg-html: #e5e5e5;
    --bg-body: #ffffff;
    --text-main: #1a1a1a;
    --border-main: #ccc;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --bg-footer: #f0f0f0;
    --bg-carousel: #f9f9f9;
    --bg-burger: rgba(240, 240, 240, 0.95);
    --bg-caption: rgba(255,255,255,0.7);
    --bg-marker-transparent: rgba(255, 255, 255, 0);
    --bg-marker-bar: rgba(255, 255, 255, 0.2);
    --bg-marker-border: rgba(255, 255, 255, 0.9);
}

/* --- Global Styles --- */
body, h1, h2, ul, p, button {
    margin: 0;
    padding: 0;
    font-family: 'Courier New', Courier, monospace;
}

html {
    background-color: var(--bg-html);
    scroll-behavior: smooth; /* Enables smooth scrolling for anchor links */
    scrollbar-gutter: stable;
}

/* --- Layout & Body Styling --- */
body {
    line-height: 1.6;
    color: var(--text-main);
    width: 95%;
    margin: 2rem auto;
    background-color: var(--bg-body);
    border-radius: 8px;
    box-shadow: 0 4px 15px var(--shadow-color);
    border-left: 2px solid var(--border-main);
    border-right: 2px solid var(--border-main);
    min-height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
}

/* --- Header & Navigation --- */
header {
    padding: 1.5rem 20px;
    text-align: center;
}

header h1 {
    margin-bottom: 1.5rem;
    font-weight: bold;
    text-transform: uppercase;
    font-size: clamp(1.2rem, 8vw, 2rem);
    overflow-wrap: break-word;
}

header nav {
    padding: 1rem 0;
    border-top: 2px solid var(--border-main);
    border-bottom: 2px solid var(--border-main);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

header nav ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

header nav ul li {
    margin: 5px 15px;
}

header nav a {
    color: var(--text-main);
    text-decoration: none;
}

header nav a.active {
    font-weight: bold;
    text-decoration: underline;
    text-underline-offset: 6px; /* Pushes the underline slightly down for better readability */
}

#theme-toggle {
    position: fixed;
    bottom: 20px;
    right: calc(2.5% + 20px); 
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 2.5rem; 
    cursor: pointer;
    z-index: 1000;
    opacity: 0.25; /* 25% transparency by default */
    transition: opacity 0.3s ease;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
    line-height: 1;
}

/* Combined hover effect for bottom buttons */
#back-to-top:hover,
#back-to-top.show:hover,
#theme-toggle:hover {
    opacity: 1;
}

/* --- Burger Menu Styles --- */
#burger-nav-container {
    position: relative;
    padding: 1.5rem 0 0.5rem;
    display: inline-block;
    transition: top 0.5s ease-in-out, left 0.5s ease-in-out, opacity 0.5s ease-in-out;
    opacity: 1; /* Start fully opaque */
    z-index: 1001; /* Ensure it's on top */
}

#burger-nav-container.scrolled {
    position: fixed;
    top: 20px;
    /* The 'left' value will be set by JavaScript */
    padding: 0;
    opacity: 0.5; 
}

#burger-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#burger-toggle .bar {
    width: 25px;
    height: 3px;
    background-color: var(--text-main);
    transition: all 0.3s ease-in-out;
}

#burger-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-burger);
    padding: 1rem;
    border: 1px solid var(--border-main);
    border-radius: 4px;
    white-space: nowrap;
}

#burger-nav-container.scrolled #burger-menu {
    left: 0;
    transform: none;
}

#burger-menu.open {
    display: block;
}

#burger-menu a {
    display: block;
    color: var(--text-main);
    text-decoration: none;
    padding: 0.5rem 0;
}

/* Placeholder to prevent content jump */
#burger-menu-placeholder {
    display: none;
    height: 0; /* Height will be set by JS */
}

/* --- Main Content Styling --- */
main {
    flex: 1;
}

main.gallery-main {
    padding: 0;
}

main h2 {
    margin-top: 1.5rem;
    margin-bottom: 2rem;
    text-align: center;
    font-weight: bold;
    text-transform: uppercase;
}

/* --- Image Grid (Masonry Style) --- */
.image-grid {
    column-count: 3;
    column-gap: 8px;
    padding: 0 2rem 4rem;
}

.grid-item {
    margin-bottom: 8px;
    break-inside: avoid;
}

.grid-item a {
    display: block;
}

.grid-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease; /* Smooth hover transition */
}

@media (hover: hover) {
    .grid-item img:hover {
        transform: scale(1.1); /* Expands the image 10% on hover */
        position: relative; /* Allows z-index to take effect */
        z-index: 10; /* Ensures the expanded image overlaps other grid items */
    }
}

/* Responsive adjustments for the grid */
@media (max-width: 900px) {
    .image-grid {
        column-count: 2;
    }
}

@media (max-width: 600px) {
    .image-grid {
        column-count: 1;
    }
}

/* --- Carousel Styles --- */
.carousel-section {
    margin-bottom: 4rem;
}

.carousel-section h2 {
    display: table;
    margin-left: auto;
    margin-right: auto;
    border-bottom: 3px solid currentColor;
    padding: 0 2ch;
    padding-bottom: 0;
}

.carousel {
    position: relative;
    overflow: hidden;
    background-color: var(--bg-carousel);
}

.carousel-inner {
    display: flex;
    align-items: center;
    height: 90vh;
    transition: transform 0.5s ease-in-out;
    will-change: transform; /* Hardware acceleration for smoother animations */
}

.carousel-item {
    min-width: 100%;
    height: 100%;
    box-sizing: border-box;
    position: relative;
}

.carousel-item a {
    display: block;
    width: 100%;
    height: 100%;
    cursor: default; /* Removes the pointing hand cursor */
}

.carousel-item img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.carousel-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: var(--bg-caption);
    text-align: center;
}

.carousel-control {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: transparent;
    border: none;
    color: var(--text-main);
    font-size: 3rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    user-select: none;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
    touch-action: manipulation; /* Removes any mobile tap delays */
}

.carousel-control.prev {
    left: 10px;
}

.carousel-control.next {
    right: 10px;
}

.carousel.controls-visible .carousel-control {
    opacity: 1;
}

/* --- Carousel Markers --- */
.carousel-markers {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0;
    z-index: 15;
    list-style: none;
    padding: 4px 40px;
    margin: 0;
    border-radius: 20px;
    background-image: 
        linear-gradient(to right, var(--bg-marker-transparent) 0%, var(--bg-marker-bar) 50%, var(--bg-marker-transparent) 100%);
    max-width: calc(100vw - 250px);
    overflow-x: hidden;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    scroll-behavior: smooth;
}

.carousel-markers::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

.carousel-marker {
    width: 0;
    margin: 0;
    height: 12px;
    border-radius: 50%;
    background-color: var(--text-main);
    opacity: 0;
    transition: all 0.3s ease;
    cursor: pointer;
    flex-shrink: 0;
    pointer-events: none;
}

.carousel-marker.desktop-visible {
    width: 12px;
    margin: 0 5px;
    opacity: 0.4;
    pointer-events: auto;
}

.carousel-marker.desktop-visible:hover,
.carousel-marker.desktop-visible.active {
    opacity: 0.9;
}

/* --- Footer Styling --- */
footer {
    background-color: var(--bg-footer);
    color: var(--text-main);
    text-align: center;
    padding: 1.5rem 0;
    position: relative;
    width: 100%;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* --- Back to Top Button --- */
#back-to-top {
    position: fixed;
    bottom: 20px;
    right: calc(2.5% + 75px); /* Aligns safely inside the main body's right border */
    background: transparent;
    border: none;
    color: var(--text-main); 
    font-size: 2.5rem;
    cursor: pointer;
    z-index: 1000;
    opacity: 0; /* Hidden by default, faded in with .show class */
    visibility: hidden;
    transition: opacity 0.3s ease;
    line-height: 1;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8); /* Shadow for visibility on any background */
}

#back-to-top.show {
    opacity: 0.25; /* 25% transparency when shown */
    visibility: visible;
}

/* --- Mobile Scroll Snapping --- */
@media (max-width: 768px) {
    html {
        /* Snapping is disabled by default to allow free scrolling in the header area */
        scroll-snap-type: none;
    }
    /* When scrolled past the header, mandatory snapping is activated */
    html.snapping-active {
        scroll-snap-type: y mandatory;
    }
    .carousel-section {
        scroll-snap-align: center;
    }

    .carousel-markers {
        max-width: calc(100vw - 200px); /* Confine to avoid button overlap */
    }

    .carousel-marker.desktop-visible {
        width: 0;
        margin: 0;
        opacity: 0;
        pointer-events: none;
    }
    .carousel-marker.mobile-visible {
        width: 12px;
        margin: 0 5px; /* Replaces the 10px gap to allow layout animation */
        opacity: 0.4;
        pointer-events: auto;
    }
    .carousel-marker.mobile-visible.active {
        opacity: 0.9;
    }

    #theme-toggle {
        right: calc(2.5% + 10px);
    }
    #back-to-top {
        right: calc(2.5% + 10px + 2.5rem); /* No gap between the buttons */
    }
}

/* --- Contact Form Styles --- */
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 500px;
    margin: 2rem auto;
    text-align: left;
}

.contact-form label {
    font-weight: bold;
}

.contact-form input,
.contact-form textarea {
    padding: 0.75rem;
    background-color: var(--bg-body);
    color: var(--text-main);
    border: 2px solid var(--border-main);
    border-radius: 0;
    font-family: inherit;
    resize: none;
}

.contact-form button[type="submit"] {
    padding: 0.75rem;
    background-color: var(--bg-body);
    color: var(--text-main);
    border: 2px solid var(--border-main);
    border-radius: 0;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    transition: background-color 0.3s ease;
}

.contact-form button[type="submit"]:hover {
    background-color: var(--bg-html);
}

/* --- Popup Notification Styles --- */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.popup-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.popup-content {
    background-color: var(--bg-body);
    padding: 2.5rem 2rem;
    border: 2px solid var(--border-main);
    text-align: center;
    max-width: 400px;
    width: 80%;
    box-shadow: 0 4px 15px var(--shadow-color);
}

.popup-content p {
    margin-bottom: 2rem;
    font-weight: bold;
    line-height: 1.4;
}

.popup-content button {
    border-radius: 0;
    padding: 0.5rem 2rem;
    background-color: var(--bg-body);
    color: var(--text-main);
    border: 2px solid var(--border-main);
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    transition: background-color 0.3s ease;
}

.popup-content button:hover {
    background-color: var(--bg-html);
}
