/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-card-hover: #1a1a28;
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --text: #e4e4e7;
    --text-muted: #71717a;
    --accent: #818cf8;
    --accent-glow: rgba(129, 140, 248, 0.15);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 12px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

/* ===== Custom Cursor ===== */
.cursor-ring,
.cursor-dot {
    position: fixed;
    top: 0;
    left: 0;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    will-change: transform;
    transition: width 0.35s cubic-bezier(0.25, 1, 0.5, 1),
                height 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Small white ring — follows mouse with slight delay */
.cursor-ring {
    width: 12px;
    height: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.8);
    background: transparent;
}

/* Larger accent dot — follows ring with more delay */
.cursor-dot {
    width: 36px;
    height: 36px;
    background: rgba(129, 140, 248, 0.15);
    border: 1px solid rgba(129, 140, 248, 0.3);
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

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

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== Animated Background Grid ===== */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse 60% 50% at 50% 0%, black 30%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 60% 50% at 50% 0%, black 30%, transparent 100%);
}

.bg-particles {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    width: 100%;
    height: 100%;
}

/* ===== Header ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 16px 0;
    background: rgba(10, 10, 15, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-bracket {
    color: var(--accent);
    font-weight: 400;
}

.nav {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-link:hover {
    color: var(--text);
}

.nav-link--github svg {
    opacity: 0.7;
    transition: opacity var(--transition);
}

.nav-link--github:hover svg {
    opacity: 1;
}

/* ===== Hero ===== */
.hero {
    padding: 160px 0 80px;
    text-align: center;
}

.hero-greeting {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 12px;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.6s ease forwards 0.2s;
}

.hero-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 16px;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.6s ease forwards 0.4s;
}

.hero-title .accent {
    color: var(--accent);
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-muted);
    max-width: 480px;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.6s ease forwards 0.6s;
}

/* ===== Section Title ===== */
.section-title {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-bottom: 48px;
}

.section-title__line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ===== Projects Grid ===== */
.projects {
    padding: 40px 0 100px;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

/* Project Card */
.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.project-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), var(--accent-glow), transparent 40%);
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
}

.project-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #a78bfa, #818cf8);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.project-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(129, 140, 248, 0.06);
}

.project-card:hover::before {
    opacity: 1;
}

.project-card:hover::after {
    transform: scaleX(1);
}

.project-card__content {
    position: relative;
    z-index: 1;
    padding: 24px 24px 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Card Icon */
.project-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(129, 140, 248, 0.08);
    border: 1px solid rgba(129, 140, 248, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--accent);
    transition: var(--transition);
}

.project-card:hover .project-card__icon {
    background: rgba(129, 140, 248, 0.15);
    border-color: rgba(129, 140, 248, 0.25);
}

/* Card Header */
.project-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.project-card__header .project-card__title {
    margin-bottom: 0;
}

.project-card__live {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    color: #34d399;
    background: rgba(52, 211, 153, 0.08);
    border: 1px solid rgba(52, 211, 153, 0.15);
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.project-card__title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 8px;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.01em;
}

.project-card__description {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 0;
}

.project-card__tag {
    font-size: 0.68rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    transition: var(--transition);
}

.project-card:hover .project-card__tag {
    background: rgba(129, 140, 248, 0.08);
    border-color: rgba(129, 140, 248, 0.15);
    color: var(--accent);
}

/* Card Meta */
.project-card__meta {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--text-muted);
}

.project-card__lang {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.lang-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.project-card__stars {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: #fbbf24;
}

.project-card__forks {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.project-card__updated {
    margin-left: auto;
}

.project-card__arrow {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    opacity: 0;
    transform: translate(-4px, 4px);
    transition: var(--transition);
    z-index: 1;
}

.project-card:hover .project-card__arrow {
    opacity: 1;
    transform: translate(0, 0);
    color: var(--accent);
}

/* ===== Skeleton Loading ===== */
.project-card--skeleton {
    pointer-events: none;
    cursor: default;
}

.skeleton-line {
    height: 14px;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.04) 25%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.04) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-title {
    width: 55%;
    height: 18px;
    margin-bottom: 16px;
}

.skeleton-desc {
    width: 90%;
    margin-bottom: 8px;
}

.skeleton-desc.short {
    width: 60%;
    margin-bottom: 16px;
}

.skeleton-meta {
    width: 40%;
    margin-top: 8px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Error State ===== */
.projects-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.projects-error svg {
    margin-bottom: 16px;
}

.projects-error p {
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.retry-btn {
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 8px 20px;
    border: 1px solid var(--border-hover);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
}

.retry-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

.projects-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.modal {
    background: #111118;
    border: 1px solid var(--border-hover);
    border-radius: 16px;
    width: 100%;
    max-width: 680px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

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

.modal::-webkit-scrollbar {
    width: 6px;
}

.modal::-webkit-scrollbar-track {
    background: transparent;
}

.modal::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
}

.modal__close {
    position: sticky;
    top: 16px;
    float: right;
    margin: 16px 16px 0 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

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

.modal__header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 32px 28px 0;
}

.modal__icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(129, 140, 248, 0.1);
    border: 1px solid rgba(129, 140, 248, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.modal__title {
    font-size: 1.3rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.modal__description {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.modal__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 20px 28px 0;
}

.modal__stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    padding: 5px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.modal__stat svg {
    flex-shrink: 0;
}

.modal__stat--lang {
    color: var(--text);
}

.modal__stat--stars {
    color: #fbbf24;
}

.modal__stat--forks {
    color: #60a5fa;
}

.modal__stat--pages {
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.15);
    background: rgba(52, 211, 153, 0.05);
}

.modal__actions {
    display: flex;
    gap: 10px;
    padding: 20px 28px 0;
}

.modal__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid var(--border-hover);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.modal__btn:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255,255,255,0.18);
}

.modal__btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #0a0a0f;
    font-weight: 600;
}

.modal__btn--primary:hover {
    background: #6366f1;
    border-color: #6366f1;
}

.modal__divider {
    height: 1px;
    background: var(--border);
    margin: 24px 28px 0;
}

.modal__readme {
    padding: 24px 28px 28px;
    min-height: 80px;
}

.modal__readme-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.modal__readme-empty {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.08);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* README rendered styles */
.modal__readme-content {
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text);
}

.modal__readme-content h1,
.modal__readme-content h2,
.modal__readme-content h3,
.modal__readme-content h4 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    line-height: 1.3;
}

.modal__readme-content h1 { font-size: 1.3rem; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.modal__readme-content h2 { font-size: 1.1rem; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.modal__readme-content h3 { font-size: 1rem; }

.modal__readme-content p {
    margin-bottom: 0.8em;
}

.modal__readme-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.modal__readme-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8em;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
}

.modal__readme-content pre {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.modal__readme-content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.78rem;
    line-height: 1.5;
}

.modal__readme-content ul,
.modal__readme-content ol {
    margin: 0.5em 0 1em 1.5em;
}

.modal__readme-content li {
    margin-bottom: 0.3em;
}

.modal__readme-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 8px 0;
}

.modal__readme-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 14px;
    margin: 12px 0;
    color: var(--text-muted);
}

.modal__readme-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.8rem;
}

.modal__readme-content th,
.modal__readme-content td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}

.modal__readme-content th {
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
}

.modal__readme-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ===== Footer ===== */
.footer {
    padding: 32px 0;
    border-top: 1px solid var(--border);
    text-align: center;
}

.footer-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== Animations ===== */
@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scroll reveal */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .hero {
        padding: 140px 0 60px;
    }

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

    .nav {
        gap: 16px;
    }

    .modal {
        max-height: 90vh;
        border-radius: 12px;
    }

    .modal-overlay {
        padding: 12px;
    }

    .modal__header {
        padding: 24px 20px 0;
    }

    .modal__stats,
    .modal__actions {
        padding-left: 20px;
        padding-right: 20px;
    }

    .modal__divider {
        margin-left: 20px;
        margin-right: 20px;
    }

    .modal__readme {
        padding: 20px;
    }

    .modal__actions {
        flex-wrap: wrap;
    }
}
}
