/* Spartans Projects — Pixel Game Theme */
:root {
    --pixel-accent: #86c9f7;
    --pixel-white: #ffffff;
    --pixel-bg: #0a0a0a;
    --pixel-card-bg: rgba(15, 12, 27, 0.92);
    --font-pixel: 'Press Start 2P', cursive;
    --font-retro: 'VT323', monospace;
}

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

html, body {
    min-height: 100vh;
}

body.projects-page {
    background-color: var(--pixel-bg);
    color: var(--pixel-white);
    font-family: var(--font-retro);
    overflow-x: hidden;
    image-rendering: pixelated;
}

/* ── Background Layers ── */
.projects-bg {
    position: fixed;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
    image-rendering: pixelated;
}

.projects-bg-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(10, 10, 10, 0.75) 0%,
        rgba(10, 10, 10, 0.85) 50%,
        rgba(10, 10, 10, 0.92) 100%
    );
    z-index: 1;
}

.projects-particles {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background-image:
        radial-gradient(circle, #fff 1px, transparent 1px),
        radial-gradient(circle, var(--pixel-accent) 1px, transparent 1px);
    background-size: 100px 100px, 150px 150px;
    background-position: 0 0, 50px 50px;
    animation: particleFloat 20s linear infinite;
    opacity: 0.15;
}

.noise {
    position: fixed;
    inset: 0;
    background: url('https://grainy-gradients.vercel.app/noise.svg');
    opacity: 0.1;
    pointer-events: none;
    z-index: 999;
}

@keyframes particleFloat {
    from { background-position: 0 0, 50px 50px; }
    to { background-position: -100px -100px, -50px -50px; }
}

/* ── Page Content ── */
.projects-page-content {
    position: relative;
    z-index: 10;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 5% 6rem;
}

/* ── Pixel Loader ── */
#page-loader {
    position: fixed;
    inset: 0;
    background: #030303;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1), visibility 1s;
}

#page-loader.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-scanline {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        transparent 50%,
        rgba(134, 201, 247, 0.05) 50%
    );
    background-size: 100% 4px;
    z-index: 2;
    pointer-events: none;
    animation: scanlineScroll 10s linear infinite;
}

.loader-noise {
    position: absolute;
    inset: 0;
    background: url('https://grainy-gradients.vercel.app/noise.svg');
    opacity: 0.15;
    z-index: 1;
    pointer-events: none;
}

.loader-corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(134, 201, 247, 0.3);
    z-index: 5;
}

.top-left { top: 40px; left: 40px; border-right: none; border-bottom: none; }
.top-right { top: 40px; right: 40px; border-left: none; border-bottom: none; }
.bottom-left { bottom: 40px; left: 40px; border-right: none; border-top: none; }
.bottom-right { bottom: 40px; right: 40px; border-left: none; border-top: none; }

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    z-index: 10;
    position: relative;
    width: 100%;
    max-width: 400px;
}

.loader-orb-container {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-orb {
    width: 40px;
    height: 40px;
    border: 3px solid var(--pixel-white);
    border-top-color: var(--pixel-accent);
    animation: orbRotate 1s steps(8) infinite;
    position: relative;
    z-index: 2;
}

.loader-orb-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 1px dashed rgba(134, 201, 247, 0.4);
    animation: ringRotate 4s linear infinite reverse;
}

.loader-metadata {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-family: var(--font-retro);
    font-size: 0.9rem;
    color: rgba(134, 201, 247, 0.6);
    text-align: center;
}

.loader-progress-container {
    width: 80%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.loader-progress-bar {
    width: 0%;
    height: 4px;
    background: var(--pixel-accent);
    box-shadow: 0 0 10px var(--pixel-accent);
    transition: width 0.1s linear;
}

.loader-progress-percentage {
    font-family: var(--font-pixel);
    color: rgba(134, 201, 247, 0.6);
    font-size: 0.55rem;
    letter-spacing: 2px;
}

.loader-status {
    font-family: var(--font-retro);
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.85rem;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.loader-footer {
    position: absolute;
    bottom: 60px;
    font-size: 0.7rem;
    opacity: 0.5;
    letter-spacing: 2px;
}

@keyframes scanlineScroll {
    from { background-position: 0 0; }
    to { background-position: 0 100%; }
}

@keyframes orbRotate {
    to { transform: rotate(360deg); }
}

@keyframes ringRotate {
    to { transform: rotate(360deg); }
}

/* ── Typography ── */
.pixel-heading {
    font-family: var(--font-pixel);
    font-size: clamp(1rem, 3.5vw, 2rem);
    line-height: 1.6;
    letter-spacing: 2px;
    color: var(--pixel-white);
    text-shadow: 0 0 10px rgba(134, 201, 247, 0.5);
    animation: hologramPulse 4s infinite alternate;
}

.pixel-subline {
    font-family: var(--font-retro);
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    color: var(--pixel-accent);
    letter-spacing: 1px;
}

.pixel-card-title {
    font-family: var(--font-pixel);
    font-size: 0.75rem;
    color: var(--pixel-white);
    line-height: 1.5;
}

.pixel-card-desc {
    font-family: var(--font-retro);
    font-size: 1.1rem;
    color: #aaa;
    line-height: 1.4;
}

.pixel-retro-small {
    font-family: var(--font-pixel);
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 1px;
}

.loading-text {
    letter-spacing: 5px;
    font-size: 1rem;
    animation: textGlitch 4s infinite;
}

@keyframes hologramPulse {
    from { text-shadow: 0 0 10px rgba(134, 201, 247, 0.4); }
    to { text-shadow: 0 0 20px rgba(134, 201, 247, 0.8); }
}

@keyframes textGlitch {
    0%, 100% { opacity: 1; }
    92% { opacity: 1; }
    93% { opacity: 0.4; transform: translateX(-2px); }
    94% { opacity: 1; transform: translateX(2px); }
    95% { opacity: 0.6; }
    96% { opacity: 1; }
}

/* ── Back Button ── */
.back-home {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 100;
    text-decoration: none;
    display: inline-block;
}

/* ── Header ── */
.projects-header {
    text-align: center;
    padding: 5rem 1rem 3rem;
}

.header-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 8px var(--pixel-accent));
}

/* ── Pixel Buttons ── */
.pixel-btn-small {
    background: transparent;
    border: 2px solid var(--pixel-white);
    color: var(--pixel-white);
    font-family: var(--font-pixel);
    font-size: 0.6rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    letter-spacing: 1px;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
}

.pixel-btn-small:hover {
    background: var(--pixel-accent);
    color: #000;
    border-color: var(--pixel-accent);
    box-shadow: 4px 4px 0 var(--pixel-white);
    transform: translateY(-2px);
}

.pixel-btn-small:active {
    transform: scale(0.95) translate(2px, 2px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}

/* ── Pixel Border Box ── */
.pixel-border-box {
    background: rgba(0, 0, 0, 0.8);
    border: 4px solid var(--pixel-white);
    padding: 4px;
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.5);
}

.search-inner {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    background: var(--pixel-card-bg);
    position: relative;
}

/* ── Controls ── */
.controls-container {
    max-width: 900px;
    margin: 0 auto 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
}

.search-inner {
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    z-index: 2;
    pointer-events: none;
}

#projectSearch {
    width: 100%;
    padding: 12px 15px 12px 45px;
    background: var(--pixel-card-bg);
    border: none;
    color: var(--pixel-white);
    font-family: var(--font-retro);
    font-size: 1.2rem;
    outline: none;
    transition: all 0.3s ease;
}

#projectSearch::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

#projectSearch:focus {
    background: rgba(15, 12, 27, 0.98);
    box-shadow: inset 0 0 10px rgba(134, 201, 247, 0.15);
}

.filter-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.filter-btn.active {
    background: var(--pixel-accent);
    color: #000;
    border-color: var(--pixel-accent);
    box-shadow: 4px 4px 0 var(--pixel-white);
}

/* ── Project Grid ── */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

/* ── Project Cards (scene-card style) ── */
.project-card {
    background: rgba(0, 0, 0, 0.8);
    border: 4px solid var(--pixel-white);
    padding: 4px;
    position: relative;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.5);
    opacity: 0;
    animation: cardEntrance 0.6s steps(6) forwards;
}

@keyframes cardEntrance {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.project-card:hover {
    transform: translateY(-8px);
    border-color: var(--pixel-accent);
    box-shadow: 8px 8px 0 var(--pixel-accent);
    z-index: 2;
}

.project-card-inner {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    background: var(--pixel-card-bg);
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.project-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    image-rendering: auto;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.15);
    transition: transform 0.4s steps(4);
}

.project-card:hover img {
    transform: scale(1.03);
}

.card-content {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.75rem;
}

.card-content h2 {
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    color: var(--pixel-white);
    line-height: 1.5;
    margin: 0;
}

.card-content p {
    font-family: var(--font-retro);
    font-size: 1.05rem;
    color: #aaa;
    line-height: 1.3;
    margin: 0;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Tags ── */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tags span {
    background: rgba(134, 201, 247, 0.1);
    color: var(--pixel-accent);
    padding: 0.25rem 0.6rem;
    font-family: var(--font-retro);
    font-size: 0.95rem;
    border: 1px solid rgba(134, 201, 247, 0.3);
    transition: all 0.2s;
}

.tags span:hover {
    background: var(--pixel-accent);
    color: #000;
    border-color: var(--pixel-accent);
}

/* ── Details Button ── */
.details-btn {
    margin-top: auto;
    align-self: flex-start;
}

.project-card:hover .details-btn {
    background: var(--pixel-accent);
    color: #000;
    border-color: var(--pixel-accent);
}

/* ── No Results / Error ── */
.no-results,
.error-msg {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 2rem;
    font-family: var(--font-retro);
    font-size: 1.4rem;
    color: #aaa;
    background: rgba(0, 0, 0, 0.8);
    border: 4px solid var(--pixel-white);
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.5);
}

/* ── Modal ── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    padding: 2rem;
}

.modal-content {
    background: rgba(0, 0, 0, 0.95);
    max-width: 700px;
    width: 100%;
    position: relative;
    transform: translateY(20px) scale(0.97);
    transition: all 0.3s steps(4);
    overflow: hidden;
}

.modal-inner {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    background: var(--pixel-card-bg);
    overflow: hidden;
}

.modal.show .modal-content {
    transform: translateY(0) scale(1);
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    font-family: var(--font-pixel);
    color: var(--pixel-white);
    cursor: pointer;
    z-index: 10;
    background: rgba(0, 0, 0, 0.8);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--pixel-white);
    transition: all 0.2s;
    line-height: 1;
}

.close-btn:hover {
    background: var(--pixel-accent);
    color: #000;
    border-color: var(--pixel-accent);
}

#modalImage {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: block;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.15);
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#modalTitle {
    font-size: 0.85rem;
}

#modalDescription {
    font-size: 1.2rem;
    color: #ccc;
    line-height: 1.5;
}

.modal-link-btn {
    align-self: flex-start;
    margin-top: 0.5rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .projects-header {
        padding: 4rem 0.5rem 2rem;
    }

    .back-home {
        top: 1rem;
        left: 1rem;
        font-size: 0.5rem;
        padding: 0.4rem 0.7rem;
    }

    .project-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .filter-btn {
        font-size: 0.5rem;
        padding: 0.4rem 0.7rem;
    }

    .modal.show {
        padding: 0;
        align-items: stretch;
    }

    .modal-content {
        min-height: 100vh;
        max-width: 100%;
    }

    #modalImage {
        height: 220px;
    }
}
