/* Image animation styles */
.image-container {
    position: relative;
    overflow: hidden;
    width: 100%;
    /* Let the container determine height using an aspect ratio (prevents collapsing to 0)
       Portrait mockups use ~9:16; change if needed. */
    aspect-ratio: 9 / 16;
    height: auto;
    min-height: 300px;
    /* never exceed viewport (leave room for header/controls) */
    max-height: calc(100vh - 120px);
    /* adjust 120px as needed for header + margins */
    /* or use clamp for a safer range */
    max-height: clamp(320px, 70vh, 800px);
}

.image-stack {
    position: relative;
    width: 100%;
    height: 100%;
}

.image-stack a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    opacity: 0;
    visibility: hidden;
    transform: translateZ(0);
    backface-visibility: hidden;
    transition: none;
    /* GSAP will handle transitions */
}

.image-stack a.active {
    opacity: 1;
    visibility: visible;
}

/* Ensure the active anchor's image is visible even before 'loaded' class is added */
.image-stack a.active img {
    opacity: 1;
    visibility: visible;
}

/* Make sure images fill the container and override other site rules */
.featured__work-thumb .image-stack a img {
    width: auto;
    height: 100%;
    object-fit: cover;
    /* or 'contain' if you prefer full-image visibility without cropping */
    border-radius: 8px;
}

/* Fallback generic rule */
.image-stack img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    border-radius: 8px;
}

/* Animation controls */
.animation-controls {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 8px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.featured__work-thumb:hover .animation-controls {
    opacity: 1;
}

.anim-style-btn {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
}

.anim-style-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-2px);
}

.anim-style-btn.active {
    background: #007bff;
}

/* Preloader for smooth image transitions */
.image-stack img {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-stack img.loaded {
    opacity: 1;
}

/* Animation status indicator */
.animation-status {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    display: none;
}

.featured__work-thumb:hover .animation-status {
    display: block;
}

/* smaller screens: tighter cap */
@media (max-width: 767px) {
    .image-container {
        max-height: 55vh;
    }
}