/* =========================================================
   Gallery Cards
   ========================================================= */

.gallery-card-img-wrap.courses-one__single-img::before {
    pointer-events: none;
}

.gallery-card-trigger {
    cursor: pointer;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.gallery-card-trigger:focus-visible {
    outline: 3px solid rgba(var(--thm-base-rgb, 77, 95, 227), 0.55);
    outline-offset: 3px;
}

.gallery-card-img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-card-trigger:hover .gallery-card-img {
    transform: scale(1.06);
}

.gallery-card-zoom {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.05) 0%, rgba(17, 24, 39, 0.62) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 2;
    pointer-events: none;
}

.gallery-card-zoom i {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(8px);
    color: #ffffff;
    font-size: 1.35rem;
    transform: translateY(12px) scale(0.92);
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), background 0.4s ease;
}

.gallery-card-trigger:hover .gallery-card-zoom {
    opacity: 1;
}

.gallery-card-trigger:hover .gallery-card-zoom i {
    transform: translateY(0) scale(1);
    background: rgba(var(--thm-base-rgb, 77, 95, 227), 0.88);
}

.gallery-card-badge {
    position: absolute;
    left: 14px;
    bottom: 14px;
    z-index: 3;
    background: rgba(255, 255, 255, 0.92);
    color: #1f2937;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 7px 12px;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
    pointer-events: none;
}

.gallery-card-badge::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 7px;
    border-radius: 50%;
    background: var(--thm-base, #4d5fe3);
    vertical-align: middle;
}

.courses-one__single:hover {
    transform: translateY(-4px);
    transition: transform 0.35s ease;
}

/* Gallery grid: 3 equal columns filling full row width */
.courses-one--courses .gallery-page-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 30px;
    width: 100%;
    margin: 0;
}

.courses-one--courses .gallery-page-grid > .filter-item {
    display: flex;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.courses-one--courses .gallery-page-grid > .filter-item.is-filter-hidden {
    display: none !important;
}

.gallery-page-grid .gallery-card-box {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    margin-bottom: 0;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

.gallery-page-grid .gallery-card-box .courses-one__single-img {
    flex-shrink: 0;
}

.gallery-page-grid .gallery-card-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 118px;
    padding: 22px 22px 18px;
}

.gallery-page-grid .gallery-card-teacher {
    margin: 0 0 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-page-grid .gallery-card-title {
    margin: 0;
    flex: 1 1 auto;
    min-height: 52px;
}

.gallery-page-grid .gallery-card-title a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    word-break: break-word;
    line-height: 1.45;
    max-height: 2.9em;
}

.gallery-page-grid .gallery-card-year {
    margin: 10px 0 0;
    flex-shrink: 0;
}

@media (max-width: 991px) {
    .courses-one--courses .gallery-page-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px;
    }
}

@media (max-width: 767px) {
    .courses-one--courses .gallery-page-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .gallery-page-grid .gallery-card-content {
        min-height: 100px;
    }
}

/* =========================================================
   Lightbox Modal - compact professional layout
   ========================================================= */

#galleryModal.gallery-lightbox-modal .modal-dialog.gallery-modal-dialog {
    max-width: min(920px, calc(100vw - 24px));
    margin: 0.75rem auto;
    width: auto;
}

#galleryModal .modal-content.gallery-modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #151922;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    padding: 0;
}

#galleryModal .gallery-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: #1e2433;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#galleryModal .gallery-modal-headings {
    flex: 1;
    min-width: 0;
}

#galleryModal #galleryModalLabel,
#galleryModal .gallery-modal-title {
    margin: 0 !important;
    color: #ffffff !important;
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    line-height: 1.35 !important;
    word-break: break-word;
}

#galleryModal #galleryModalSubtitle,
#galleryModal .gallery-modal-subtitle {
    margin: 4px 0 0 !important;
    color: #b8c1d1 !important;
    font-size: 0.88rem !important;
    line-height: 1.4 !important;
}

#galleryModal .gallery-modal-close {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border: 2px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff !important;
    font-size: 1.65rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

#galleryModal .gallery-modal-close span {
    display: block;
    margin-top: -2px;
    color: #ffffff !important;
}

#galleryModal .gallery-modal-close:hover {
    background: #4d5fe3;
    border-color: #4d5fe3;
    transform: scale(1.05);
}

#galleryModal .gallery-modal-body {
    position: relative;
    background: #0f1218;
    min-height: 0;
}

#galleryModal .gallery-modal-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 18, 24, 0.5);
    z-index: 4;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

#galleryModal .gallery-modal-loader.is-active {
    opacity: 1;
    visibility: visible;
}

#galleryModal .gallery-modal-loader-spinner {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffd45f;
    animation: gallerySpin 0.8s linear infinite;
}

#galleryModal .gallery-modal-swiper {
    width: 100%;
    min-height: 0;
    height: auto;
}

#galleryModal .gallery-modal-swiper .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 52px;
    box-sizing: border-box;
    height: auto;
}

#galleryModal .gallery-slide-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
}

#galleryModal .gallery-modal-swiper img {
    display: block;
    max-width: 100%;
    max-height: min(62vh, 560px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 0.35s ease;
}

#galleryModal .gallery-modal-swiper img.is-loaded {
    opacity: 1;
}

#galleryModal .gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    background: rgba(30, 36, 51, 0.85);
    color: #ffffff !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

#galleryModal .gallery-nav-btn:hover {
    background: #4d5fe3;
    border-color: #4d5fe3;
    transform: translateY(-50%) scale(1.05);
}

#galleryModal .gallery-nav-prev { left: 10px; }
#galleryModal .gallery-nav-next { right: 10px; }

#galleryModal .gallery-nav-btn.is-hidden,
#galleryModal .gallery-nav-btn.swiper-button-disabled {
    opacity: 0 !important;
    visibility: hidden;
    pointer-events: none !important;
}

#galleryModal .gallery-modal-bottombar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: #1e2433;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#galleryModal .gallery-counter {
    color: #ffffff !important;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    background: #4d5fe3;
    padding: 5px 12px;
    border-radius: 999px;
    white-space: nowrap;
}

#galleryModal .gallery-modal-dots {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

#galleryModal .gallery-modal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 0;
    padding: 0;
    background: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    transition: width 0.2s ease, background 0.2s ease;
}

#galleryModal .gallery-modal-dot.is-active {
    width: 22px;
    border-radius: 999px;
    background: #ffd45f;
}

body.gallery-modal-open {
    overflow: hidden;
}

#galleryModal.show ~ .modal-backdrop,
.modal-backdrop.show {
    opacity: 0.75;
}

#galleryModal.gallery-lightbox-modal.show .modal-dialog {
    animation: galleryModalIn 0.35s ease;
}

@keyframes galleryModalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes gallerySpin {
    to { transform: rotate(360deg); }
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 991px) {
    #galleryModal.gallery-lightbox-modal .modal-dialog.gallery-modal-dialog {
        max-width: calc(100vw - 16px);
        margin: 0.5rem auto;
    }
}

@media (max-width: 767px) {
    #galleryModal.gallery-lightbox-modal .modal-dialog.gallery-modal-dialog {
        max-width: calc(100vw - 8px);
        margin: 0.35rem auto;
    }

    #galleryModal .gallery-modal-header {
        padding: 12px 14px;
    }

    #galleryModal #galleryModalLabel,
    #galleryModal .gallery-modal-title {
        font-size: 1rem !important;
    }

    #galleryModal .gallery-modal-close {
        width: 38px;
        height: 38px;
        font-size: 1.45rem;
    }

    #galleryModal .gallery-modal-swiper .swiper-slide {
        padding: 8px 42px;
    }

    #galleryModal .gallery-modal-swiper img {
        max-height: 58vh;
    }

    #galleryModal .gallery-nav-btn {
        width: 36px;
        height: 36px;
    }

    #galleryModal .gallery-nav-prev { left: 6px; }
    #galleryModal .gallery-nav-next { right: 6px; }

    #galleryModal .gallery-modal-bottombar {
        flex-wrap: wrap;
    }

    #galleryModal .gallery-modal-dots {
        justify-content: flex-start;
        width: 100%;
    }

    .gallery-card-img {
        aspect-ratio: 16 / 11;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-card-img,
    .gallery-card-zoom,
    .gallery-card-zoom i,
    .gallery-modal-swiper img,
    .gallery-lightbox-modal.show .modal-dialog,
    .gallery-nav-btn,
    .gallery-modal-close {
        transition: none;
        animation: none;
    }
}
