@import url('https://fonts.loli.net/css2?family=Inter:wght@300;400;600;800&family=Outfit:wght@400;700&display=swap');

:root {
    --bg-color: #07090f;
    /* Deeper space dark */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent-color: #58a6ff;
    --accent-hover: #79c0ff;
    --card-bg: rgba(15, 20, 30, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(16px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Space Background Effects */
.bg-gradients {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    overflow: hidden;
    background: url('assets/space_bg_v2.png') center/cover no-repeat, #07090f;
}

/* Starfield emulation using box-shadows on pseudo elements */
.bg-gradients::before {
    content: "";
    position: absolute;
    width: 2px;
    height: 2px;
    background: transparent;
    box-shadow: 100px 200px #fff, 400px 800px 1px #ffd700, 800px 300px #fff, 1200px 900px #ffea00, 300px 100px #fff, 900px 600px #fff, 500px 500px 2px #ffd700, 1300px 100px #fff, 100px 900px #fff, 1100px 400px 1px #ffcc00, 250px 750px #ffea00, 850px 650px 2px #ffd700, 1500px 150px #ffdb58, 600px 200px 1px #ffd700;
    animation: drift 80s linear infinite;
    opacity: 0.4;
}

.bg-gradients::after {
    content: "";
    position: absolute;
    width: 3px;
    height: 3px;
    background: transparent;
    box-shadow: 200px 300px #58a6ff, 600px 700px #8839ef, 1000px 200px 2px #ffd700, 1400px 800px #8839ef, 400px 900px #58a6ff, 800px 100px 3px #ffdb58, 1500px 500px #58a6ff, 100px 500px 2px #ffd700, 700px 350px #ffcc00, 1250px 750px 2px #ffea00;
    animation: drift 50s linear infinite;
    opacity: 0.5;
}

@keyframes drift {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-1000px);
    }
}

/* Flowing Planet */
.planet-container {
    position: absolute;
    top: 15%;
    right: 10%;
    width: 200px;
    height: 200px;
    animation: rotatePlanet 120s linear infinite;
    pointer-events: none;
    opacity: 0.25;
}

.planet {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle at 30% 30%, #3e4b6b, #121824);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: inset -10px -10px 20px rgba(0, 0, 0, 0.8);
}

.planet-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 180px;
    height: 70px;
    border: 12px solid rgba(136, 153, 180, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%) rotateX(75deg);
    box-shadow: 0 0 10px rgba(136, 153, 180, 0.1);
}

@keyframes rotatePlanet {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Lang Toggle */
.top-nav {
    display: flex;
    justify-content: flex-end;
    padding: 20px 40px 0;
}

#lang-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    backdrop-filter: var(--glass-blur);
    transition: all 0.3s ease;
}

#lang-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

header {
    text-align: center;
    padding: 60px 20px 40px;
    animation: fadeInDown 1s ease forwards;
}

header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 4rem;
    font-weight: 800;
    background: linear-gradient(135deg, #e6edf3, #8b949e);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 20px;
}

header p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Category Filter */
.filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px;
    margin-bottom: 40px;
}

.filter-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 30px;
    cursor: pointer;
    backdrop-filter: var(--glass-blur);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    transition: all 0.3s ease;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-hover);
    box-shadow: 0 0 15px rgba(88, 166, 255, 0.4);
}

/* Projects Grid */
.projects-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 30px;
    padding: 0 40px 80px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Glassmorphism Cards */
.project-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    overflow: hidden;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease;
    opacity: 0;
    transform: translateY(20px);
    cursor: pointer;
    /* Indicates it's clickable for detail */
}

.project-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(88, 166, 255, 0.1);
    border-color: rgba(88, 166, 255, 0.3);
}

.media-container {
    width: 100%;
    height: 250px;
    background: rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    pointer-events: none;
    /* Let card capture click */
}

.media-container img,
.media-container video,
model-viewer {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

model-viewer {
    background-color: transparent;
}

.project-card:hover .media-container img,
.project-card:hover .media-container video {
    transform: scale(1.05);
}

.pills {
    position: absolute;
    top: 15px;
    left: 15px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    z-index: 2;
}

.pill {
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.content {
    padding: 25px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.4rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.content p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Modal Details View */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content-box {
    background: #121620;
    /* Solid dark for readibility */
    border: 1px solid var(--card-border);
    width: 90%;
    max-width: 1100px;
    max-height: 90vh;
    border-radius: 20px;
    overflow-y: auto;
    position: relative;
    padding: 40px;
    transform: scale(0.95);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal-content-box {
    transform: scale(1);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.floating-close-btn {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(18, 22, 32, 0.92);
    color: #fff;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    z-index: 120;
    display: grid;
    place-items: center;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px) scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.floating-close-btn:hover {
    background: rgba(37, 44, 62, 0.95);
}

.modal-overlay.active .floating-close-btn {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

#modal-title {
    font-family: 'Outfit', sans-serif;
    font-size: 2.2rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    padding-right: 80px;
}

.modal-desc {
    color: #c9d1d9;
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 30px;
}

.modal-desc h3 {
    font-family: 'Outfit', sans-serif;
    color: var(--accent-color);
    margin: 40px 0 15px 0;
    font-size: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}

.modal-desc h3:first-child {
    margin-top: 0;
}

.modal-desc p {
    margin-bottom: 20px;
}

.modal-desc ul {
    margin-left: 25px;
    margin-bottom: 30px;
}

.modal-desc li {
    margin-bottom: 10px;
}

.modal-desc strong {
    color: var(--text-primary);
}

.inline-video {
    width: 100%;
    border-radius: 12px;
    margin: 15px 0 35px 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #000;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

/* Gallery Grid */
.modal-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
}

.gallery-item {
    width: 100%;
    height: 300px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.gallery-item.gallery-3d {
    height: 400px;
    /* larger 3d viewer */
    grid-column: 1 / -1;
    /* spans full width if needed */
}

.gallery-item img,
.gallery-item video,
.gallery-item model-viewer {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Don't crop detail media */
}

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

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

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

.hidden {
    display: none !important;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 3rem;
    }

    .projects-container {
        grid-template-columns: 1fr;
        padding: 0 20px 60px;
    }

    .modal-overlay {
        align-items: stretch;
    }

    .modal-content-box {
        width: 100%;
        max-width: none;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        padding: 24px 16px 84px;
    }

    .close-btn {
        top: 14px;
        right: 12px;
        padding: 7px 14px;
    }

    #modal-title {
        font-size: 1.7rem;
        padding-right: 0;
        margin-top: 24px;
    }

    .modal-desc {
        font-size: 1rem;
        line-height: 1.7;
    }

    .modal-desc div[style*="display: flex"] {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    .modal-desc div[style*="display: flex"] > img,
    .modal-desc div[style*="display: flex"] > video,
    .modal-desc div[style*="display: flex"] > .inline-video,
    .modal-desc div[style*="display: flex"] > div {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        align-self: stretch !important;
    }

    .inline-video {
        margin: 12px 0 26px 0;
    }

    .floating-close-btn {
        right: max(14px, env(safe-area-inset-right));
        bottom: max(14px, env(safe-area-inset-bottom));
        width: 52px;
        height: 52px;
    }

    .modal-gallery {
        grid-template-columns: 1fr;
    }

    .gallery-item,
    .gallery-item.gallery-3d {
        height: 260px;
    }
}
