/* =========================================================
   GOOGLE DRIVE PORTFOLIO CSS
   ========================================================= */

/* Prevent flashing of static legacy images during load */
[id="5677"] .container.fullwidth > .cont:not(:has(.gd-desktop-grid)) {
    min-height: 400px;
    position: relative;
}
[id="5677"] .container.fullwidth > .cont:not(:has(.gd-desktop-grid))::before {
    content: "Загрузка проектов...";
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(255,255,255,0.5);
    font-family: sans-serif;
    font-size: 16px;
    letter-spacing: 1px;
    z-index: 10;
}
[id="5677"] .container.fullwidth > .cont:not(:has(.gd-desktop-grid)) > * {
    opacity: 0 !important;
    pointer-events: none;
}

#km-portfolio .km-grid:not([data-gd-injected="true"]) {
    min-height: 400px;
    position: relative;
}
#km-portfolio .km-grid:not([data-gd-injected="true"])::before {
    content: "Загрузка...";
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(255,255,255,0.5);
    font-family: sans-serif;
    font-size: 14px;
    z-index: 10;
}
#km-portfolio .km-grid:not([data-gd-injected="true"]) > * {
    opacity: 0 !important;
    pointer-events: none;
}

/* Desktop Grid (Replaces Creatium Grid) */
.gd-desktop-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
}

@media(max-width: 900px) {
    .gd-desktop-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* All Projects View - Vertical Cards Layout */
.gd-projects-view .gd-desktop-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 15px;
}

@media(max-width: 1024px) {
    .gd-projects-view .gd-desktop-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media(max-width: 768px) {
    .gd-projects-view .gd-desktop-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media(max-width: 500px) {
    .gd-projects-view .gd-card {
        height: 180px;
    }
    .gd-projects-view .gd-card-overlay h3 {
        font-size: 13px;
    }
}
@media(max-width: 600px) {
    .gd-desktop-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .gd-card {
        height: 220px;
    }
    .gd-card-overlay {
        padding: 12px;
    }
    .gd-card-overlay h3 {
        font-size: 18px;
        letter-spacing: 1px;
    }
    .gd-badge {
        font-size: 9px;
        padding: 4px 8px;
        margin-bottom: 5px;
    }
}

/* Common Card Styling */
.gd-card {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    height: 350px;
    background: #111;
}

.gd-card:hover {
    transform: scale(1.03);
    box-shadow: 0 15px 30px rgba(154,35,196,0.3);
}

.gd-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
}

.gd-card-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
    z-index: 1;
}

.gd-card:hover .gd-card-bg {
    transform: scale(1.1);
}

/* =============================================
   CARD ROTATION ANIMATIONS
   ============================================= */

/* GPU acceleration for all animated cards */
.gd-card,
.gd-mobile-thumb {
    will-change: transform, opacity;
}

/* Snappy entrance animation on page load */
.gd-card-entrance {
    animation: gdCardEntrance 0.5s cubic-bezier(0.19, 1, 0.22, 1) both;
}

@keyframes gdCardEntrance {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Fast Slide & Cross-fade swap (300ms out + 300ms in) */
.gd-card-swap-out {
    animation: gdCardSwapOut 0.3s cubic-bezier(0.55, 0.055, 0.675, 0.19) forwards;
}

@keyframes gdCardSwapOut {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(-30px) scale(0.95);
    }
}

.gd-card-swap-in {
    animation: gdCardSwapIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes gdCardSwapIn {
    0% {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Glow highlight when a new card appears */
.gd-new-glow {
    animation: gdNewGlow 1.2s ease-out forwards;
}
@keyframes gdNewGlow {
    0% {
        box-shadow: 0 0 0px rgba(154, 35, 196, 0);
    }
    25% {
        box-shadow: 0 0 20px rgba(154, 35, 196, 0.5), inset 0 0 10px rgba(154, 35, 196, 0.1);
    }
    100% {
        box-shadow: 0 0 0px rgba(154, 35, 196, 0);
    }
}

/* Shimmer sweep effect on the overlay of newly appeared cards */
.gd-card.gd-shimmer .gd-card-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
    animation: gdShimmerSweep 0.8s 0.3s ease-out forwards;
    z-index: 5;
    pointer-events: none;
}
@keyframes gdShimmerSweep {
    0% { left: -60%; }
    100% { left: 120%; }
}

.gd-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.2) 60%, transparent 100%);
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 25px;
    box-sizing: border-box;
}

.gd-badge {
    align-self: flex-start;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: #fff;
    font-size: 11px;
    text-transform: uppercase;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    margin-bottom: 10px;
}

.gd-card-overlay h3 {
    color: #fff;
    font-size: 24px;
    font-weight: 400;
    margin: 0;
    font-family: 'Bebas Neue Light', sans-serif;
    letter-spacing: 1px;
    text-shadow: 0 2px 7px rgba(0,0,0,0.8);
    text-transform: uppercase;
}

/* Mobile Thumbnails */
.gd-mobile-thumb {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}
.gd-mobile-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

/* Staggered entrance for mobile cards */
.gd-mobile-entrance {
    animation: gdMobileEntrance 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.gd-mobile-entrance:nth-child(1) { animation-delay: 0.05s; }
.gd-mobile-entrance:nth-child(2) { animation-delay: 0.1s; }
.gd-mobile-entrance:nth-child(3) { animation-delay: 0.15s; }
.gd-mobile-entrance:nth-child(4) { animation-delay: 0.2s; }
.gd-mobile-entrance:nth-child(5) { animation-delay: 0.25s; }
.gd-mobile-entrance:nth-child(6) { animation-delay: 0.3s; }

@keyframes gdMobileEntrance {
    0% {
        opacity: 0;
        transform: scale(0.88) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Modal Styling */
.gd-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.gd-modal.open {
    opacity: 1;
    visibility: visible;
}

.gd-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 1;
}

.gd-modal-content {
    position: relative;
    z-index: 2;
    width: 95%;
    max-width: 1300px;
    height: 90vh;
    border-radius: 12px;
    background: #0f0f13;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.gd-modal.open .gd-modal-content {
    transform: translateY(0);
}

.gd-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    z-index: 10;
    transition: color 0.2s;
    line-height: 1;
    padding: 5px;
    border-radius: 50%;
}

.gd-modal-close:hover {
    color: #9a23c4;
    text-shadow: 0 0 10px rgba(154,35,196,0.8);
}

.gd-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    scrollbar-width: thin;
    scrollbar-color: #9a23c4 #111;
}

.gd-modal-body::-webkit-scrollbar {
    width: 8px;
}
.gd-modal-body::-webkit-scrollbar-track {
    background: #111; 
}
.gd-modal-body::-webkit-scrollbar-thumb {
    background-color: #9a23c4; 
    border-radius: 10px;
}

.gd-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    grid-auto-flow: dense;
}

@media(max-width: 600px) {
    .gd-media-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .gd-modal-body {
        padding: 15px;
    }
}

.gd-media-item {
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    position: relative;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
}

.gd-media-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gd-media-item img:hover {
    transform: scale(1.02);
}

/* Utility constraints to match creatium wrapper */
#5677 .max-width .cont {
    width: 100%; /* Ensure our dynamic grid expands */
}

/* =========================================================
   LIGHTBOX STYLING (FULLSCREEN IMAGE VIEWER)
   ========================================================= */
.gd-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999999;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    user-select: none;
}

.gd-lightbox.open {
    opacity: 1;
    visibility: visible;
}

.gd-lightbox-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.gd-lightbox-content {
    position: relative;
    z-index: 2;
    width: 95vw;
    height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gd-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 50px rgba(154, 35, 196, 0.4);
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.gd-lightbox.open img {
    transform: scale(1);
}

.gd-lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.gd-lightbox-close:hover {
    background: #9a23c4;
    border-color: #9a23c4;
    box-shadow: 0 0 15px rgba(154,35,196,0.8);
    transform: rotate(90deg);
}

.gd-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    font-size: 24px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.gd-lightbox-nav:hover {
    background: #9a23c4;
    border-color: #9a23c4;
    box-shadow: 0 0 20px rgba(154,35,196,0.8);
}

.gd-lightbox-prev {
    left: 40px;
}

.gd-lightbox-next {
    right: 40px;
}

.gd-lightbox-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    font-family: sans-serif;
    letter-spacing: 2px;
}

@media (max-width: 768px) {
    .gd-lightbox-nav {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    .gd-lightbox-prev { left: 15px; }
    .gd-lightbox-next { right: 15px; }
    .gd-lightbox-close { top: 15px; right: 15px; width: 40px; height: 40px; font-size: 24px; }
}
