/* ============ GALLERY GRID ============ */
.ecg-gallery-wrapper {
    width: 100%;
    max-width: 100%;
    display: block;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    --ecg-bg: #101010;
    --ecg-accent: #DD7210;
    --ecg-light: #F9F9F9;
}

.ecg-gallery {
    display: grid;
    /* Default to 3 columns on desktop */
    grid-template-columns: repeat(3, 1fr); 
    gap: 20px;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.ecg-item {
    position: relative;
    overflow: hidden;
    border-radius: 14px;
    background: rgba(249, 249, 249, 0.04);
    border: 1px solid rgba(249, 249, 249, 0.08);
    transition: transform 0.4s ease,
                box-shadow 0.4s ease,
                border-color 0.4s ease;
    width: 100%;
    max-width: 100%;
    margin: 0;
}

.ecg-item:hover {
    transform: translateY(-6px);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55),
                0 0 0 1px rgba(221, 114, 16, 0.35);
    border-color: rgba(221, 114, 16, 0.55);
}

.ecg-item-link {
    display: block;
    text-decoration: none;
    color: inherit;
    outline: none;
    position: relative;
    height: 100%;
    width: 100%;
}

/* ============ IMAGE ============ */
.ecg-item-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ecg-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1),
                filter 0.65s ease;
    will-change: transform;
}

.ecg-item:hover .ecg-item-image img {
    transform: scale(1.12);
    filter: brightness(1.08) saturate(1.05);
}

/* ============ TITLE — OVERLAID ON IMAGE ============ */
.ecg-item-title {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;

    padding: 50px 16px 16px; /* Top padding creates the fade */
    margin: 0;
    width: 100%;
    box-sizing: border-box;

    font-size: 16px;
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.5px;
    color: #FFFFFF; /* Always white */

    /* Dark gradient to ensure white text is readable */
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.95) 0%,
        rgba(0, 0, 0, 0.8) 20%,
        rgba(0, 0, 0, 0.4) 50%,
        rgba(0, 0, 0, 0) 100%
    );

    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    transition: color 0.3s ease, padding 0.35s ease;
    pointer-events: none;
}

.ecg-item:hover .ecg-item-title {
    color: var(--ecg-accent);
    padding-bottom: 20px;
}

/* Orange accent line */
.ecg-item::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    height: 3px;
    width: 0;
    background: var(--ecg-accent);
    transform: translateX(-50%);
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 6;
    border-radius: 3px 3px 0 0;
}

.ecg-item:hover::after {
    width: 60%;
}

/* ============ OVERLAY + ICON ============ */
.ecg-item-overlay {
    position: absolute;
    inset: 0;
    background: rgba(16, 16, 16, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 4;
}

.ecg-item:hover .ecg-item-overlay {
    opacity: 1;
}

.ecg-icon-zoom {
    width: 46px;
    height: 46px;
    padding: 11px;
    color: var(--ecg-light);
    background: rgba(221, 114, 16, 0.92);
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(221, 114, 16, 0.45);
    transform: scale(0.4) rotate(-90deg);
    opacity: 0;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.05s,
                opacity 0.45s ease 0.05s;
}

.ecg-item:hover .ecg-icon-zoom {
    transform: scale(1) rotate(0deg);
    opacity: 1;
}

/* ============ MODAL ============ */
.ecg-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.ecg-modal.is-open {
    display: flex;
}

.ecg-modal.is-visible {
    opacity: 1;
}

.ecg-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 16, 16, 0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.ecg-modal-content {
    position: relative;
    z-index: 2;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0.85);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.4s ease;
}

.ecg-modal.is-visible .ecg-modal-content {
    transform: scale(1);
    opacity: 1;
}

.ecg-modal-image-wrap {
    max-width: 90vw;
    max-height: 75vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid rgba(221, 114, 16, 0.35);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.75),
                0 0 0 1px rgba(221, 114, 16, 0.15);
    background: #0a0a0a;
}

.ecg-modal-image {
    max-width: 90vw;
    max-height: 75vh;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    border-radius: 12px;
}

.ecg-modal-caption {
    margin-top: 20px;
    color: var(--ecg-light);
    font-size: 18px;
    font-weight: 500;
    text-align: center;
    letter-spacing: 0.5px;
    padding: 8px 26px;
    background: rgba(221, 114, 16, 0.14);
    border: 1px solid rgba(221, 114, 16, 0.45);
    border-radius: 40px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.ecg-modal-caption:empty {
    display: none;
}

.ecg-modal-close {
    position: absolute;
    top: -52px;
    right: 0;
    width: 42px;
    height: 42px;
    background: rgba(249, 249, 249, 0.06);
    border: 1px solid rgba(249, 249, 249, 0.18);
    border-radius: 50%;
    color: var(--ecg-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
    padding: 0;
}

.ecg-modal-close:hover {
    background: var(--ecg-accent);
    border-color: var(--ecg-accent);
    transform: rotate(90deg);
}

.ecg-modal-close svg { width: 20px; height: 20px; }

.ecg-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    background: rgba(249, 249, 249, 0.06);
    border: 1px solid rgba(249, 249, 249, 0.18);
    border-radius: 50%;
    color: var(--ecg-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
    padding: 0;
    z-index: 3;
}

.ecg-modal-nav:hover {
    background: var(--ecg-accent);
    border-color: var(--ecg-accent);
    transform: translateY(-50%) scale(1.08);
}

.ecg-modal-prev { left: -70px; }
.ecg-modal-next { right: -70px; }
.ecg-modal-nav svg { width: 24px; height: 24px; }
.ecg-modal-nav.is-hidden { opacity: 0; pointer-events: none; }

body.ecg-modal-open { overflow: hidden; }


/* =========================================================
   RESPONSIVE OVERRIDES 
   (Forces 1 column on mobile, 2 on tablet to fill width)
   ========================================================= */

@media (max-width: 1024px) {
    .ecg-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px; /* Slightly smaller gap on tablet */
    }
    .ecg-modal-prev { left: -20px; }
    .ecg-modal-next { right: -20px; }
    .ecg-modal-nav { width: 42px; height: 42px; }
}

@media (max-width: 767px) {
    /* Force 1 column on mobile so images are huge and full-width */
    .ecg-gallery {
        grid-template-columns: 1fr; 
        gap: 15px; 
    }
    
    .ecg-item-title { 
        font-size: 16px; 
        padding: 40px 12px 12px; 
    }
    
    .ecg-modal-caption { font-size: 15px; }
    .ecg-modal-prev { left: 5px; }
    .ecg-modal-next { right: 5px; }
    .ecg-modal-close { top: -45px; right: 0; }
}