/* ===========================================
   MASOOD SULTAN — v2 REDESIGN
   Editorial. Typographic. Not generic.
   =========================================== */

:root {
    --bg: #0c0c0e;
    --bg-elevated: #131316;
    --bg-surface: #1a1a1f;
    --border: rgba(255,255,255,0.06);
    --border-hover: rgba(255,255,255,0.12);
    --text: #e8e6e3;
    --text-secondary: #8a8a8f;
    --text-muted: #4a4a52;
    --accent: #c4f04d;
    --accent-dim: rgba(196,240,77,0.12);
    --accent-2: #5eead4;
    --red: #ef4444;
    --yellow: #fbbf24;
    --green: #4ade80;
    --font-sans: 'Space Grotesk', system-ui, sans-serif;
    --font-serif: 'Instrument Serif', Georgia, serif;
    --font-mono: 'DM Mono', 'Consolas', monospace;
    --max-w: 1140px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="light"] {
    --bg: #f9f8f5;
    --bg-elevated: #ffffff;
    --bg-surface: #f1f0ec;
    --border: rgba(0,0,0,0.08);
    --border-hover: rgba(0,0,0,0.14);
    --text: #2a2826;
    --text-secondary: #5c5855;
    --text-muted: #8c8782;
    --accent: #ca5d22;
    --accent-dim: rgba(202, 93, 34, 0.1);
    --accent-2: #248194;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

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

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

::selection {
    background: var(--accent);
    color: var(--bg);
}

/* --- Terrain Canvas --- */
#terrain-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.4;
}

/* --- Top Bar --- */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    padding: 0 2rem;
    height: 60px;
    display: flex;
    align-items: center;
    transition: background 0.4s var(--ease), backdrop-filter 0.4s var(--ease);
}

.topbar.scrolled {
    background: var(--bg);
    opacity: 0.95;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar-name {
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
}

.accent-dot { color: var(--accent); }

.topbar-nav {
    display: flex;
    gap: 2rem;
}

.topbar-nav a {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s var(--ease);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: inline-block;
}

.topbar-nav a:hover { 
    color: var(--accent); 
    transform: translateY(-2px);
    text-shadow: 0 4px 10px var(--accent-dim);
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 24px;
    height: 24px;
    transition: color 0.2s;
}

.theme-toggle:hover {
    color: var(--accent);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

/* --- HERO --- */
.hero {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 8rem 2rem 4rem;
    max-width: var(--max-w);
    margin: 0 auto;
}

.hero-inner {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 4rem;
    align-items: center;
}

.hero-overline {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.overline-line {
    width: 40px;
    height: 1px;
    background: var(--accent);
}

.hero-heading {
    font-size: clamp(2.8rem, 5.5vw, 4.5rem);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.03em;
    margin-bottom: 1.5rem;
}

.serif-accent {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    color: var(--accent);
}

.hero-body {
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.75;
    max-width: 520px;
    margin-bottom: 2.5rem;
}

.hero-ctas {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.cta-primary {
    display: inline-flex;
    align-items: center;
    padding: 0.85rem 2rem;
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 6px;
    letter-spacing: 0.01em;
    transition: all 0.3s var(--ease);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.cta-primary:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 30px var(--accent-dim);
}

.cta-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s var(--ease);
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

.cta-ghost:hover {
    border-color: var(--border-hover);
    color: var(--text);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 25px rgba(0,0,0,0.08);
}

/* Hero Portrait */
.hero-right {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.hero-portrait {
    position: relative;
    width: 380px;
    height: 440px;
    border-radius: 12px;
    overflow: hidden;
}

.hero-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(30%) contrast(1.1);
    transition: filter 0.5s var(--ease);
}

.hero-portrait:hover img {
    filter: grayscale(0%) contrast(1);
}

.portrait-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 50%, rgba(12,12,14,0.7) 100%);
    pointer-events: none;
}

.hero-signal {
    margin-top: 1.5rem;
}

.signal-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.signal-pulse {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(196,240,77,0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(196,240,77,0); }
}

/* Scroll Hint */
.hero-scroll-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-top: 4rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-muted);
}

.scroll-line {
    width: 1px;
    height: 50px;
    background: linear-gradient(180deg, var(--text-muted), transparent);
    animation: scroll-bob 2s ease-in-out infinite;
}

@keyframes scroll-bob {
    0%, 100% { transform: scaleY(1); opacity: 0.5; }
    50% { transform: scaleY(0.6); opacity: 1; }
}

/* --- SECTION LABELS --- */
.section-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 2rem;
}

.section-label {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 4rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.label-num {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent);
}

.label-text {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    font-weight: 500;
}

/* --- WORK / PROJECTS --- */
.work {
    position: relative;
    z-index: 1;
    padding: 8rem 0;
}

.project {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: start;
    position: relative;
    padding-left: 4rem;
}

.project-reverse { direction: rtl; }
.project-reverse > * { direction: ltr; }

.project-index {
    position: absolute;
    left: 0;
    top: 0;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.project-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.meta-tag {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
}

.project-title {
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

.project-title a {
    transition: color 0.2s;
}

.project-title a:hover {
    color: var(--accent);
}

.project-desc {
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.project-desc strong {
    color: var(--text);
    font-weight: 600;
}

.project-features {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.feature {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
}

.feature-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-dim);
    border-radius: 6px;
}

.feature-icon svg {
    width: 16px;
    height: 16px;
    stroke: var(--accent);
}

.feature strong {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.1rem;
}

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

.project-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    transition: all 0.3s var(--ease);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    background: transparent;
}

.project-link:hover { 
    gap: 0.8rem; 
    transform: translateY(-3px);
    background: var(--bg-surface);
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}

.project-divider {
    height: 1px;
    background: var(--border);
    margin: 5rem 0;
    margin-left: 4rem;
}

/* Thesis Grid */
.thesis-grid {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.thesis-figure-main, .thesis-figure-secondary {
    margin: 0;
}

.thesis-figure-main {
    flex: 1;
    min-width: 250px;
}

.thesis-figure-main img, .thesis-figure-secondary img {
    width: 100%;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.thesis-figure-main figcaption {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-align: center;
}

.thesis-figure-secondary {
    flex: 2;
    min-width: 250px;
    display: flex;
    gap: 1rem;
}

.thesis-figure-secondary div {
    flex: 1;
}

/* Terminal */
.terminal-window {
    background: #0d1117;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    overflow: hidden;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.7;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.terminal-dark { background: #0a0f16; }

.terminal-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.term-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.term-dot.red { background: var(--red); }
.term-dot.yellow { background: var(--yellow); }
.term-dot.green { background: var(--green); }

.term-title {
    margin-left: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.terminal-body {
    padding: 1rem 1.2rem;
}

.term-line {
    white-space: nowrap;
    overflow: hidden;
}

.term-line.dim { color: var(--text-muted); }
.term-line.accent { color: var(--accent); }

.term-prompt { color: var(--accent); }
.term-cmd { color: var(--text); font-weight: 500; }
.term-arg { color: var(--accent-2); }
.term-info { color: #6366f1; }
.term-highlight { color: var(--accent); font-weight: 600; }

.cursor-block {
    animation: cursor-blink 1s step-end infinite;
    color: var(--accent);
}

@keyframes cursor-blink {
    50% { opacity: 0; }
}

/* --- ABOUT --- */
.about {
    position: relative;
    z-index: 1;
    padding: 8rem 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    transition: background-color 0.4s var(--ease), border-color 0.4s var(--ease);
}

.about-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 5rem;
}

.about-heading {
    font-size: clamp(1.8rem, 3.5vw, 2.6rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin-bottom: 2rem;
}

.about-prose p {
    font-size: 0.95rem;
    line-height: 1.85;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.about-prose strong {
    color: var(--text);
    font-weight: 600;
}

/* Sidebar */
.about-sidebar {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    padding-left: 2rem;
    border-left: 1px solid var(--border);
}

.sidebar-block h4 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 500;
}

.edu-item {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.edu-years {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.edu-item strong {
    font-size: 0.9rem;
    font-weight: 600;
}

.edu-school {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.highlight-item strong {
    color: var(--accent);
}

.lang-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.lang-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}

.lang-item strong { font-weight: 500; }
.lang-item span { color: var(--text-muted); font-family: var(--font-mono); font-size: 0.75rem; }

/* --- STACK --- */
.stack {
    position: relative;
    z-index: 1;
    padding: 8rem 0;
}

.stack-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
}

.stack-heading {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.stack-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.stack-list li {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0;
    transition: color 0.2s;
}

.stack-list li:hover { color: var(--text); }

.stack-note {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    background: var(--bg-surface);
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
}

/* --- CONTACT --- */
.contact {
    position: relative;
    z-index: 1;
    padding: 8rem 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    transition: background-color 0.4s var(--ease), border-color 0.4s var(--ease);
}

.contact-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 4rem;
    align-items: start;
}

.contact-heading {
    font-size: clamp(1.8rem, 3.5vw, 2.6rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 1.2rem;
}

.contact-body {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.contact-links {
    display: flex;
    flex-direction: column;
}

.contact-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.3rem 0;
    border-bottom: 1px solid var(--border);
    transition: all 0.3s var(--ease);
}

.contact-link:first-child {
    border-top: 1px solid var(--border);
}

.contact-link:hover {
    padding-left: 1rem;
    border-color: transparent;
    transform: translateY(-2px);
    background: var(--bg-surface);
    box-shadow: 0 8px 20px rgba(0,0,0,0.05);
    border-radius: 8px;
    margin-bottom: -1px; /* prevent border jumping */
}

.contact-link:hover .cl-value { color: var(--accent); }

.cl-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    width: 60px;
    flex-shrink: 0;
}

.cl-value {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.contact-link svg {
    color: var(--text-muted);
    transition: transform 0.3s var(--ease);
}

.contact-link:hover svg {
    transform: translate(3px, -3px);
}

/* --- FOOTER --- */
.footer {
    position: relative;
    z-index: 1;
    padding: 2rem;
    border-top: 1px solid var(--border);
}

.footer-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Scroll Reveal --- */
.reveal-up {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

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

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
    .hero-inner {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .hero-right { align-items: center; }
    .hero-portrait { width: 280px; height: 340px; }

    .project {
        grid-template-columns: 1fr;
        padding-left: 2rem;
    }

    .project-reverse { direction: ltr; }

    .about-layout,
    .contact-layout {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .about-sidebar {
        padding-left: 0;
        border-left: none;
        border-top: 1px solid var(--border);
        padding-top: 2rem;
    }

    .stack-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .topbar-nav { display: none; }
}

@media (max-width: 550px) {
    .stack-grid { grid-template-columns: 1fr; }
    .hero-heading { font-size: 2.2rem; }
    .lang-grid { grid-template-columns: 1fr; }
    
    .thesis-figure-secondary {
        flex-direction: column;
    }
}
