/* ========================================
   PORTFOLIO (OUR PROJECTS) SECTION
   ======================================== */

#portfolio h2 {
    position: relative;
    display: inline-block;
    padding-bottom: 20px;
    margin-bottom: 40px;
}

#portfolio h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 4px;
    background-color: rgb(118, 120, 237);
    border-radius: 2px;
}

/* Portfolio Item Wrapper */
.portfolio-item {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    cursor: pointer;
    /* Force height for consistency */
    height: 300px; 
}

/* Image Hover Zoom */
.portfolio-img {
    width: 100%;
    height: 100%; /* Fill the wrapper */
    object-fit: cover; /* Crop to fit, ensuring consistency */
    display: block;
    transition: transform 0.5s ease;
}

.portfolio-item:hover .portfolio-img {
    transform: scale(1.1); /* Standard subtle zoom */
}

/* ========================================
   LIGHTBOX (FULL SCREEN ZOOM)
   ======================================== */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 20000; /* Increased to stay above nav-bar (10001) and top-bar (10002) */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-img {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

.lightbox.active .lightbox-img {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 30px;
    right: 30px;
    color: white;
    font-size: 40px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    transition: color 0.3s ease;
    z-index: 10000;
}

.lightbox-close:hover {
    color: rgb(118, 120, 237);
}

/* Lightbox Content Wrapper */
.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Lightbox Image */
.lightbox-image {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    transform: scale(0.9);
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

.lightbox.active .lightbox-image {
    transform: scale(1);
}

/* Lightbox Navigation Buttons - posizionate fisse ai lati dello schermo */
.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 24px;
    padding: 15px;
    cursor: pointer;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, transform 0.3s ease;
    z-index: 20001;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

/* Lightbox Caption */
.lightbox-caption {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
    text-align: center;
    max-width: 80vw;
    font-family: 'Niramit', sans-serif;
}

/* Lightbox Counter */
.lightbox-counter {
    position: absolute;
    bottom: -40px;
    right: 0;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-family: 'Roboto', sans-serif;
}

/* Responsive Navigation */
@media (max-width: 768px) {
    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 18px;
        padding: 10px;
    }

    .lightbox-caption {
        bottom: -60px;
        font-size: 14px;
        padding: 0 10px;
    }

    .lightbox-counter {
        bottom: -60px;
    }
}

/* Lightbox Tour Overlay */
.lightbox-tour-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 10;
    transition: background 0.3s ease;
}

.lightbox-tour-overlay:hover {
    background: rgba(0, 0, 0, 0.3);
}

.lightbox-tour-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    color: white;
    font-family: 'Niramit', sans-serif;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.lightbox-tour-content i {
    font-size: 4rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

.lightbox-tour-content span {
    font-size: 1.3rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: rgba(241, 126, 24, 0.95);
    padding: 14px 28px;
    border-radius: 8px;
}

@media (max-width: 768px) {
    .lightbox-tour-content i {
        font-size: 2.5rem;
    }

    .lightbox-tour-content span {
        font-size: 1rem;
        padding: 10px 18px;
    }
}

/* Overlay */
.portfolio-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(25, 29, 42, 0.2);
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: none; /* Hide default cursor */
    z-index: 5;
}

.portfolio-item:hover .portfolio-overlay {
    opacity: 1;
}

/* Icon - Follows Cursor */
.portfolio-icon {
    position: absolute;
    top: 0; /* Reset */
    left: 0; /* Reset */
    width: 60px;
    height: 60px;
    background-color: rgba(118, 120, 237, 0.9);
    border-radius: 50%;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none; /* Allow clicks to pass through */
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
    z-index: 10;
}

.portfolio-item:hover .portfolio-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.portfolio-icon svg {
    width: 30px;
    height: 30px;
    stroke-width: 2;
    stroke: currentColor;
}

/* ========================================
   GALLERY WITH THUMBNAILS
   ======================================== */

.gallery-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%; /* Fill parent .modern-image (400px) */
}

.gallery-main {
    position: relative;
    width: 100%;
    flex: 1; /* Take remaining space after thumbnails */
    min-height: 0; /* Important for flex shrinking */
    overflow: hidden;
    border-radius: 20px;
    cursor: zoom-in;
}

/* Override portfolio-item fixed height when used in gallery */
.gallery-container .gallery-main.portfolio-item {
    height: 400px !important; /* Force fixed height for consistency */
    min-height: 0; /* Allow flex shrinking */
    flex: none; /* Don't use flex, use explicit dimensions */
    width: 100%;
}

.gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease, transform 0.5s ease;
    display: block; /* Remove inline spacing */
}

.gallery-main:hover img {
    transform: scale(1.05);
}

/* Thumbnails Container */
.gallery-thumbnails {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar styling */
.gallery-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.gallery-thumbnails::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.gallery-thumbnails::-webkit-scrollbar-thumb {
    background: var(--alife-primary);
    border-radius: 3px;
}

.gallery-thumbnails::-webkit-scrollbar-thumb:hover {
    background: var(--alife-dark);
}

/* Individual Thumbnail */
.gallery-thumbnail {
    flex-shrink: 0;
    width: 90px; /* Fixed width - square thumbnails */
    height: 90px; /* Fixed height - square thumbnails */
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.6;
    display: block; /* Ensure img displays correctly */
}

.gallery-thumbnail:hover {
    opacity: 0.9;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-thumbnail.active {
    border-color: var(--alife-primary);
    opacity: 1;
    box-shadow: 0 4px 12px rgba(241, 126, 24, 0.3);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .gallery-main {
        height: 300px; /* Reduced height for mobile */
    }

    .gallery-thumbnail {
        width: 75px; /* Square thumbnails on mobile */
        height: 75px;
    }
}
