/* Hero Banner */
.hero-banner {
    background-size: cover;
    background-position: center top;
    background-attachment: scroll;
    height: 100vh; /* Fixed height at 100vh */
    display: flex;
    flex-direction: column; /* Stack children vertically */
    align-items: center;
    justify-content: flex-start;
    position: relative;
    background-color: transparent;
    overflow: visible; /* allow gallery content to overflow below hero */
    z-index: 1; /* ensure hero (and its overflowing gallery) sits above following sections */
}

.hero-banner::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    pointer-events: none;
    z-index: 1;
    background: linear-gradient(to bottom, transparent 0%, rgba(255, 255, 255, 0.3) 30%, rgba(255, 255, 255, 0.7) 70%, rgba(255, 255, 255, 1) 100%);
}

.hero-overlay::before, .hero-overlay::after { content: none !important; background: transparent !important; }

.hero-overlay {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 3;
    margin-top: 28rem;
}

.hero-overlay::before {
    content: '';
    flex: 1;
}

.hero-overlay::after {
    content: '';
    flex: 2;
}

.hero-content {
    text-align: center;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0;
    color: #2c4048;
}

.hero-subtitle {
    font-size: 2rem;
    font-weight: 400;
    margin-top: 10px;
    color: #2c4048;
}

/* Gallery Sections */
.gallery-section {
    background: #ffffff;
    width: 100%;
    margin-bottom: 5rem;
}

/* Let the PHOTO gallery section sit slightly on top of the bottom of the hero-banner,
   and fade from transparent (over hero) into white behind the cards */
#gallery-photos.gallery-section {
    position: absolute;
    top: 50vh; /* Start from center of hero-banner (50% of viewport height) */
    width: 100%;
    z-index: 2;
    background: transparent;
    max-width: 1400px;
}

/* Video gallery section positioned below photos section */
#gallery-videos.gallery-section {
    position: absolute;
    top: calc(50vh + 600px); /* Initial estimate, will be updated by JavaScript */
    width: 100%;
    z-index: 2;
    background: #ffffff;
    margin-top: 0;
    padding-top: 2rem; /* Add some spacing from photos section */
    max-width: 1400px;
}

/* Ensure footer appears below gallery content */
.hero-banner + * {
    position: relative;
    z-index: 1;
}

.gallery-section-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 40px;
    padding: 0 16px;
    justify-content: center; /* center header (titles) horizontally */
    text-align: center;
}

.gallery-icon {
    width: 60px;
    height: 60px;
    object-fit: contain;
    flex-shrink: 0;
}

.gallery-section-title {
    font-size: 3rem;
    font-weight: 700;
    color: #ffffff; /* white text */
    margin: 0;
    text-align: center;
    width: 100%;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7); /* black shadow for contrast */
}

.gallery-section .container {
    width: 100%;
    margin: 0 auto;
    padding: 0 16px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(250px, 1fr));
    gap: 1.6rem;
    align-items: stretch;
    justify-items: center;
    justify-content: center;
    width: 100%;
    margin: 0 auto;
}

.gallery-grid .nino-portfolioItems {
    display: contents;
    list-style: none;
    margin: 0;
    padding: 0;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(250px, 1fr));
    gap: 1.6rem;
    margin-top: 2rem; /* keep video grid aligned with photo grid spacing */
    align-items: stretch;
    justify-items: center;
    justify-content: center;
}

.video-grid .nino-portfolioItems {
    display: contents;
    list-style: none;
    margin: 0;
    padding: 0;
}

.gallery-grid .item,
.video-grid .item {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
}

.gallery-card {
    background: #ffffff;
    border: 1px solid #e5e5e5;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    transform: scale(1);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.gallery-card:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 10;
    position: relative;
}

.gallery-card .media {
    background: #e9eaec;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    width: 100%;
    aspect-ratio: 4 / 3; /* horizontal rectangle for photos */
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    box-sizing: border-box;
    border-bottom: none;
}

/* Blurred transition between media and caption on hover */
.gallery-card .media::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to bottom, transparent 0%, rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0.8) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 6;
    pointer-events: none;
}

.gallery-card:hover .media::after {
    opacity: 1;
    visibility: visible;
}

.gallery-card:hover .media {
    border-bottom: none;
}

.gallery-card:hover .media {
    transform: scale(1.02);
}

.gallery-card:hover .media img {
    transform: scale(1.05);
}

.gallery-card .media iframe {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border: none;
    z-index: 2;
    background: #e9eaec;
    transition: transform 0.3s ease;
}

.gallery-card:hover .media iframe {
    transform: scale(1.05);
}

.gallery-card .media .overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

/* Ensure the main gallery image is always visible */
.gallery-card .media a > img:first-of-type {
    z-index: 2;
}

.gallery-card .media a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.gallery-card .media .placeholder span {
    position: relative;
    z-index: 1;
    color: #666;
    font-size: 1.2rem;
}

.gallery-card .media a:hover {
    text-decoration: none;
    color: inherit;
}

/* Video play overlay */
.video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 20;
}

/* Video play overlay hover effect removed */
.gallery-card .media a:hover .video-play-overlay {
    background: rgba(0, 0, 0, 0.7);
    transform: translate(-50%, -50%);
}

.gallery-card .media {
    position: relative;
}

/* Gallery hover overlay - matching template.css style */
.gallery-hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
    z-index: 10;
    pointer-events: none;
    padding: 20px;
    box-sizing: border-box;
}

.gallery-hover-overlay:before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: all 0.3s ease-in-out;
    background: rgba(96, 96, 96, 0.9);
    background: -webkit-linear-gradient(top, rgba(96, 96, 96, 0.9), rgba(255, 255, 255, 0.9));
    background: -o-linear-gradient(top, rgba(96, 96, 96, 0.9), rgba(255, 255, 255, 0.9));
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.5), rgba(155, 16, 3, 0.1), rgba(155, 16, 3, 0.2));
    z-index: -1;
}

/* Hover effects removed */
.gallery-card:hover .gallery-hover-overlay {
    opacity: 0;
    visibility: hidden;
}

.gallery-card:hover .gallery-hover-overlay:before {
    opacity: 0;
}

/* Country flag overlay inside hover overlay */
.country-flag-overlay {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.country-flag-overlay .flag-icon {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    background: #ffffff;
}

/* Gallery title in hover overlay */
.gallery-hover-title {
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
    line-height: 1.4;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    max-width: 90%;
}

.gallery-card.tall .media { aspect-ratio: 4 / 3; }
.gallery-card.wide .media { aspect-ratio: 4 / 3; }

/* Make video cards a bit wider (16:9) */
.video-grid .gallery-card .media { aspect-ratio: 16 / 9; }

.gallery-card .caption {
    background: #ffffff;
    padding: 14px 16px;
    border-top: 1px solid #e5e5e5;
    color: #2c3e50;
    text-align: center;
    transition: color 0.3s ease, background-color 0.3s ease, border-top 0.3s ease;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

/* Blurred top edge of caption on hover */
.gallery-card .caption::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.3) 50%, transparent 100%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.gallery-card:hover .caption::before {
    opacity: 1;
    visibility: visible;
}

.gallery-card:hover .caption {
    color: #1e244f;
    background: #f8f9fa;
    border-top: none;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* Card hover overlay with flag and title */
.card-hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 5;
    pointer-events: none;
    margin: 0;
    padding: 0;
    transform: translateZ(0);
    will-change: opacity;
}

/* Only show gradient background when flag icon is present */
.card-hover-overlay:has(.card-flag-icon) {
    background: linear-gradient(to bottom, rgba(44, 64, 72, 1), rgba(255, 255, 255, 1));
}

.gallery-card:hover .card-hover-overlay {
    opacity: 1;
    visibility: visible;
}

.card-flag-icon {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: none;
    position: absolute;
    transform: translate(-50%, -50%);
    margin: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    will-change: transform;
}

.gallery-card .card-flag-icon,
.gallery-card:hover .card-flag-icon {
    transform: translate(-50%, -50%);
}

.placeholder {
    font-weight: 500;
}

/* No galleries message */
.no-galleries {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 1.2rem;
}

/* Responsive breakpoints - Hero Banner */

/* XXL (Large Desktops): ≥ 1400px - Base styles apply */

/* Extra Large (Desktops): 1200px - 1399px */
@media (max-width: 1399px) {
    .hero-banner {
        background-position: center top;
    }
    .hero-overlay {
        margin-top: 28rem;
    }
    .hero-title {
        font-size: 3rem;
    }
    .hero-subtitle {
        font-size: 2rem;
    }
}

/* Large (Tablets Landscape/Laptops): 992px - 1199px */
@media (max-width: 1199px) {
    .hero-banner {
        background-position: center top;
        min-height: 600px;
    }
    .hero-overlay {
        margin-top: 24rem;
    }
    .hero-title {
        font-size: 2.6rem;
    }
    .hero-subtitle {
        font-size: 1.75rem;
    }
    .gallery-grid { 
        grid-template-columns: repeat(4, minmax(240px, 1fr)); 
    }
    .video-grid { 
        grid-template-columns: repeat(4, minmax(240px, 1fr)); 
    }
}

/* Medium (Tablets Portrait): 768px - 991px */
@media (max-width: 991px) {
    .hero-banner {
        background-position: center top;
        min-height: 550px;
    }
    .hero-overlay {
        margin-top: 22rem;
    }
    .hero-title {
        font-size: 2.4rem;
        line-height: 1.2;
    }
    .hero-subtitle {
        font-size: 1.6rem;
        margin-top: 8px;
    }
    .gallery-section .container { 
        padding: 0 14px; 
    }
    .gallery-grid { 
        grid-template-columns: repeat(3, minmax(220px, 1fr)); 
    }
    .video-grid { 
        grid-template-columns: repeat(3, minmax(220px, 1fr)); 
    }
}

/* Small (Large Phones/Small Tablets): 576px - 767px */
@media (max-width: 767px) {
    .hero-banner {
        background-position: center top;
        min-height: 500px;
    }
    .hero-overlay {
        margin-top: 18rem;
    }
    .hero-title {
        font-size: 2rem;
        line-height: 1.2;
    }
    .hero-subtitle {
        font-size: 1.4rem;
        margin-top: 8px;
    }
    .gallery-section .container { 
        padding: 0 20px; 
    }
    .gallery-grid { 
        gap: 24px; 
        grid-template-columns: repeat(2, minmax(200px, 1fr)); 
    }
    .video-grid { 
        grid-template-columns: repeat(2, minmax(200px, 1fr)); 
    }
    .gallery-section-header { 
        padding: 0 20px; 
    }
    .gallery-icon { 
        width: 40px; 
        height: 40px; 
    }
    .gallery-section-title { 
        font-size: 1.75rem; 
    }
}

/* Extra Small (Mobile Portrait): < 576px (320px - 480px) */
@media (max-width: 575px) {
    .hero-banner {
        background-position: center top;
        min-height: 450px;
        height: 100vh;
    }
    .hero-overlay {
        margin-top: 15rem;
        padding: 0 20px;
    }
    .hero-title {
        font-size: 1.75rem;
        line-height: 1.2;
        padding: 0 10px;
    }
    .hero-subtitle {
        font-size: 1.2rem;
        margin-top: 6px;
        padding: 0 10px;
    }
    .gallery-section .container { 
        padding: 0 30px; 
    }
    .gallery-grid { 
        gap: 24px; 
        grid-template-columns: repeat(1, minmax(200px, 1fr)); 
    }
    .video-grid { 
        grid-template-columns: repeat(1, minmax(200px, 1fr)); 
    }
    .gallery-section-header { 
        padding: 0 30px; 
        gap: 12px; 
    }
    .gallery-icon { 
        width: 36px; 
        height: 36px; 
    }
    .gallery-section-title { 
        font-size: 1.5rem; 
    }
}
