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

:root {
    --bg: #0b0f19;
    --bg-elevated: #111827;
    --card: #151b2b;
    --card-hover: #1a2235;
    --border: #252d3f;
    --border-hover: #374151;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    --accent: #f59e0b;
    --accent-hover: #fbbf24;
    --accent-blue: #38bdf8;
    --success: #34d399;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    --glow: 0 0 20px rgba(245, 158, 11, 0.15);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem 1.5rem 2rem;
}

/* ===== Hero ===== */
.hero {
    text-align: center;
    padding: 3rem 0 4rem;
    animation: fadeInUp 0.8s ease-out;
}

.avatar {
    width: 120px;
    height: 120px;
    margin: 0 auto 1.5rem;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--border);
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.avatar:hover {
    border-color: var(--accent);
    transform: scale(1.05);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bio {
    color: var(--text-muted);
    font-size: 1.125rem;
    max-width: 480px;
    margin: 0 auto 1.5rem;
    line-height: 1.7;
}

.tagline {
    color: var(--text-dim);
    font-size: 0.95rem;
    font-weight: 400;
    max-width: 640px;
    margin: 0 auto 1rem;
    line-height: 1.7;
    text-align: center;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    margin-bottom: 1.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: 100px;
    transition: var(--transition);
}

.github-link:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(245, 158, 11, 0.05);
}

/* ===== Repos Section ===== */
.section-header {
    margin-bottom: 2rem;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
}

.section-desc {
    color: var(--text-dim);
    font-size: 0.875rem;
}

.repos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
    perspective: 1000px;
}

/* ===== Repo Card ===== */
.repo-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: transform 0.15s ease-out, box-shadow 0.25s ease, border-color 0.25s ease, background 0.25s ease;
    animation: fadeInUp 0.5s ease-out backwards;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transform-style: preserve-3d;
    will-change: transform;
}

.repo-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-blue));
    opacity: 0;
    transition: opacity 0.25s ease;
}

.repo-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg), var(--glow);
    background: var(--card-hover);
}

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

.repo-card:active {
    transform: scale(0.98) !important;
}

.repo-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.repo-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--accent-blue);
    word-break: break-word;
    line-height: 1.4;
    transition: color 0.2s ease;
}

.repo-card:hover .repo-name {
    color: var(--accent-hover);
}

.repo-visibility {
    font-size: 0.75rem;
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    white-space: nowrap;
    flex-shrink: 0;
}

.repo-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.repo-footer {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    flex-wrap: wrap;
}

.repo-lang {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.lang-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.repo-stars,
.repo-forks {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.repo-updated {
    margin-left: auto;
}

/* ===== Loading & States ===== */
.loading,
.error,
.empty,
.sentinel-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 2rem;
}

.loading {
    color: var(--text-dim);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 0.8s linear infinite;
}

.sentinel-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-dim);
    font-size: 0.9rem;
    padding: 2rem;
}

.sentinel-loading .spinner {
    width: 24px;
    height: 24px;
    margin: 0;
}

.error {
    color: #f87171;
    background: rgba(248, 113, 113, 0.05);
    border: 1px solid rgba(248, 113, 113, 0.15);
    border-radius: var(--radius);
}

.empty {
    color: var(--text-dim);
}

.sentinel {
    height: 60px;
    margin-top: 1rem;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.open {
    opacity: 1;
    visibility: visible;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.modal-content {
    position: relative;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1;
}

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

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text);
    background: var(--card);
}

.modal-body {
    padding: 2rem;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-right: 2rem;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-blue);
    word-break: break-word;
}

.modal-desc {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 1.25rem;
}

.topics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.topic-tag {
    font-size: 0.75rem;
    color: var(--accent);
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    padding: 0.35rem 0.75rem;
    border-radius: 100px;
}

.modal-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.modal-stat {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--accent);
    color: #0b0f19;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

.btn-secondary {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--card-hover);
    border-color: var(--border-hover);
}

.hidden {
    display: none !important;
}

/* ===== Modal README ===== */
.modal-readme {
    margin-top: 1.5rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    animation: fadeInUp 0.3s ease-out;
}

.readme-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.readme-content {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text);
    word-break: break-word;
}

.readme-content .readme-loading {
    color: var(--text-dim);
    font-style: italic;
    margin: 0;
}

.readme-content h1,
.readme-content h2,
.readme-content h3,
.readme-content h4,
.readme-content h5,
.readme-content h6 {
    color: var(--text);
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
}

.readme-content h1 { font-size: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
.readme-content h2 { font-size: 1.25rem; border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }
.readme-content h3 { font-size: 1.1rem; }
.readme-content h4 { font-size: 1rem; }
.readme-content h5,
.readme-content h6 { font-size: 0.9rem; color: var(--text-muted); }

.readme-content p {
    margin-bottom: 0.75rem;
}

.readme-content strong {
    font-weight: 600;
    color: var(--text);
}

.readme-content em {
    font-style: italic;
}

.readme-content a {
    color: var(--accent-blue);
    text-decoration: none;
}

.readme-content a:hover {
    text-decoration: underline;
}

.readme-content ul,
.readme-content ol {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
}

.readme-content li {
    margin-bottom: 0.25rem;
}

.readme-content li > ul,
.readme-content li > ol {
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

.readme-content code {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.85em;
}

.readme-content pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 0.75rem;
}

.readme-content pre code {
    background: none;
    color: var(--text-muted);
    padding: 0;
    font-size: 0.8rem;
    line-height: 1.6;
}

.readme-content blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
    margin-left: 0;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.readme-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

.readme-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.readme-content th,
.readme-content td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.readme-content th {
    background: var(--bg-elevated);
    font-weight: 600;
}

.readme-content tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.readme-content img {
    max-width: 100%;
    border-radius: var(--radius-sm);
}

.readme-content > *:first-child {
    margin-top: 0;
}

.readme-content::-webkit-scrollbar {
    width: 6px;
}

.readme-content::-webkit-scrollbar-track {
    background: transparent;
}

.readme-content::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 3px;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 3rem 0 1rem;
    color: var(--text-dim);
    font-size: 0.875rem;
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .container {
        padding: 2rem 1rem 1rem;
    }

    .hero {
        padding: 1.5rem 0 2.5rem;
    }

    .hero h1 {
        font-size: 1.875rem;
    }

    .tagline {
        font-size: 0.85rem;
        padding: 0 0.5rem;
    }

    .stats {
        gap: 1.5rem;
    }

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

    .repo-updated {
        width: 100%;
        margin-left: 0;
        margin-top: 0.25rem;
    }

    .modal {
        padding: 1rem;
    }

    .modal-body {
        padding: 1.5rem;
    }

    .modal-title {
        font-size: 1.25rem;
    }

    .modal-actions {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary {
        justify-content: center;
    }
}
