/* 1. Global Styles & Variables */
:root {
    --background-color: #f5f5f7;
    --text-color: #1d1d1f;
    --primary-color: #0071e3;
    --secondary-color: #ffffff;
    --border-color: #d2d2d7;
    --text-secondary: #545458;
    --code-bg-color: #f8f9fa;
}

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

html, body {
    height: 100%;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* 2. Header & Navigation */
header {
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    background: rgba(245, 245, 247, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
header.scrolled {
    border-bottom-color: var(--border-color);
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.06);
}
nav {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav-brand {
    font-weight: 600;
    font-size: 1.1rem;
}
nav ul {
    list-style: none;
    display: flex;
    gap: 32px;
}
nav a {
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
    padding-bottom: 5px;
}
nav a:hover { color: var(--primary-color); }

/* 3. Main Content & Sections */
main { padding-top: 64px; }
.section-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 96px 24px;
}
.section-title {
    font-size: 2.8rem;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
    letter-spacing: -1.5px;
}
.section-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 64px;
    font-size: 1.1rem;
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
}

/* 4. Hero Section */
.hero { text-align: center; padding: 64px 24px; }
.hero-content { max-width: 800px; margin: 0 auto; }
.hero h1 {
    font-size: 3.8rem;
    font-weight: 700;
    letter-spacing: -2px;
    margin-bottom: 16px;
    line-height: 1.15;
    color: var(--text-color);
}
.hero h1 span {
    background-image: linear-gradient(90deg, 
        var(--primary-color) 0%, 
        var(--text-color) 50%, 
        var(--primary-color) 100%);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: moveGradient 5s linear infinite;
}
.hero p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 65ch; 
    margin: 0 auto 24px auto;
}
.hero-status { color: var(--text-secondary); margin-bottom: 32px; }
.hero-status span { font-weight: 600; color: var(--text-color); }
.cta-button {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: 32px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1), background-color 0.3s ease;
}
.cta-button:hover {
    transform: scale(1.05);
    background-color: #0077ed;
}

/* 5. Projects Section */
#projects { background-color: var(--secondary-color); }
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 32px;
    perspective: 1000px;
}
.project-card {
    background: var(--background-color);
    padding: 32px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity .6s ease-out, transform .6s ease-out, box-shadow .4s ease-out;
}
.project-card.visible {
    opacity: 1;
    transform: translateY(0);
}
.project-card:hover {
    box-shadow: 0 20px 40px rgba(0,0,0,.08);
    border-color: rgba(0,113,227,.4);
}
.project-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at var(--mouse-x,50%) var(--mouse-y,50%),rgba(255,255,255,.2),rgba(255,255,255,0) 40%);
    border-radius: 16px;
    opacity: 0;
    transition: opacity .4s ease-out;
    z-index: 1;
}
.project-card:hover::before {
    opacity: 1;
}
.card-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.project-card h3 { 
    font-size: 1.4rem; 
    margin-bottom: 8px; 
    transition: color .3s ease;
}
.project-card:hover h3 {
    color: var(--primary-color);
}
.project-card p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 1rem;
    flex-grow: 1;
    min-height: 96px; 
}
.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}
.project-tags span {
    background: #e8e8ed;
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 24px;
    font-size: .8rem;
    font-weight: 500;
    transition: all .3s ease;
}
.project-card:hover .project-tags span {
    background-color: #e0e0e6;
    transform: translateY(-2px);
}
.project-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    margin-top: auto;
}
.project-link .arrow {
    display: inline-block;
    transition: transform .2s ease-in-out,color .3s ease;
}
.project-card:hover .project-link .arrow {
    transform: translateX(6px);
    color: var(--primary-color);
}

/* 6. Experience Section */
#experience { background-color: var(--background-color); }
.experience-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 32px;
}
.experience-item {
    background: var(--secondary-color);
    padding: 32px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    height: 100%;
    transition: background-color .3s ease;
}
.experience-item:hover {
    background-color: #fcfcff;
}
.experience-item h3 { font-size: 1.2rem; }
.experience-company {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 16px;
}
.experience-item ul { list-style-position: outside; padding-left: 24px; color: var(--text-secondary); }
.experience-item li { margin-bottom: 8px; line-height: 1.5; }

/* 7. Footer */
footer {
    background-color: var(--secondary-color);
    text-align: center;
    padding: 80px 24px;
    border-top: 1px solid var(--border-color);
}
footer h2 { font-size: 2.5rem; margin-bottom: 16px; letter-spacing: -1px; }
footer p { color: var(--text-secondary); max-width: 600px; margin: 0 auto 32px auto; }
.contact-links a {
    color: var(--primary-color);
    text-decoration: none;
    margin: 0 16px;
    font-size: 1.1rem;
    font-weight: 500;
    position: relative;
    padding-bottom: 5px;
}
.contact-links a:hover {
    text-decoration: none;
}
.footer-bottom { margin-top: 64px; color: var(--text-secondary); font-size: .9rem; }

/* 8. Case Study & Modal Styles */
.modal-container { background: var(--secondary-color); padding: 0; border-radius: 16px; width: 90%; max-width: 800px; max-height: 90vh; overflow-y: auto; position: relative; transform: scale(.95); transition: transform .4s cubic-bezier(.16,1,.3,1); box-shadow: 0 25px 50px -12px rgba(0,0,0,.25); }
.modal-header h2 { font-size: 2.5rem; letter-spacing: -.5px; margin-bottom: 8px; }
.modal-header .project-tags { margin-bottom: 32px; }
.case-study-content { padding: 24px 40px 40px 40px; }
.case-study-section { margin-bottom: 40px; }
.case-study-section h4 { font-size: 1.2rem; font-weight: 600; border-bottom: 2px solid var(--primary-color); padding-bottom: 8px; margin-bottom: 16px; display: inline-block; }
.case-study-section p, .case-study-section li { color: var(--text-secondary); line-height: 1.75; }
.case-study-section ul { list-style-type: '✓ '; padding-left: 24px; }
.case-study-section li { margin-bottom: 8px; }
.case-study-section .cta-button { margin-top: 16px; }

/* 9. SVG Diagram & Code Block Styles */
.architecture-svg { background-color: var(--secondary-color); border: 1px solid var(--border-color); border-radius: 16px; width: 100%; margin: 24px 0; padding: 24px; box-shadow: 0 4px 16px rgba(0,0,0,.05); font-family: 'Inter',sans-serif; }
.diagram-title { font-size: 12px; font-weight: 600; fill: var(--text-color); }
.diagram-subtitle { font-size: 10px; fill: var(--text-secondary); }
.diagram-label { font-size: 11px; fill: var(--text-secondary); }
.diagram-node { fill: #fff; stroke: var(--border-color); stroke-width: 1px; transition: all .2s ease-in-out; }
.diagram-node:hover { stroke: var(--primary-color); stroke-width: 1.5px; transform: scale(1.03); }
.diagram-node-cluster { fill: #f9f9fb; stroke: var(--border-color); stroke-dasharray: 4 4; }
.diagram-arrow-main, .diagram-arrow-main path { stroke: var(--primary-color); stroke-width: 1.5px; fill: var(--primary-color); }
.diagram-arrow-secondary, .diagram-arrow-secondary path { stroke: var(--border-color); stroke-width: 1px; fill: var(--border-color); }
.diagram-icon { fill: var(--text-color); }
.case-study-section pre { background-color: var(--code-bg-color); border: 1px solid var(--border-color); border-radius: 8px; padding: 16px; overflow-x: auto; font-family: 'SF Mono','Fira Code','monospace'; font-size: .85rem; line-height: 1.6; margin-top: 16px; }
.case-study-section code { color: var(--text-color); }

/* 10. Accessibility & Animations */
.skip-link { position: absolute; top: -999px; left: 0; background: var(--primary-color); color: #fff; padding: 1rem; z-index: 1002; }
.skip-link:focus { top: 0; }

/* 11. Responsive Design */
@media (max-width:768px) { .nav-brand { display: none; } nav { justify-content: center; } .hero h1 { font-size: 2.8rem; line-height: 1.25; } .hero p { font-size: 1.1rem; } .section-title { font-size: 2.2rem; } .section-container, .case-study-content { padding: 64px 24px; } }
@media (min-width:769px) and (max-width:1199px) { .experience-grid { grid-template-columns: repeat(2,1fr); } }
@media (min-width:1200px) { .experience-grid { grid-template-columns: repeat(2,1fr); } }

/* 12. Accessibility & Focus Styling */
a:focus, button:focus, [tabindex]:focus { outline: none!important; }
:focus-visible { outline: 2px solid rgba(0,113,227,.6)!important; outline-offset: 3px; border-radius: 4px; }

/* 13. Modal Styles */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(29,29,31,.7); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; justify-content: center; align-items: center; z-index: 2000; opacity: 0; visibility: hidden; transition: opacity .4s cubic-bezier(.16,1,.3,1),visibility 0s .4s; }
.modal-overlay.active { opacity: 1; visibility: visible; transition: opacity .4s cubic-bezier(.16,1,.3,1); }
.modal-overlay.active .modal-container { transform: scale(1); }
.modal-close-button { position: fixed; top: 24px; right: 24px; background: rgba(0,0,0,.2); border: 1px solid rgba(255,255,255,.1); border-radius: 50%; width: 40px; height: 40px; font-size: 1.5rem; color: rgba(255,255,255,.7); cursor: pointer; z-index: 2001; transition: all .3s ease; display: flex; justify-content: center; align-items: center; }
.modal-close-button:hover { color: #fff; background: rgba(0,0,0,.4); transform: scale(1.1); }
.reading-progress-bar { position: sticky; top: 0; left: 0; width: 0; height: 4px; background-color: var(--primary-color); z-index: 100; transition: width .1s linear; }

/* 14. Error Page Styles */
.error-container { display: flex; justify-content: center; align-items: center; text-align: center; height: 100%; padding: 24px; }
.error-content h1 { font-size: 6rem; font-weight: 700; color: var(--primary-color); letter-spacing: -5px; margin-bottom: 0; line-height: 1; }
.error-content h2 { font-size: 2rem; font-weight: 600; margin-bottom: 16px; }
.error-content p { color: var(--text-secondary); margin-bottom: 32px; }

/* 15. Back to Top Button Styles */
#back-to-top-btn { display: flex; justify-content: center; align-items: center; position: fixed; bottom: 30px; right: 30px; z-index: 1000; background-color: var(--secondary-color); color: var(--text-color); border: 1px solid var(--border-color); border-radius: 50%; width: 50px; height: 50px; cursor: pointer; opacity: 0; visibility: hidden; transform: translateY(20px); transition: opacity .3s ease,visibility .3s ease,transform .3s ease,background-color .3s ease,color .3s ease; }
#back-to-top-btn.visible { opacity: 1; visibility: visible; transform: translateY(0); }
#back-to-top-btn:hover { background-color: var(--primary-color); color: #fff; transform: scale(1.1); }
#back-to-top-btn svg { width: 20px; height: 20px; stroke-width: 3px; }

/* 16. Tech Link Styles */
.tech-link { color: var(--primary-color); text-decoration: none; font-weight: 500; border-bottom: 1px solid rgba(0,113,227,.2); transition: all .2s ease-in-out; }
.tech-link:hover { background-color: rgba(0,113,227,.08); border-bottom-color: var(--primary-color); }

/* 17. Animation Keyframes & Reveal Styles */
@keyframes moveGradient { 0% { background-position: 0 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.reveal { opacity: 0; transform: translateY(30px); transition: opacity 1s ease-in-out,transform 1s ease-in-out; }
.reveal.visible { opacity: 1; transform: translateY(0); }
.reveal-delay-1 { transition-delay: .2s; }
.reveal-delay-2 { transition-delay: .4s; }
#projects.visible .project-card { opacity: 1; transform: translateY(0); }
#projects.visible .project-card:nth-child(1) { transition-delay: 150ms; }
#projects.visible .project-card:nth-child(2) { transition-delay: 250ms; }
#projects.visible .project-card:nth-child(3) { transition-delay: 350ms; }
#projects.visible .project-card:nth-child(4) { transition-delay: 450ms; }
#projects.visible .project-card:nth-child(5) { transition-delay: 550ms; }
#projects.visible .project-card:nth-child(6) { transition-delay: 650ms; }

/* 18. Metric Highlight Styles */
.metric-highlights { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 32px; border-top: 1px solid var(--border-color); padding-top: 32px; }
.metric-card { background-color: var(--background-color); border-radius: 12px; padding: 16px 24px; text-align: center; flex-grow: 1; border: 1px solid var(--border-color); }
.metric-card .metric-value { display: block; font-size: 2rem; font-weight: 700; color: var(--primary-color); line-height: 1.2; }
.metric-card .metric-label { display: block; font-size: .9rem; color: var(--text-secondary); }

/* 19. Kinetic Underline Styles */
nav a::after, .contact-links a::after { content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 2px; background-color: var(--primary-color); transform: scaleX(0); transform-origin: center; transition: transform .3s cubic-bezier(.19,1,.22,1); }
nav a:hover::after, .contact-links a:hover::after { transform: scaleX(1); }

/* 20. Credential Tooltip Styles */
.credential-link { color: var(--text-color); font-weight: 600; text-decoration: none; position: relative; border-bottom: 2px dotted var(--border-color); transition: border-bottom-color .3s ease; }
.credential-link:hover { border-bottom-color: var(--primary-color); }
.credential-tooltip { position: absolute; bottom: 140%; left: 50%; transform: translateX(-50%); background-color: var(--secondary-color); border: 1px solid var(--border-color); border-radius: 12px; padding: 16px; width: 200px; display: flex; flex-direction: column; align-items: center; gap: 8px; box-shadow: 0 10px 25px rgba(0,0,0,.1); opacity: 0; visibility: hidden; transform: translateX(-50%) translateY(10px); transition: opacity .3s ease,transform .3s ease,visibility .3s; z-index: 10; }
.credential-link:hover .credential-tooltip { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.credential-tooltip img { width: 80px; height: 80px; border-radius: 50%; }
.credential-tooltip span { font-size: .8rem; color: var(--text-secondary); font-weight: 500; }

/* 21. Exit Intent Prompt Styles */
.exit-intent-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(29,29,31,.7); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; justify-content: center; align-items: center; z-index: 3000; opacity: 0; visibility: hidden; transition: opacity .4s cubic-bezier(.16,1,.3,1),visibility 0s .4s; }
.exit-intent-overlay.active { opacity: 1; visibility: visible; transition: opacity .4s cubic-bezier(.16,1,.3,1); }
.exit-intent-prompt { background: var(--secondary-color); padding: 40px; border-radius: 16px; width: 90%; max-width: 500px; text-align: center; position: relative; transform: scale(.95); transition: transform .4s cubic-bezier(.16,1,.3,1); box-shadow: 0 25px 50px -12px rgba(0,0,0,.25); }
.exit-intent-overlay.active .exit-intent-prompt { transform: scale(1); }
.exit-intent-prompt h3 { font-size: 1.8rem; font-weight: 600; margin-bottom: 8px; }
.exit-intent-prompt p { color: var(--text-secondary); margin-bottom: 32px; }
.exit-intent-close { position: absolute; top: 12px; right: 12px; background: none; border: none; font-size: 2rem; color: var(--text-secondary); cursor: pointer; line-height: 1; opacity: .6; transition: opacity .3s ease; }
.exit-intent-close:hover { opacity: 1; }
