/* ---------------------------------------- */
/* PORTFOLIO / FEATURED PROJECTS            */
/* ---------------------------------------- */

.portfolio {
    padding: 100px 5%;
    background: var(--bg-primary);
    position: relative;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 35px;
    margin-top: 50px;
    perspective: 1000px;
}

/* Minimalist Portfolio Card */
.portfolio-card {
    background: rgba(var(--bg-secondary-rgb), 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.portfolio-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    border-color: rgba(var(--primary-rgb), 0.5);
}

[data-theme="dark"] .portfolio-card {
    border: var(--card-border);
    box-shadow: var(--card-inner-shadow), 0 8px 32px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .portfolio-card:hover {
    border: var(--card-hover-border);
    box-shadow: var(--card-hover-shadow), 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* Medal Rankings - Robust Nth-Child Selectors */
.portfolio-card:nth-child(1)::before,
.portfolio-card:nth-child(2)::before,
.portfolio-card:nth-child(3)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    pointer-events: none;
    border-radius: 16px;
    box-sizing: border-box;
}

/* Gold - 1st Card */
.portfolio-card:nth-child(1)::before {
    background: rgba(255, 215, 0, 0.15);
    /* Light Gold tint */
    border: 2px solid rgba(255, 215, 0, 0.5);
    box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.2), 0 0 20px rgba(255, 215, 0, 0.2);
}

/* Bronze - 2nd Card */
.portfolio-card:nth-child(2)::before {
    background: rgba(205, 127, 50, 0.15);
    /* Light Bronze tint */
    border: 2px solid rgba(205, 127, 50, 0.5);
    box-shadow: inset 0 0 20px rgba(205, 127, 50, 0.1), 0 0 20px rgba(205, 127, 50, 0.1);
}

/* Silver - 3rd Card */
.portfolio-card:nth-child(3)::before {
    background: rgba(224, 224, 224, 0.15);
    /* Light Silver tint */
    border: 2px solid rgba(224, 224, 224, 0.5);
    box-shadow: inset 0 0 20px rgba(224, 224, 224, 0.1), 0 0 20px rgba(224, 224, 224, 0.1);
}

.portfolio-image {
    height: 220px;
    width: 100%;
    overflow: hidden;
    background: var(--bg-primary);
}

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

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

.portfolio-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.portfolio-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.portfolio-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.portfolio-tech {
    margin-top: auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tech-tag {
    font-size: 0.75rem;
    padding: 4px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    font-weight: 500;
}

.btn-card {
    margin-top: 15px;
    padding: 8px 16px;
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.portfolio-card:hover .btn-card {
    background: var(--primary-color);
    color: white;
}

/* Minimalist Project Modal */
.project-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    /* backdrop-filter: blur(5px); Removed for compatibility */
    z-index: 999999;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.project-modal-content {
    background: var(--bg-secondary);
    width: 100%;
    max-width: 700px;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    /* animation: modalSlideUp 0.3s ease-out; Removed for debugging */
    background: #1e293b;
    z-index: 200001;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.project-modal-overlay {
    /* ... existing properties ... */
    pointer-events: auto !important;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.close-project-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    z-index: 200005;
    /* Ensure above content and image */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.close-project-modal:hover {
    background: rgba(0, 0, 0, 0.8);
}

.project-modal-header {
    height: 300px;
    /* Large header image */
    overflow: hidden;
    position: relative;
}

.project-modal-header img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.project-modal-body {
    padding: 30px;
}

.modal-info-bar {
    margin-bottom: 20px;
}

.modal-info-bar h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.modal-tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.modal-tech-tag {
    background: var(--primary-color-light, rgba(74, 222, 128, 0.1));
    color: var(--primary-color);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.modal-description {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 1rem;
    margin-bottom: 30px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
}

.modal-actions .btn {
    padding: 12px 28px;
    font-weight: 600;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(44, 95, 93, 0.2);
}

.modal-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(44, 95, 93, 0.3);
    filter: brightness(1.1);
}

/* Carousel Layout for Featured Projects */
.portfolio-grid.carousel-view {
    display: flex;
    overflow-x: auto;
    gap: 30px;
    padding: 20px 4px;
    scroll-behavior: smooth;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
    flex-wrap: nowrap;
    justify-content: start;
}

.portfolio-grid.carousel-view::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.portfolio-grid.carousel-view .portfolio-card {
    min-width: 320px;
    max-width: 320px;
    height: 450px;
    /* Fixed height for consistency */
    flex: 0 0 auto;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Carousel Controls */
.carousel-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.carousel-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: rgba(44, 95, 93, 0.1);
    /* Light Teal tint */
    color: var(--primary-color);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.carousel-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(44, 95, 93, 0.3);
}

.carousel-btn:active {
    transform: scale(0.95);
}

/* Dark Mode Adjustments */
[data-theme='dark'] .project-modal-content {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme='dark'] .tech-tag {
    background: var(--bg-accent);
    border-color: var(--border-color);
}