/* Portfolio Section */
.portfolio-section {
    padding: calc(var(--spacing-3xl) / 2) 0 var(--spacing-3xl);
    background: var(--bg-primary);
    scroll-margin-top: 100px;
}

html,
body {
    scrollbar-gutter: stable;
}

body.no-scroll {
    overflow: hidden !important;
}

html.no-scroll {
    overflow: hidden !important;
}

body.is-locked {
    overflow: hidden !important;
    touch-action: none;
}

/* Portfolio Filter */
.portfolio-filter {
    position: sticky;
    top: 80px;
    z-index: 50;
    background: var(--bg-primary);
    padding: var(--spacing-lg) 0;
    margin-top: var(--spacing-lg) / 2;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.filter-btn {
    padding: var(--spacing-sm) var(--spacing-xl);
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-normal);
    font-weight: 500;
    white-space: nowrap;
    font-size: 1rem;
    min-height: 44px;
}

.filter-btn:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    background: rgba(124, 58, 237, 0.05);
}

.filter-btn.active {
    background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
    border-color: #7c3aed;
    color: white;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
}

/* Portfolio Grid */
.portfolio-grid-full {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-xl);
    margin-top: var(--spacing-xl);
}

/* Portfolio Card */
.portfolio-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2xl);
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease, transform 0.4s ease;
}

/* Filter animation - smooth movement to new positions */
.portfolio-card.filtering-out {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    position: absolute;
    visibility: hidden;
}

.portfolio-card.filtering-in {
    animation: filterSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes filterSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.portfolio-card.hidden {
    display: none;
}

.portfolio-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

.portfolio-card .portfolio-image {
    aspect-ratio: 4/3;
    overflow: hidden;
}

.portfolio-card .portfolio-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.portfolio-card:hover .portfolio-image img {
    transform: scale(1.05);
}

/* Portfolio Info */
.portfolio-info {
    padding: var(--spacing-lg);
}

.portfolio-category {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-sm);
}

.portfolio-info h3 {
    font-size: 1.2rem;
    margin-bottom: var(--spacing-xs);
}

.portfolio-info p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
}



/* Portfolio CTA */
.portfolio-cta {
    text-align: center;
    padding: var(--spacing-2xl);
    background: var(--bg-secondary);
    border-radius: var(--radius-2xl);
}

.portfolio-cta p {
    font-size: 1.1rem;
    margin-bottom: var(--spacing-lg);
    color: var(--text-secondary);
}

/* ================================================
   PORTFOLIO PAGE RESPONSIVE
   ================================================ */

@media (max-width: 768px) {
    .portfolio-filter {
        top: 70px;
        padding: var(--spacing-md) 0;
        overflow-x: auto;
        display: flex;
        gap: var(--spacing-sm);
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
    }

    .portfolio-filter::-webkit-scrollbar {
        display: none;
    }

    .filter-btn {
        padding: var(--spacing-xs) var(--spacing-md);
        font-size: 0.9rem;
    }

    .portfolio-grid-full {
        grid-template-columns: 1fr;
    }
}

/* Portfolio Modal Styles */

/* Placeholder used during active state */
.portfolio-card-placeholder {
    visibility: hidden;
}

/* Active State for Portfolio Card */
.portfolio-card.active {
    position: fixed;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90vw !important;
    height: 85vh !important;
    max-width: 1200px;
    max-height: 800px;
    z-index: 1000;
    cursor: default;

    /* Layout */
    display: grid;
    grid-template-columns: 45% 55%;
    /* More balanced ratio */
    align-items: stretch;

    /* Override Hover Effects */
    box-shadow: 0 50px 100px -20px rgba(0, 0, 0, 0.5);
    /* Deeper shadow */
    background: var(--bg-primary);
    /* Ensure solid background */
    margin: 0;
    border-color: transparent;
}

.no-transition {
    transition: none !important;
}

/* Force layout reset during closing to avoid squashed content */
/* Force layout reset during closing to avoid squashed content */
.portfolio-card.closing {
    display: block !important;
    grid-template-columns: none !important;
    overflow: hidden !important;
}

.portfolio-card.closing .portfolio-image {
    height: auto !important;
    aspect-ratio: 4/3 !important;
    /* Revert to original aspect ratio */
    border-right: none !important;
    border-bottom: none !important;
}

.portfolio-card.closing .portfolio-info {
    padding: var(--spacing-lg) !important;
    background: transparent !important;
}

.portfolio-card.closing h3 {
    font-size: 1.2rem !important;
    background: none !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    margin-bottom: var(--spacing-xs) !important;
}

.portfolio-card.closing .portfolio-category {
    font-size: 0.85rem !important;
    color: var(--primary-color) !important;
    margin-bottom: var(--spacing-sm) !important;
}

.portfolio-card.closing p {
    font-size: 0.95rem !important;
    /* Revert text size */
    max-width: none !important;
    margin: 0 !important;
}

/* Ensure transition works for position/size */
.portfolio-card {
    transition:
        transform 0.5s cubic-bezier(0.19, 1, 0.22, 1),
        /* Expo out for premium feel */
        top 0.5s cubic-bezier(0.19, 1, 0.22, 1),
        left 0.5s cubic-bezier(0.19, 1, 0.22, 1),
        width 0.5s cubic-bezier(0.19, 1, 0.22, 1),
        height 0.5s cubic-bezier(0.19, 1, 0.22, 1),
        border-radius 0.4s ease,
        box-shadow 0.4s ease,
        opacity 0.4s ease,
        background-color 0.4s ease,
        border-color 0.4s ease;

    z-index: 1;
}

.portfolio-card.closing::before {
    display: none !important;
    opacity: 0 !important;
}

/* Modal Overlay Backdrop */
.portfolio-card.active::before {
    content: '';
    position: fixed;
    top: -50vh;
    left: -50vw;
    width: 200vw;
    height: 200vh;
    background: rgba(15, 23, 42, 0.85);
    /* Darker, slightly blue-tinted backdrop */
    backdrop-filter: blur(8px);
    /* Glass effect on background */
    z-index: -1;
    pointer-events: auto;
    opacity: 0;
    animation: fadeIn 0.4s forwards;
    display: block;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Image adjustments in active state */
.portfolio-card.active .portfolio-image {
    height: 100%;
    aspect-ratio: auto;
    border-right: 1px solid var(--border-color);
}

.portfolio-card.active .portfolio-image img {
    height: 100%;
    object-fit: cover;
    transform: none !important;
}

/* Info adjustments in active state */
.portfolio-card.active .portfolio-info {
    padding: var(--spacing-3xl);
    /* More breathing room */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--bg-secondary);
}

.portfolio-card.closing .portfolio-info {
    overflow: hidden;
    /* Prevent scrollbar flickering */
    justify-content: flex-start;
    /* Reset alignment to avoid jumps */
    padding: var(--spacing-lg);
    /* Reset padding to match card state smoothly */
    transition: padding 0.3s;
}

/* Typography Enhancements for Active State */
.portfolio-card.active h3 {
    font-size: 2.5rem;
    /* Larger Title */
    margin-bottom: var(--spacing-md);
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.portfolio-card.active .portfolio-category {
    font-size: 1rem;
    color: var(--accent-purple);
    margin-bottom: var(--spacing-sm);
    display: inline-block;
}

.portfolio-card.active p {
    font-size: 1.1rem;
    /* Larger text */
    line-height: 1.6;
    max-width: 60ch;
}

/* Details Section */
.portfolio-details {
    display: none;
    margin-top: var(--spacing-2xl);
    padding-top: var(--spacing-xl);
    border-top: 1px solid var(--border-color);
    animation: fadeInDetails 0.6s 0.2s cubic-bezier(0.19, 1, 0.22, 1) forwards;
    opacity: 0;
    transform: translateY(10px);
}

.portfolio-card.active .portfolio-details {
    display: block;
}

@keyframes fadeInDetails {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.portfolio-details h4 {
    font-size: 1.25rem;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
    font-weight: 600;
}

.detail-block {
    margin-bottom: var(--spacing-md);
    line-height: 1.5;
}

.detail-block strong {
    color: var(--accent-purple);
    display: block;
    /* Ensures text starts on a new line */
    font-size: 1rem;
    /* Slightly larger */
    font-weight: 700;
    /* More prominent (markanter) */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-xs);
    /* Add spacing below the heading */
}

@media (max-width: 600px) {
    .detail-block strong {
        display: block;
        margin-bottom: 4px;
    }
}

/* Closing State - Hide details immediately found! */
.portfolio-card.closing .portfolio-details {
    display: none !important;
}

/* Also hide extra text but keep title/category/p to avoid empty box */
.portfolio-card.closing .portfolio-info>*:not(h3):not(.portfolio-category):not(p) {
    opacity: 0;
    transition: opacity 0.1s ease-out;
}

.detail-tags {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    margin-top: var(--spacing-xl);
}

.detail-tags span {
    padding: 6px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
    transition: all 0.2s;
}

.detail-tags span:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    transform: translateY(-2px);
}

/* Close Button */
/* Close Button */
.close-modal-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    /* font-size: 28px; Removed for SVG */
    color: var(--text-secondary);
    transition: all 0.2s;
    box-shadow: var(--shadow-md);
    z-index: 20;
    opacity: 0;
}

.portfolio-card.active .close-modal-btn {
    display: flex;
    /* Show only when active */
    animation: fadeIn 0.3s 0.3s forwards;
    /* Delay show */
}

.portfolio-card.closing .close-modal-btn {
    display: none !important;
}

.close-modal-btn:hover {
    background: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
    transform: rotate(90deg);
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .portfolio-card.active {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0;
        grid-template-columns: 1fr;
        grid-template-rows: 30vh 1fr;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
    }

    .portfolio-card.active .portfolio-image {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .portfolio-card.active .portfolio-info {
        padding: var(--spacing-xl);
        background: var(--bg-primary);
        justify-content: flex-start;
        /* content starts directly under the image, not centered */
        padding-top: var(--spacing-lg);
    }

    .portfolio-card.active h3 {
        font-size: 1.8rem;
    }

    .close-modal-btn {
        top: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.9);
        color: black;
    }
}

/* CTA Portfolio Modifier */
.cta-section.cta-portfolio {
    position: relative;
    overflow: hidden;
}

.cta-section.cta-portfolio h2 {
    font-size: 2.2rem;
    margin-bottom: var(--spacing-md);
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.2;
}

.cta-section.cta-portfolio p {
    font-size: 1.1rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    opacity: 0.9;
}

/* Blur Background Elements */
.cta-section.cta-portfolio::before,
.cta-section.cta-portfolio::after,
.cta-section.cta-portfolio .cta-ocean,
.cta-section.cta-portfolio .cta-particles {
    filter: blur(8px);
    opacity: 0.8;
    /* Slightly reduce opacity to blend better */
}

/* Ensure content stays sharp and on top */
.cta-section.cta-portfolio .cta-content {
    position: relative;
    z-index: 10;
    /* ensure above the blurred layers */
}