/* --- FONT --- */
@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('/assets/fonts/PlusJakartaSans-VariableFont_wght.woff2') format('woff2'),
       url('/assets/fonts/PlusJakartaSans-VariableFont_wght.ttf') format('truetype');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

/* --- 1. DESIGN SYSTEM --- */
/* CHANGED: Removed duplicate :root dark variables. All tokens now come from theme.css.
   Only layout/spacing tokens that don't change between themes are kept here. */
:root {
    --radius: 24px;
    --padding: 28px;
    --gap: 20px;
}

/* --- 2. GLOBAL RESET --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Force form elements to inherit font */
button,
input,
textarea,
select {
    font-family: inherit;
}

body {
    /* CHANGED: uses CSS var from theme.css */
    background-color: var(--bg-page);
    color: var(--text-main);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    justify-content: center;
    padding: 40px 20px;
    min-height: 100vh;
    line-height: 1.6;
    /* CHANGED: smooth theme transition */
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Background Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    /* CHANGED: opacity controlled per-blob below */
    animation: moveBlob 20s infinite alternate;
}

/* CHANGED: blob colors now use CSS variables so they adapt per theme */
.blob-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--blob-1) 0%, transparent 70%);
    animation-duration: 25s;
    opacity: 1;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--blob-2) 0%, transparent 70%);
    animation-duration: 30s;
    animation-delay: -5s;
    opacity: 1;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--blob-3) 0%, transparent 70%);
    animation-duration: 22s;
    animation-delay: -10s;
    opacity: 1;
}

@keyframes moveBlob {
    0% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(300px, -100px) scale(1.1);
    }

    66% {
        transform: translate(-200px, 200px) scale(0.9);
    }

    100% {
        transform: translate(100px, -150px) scale(1);
    }
}

.container {
    width: 100%;
    max-width: 1100px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--gap);
    grid-auto-flow: dense;
    min-width: 0;
}

/* --- 3. CARD STYLES --- */
/* CHANGED: replaced hardcoded rgba(13,17,23,.6) with var(--bg-card) */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: var(--padding);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    min-height: 160px;
    /* CHANGED: add consistent shadow for light theme depth */
    box-shadow: var(--shadow);
    min-width: 0;
    max-width: 100%;
    overflow-wrap: break-word;
}

/* CHANGED: replaced hardcoded rgba(21,28,39,.8) with var(--bg-card-hover) */
a.card:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-4px);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.15);
}

/* --- 4. TYPOGRAPHY --- */
h1 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.03em;
    line-height: 1.1;
    /* CHANGED: inherits from body (var(--text-main)) */
    color: var(--text-main);
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    /* CHANGED: explicit color */
    color: var(--text-main);
}

h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
    line-height: 1.3;
}

p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.meta {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: block;
    font-weight: 600;
}

.list-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.experience-desc-list {
    padding-left: 20px;
    list-style-type: disc;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.skill-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 12px;
    display: block;
}

/* CHANGED: replaced rgba(255,255,255,0.03) with var(--bg-card-hover) */
.project-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 7px;
    display: inline-block;
    width: fit-content;
    background: var(--bg-card-hover);
    padding: 0px 12px;
    border-radius: 100px;
    border: 1px solid var(--border-color);
}

/* --- 5. COMPONENTS --- */
.col-span-1 {
    grid-column: span 1;
}

.col-span-2 {
    grid-column: span 2;
}

.col-span-4 {
    grid-column: span 4;
}

.row-span-2 {
    grid-row: span 2;
}

/* CHANGED: replaced rgba(255,255,255,0.05) with var(--bg-card-hover) */
.icon-box {
    width: 44px;
    height: 44px;
    background: var(--bg-card-hover);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--accent);
    border: 1px solid var(--border-color);
}

/* CHANGED: icon SVGs now use accent color instead of hardcoded #ffffff */
.icon-box svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.arrow-indicator {
    position: absolute;
    top: 24px;
    right: 24px;
    font-size: 1.2rem;
    color: var(--text-muted);
    opacity: 0;
    transition: 0.3s;
}

a.card:hover .arrow-indicator {
    opacity: 1;
    transform: translate(2px, -2px);
    color: var(--accent);
}

.nav-back {
    grid-column: span 4;
    display: flex;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 4px;
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    transition: 0.2s;
}

.btn-back:hover {
    color: var(--accent);
    gap: 12px;
}

.expand-item {
    text-align: center;
    cursor: pointer;
    color: var(--accent);
    font-weight: 500;
    font-size: 0.9rem
}

.resume-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.resume-item {
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: 0.2s;
    padding-right: 10px;
    position: relative;
}

.resume-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.resume-item:hover h3 {
    color: var(--accent);
}

.resume-item:hover:after {
    content: '↗';
    position: absolute;
    right: 0;
    top: 20px;
    color: var(--accent);
    font-size: 1.4rem;
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* CHANGED: replaced rgba(255,255,255,0.03) with var(--bg-card-hover) */
.tag {
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: 0.2s;
}

.tag:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    color: var(--text-main);
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

/* CHANGED: replaced rgba(255,255,255,0.03) with var(--bg-card-hover) */
.project-item {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 0;
    transition: 0.3s;
    border: 1px solid var(--border-color);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    box-shadow: var(--shadow);
}

.project-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-bottom: 1px solid var(--border-color);
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

.project-content {
    padding: 20px;
    gap: 4px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.project-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.cta-card {
    align-items: center;
    text-align: center;
    justify-content: center;
    padding: 60px 20px;
    position: relative;
}

/* CHANGED: btn-primary now uses accent color on light bg instead of white text on white bg */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent);
    color: #ffffff;
    padding: 12px 28px;
    border-radius: 100px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: 0.2s;
    margin-top: 10px;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: scale(1.03);
}

/* CHANGED: btn-outline uses border-color var */
.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    color: var(--text-secondary);
    padding: 12px 28px;
    border-radius: 100px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: 0.2s;
    margin-top: 10px;
}

.btn-outline:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.03);
}

/* --- HERO CARD STYLES --- */
.hero-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 0;
}

/* CHANGED: status badge uses accent-dim instead of hardcoded blue rgba */
.status-badge {
    width: fit-content;
    display: inline-block;
    background: var(--accent-dim);
    color: var(--accent);
    padding: 6px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--border-hover);
    margin-bottom: 20px;
}

.hero-text {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex-grow: 1;
}

.hero-text .btn-primary {
    margin-top: auto;
    align-self: flex-start;
}



/* --- MODAL STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* CHANGED: backdrop is slightly darker for light theme contrast */
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

/* CHANGED: modal background uses var(--bg-card-solid) */
.modal-content {
    background: var(--bg-card-solid);
    backdrop-filter: blur(12px);
    width: 100%;
    max-width: 800px;
    padding: 32px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
    z-index: 10;
}

.close-modal:hover,
.close-modal:focus-visible {
    background-color: var(--bg-card-hover);
    color: var(--text-main);
}

/* --- FORM STYLES --- */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

/* CHANGED: input uses --bg-input and --text-main vars */
.form-input,
.form-textarea {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: 0.2s;
}

.form-textarea {
    resize: none;
    min-height: 140px;
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    outline: none;
}

/* --- DETAIL POPUP STYLES --- */
.detail-header {
    margin-bottom: 0;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.detail-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--text-main);
}

.detail-subtitle {
    font-size: 1.1rem;
    color: var(--accent);
    margin-bottom: 12px;
    font-weight: 500;
    display: block;
}

.detail-meta-row {
    display: flex;
    gap: 0px 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

/* CHANGED: detail-meta-item replaced rgba(255,255,255,0.03) with var */
.detail-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0px 9px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    margin-bottom: 10px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: 0.2s;
}

.detail-meta-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    color: var(--text-main);
}

.detail-scroll-area {
    overflow-y: auto;
    flex-grow: 1;
    padding-top: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) transparent;
}

.detail-scroll-area::-webkit-scrollbar {
    width: 8px;
}

.detail-scroll-area::-webkit-scrollbar-track {
    background: transparent;
}

/* CHANGED: scrollbar thumb uses border-color var */
.detail-scroll-area::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.detail-scroll-area::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}

.detail-body {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.7;
}

.detail-body ul,
.detail-body ol {
    padding-left: 20px;
    margin-bottom: 15px;
}

.detail-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin-top: 24px;
}

.gallery-item {
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    aspect-ratio: 16/9;
    cursor: pointer;
    border: 1px solid var(--border-color);
    flex: 1 1 250px;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: 0.3s;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

/* CHANGED: gallery-caption uses var(--bg-card) */
.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: color-mix(in srgb, var(--bg-card), transparent 30%);
    color: var(--text-main);
    font-size: 0.75rem;
    padding: 4px;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* CHANGED: gallery-more-overlay uses var(--bg-card) */
.gallery-more-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-card);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.2rem, 3.5vw, 1.75rem);
    font-weight: 700;
    cursor: pointer;
    backdrop-filter: blur(2px);
    transition: 0.2s;
}

.gallery-more-overlay:hover {
    background-color: var(--bg-card-hover);
}

/* --- LIGHTBOX STYLES --- */
.lightbox-overlay {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.lightbox-content {
    max-width: 90%;
    max-height: 80vh;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    object-fit: contain;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* CHANGED: lightbox caption uses theme vars */
.lightbox-caption-text {
    color: #e5e7eb;
    margin: 15px 20px 0;
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
}

/* Lightbox close button is always white-on-dark (overlay is always dark) */
.close-lightbox {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.8rem;
    cursor: pointer;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10001;
    line-height: 1;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.close-lightbox:hover,
.close-lightbox:focus-visible {
    background-color: rgba(0, 0, 0, 0.7);
    color: var(--accent);
}


/* --- ANIMATIONS --- */
@keyframes slideDownFade {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.anim-enter {
    opacity: 0;
    animation: slideDownFade 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes textGlow {
    30% {
        transform: translateY(-2px);
        text-shadow: 0 0 15px var(--accent);
    }
}

.glow-effect {
    animation: textGlow 1.2s ease-in-out;
}

/* --- RESPONSIVE BREAKPOINTS --- */

@media (max-width: 1024px) {
    .container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .col-span-2 {
        grid-column: span 1;
    }

    .hero-card {
        grid-column: span 2;
        order: 0;
    }

    .card:nth-of-type(6) {
        grid-column: span 2;
    }

    .col-span-4,
    .nav-back {
        grid-column: span 2;
    }

    .row-span-2 {
        grid-row: auto;
    }
}

@media (max-width: 640px) {
    body {
        padding: 16px 20px;
    }

    .container {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }

    .card {
        padding: 22px 16px;
        min-height: auto;
    }

    h1 {
        font-size: 1.8rem;
        line-height: 1.25;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    h2 {
        font-size: 1.25rem;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .btn-primary {
        width: 100%;
    }

    /* Small cards occupy 1 column (half width) */
    .col-span-1 {
        grid-column: span 1;
        width: auto;
        min-width: 0;
    }

    /* Larger cards occupy 2 columns (full width) */
    .col-span-2,
    .col-span-4,
    .nav-back {
        grid-column: span 2;
        width: auto;
        min-width: 0;
    }

    /* Reset row spans to let content dictate height */
    .row-span-2 {
        grid-row: auto;
    }

    .hero-card {
        order: 0;
    }

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

    .gallery-item {
        flex-basis: calc(50% - 10px);
    }

    .cta-card {
        padding: 40px 20px;
    }

    .hero-layout {
        align-items: center;
        text-align: center;
        gap: 20px;
    }

    .status-badge {
        margin-bottom: 0;
    }

    .hero-text {
        align-items: center;
    }

    .hero-text .btn-primary {
        align-self: center;
    }
}