/* Portfolio Section Styles */

/* Main Container */
.portfolio-container {
    position: absolute;
    height: 100vh;
    width: 100%;
    overflow-y: auto; /* Changed from scroll to auto for better touch handling */
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
    top: 0;
    left: 0;
    padding-top: 0; /* Remove top padding as it's now applied to each page */
    box-sizing: border-box;
    z-index: 1;
    -webkit-overflow-scrolling: touch;
    will-change: scroll-position;
    backface-visibility: hidden;
    overscroll-behavior: none;
    contain: strict;
    touch-action: pan-y; /* Explicitly enable vertical touch actions */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    -webkit-backface-visibility: hidden;
}

/* Hide scrollbar for Chrome/Safari */
.portfolio-container::-webkit-scrollbar {
    display: none;
}

/* Portfolio Pages */
.portfolio-page {
    position: relative;
    min-height: 100vh;
    height: 100vh; /* Force exact viewport height */
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    padding-top: 30px; /* Account for header height */
    scroll-snap-align: start;
    scroll-snap-stop: always;
    box-sizing: border-box;
    contain: content; /* Improve performance by containing layout */
    transition: visibility 0s linear, opacity 0.25s ease-in-out;
    opacity: 0.25;
    will-change: transform, opacity;
}

/* Make current page fully visible */
.portfolio-page.active {
    opacity: 1;
}

/* Theme-based background colors */
.portfolio-page[data-theme="purple"] {
    --blob-outline-color: #9c27b0;
    --blob-fill-color: rgba(156, 39, 176, 0.45);
    --blob-dot-color: #9c27b0;
    --card-shadow-color: rgba(156, 39, 176, 0.25);
    --blob-glow-color: rgba(156, 39, 176, 0.6);
}

.portfolio-page[data-theme="green"] {
    --blob-outline-color: #4caf50;
    --blob-fill-color: rgba(76, 175, 80, 0.45);
    --blob-dot-color: #4caf50;
    --card-shadow-color: rgba(76, 175, 80, 0.25);
    --blob-glow-color: rgba(76, 175, 80, 0.6);
}

.portfolio-page[data-theme="blue"] {
    --blob-outline-color: #2196f3;
    --blob-fill-color: rgba(33, 150, 243, 0.45);
    --blob-dot-color: #2196f3;
    --card-shadow-color: rgba(33, 150, 243, 0.25);
    --blob-glow-color: rgba(33, 150, 243, 0.6);
}

.portfolio-page[data-theme="yellow"] {
    --blob-outline-color: #ffeb3b;
    --blob-fill-color: rgba(255, 235, 59, 0.45);
    --blob-dot-color: #ffeb3b;
    --card-shadow-color: rgba(255, 235, 59, 0.25);
    --blob-glow-color: rgba(255, 235, 59, 0.6);
}

.portfolio-page[data-theme="red"] {
    --blob-outline-color: #f44336;
    --blob-fill-color: rgba(244, 67, 54, 0.45);
    --blob-dot-color: #f44336;
    --card-shadow-color: rgba(244, 67, 54, 0.25);
    --blob-glow-color: rgba(244, 67, 54, 0.6);
}

/* Dark mode overrides for background */
body.dark-mode .portfolio-page {
    background-color: rgba(10, 10, 10, 0.7);
}

body:not(.dark-mode) .portfolio-page {
    background-color: rgba(250, 250, 250, 0.7);
}

/* Blob Container */
.portfolio-blob-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

/* Blob Base Style */
.portfolio-blob {
    position: absolute;
    contain: layout paint style;
    animation-duration: 60s !important;
}

/* Outlined blob */
.blob-outlined {
    border: 3px solid;
    background-color: transparent !important;
    border-color: var(--blob-outline-color);
    box-shadow: 0 0 15px var(--blob-glow-color);
}

/* Filled blob */
.blob-filled {
    background-color: var(--blob-fill-color);
    box-shadow: inset 0 0 30px rgba(var(--blob-outline-color), 0.2),
    0 0 20px var(--blob-glow-color);
}

/* Dotted pattern blob */
.blob-dotted {
    background-image: radial-gradient(circle, var(--blob-dot-color) 1.5px, transparent 1.5px);
    background-size: 12px 12px;
    opacity: 0.7;

    background-color: transparent !important;
    border: none !important;
}

/* Dense dotted pattern blob */
.blob-dotted-dense {
    background-image: radial-gradient(circle, var(--blob-dot-color) 1.5px, transparent 1px);
    background-size: 10px 10px;
    opacity: 0.7;

    background-color: transparent !important;
    border: none !important;
}

/* New positioning and animations for four strategic blobs */
/* Top-left: Outlined blob */
.blob-top-left {
    width: 400px;
    height: 400px;
    top: -100px;
    left: -100px;
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    animation: blob-move-outline 28s infinite ease-in-out;
    transform-origin: center center;
}

/* Bottom-right: Filled blob */
.blob-bottom-right {
    width: 350px;
    height: 350px;
    bottom: -50px;
    right: -80px;
    border-radius: 40% 60% 70% 30% / 40% 50% 50% 60%;
    animation: blob-move-filled 32s infinite cubic-bezier(0.4, 0, 0.6, 1);
    transform-origin: center center;
}

/* Top-right: Dotted pattern blob */
.blob-top-right {
    width: 300px;
    height: 300px;
    top: -30px;
    right: -50px;
    border-radius: 50%;
    animation: blob-move-dotted 26s infinite cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center center;
}

/* Bottom-left: Dotted dense pattern blob */
.blob-bottom-left {
    width: 280px;
    height: 280px;
    bottom: -20px;
    left: -40px;
    border-radius: 50%;
    animation: blob-move-dotted-dense 35s infinite cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: center center;
}

/* Animation for outlined blob */
@keyframes blob-move-outline {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    25% {
        transform: translate(80px, -40px) rotate(15deg) scale(1.05);
    }
    50% {
        transform: translate(120px, 60px) rotate(-10deg) scale(0.95);
    }
    75% {
        transform: translate(-30px, 90px) rotate(25deg) scale(1.08);
    }
    100% {
        transform: translate(-60px, -20px) rotate(-5deg) scale(1.02);
    }
}

/* Animation for filled blob */
@keyframes blob-move-filled {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    20% {
        transform: translate(-70px, -80px) rotate(-20deg) scale(1.1);
    }
    40% {
        transform: translate(-120px, -30px) rotate(10deg) scale(0.9);
    }
    60% {
        transform: translate(-90px, 70px) rotate(-30deg) scale(1.15);
    }
    80% {
        transform: translate(40px, 50px) rotate(20deg) scale(0.95);
    }
    100% {
        transform: translate(20px, -40px) rotate(-8deg) scale(1.05);
    }
}

/* Animation for dotted blob */
@keyframes blob-move-dotted {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    30% {
        transform: translate(-60px, 50px) rotate(30deg) scale(1.12);
    }
    60% {
        transform: translate(90px, -30px) rotate(-25deg) scale(0.88);
    }
    85% {
        transform: translate(70px, 80px) rotate(45deg) scale(1.18);
    }
    100% {
        transform: translate(-20px, -10px) rotate(12deg) scale(1.06);
    }
}

/* Animation for dense dotted blob */
@keyframes blob-move-dotted-dense {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    15% {
        transform: translate(90px, -50px) rotate(18deg) scale(1.08);
    }
    35% {
        transform: translate(110px, 40px) rotate(-35deg) scale(0.92);
    }
    55% {
        transform: translate(-40px, 100px) rotate(40deg) scale(1.2);
    }
    75% {
        transform: translate(-80px, -30px) rotate(-15deg) scale(0.85);
    }
    90% {
        transform: translate(30px, 60px) rotate(28deg) scale(1.12);
    }
    100% {
        transform: translate(10px, 20px) rotate(8deg) scale(1.04);
    }
}

/* Dark mode blob adjustments */
body.dark-mode .blob-outlined {
    opacity: 0.85;
    border-width: 3px;
}

body.dark-mode .blob-filled {
    opacity: 0.45;
}

body.dark-mode .blob-dotted {
    opacity: 0.45;
}

/* Light mode blob adjustments */
body:not(.dark-mode) .blob-outlined {
    opacity: 0.85;
    border-width: 3px;
}

body:not(.dark-mode) .blob-filled {
    opacity: 0.35;
}

body:not(.dark-mode) .blob-dotted {
    opacity: 0.5;
}

/* Content Area */
.portfolio-content {
    width: 100%;
    max-width: 2000px;
    z-index: 2;
    display: flex;
    justify-content: center;
    margin-top: 50px;
    align-items: center;
    padding: 2rem 1rem;
}

/* Portfolio Card */
.portfolio-card {
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 1800px;
    box-shadow: 0 20px 50px var(--card-shadow-color);
    opacity: 1;
    display: flex;
    flex-direction: column;
    contain: layout style;
}

/* Card background adjustments for dark/light mode */
body.dark-mode .portfolio-card {
    background-color: rgba(50, 50, 50, 0.12);
    color: #fff;
}

body:not(.dark-mode) .portfolio-card {
    background-color: rgba(255, 255, 255, 0.6);
    color: #222;
}

/* Portfolio Content Elements */
.portfolio-title {
    font-size: 3rem;
    margin-bottom: 1rem;
    text-align: center;
}

.portfolio-subtitle {
    font-size: 1.25rem;
    text-align: center;
    margin-bottom: 2rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

/* Portfolio Image */
.portfolio-image {
    width: 100%;
    overflow: hidden;
    position: relative;
    aspect-ratio: 5/3;
    background: transparent;
    transition: transform 0.7s ease-in-out;
}

.portfolio-image img {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 0.8s ease;
    object-fit: cover;
}

.portfolio-image:hover {
    transform: scale(1.1) translateY(-20px);
}

.portfolio-image img.mobile-image {
    display: none;
}

/* Text color adjustments for dark/light mode */
body.dark-mode .portfolio-title {
    color: #fff;
}

body.dark-mode .portfolio-subtitle {
    color: rgba(255, 255, 255, 0.8);
}

body:not(.dark-mode) .portfolio-title {
    color: #222;
}

body:not(.dark-mode) .portfolio-subtitle {
    color: rgba(0, 0, 0, 0.7);
}

/* Responsive Adjustments */
@media (min-width: 992px) {
    .portfolio-container {
        scroll-snap-type: none;
        scroll-behavior: smooth;
        transition-duration: 800ms;
        transition-timing-function: cubic-bezier(0.45, 0.05, 0.55, 0.95);
    }

    .portfolio-page {
        scroll-snap-align: start;
        scroll-snap-stop: always;
        opacity: 0.3;
        transform: scale(0.95);
        will-change: opacity, transform;
        transition: opacity 0.8s cubic-bezier(0.19, 1, 0.22, 1),
        transform 0.8s cubic-bezier(0.19, 1, 0.22, 1);
        filter: blur(1px);
    }

    .portfolio-page.active {
        opacity: 1;
        transform: scale(1);
        transition: opacity 0.8s cubic-bezier(0.19, 1, 0.22, 1),
        transform 0.8s cubic-bezier(0.19, 1, 0.22, 1);
        z-index: 2;
        filter: blur(0);
    }

    /* Add slight parallax effect to portfolio content */
    .portfolio-page .portfolio-content {
        transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    }

    .portfolio-page.active .portfolio-content {
        transform: translateY(0);
    }

    .portfolio-page:not(.active) .portfolio-content {
        transform: translateY(40px);
    }

    .portfolio-card {
        display: grid;
        grid-template-columns: 0.8fr 1.5fr;
        grid-gap: 2rem;
        align-items: center;
        max-width: 1600px;
        padding: 3rem;
        margin-right: 2.5rem;
        margin-left: 2.5rem;
    }

    .portfolio-content-text {
        padding-right: 1rem;
    }

    .portfolio-title {
        text-align: left;
        font-size: 2.8rem;
        margin-bottom: 1.5rem;
    }

    .portfolio-subtitle {
        text-align: left;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    .portfolio-image {
        aspect-ratio: 5/3;
        height: auto;
        max-height: none;
    }

    .portfolio-image img.desktop-image {
        height: 100%;
        object-fit: cover;
    }
}

@media (min-width: 1400px) {
    .portfolio-card {
        max-width: 1800px;
        padding: 4rem;
    }

    .portfolio-image {
        height: auto;
        max-height: none;
    }
}

@media (max-width: 1200px) {
    .portfolio-content {
        padding: 1.5rem;
    }

    .portfolio-card {
        padding: 2rem;
    }

    .portfolio-title {
        font-size: 2.5rem;
    }

    /* Adjust blob sizes for larger screens */
    .blob-top-left {
        width: 350px;
        height: 350px;
    }

    .blob-bottom-right {
        width: 320px;
        height: 320px;
    }

    .blob-top-right {
        width: 280px;
        height: 280px;
    }

    .blob-bottom-left {
        width: 260px;
        height: 260px;
    }
}

@media (max-width: 992px) {
    .portfolio-title {
        font-size: 2.2rem;
    }

    /* Adjust blob sizes */
    .blob-top-left {
        width: 300px;
        height: 300px;
    }

    .blob-bottom-right {
        width: 280px;
        height: 280px;
    }

    .blob-top-right {
        width: 250px;
        height: 250px;
    }

    .blob-bottom-left {
        width: 230px;
        height: 230px;
    }

    .portfolio-card {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .portfolio-card {
        padding: 1.5rem;
    }

    .portfolio-title {
        font-size: 1.8rem;
    }

    .portfolio-subtitle {
        font-size: 1.1rem;
        margin-bottom: 1.5rem;
    }

    /* Hide top-right and bottom-left blobs on mobile */
    .blob-top-right,
    .blob-bottom-left {
        display: none;
    }

    /* Adjust remaining blobs for mobile */
    .blob-top-left {
        width: 250px;
        height: 250px;
        top: -50px;
        left: -50px;
    }

    .blob-bottom-right {
        width: 230px;
        height: 230px;
        bottom: -30px;
        right: -40px;
    }

    /* Show mobile image, hide desktop image */
    .portfolio-image img.desktop-image {
        display: none;
    }

    .portfolio-image img.mobile-image {
        display: block;
    }

    /* Set 3:4 aspect ratio for mobile */
    .portfolio-image {
        aspect-ratio: 3/4;
        height: auto;
        width: 100%;
        margin-top: 1.5rem;
    }

    /* Make sure images fill the container properly */
    .portfolio-image img {
        height: 100%;
        width: 100%;
        object-fit: cover;
        object-position: center;
    }

    /* Optimize paint operations on mobile */
    .portfolio-blob-container {
        contain: strict;
        touch-action: none;
    }

    /* Better memory management for mobile */
    .portfolio-page:not(.active) .portfolio-blob {
        opacity: 0.5;
        transition: opacity 0.3s ease;
    }

    /* Specifically optimize for mobile scrolling */
    .portfolio-container {
        scroll-snap-type: y mandatory; /* Ensure snapping on mobile */
        overscroll-behavior: contain; /* Better containment for mobile */
        -webkit-overflow-scrolling: touch !important; /* Force momentum scrolling on iOS */
    }

    /* Reduce blob animation complexity */
    .portfolio-blob {
        animation-play-state: paused; /* Pause animations while scrolling */
    }

    /* Only animate blobs in active page */
    .portfolio-page.active .portfolio-blob {
        animation-play-state: running;
    }

    /* Fade in page content */
    .portfolio-card {
        transition: opacity 0.3s ease;
    }

    .portfolio-page:not(.active) .portfolio-card {
        opacity: 0.7;
    }

    .portfolio-page.active .portfolio-card {
        opacity: 1;
    }
}

@media (max-width: 576px) {
    .portfolio-card {
        padding: 1.2rem;
        border-radius: 18px;
    }

    .portfolio-title {
        font-size: 1.6rem;
    }

    .portfolio-subtitle {
        font-size: 1rem;
        margin-bottom: 1.2rem;
    }

    /* Further reduce blob sizes for very small screens */
    .blob-top-left {
        width: 200px;
        height: 200px;
        top: -40px;
        left: -40px;
    }

    .blob-bottom-right {
        width: 180px;
        height: 180px;
        bottom: -20px;
        right: -30px;
    }
}

@media (max-width: 576px) and (min-height: 700px) {
    .portfolio-card {
        max-height: none;
        overflow: visible;
    }

    /* Adjust blob positions for tall screens */
    .blob-top-left {
        top: -30px;
    }

    .blob-bottom-right {
        bottom: -10px;
    }
}

/* For landscape orientation on small screens */
@media (max-height: 500px) and (orientation: landscape) {
    .portfolio-page {
        padding: 1rem 0.5rem;
    }

    .portfolio-card {
        padding: 1rem;
        max-height: none;
        overflow: visible;
    }

    .portfolio-title {
        font-size: 1.4rem;
        margin-bottom: 0.5rem;
    }

    .portfolio-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }

    /* Adjust blob sizes and positions for landscape orientation */
    .blob-top-left {
        width: 180px;
        height: 180px;
        top: -30px;
        left: -30px;
    }

    .blob-bottom-right {
        width: 160px;
        height: 160px;
        bottom: -20px;
        right: -20px;
    }

    /* Adjust image height for landscape */
    .portfolio-image {
        aspect-ratio: 5/3;
        height: auto;
    }

    .portfolio-image img {
        height: 100%;
        width: 100%;
        object-fit: cover;
    }
}

/* Small-laptop height adjustments to prevent content from going out of bounds */
@media (min-width: 992px) and (max-height: 830px) {
    .portfolio-page {
        height: auto; /* allow page to grow if content exceeds viewport height */
        min-height: 100vh;
    }

    .portfolio-content {
        margin-top: 24px;
        padding: 1rem;
    }

    .portfolio-card {
        max-height: none;
        overflow: visible;
        padding: 2rem;
        margin-right: 1.5rem;
        margin-left: 1.5rem;
    }

    .portfolio-title {
        font-size: 2.2rem;
    }

    .portfolio-subtitle {
        font-size: 1.05rem;
    }

    /* Slightly reduce swiper height to fit shorter screens */
    .portfolio-card.swiper-card .swiper {
        min-height: 400px;
        padding-bottom: 48px;
    }

    .portfolio-card.swiper-card .swiper-slide {
        height: calc((100% - 24px) / 2);
    }
}

/* Better scroll edge detection for iOS devices */
@supports (-webkit-touch-callout: none) {
    .portfolio-container {
        height: 100%; /* Use standard height value instead of -webkit-fill-available */
    }

    @media (max-width: 768px) {
        body, html {
            position: fixed;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }

        .portfolio-container {
            position: absolute;
            height: calc(100% - 80px);
            top: 80px;
            -webkit-overflow-scrolling: touch !important;
            overscroll-behavior: contain;
        }
    }
}

@media (min-width: 992px) {
    .portfolio-card {
        display: grid;
        grid-template-columns: 0.8fr 1.5fr;
        grid-gap: 2rem;
        align-items: center;
        max-width: 1600px;
        padding: 3rem;
        margin-right: 2.5rem;
        margin-left: 2.5rem;
    }

    /* Override grid layout when using swiper */
    .portfolio-card.swiper-card {
        display: block;
        margin-right: 2.5rem;
        margin-left: 2.5rem;
    }
}

/* Swiper styles scoped to portfolio card */
.portfolio-card.swiper-card {
    display: block;
    position: relative;
}

.portfolio-card.swiper-card .swiper {
    width: 100%;
    height: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-bottom: 56px;
}

.portfolio-card.swiper-card .swiper-wrapper {
    box-sizing: border-box;
    transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

.portfolio-card.swiper-card .swiper-slide {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    text-align: center;
    font-size: 16px;
    background: transparent;
    height: calc((100% - 40px) / 3);
    display: -webkit-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-box-align: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center;
}

.portfolio-card.swiper-card .swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.portfolio-card.swiper-card .swiper-slide img {
    transition: transform 0.35s ease;
}

.portfolio-card.swiper-card .swiper-slide:hover img,
.portfolio-card.swiper-card .swiper-slide:focus-within img {
    transform: scale(1.03);
}

.portfolio-card.swiper-card .swiper-slide::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 55%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    /* Progressive fade upward for perceived progressive blur */
    mask-image: linear-gradient(to top, rgba(0, 0, 0, 1) 35%, rgba(0, 0, 0, 0.6) 65%, rgba(0, 0, 0, 0) 100%);
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    pointer-events: none;
    z-index: 1;
}

.portfolio-card.swiper-card .swiper-slide:hover::before,
.portfolio-card.swiper-card .swiper-slide:focus-within::before {
    transform: translateY(0);
    opacity: 1;
}

.portfolio-card.swiper-card .swiper-slide::after {
    content: attr(data-caption);
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 16px;
    font-size: 1rem;
    line-height: 1.5;
    color: #fff;
    /* Darker, more intense gradient for readability */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.35) 60%, rgba(0, 0, 0, 0) 100%);
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    pointer-events: none;
    text-align: center;
    direction: rtl;
    z-index: 2;
}

.portfolio-card.swiper-card .swiper-slide:hover::after,
.portfolio-card.swiper-card .swiper-slide:focus-within::after {
    transform: translateY(0);
    opacity: 1;
}

/* Tweak pagination bullets to match theme */
.portfolio-card.swiper-card .swiper-pagination-bullet {
    background: currentColor;
    opacity: 0.5;
}

.portfolio-card.swiper-card .swiper-pagination-bullet-active {
    opacity: 1;
}

/* Provide a reasonable min-height so grid shows nicely */
.portfolio-card.swiper-card .swiper {
    min-height: 480px;
}

@media (max-width: 768px) {
    .portfolio-card.swiper-card .swiper {
        min-height: 420px;
        padding-bottom: 52px;
    }
}

@media (min-width: 992px) {
    .portfolio-card.swiper-card .swiper-slide {
        height: calc((100% - 30px) / 2);
    }
}

/* Swiper controls bar below the grid */
.portfolio-card.swiper-card .swiper-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 3;
}

/* Convert bullets into line segments */
.portfolio-card.swiper-card .swiper-controls .swiper-pagination {
    position: static;
    display: flex;
    align-items: center;
    gap: 10px;
}

.portfolio-card.swiper-card .swiper-controls .swiper-pagination-bullet {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    opacity: 0.35;
    transition: opacity 0.2s ease, transform 0.2s ease;
    background: color-mix(in srgb, currentColor 30%, transparent);
    overflow: hidden;
}

.portfolio-card.swiper-card .swiper-controls .swiper-pagination-bullet-active {
    opacity: 1;
}

/* Optional progressive fill animation for active bullet, synced to autoplay delay */
:root {
    --swiper-autoplay-delay: 3000ms;
    --swiper-speed: 800ms;
}
.portfolio-card.swiper-card .swiper-controls .swiper-pagination-bullet-active {
    background-image: linear-gradient(90deg, currentColor 0%, currentColor 100%), linear-gradient(90deg, color-mix(in srgb, currentColor 30%, transparent) 0%, color-mix(in srgb, currentColor 30%, transparent) 100%);
    background-repeat: no-repeat, no-repeat;
    background-size: 0% 100%, 100% 100%;
    animation: swiperBulletProgress calc(var(--swiper-autoplay-delay, 3000ms) + var(--swiper-speed, 0ms)) linear forwards;
}

@keyframes swiperBulletProgress {
    from {
        background-size: 0% 100%, 100% 100%;
    }
    to {
        background-size: 100% 100%, 100% 100%;
    }
}

/* Navigation arrows beside the lines */
.portfolio-card.swiper-card .swiper-controls .swiper-button-prev,
.portfolio-card.swiper-card .swiper-controls .swiper-button-next {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    color: currentColor;
    background: transparent;
    border: 0;
    outline: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Adjust default pseudo arrow size */
.portfolio-card.swiper-card .swiper-controls .swiper-button-prev::after,
.portfolio-card.swiper-card .swiper-controls .swiper-button-next::after {
    font-size: 18px;
    font-weight: 600;
}

.portfolio-card.swiper-card .swiper-controls .swiper-button-prev:hover,
.portfolio-card.swiper-card .swiper-controls .swiper-button-next:hover {
    opacity: 1;
    transform: scale(1.05);
}

.portfolio-card.swiper-card .swiper-controls .swiper-button-prev:focus-visible,
.portfolio-card.swiper-card .swiper-controls .swiper-button-next:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Respect theme colors for controls */
.portfolio-page[data-theme="purple"] .swiper-controls,
.portfolio-page[data-theme="green"] .swiper-controls,
.portfolio-page[data-theme="blue"] .swiper-controls,
.portfolio-page[data-theme="yellow"] .swiper-controls,
.portfolio-page[data-theme="red"] .swiper-controls {
    color: var(--blob-outline-color);
}

@media (max-width: 768px) {
    .portfolio-card.swiper-card .swiper-controls {
        gap: 12px;
    }

    .portfolio-card.swiper-card .swiper-controls .swiper-pagination-bullet {
        width: 28px;
        height: 4px;
    }
}

/* Lightbox minimal styles */
body.no-scroll {
    overflow: hidden;
}

.lightbox {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    width: 100%;
}

.lightbox-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 80vh;
}

.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: -12px;
    right: -12px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: 0;
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
}

.lightbox-controls {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    transform: translateY(-50%);
    pointer-events: none;
}

.lightbox-prev,
.lightbox-next {
    pointer-events: all;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.lightbox-caption,
.lightbox-counter {
    text-align: center;
    color: #fff;
    margin-top: 12px;
}

/* Improve affordance for images */
.portfolio-card.swiper-card .swiper-slide img {
    cursor: zoom-in;
}
