/* Core Variables */
:root {
    /* Dark Theme Default */
    --bg: #0a0d14;
    --surface: #11151f;
    --surface-hover: #1a202c;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --primary: #38bdf8;
    --primary-glow: rgba(56, 189, 248, 0.2);
    --accent: #818cf8;
    --border: #1e293b;
    --nav-bg: rgba(10, 13, 20, 0.7);
    
    --font-heading: 'Inter', -apple-system, sans-serif;
    --font-body: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --text: #0f172a;
    --text-muted: #475569;
    --primary: #0284c7;
    --primary-glow: rgba(2, 132, 199, 0.15);
    --accent: #4f46e5;
    --border: #e2e8f0;
    --nav-bg: rgba(248, 250, 252, 0.7);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 100px;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color var(--transition), color var(--transition);
}

/* Typography Utility */
.mono { font-family: var(--font-mono); }
.text-sm { font-size: 0.85rem; }
.accent { color: var(--accent); }

/* Background Motifs */
.background-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-size: 50px 50px;
    background-image: linear-gradient(to right, var(--border) 1px, transparent 1px),
                      linear-gradient(to bottom, var(--border) 1px, transparent 1px);
    opacity: 0.15;
    z-index: -2;
    pointer-events: none;
}

.ambient-glow {
    position: fixed;
    top: -20vh;
    left: 50%;
    transform: translateX(-50%);
    width: 60vw;
    height: 60vh;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
    transition: background var(--transition);
}

/* Navigation */
.glass-nav {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: all var(--transition);
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
}

.brand .span { color: var(--primary); }

.cursor {
    display: inline-block;
    width: 8px;
    color: var(--primary);
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.desktop-nav {
    display: flex;
    gap: 2rem;
}

@media (max-width: 768px) {
    .desktop-nav { display: none; }
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary);
}

.controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.control-btn:hover {
    color: var(--text);
    background: var(--surface);
}

.divider {
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 0.5rem;
}

/* Layout */
main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 2rem;
}

.section {
    padding: 6rem 0;
    position: relative;
}

.section-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.section-line {
    width: 60px;
    height: 4px;
    background: var(--primary);
    border-radius: 2px;
    margin-bottom: 3rem;
}

/* Hero Section */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    padding-top: 80px;
}

.hero-content {
    max-width: 650px;
    position: relative;
    z-index: 2;
}

.hero-title {
    font-size: clamp(3rem, 8vw, 4.5rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-size: clamp(1rem, 3vw, 1.25rem);
    color: var(--primary);
    margin-bottom: 2rem;
    font-weight: 500;
}

.hero-intro {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 3rem;
    max-width: 540px;
}

/* Buttons */
.cta-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all var(--transition);
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary);
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface);
    border-color: var(--text-muted);
    transform: translateY(-2px);
}

/* Hero Abstract Visual */
.hero-visual {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 400px;
    height: 400px;
    pointer-events: none;
    opacity: 0.6;
}

@media (max-width: 900px) {
    .hero-visual { display: none; }
}

.node-graph {
    position: relative;
    width: 100%;
    height: 100%;
}

.node {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 20px var(--primary);
}

.n1 { top: 20%; left: 30%; }
.n2 { top: 50%; left: 60%; }
.n3 { top: 80%; left: 40%; }

.line {
    position: absolute;
    background: var(--primary);
    height: 1px;
    opacity: 0.3;
    transform-origin: left center;
}

.l1 { top: 20%; left: 30%; width: 140px; transform: rotate(35deg); }
.l2 { top: 50%; left: 60%; width: 110px; transform: rotate(115deg); }

.pulse {
    animation: nodepulse 2s infinite;
}

@keyframes nodepulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 2.5rem;
    text-decoration: none;
    color: var(--text);
    transition: all var(--transition);
    display: flex;
    overflow: hidden;
    position: relative;
}

.project-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.project-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(800px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), var(--primary-glow), transparent 40%);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 0;
    pointer-events: none;
}

.project-card:hover::before {
    opacity: 1;
}

.card-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.card-icon {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.project-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.project-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tech-stack {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.tech-stack li {
    font-size: 0.8rem;
    padding: 0.2rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
}

.card-footer {
    margin-top: auto;
}

.btn-text {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-text svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}

.project-card:hover .btn-text svg {
    transform: translateX(4px);
}

/* Featured Card with Visual */
.project-card.featured {
    flex-direction: row;
    gap: 3rem;
}

.card-visual {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .project-card.featured {
        flex-direction: column;
    }
    .card-visual {
        min-height: 200px;
        margin-top: 2rem;
    }
}

.arch-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: var(--bg);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    width: 100%;
}

.svc {
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    font-weight: 600;
}

.broker {
    padding: 0.75rem 1.25rem;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid var(--primary);
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    color: var(--primary);
    font-weight: 600;
    position: relative;
}

.arrow {
    width: 20px;
    height: 1px;
    background: var(--text-muted);
    position: relative;
}
.arrow::after {
    content: '';
    position: absolute;
    right: 0;
    top: -3px;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 4px solid var(--text-muted);
}

/* Skills Section */
.skills-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.skill-group {
    background: transparent;
    border-left: 2px solid var(--border);
    padding-left: 1.5rem;
    transition: border-color 0.3s;
}

.skill-group:hover {
    border-color: var(--primary);
}

.skill-group h4 {
    color: var(--text);
    margin-bottom: 1rem;
    font-size: 1rem;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background: var(--surface);
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.skill-group:hover .tag {
    background: var(--surface-hover);
    color: var(--text);
    border-color: rgba(56, 189, 248, 0.3);
}

/* About Section */
.glass-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 3rem;
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}

.about-icon {
    width: 40px;
    height: 40px;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.about-text {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-muted);
}

/* Contact */
.center-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.center-content .section-line { margin: 0 auto 2rem auto; }

.contact-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.email-link {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    color: var(--text);
    text-decoration: none;
    transition: color 0.3s;
    margin-bottom: 3rem;
}

.email-link:hover {
    color: var(--primary);
}

.mt-4 { margin-top: 2rem; }

/* Footer */
footer {
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-links {
    display: flex;
    gap: 1rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--text);
}

/* Animations */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), 
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Mouse Glow Effect (JS handled) */
@media (hover: hover) {
    .project-card {
        --mouse-x: 50%;
        --mouse-y: 50%;
    }
}
