/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Font loading optimization */
@font-face {
    font-family: 'Borel';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('https://fonts.gstatic.com/s/borel/v1/6qL_KZk8hstQl5xNtoQQ7A.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    /* Light mode colors (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f8f8;
    --bg-tertiary: #f0f0f0;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --overlay-bg: rgba(0, 0, 0, 0.95);
    --gallery-item-bg: #f5f5f5;
    --header-gradient: linear-gradient(180deg, #ffffff 0%, #f8f8f8 100%);
}

[data-theme="dark"] {
    /* Dark mode colors */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #0a0a0a;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-tertiary: #999999;
    --border-color: #333333;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --overlay-bg: rgba(0, 0, 0, 0.95);
    --gallery-item-bg: #2a2a2a;
    --header-gradient: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
}

body {
    font-family: 'Borel', cursive, system-ui, -apple-system, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    /* Prevent layout shift during font loading */
    font-display: swap;
}

/* Header Styles */
.site-header {
    padding: 60px 20px;
    text-align: center;
    background: var(--header-gradient);
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
}

.site-title {
    font-family: 'Borel', cursive, system-ui, -apple-system, sans-serif;
    font-size: 2.8rem;
    font-weight: 400;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    /* Reserve space to prevent layout shift */
    min-height: 1.2em;
    line-height: 1.2;
}

.site-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 300;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    /* Reserve space to prevent layout shift */
    min-height: 1.4em;
    line-height: 1.4;
}

/* Gallery Container */
.gallery-container {
    flex: 1;
    padding: 40px 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    /* CSS Containment for better performance */
    contain: layout style;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    /* Prevent layout shift during content loading */
    min-height: 200px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.gallery-grid.rendered {
    opacity: 1;
    transform: translateY(0);
}

/* Gallery Item */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
    background-color: var(--gallery-item-bg);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    aspect-ratio: 3/2;
    border: 1px solid var(--border-color);
    /* Optimize for animations */
    will-change: transform, box-shadow;
    /* CSS Containment */
    contain: layout;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px var(--shadow-color);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    /* Prevent layout shift during image loading */
    background-color: var(--gallery-item-bg);
    display: block;
}

.gallery-item:hover img {
    transform: scale(1.05);
}



/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-bg);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    /* Optimize for animations */
    will-change: opacity, transform;
    /* CSS Containment */
    contain: layout;
}

.lightbox.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.lightbox-image {
    max-width: 90%;
    max-height: 85vh;
    object-fit: contain;
    animation: scaleIn 0.3s ease;
}

.lightbox-close {
    position: absolute;
    top: 30px;
    right: 40px;
    font-size: 40px;
    color: #fff;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 1001;
}

.lightbox-close:hover {
    color: #ccc;
}

.lightbox-caption {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    text-align: center;
    padding: 10px 20px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 4px;
    font-size: 1rem;
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    font-size: 60px;
    cursor: pointer;
    padding: 10px 20px;
    transition: background-color 0.3s ease;
    border-radius: 4px;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: 30px;
}

.lightbox-next {
    right: 30px;
}

/* Footer */
.site-footer {
    padding: 30px 20px;
    text-align: center;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-tertiary);
}

.site-footer p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Theme Toggle Button */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: 2px solid var(--text-primary);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.theme-toggle:hover {
    transform: scale(1.1);
    background-color: var(--bg-secondary);
}

.theme-toggle svg {
    width: 22px;
    height: 22px;
    fill: var(--text-primary);
    transition: fill 0.3s ease;
}

.theme-toggle .sun-icon {
    display: block;
}

.theme-toggle .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .site-title {
        font-size: 2.5rem;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }
    
    .lightbox-prev,
    .lightbox-next {
        font-size: 40px;
        padding: 5px 10px;
    }
    
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
    
    .lightbox-close {
        top: 20px;
        right: 20px;
        font-size: 30px;
    }
}

/* AdSense Advertisement Styles */
.gallery-ad-item {
    grid-column: 1 / -1;
    margin: 30px 0;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 120px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.gallery-ad-item.ad-loaded {
    border-color: var(--text-secondary);
}

.gallery-ad-item.ad-fallback-shown {
    min-height: auto;
    padding: 15px;
}

.gallery-ad-content {
    width: 100%;
    max-width: 728px;
    text-align: center;
}

.ad-fallback {
    width: 100%;
    max-width: 300px;
}

/* Header Advertisement Styles */
.ads-section {
    margin: 20px 0;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 120px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.ads-section .adsbygoogle {
    width: 100%;
    max-width: 728px;
}

/* Mobile responsiveness for ads */
@media (max-width: 768px) {
    .gallery-ad-item,
    .ads-section {
        margin: 20px 0;
        padding: 15px;
        min-height: 100px;
    }

    .gallery-ad-content,
    .ads-section .adsbygoogle {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .site-title {
        font-size: 2rem;
    }

    .site-subtitle {
        font-size: 0.9rem;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .lightbox-image {
        max-width: 95%;
        max-height: 70vh;
    }

    .gallery-ad-item,
    .ads-section {
        margin: 15px 0;
        padding: 10px;
        min-height: 80px;
    }
}