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

html {
    scroll-behavior: auto;
}

/* Root variables for light/dark mode */
:root {
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --text-secondary: #666666;
}

body.dark-mode {
    --bg-color: #0a0a0a;
    --text-color: #e5e5e5;
    --text-secondary: #999999;
}

/* Base styles */
body {
    font-family: 'Garamond', 'EB Garamond', 'Cormorant Garamond', Georgia, serif;
    background: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.4s cubic-bezier(0.4, 0.0, 0.2, 1), color 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    position: fixed;
}

/* Viewport wrapper for panning and zooming */
.viewport {
    width: 100vw;
    height: 100vh;
    overflow: scroll;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-color);
    scroll-behavior: auto;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    transition: background-color 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    /* Prevent flashing during rapid transitions */
    backface-visibility: hidden;
}

.viewport::-webkit-scrollbar {
    display: none;
}

.viewport {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Collection container */
.collection-container {
    position: relative;
    width: 8000px;
    height: 8000px;
    margin: 0;
    padding: 0;
    transform-origin: center center;
    background: transparent;
    will-change: transform;
}

/* Image items - scattered positioning */
.image-item {
    position: absolute;
    opacity: 0;
    transition: left 1s cubic-bezier(0.4, 0, 0.2, 1), top 1s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.6s ease, transform 0.3s ease;
    cursor: pointer;
    /* Force GPU layer and isolate from parent background changes */
    transform: translate3d(0, 0, 0);
    isolation: isolate;
}

.image-item.loaded {
    opacity: 1;
}

.image-item:hover {
    transform: scale3d(1.05, 1.05, 1);
    z-index: 100;
}

.image-item.enlarged {
    z-index: 1000;
    transition: left 1s cubic-bezier(0.4, 0, 0.2, 1), top 1s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.image-item img {
    width: 100%;
    height: auto;
    display: block;
}

/* Date caption - shown on spacebar */
.image-date {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-family: 'Garamond', 'EB Garamond', Georgia, serif;
    font-size: 0.75rem;
    font-weight: 300;
    color: var(--text-color);
    background: var(--bg-color);
    padding: 4px 8px;
    border-radius: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, color 0.4s cubic-bezier(0.4, 0.0, 0.2, 1), background-color 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    letter-spacing: 0.02em;
}

body.show-dates .image-date {
    opacity: 0.7;
}

/* Size presets - uniform size with aspect ratio preserved */
.size-small,
.size-medium,
.size-large,
.size-xlarge,
.size-uniform {
    max-width: 350px;
    max-height: 350px;
}

.size-uniform img,
.size-small img,
.size-medium img,
.size-large img,
.size-xlarge img {
    width: auto;
    height: auto;
    max-width: 350px;
    max-height: 350px;
    object-fit: contain;
}

/* Tooltip removed */

/* Removed fade end effect */

/* Counter hover area (bottom right corner) */
.counter-trigger {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 100px;
    height: 100px;
    z-index: 999;
}

.counter-display {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-size: 11px;
    font-weight: 300;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1001;
}

.counter-trigger:hover + .counter-display {
    opacity: 1;
}



/* Remove smooth scrolling completely */
* {
    scroll-behavior: auto !important;
    overscroll-behavior: none !important;
}

/* Responsive adjustments */
@media (max-width: 1400px) {
    .collection-container {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .size-small {
        width: 180px;
    }

    .size-medium {
        width: 260px;
    }

    .size-large {
        width: 350px;
    }

    .size-xlarge {
        width: 450px;
    }
}

@media (max-width: 480px) {
    .size-small {
        width: 150px;
    }

    .size-medium {
        width: 220px;
    }

    .size-large {
        width: 300px;
    }

    .size-xlarge {
        width: 380px;
    }
}
