/* Component Styles */

/* Image loading placeholder */
.image-placeholder {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    background-color: #6b8db5;
    overflow: hidden;
}

.image-placeholder-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition:
        opacity var(--animation-medium, 0.3s) ease,
        transform var(--animation-slow, 0.8s) ease-in-out;
}

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

.image-placeholder.image-loaded {
    background-color: transparent;
}

.image-placeholder.image-loaded.image-placeholder-fallback {
    background-color: var(--accent-red);
}

.image-placeholder-fallback .image-placeholder-image {
    object-fit: contain;
    padding: var(--space-sm);
}

.image-placeholder-image.image-fallback-image,
img.image-fallback-image {
    background-color: var(--accent-red);
    object-fit: contain;
    padding: var(--space-xs);
}

.image-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(107, 141, 181, 0.35);
    transition: opacity var(--animation-medium, 0.3s) ease;
    pointer-events: none;
}

.image-placeholder.image-loaded .image-loading-overlay {
    opacity: 0;
    pointer-events: none;
}

.image-loading-spinner {
    width: clamp(40px, 12vw, 80px);
    height: clamp(40px, 12vw, 80px);
    object-fit: contain;
}

/* Gallery Styles */
.gallery-container {
    position: relative;
    min-height: 100vh;
    width: 100%;
    padding: var(--space-lg);
}

.gallery-header {
    position: absolute;
    top: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-content);
}

.gallery-title-image {
    height: auto;
    max-width: clamp(150px, 12vw, 250px);
    margin-bottom: var(--space-md);
}

.gallery-title-image.krabbels {
    transform: rotate(-1deg);
}

.gallery-title-image.naaisels {
    transform: rotate(1deg);
}

.gallery-title-image.schrijfsels {
    transform: rotate(-2deg);
}

.gallery-title-image.knutsels {
    transform: rotate(2deg);
}

/* Krabbels Gallery - Free-form collage layout */
.krabbels-gallery {
    position: relative;
    width: 100%;
    min-height: 200vh;
    padding-top: 120px;
    padding-bottom: 100px;
}

/* New: Auto-collage layout (no manual coordinates) */
.krabbels-gallery.krabbels-collage {
    position: relative;
    z-index: var(--z-content);
    min-height: 80vh;
    padding-top: clamp(100px, 10vh, 160px);
    padding-bottom: clamp(140px, 12vh, 220px);
}

.krabbels-collage .collage-item {
    position: absolute; /* positioned by JS */
    opacity: 0;
    transition: opacity var(--animation-medium, 0.3s) ease,
                transform var(--animation-slow, 0.6s) ease;
    will-change: transform;
    background: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

.krabbels-collage .collage-item.laid-out { opacity: 1; }

.krabbels-collage .collage-item img,
.krabbels-collage .collage-item .image-placeholder,
.krabbels-collage .collage-item .image-placeholder-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.krabbels-collage .collage-item:hover {
    transform: translate3d(0, -2px, 0) scale(1.02) rotate(var(--hover-rotate, 0deg));
}

@media (min-width: 1024px) {
    .krabbels-gallery.krabbels-layout {
        min-height: 0;
        margin: 0 auto var(--space-xxxl);
        position: relative;
        overflow: visible;
        padding-top: clamp(120px, 10vh, 180px);
        padding-bottom: clamp(140px, 12vh, 220px);
    }

    .krabbels-gallery.krabbels-layout .gallery-item {
        margin: 0;
        display: block;
    }
}

.gallery-item {
    position: absolute;
    cursor: pointer;
    transition: transform var(--animation-medium) var(--ease-out),
                box-shadow var(--animation-medium) var(--ease-out);
}

.gallery-item:hover {
    transform: scale(1.05) rotate(0deg) !important;
    box-shadow: var(--shadow-heavy);
    z-index: var(--z-content);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item.size-small {
    width: clamp(100px, 8vw, 150px);
    height: clamp(100px, 8vw, 150px);
}

.gallery-item.size-medium {
    width: clamp(150px, 12vw, 220px);
    height: clamp(150px, 12vw, 220px);
}

.gallery-item.size-large {
    width: clamp(200px, 16vw, 300px);
    height: clamp(200px, 16vw, 300px);
}

/* Naaisels Gallery - Structured project layout */
.naaisels-gallery {
    display: flex;
    flex-direction: column;
    gap: var(--space-xxxl);
    padding-top: 120px;
    max-width: 1000px;
    margin: 0 auto;
}

.project-item {
    display: flex;
    gap: var(--space-xl);
    align-items: center;
    position: relative;
}

.project-item:nth-child(even) {
    flex-direction: row-reverse;
}

.project-image {
    flex: 1;
    max-width: 400px;
    height: 300px;
    background-color: var(--accent-purple);
    border-radius: var(--border-radius-large);
    position: relative;
    overflow: hidden;
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.project-image .image-placeholder,
.project-image .image-placeholder-image {
    width: 100%;
    height: 100%;
}

.project-details {
    flex: 1;
    padding: var(--space-lg);
}

.project-title {
    font-family: var(--font-family-handwritten);
    font-size: var(--font-size-xl);
    font-weight: bold;
    margin-bottom: var(--space-md);
    color: var(--text-dark);
}

.project-description {
    font-size: var(--font-size-base);
    margin-bottom: var(--space-lg);
    color: var(--text-medium);
}

.project-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.project-materials,
.project-techniques {
    font-size: var(--font-size-small);
    color: var(--text-medium);
}

.project-materials strong,
.project-techniques strong {
    color: var(--text-dark);
    font-weight: bold;
}

.project-navigation {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--animation-medium) var(--ease-out);
    font-size: var(--font-size-large);
    color: var(--text-dark);
}

.project-navigation:hover {
    background: var(--white);
    transform: translateY(-50%) scale(1.1);
    box-shadow: var(--shadow-medium);
}

.project-navigation.prev {
    left: -25px;
}

.project-navigation.next {
    right: -25px;
}

/* Schrijfsels Gallery - Text-focused layout */
.schrijfsels-gallery {
    max-width: 800px;
    margin: 0 auto;
    padding-top: 120px;
}

.writing-item {
    margin-bottom: var(--space-xxxl);
    padding: var(--space-xl);
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-light);
}

.writing-title {
    font-family: var(--font-family-handwritten);
    font-size: var(--font-size-xl);
    font-weight: bold;
    margin-bottom: var(--space-md);
    color: var(--text-dark);
    transform: rotate(-1deg);
}

.writing-content {
    font-size: var(--font-size-base);
    color: var(--text-dark);
    white-space: pre-line;
}

.writing-content p {
    margin-bottom: var(--space-lg);
}

/* Navigation Elements */
.back-navigation {
    position: fixed;
    top: var(--space-lg);
    left: var(--space-lg);
    z-index: var(--z-navigation);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform var(--animation-medium) var(--ease-out);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-navigation:hover {
    transform: scale(1.1);
}

.back-navigation img {
    width: clamp(60px, 5vw, 120px);
    height: clamp(60px, 5vw, 120px);
}

/* Archive Link */
.archive-link-page {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: var(--z-navigation);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.archive-typo-page {
    display: block;
    height: auto;
    max-width: var(--archive-typo-width);
}

.archive-line-page {
    display: block;
    height: auto;
    max-width: var(--archive-line-width);
}

@media (max-width: 768px) {
    .back-navigation {
        top: var(--space-xl);
        left: var(--space-xl);
    }

    .archive-link-page {
        display: none !important;
        top: var(--space-xl);
        right: var(--space-xl);
    }

    .back-navigation img {
        width: clamp(70px, 18vw, 110px);
        height: clamp(70px, 18vw, 110px);
    }
}

/* Under construction placeholder */
.knutsels-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-size: clamp(1.4rem, 3vw, 2rem);
    line-height: 1.5;
    color: var(--text-dark);
    max-width: min(90vw, 480px);
    padding: var(--space-lg) var(--space-md);
    background: rgba(255, 255, 255, 0.25);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-light);
}

/* Modal/Lightbox for gallery items */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all var(--animation-medium) var(--ease-out);
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    max-width: 80vw;
    max-height: 80vh;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

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

.lightbox .image-placeholder-image {
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: var(--white);
    font-size: var(--font-size-xxl);
    cursor: pointer;
    padding: var(--space-sm);
    transition: transform var(--animation-fast) var(--ease-out);
}

.lightbox-close:hover {
    transform: scale(1.2);
}

.lightbox-info {
    position: absolute;
    bottom: -60px;
    left: 0;
    right: 0;
    text-align: center;
    color: var(--white);
}

.lightbox-title {
    font-size: var(--font-size-large);
    font-weight: bold;
    margin-bottom: var(--space-sm);
}

.lightbox-description {
    font-size: var(--font-size-base);
    opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .gallery-item.size-small {
        width: 100px;
        height: 100px;
    }
    
    .gallery-item.size-medium {
        width: 150px;
        height: 150px;
    }
    
    .gallery-item.size-large {
        width: 200px;
        height: 200px;
    }
    
    .project-item {
        flex-direction: column !important;
        text-align: center;
    }
    
    .project-image {
        max-width: 100%;
        height: 250px;
    }
}

@media (max-width: 768px) {
    .gallery-container {
        padding: var(--space-md);
    }
    
    .gallery-title {
        font-size: var(--font-size-xl);
    }
    
    .krabbels-gallery {
        padding-top: 80px;
    }
    
    .gallery-item.size-small {
        width: 80px;
        height: 80px;
    }
    
    .gallery-item.size-medium {
        width: 120px;
        height: 120px;
    }
    
    .gallery-item.size-large {
        width: 160px;
        height: 160px;
    }
    
    .naaisels-gallery,
    .schrijfsels-gallery {
        padding-top: 80px;
    }
    
    .writing-item {
        padding: var(--space-lg);
        margin-bottom: var(--space-xl);
    }
    
    .writing-content {
        font-size: var(--font-size-small);
    }
    
    .project-details {
        padding: var(--space-md);
    }
    
    .project-navigation {
        display: none;
    }
}
