/* ===================================
   Portfolio V3
   Sharp, monochrome, single accent
   =================================== */

:root {
    --bg: #0a0a0b;
    --surface: #111113;
    --surface-2: #17171a;
    --line: #232327;
    --line-strong: #34343a;
    --text: #ededef;
    --muted: #8d8d96;
    --accent: #5b8cff;
    --accent-soft: rgba(91, 140, 255, 0.12);
    --live: #3ddc97;

    --font-display: 'Inter Tight', 'Inter', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    --radius: 6px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --container: 1120px;
    --nav-h: 64px;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--nav-h) + 16px);
    -webkit-text-size-adjust: 100%;
}

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

img {
    display: block;
    max-width: 100%;
    height: auto;
}

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

ul,
ol {
    list-style: none;
}

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

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
}

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

.mono {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    letter-spacing: 0.01em;
}

.muted {
    color: var(--muted);
}

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

/* Background: faint grid fading out from the top */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 64px 64px;
    opacity: 0.35;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
}

.bg-grid::after {
    content: '';
    position: absolute;
    top: -20vh;
    left: 50%;
    width: 70vw;
    height: 50vh;
    transform: translateX(-50%);
    background: radial-gradient(closest-side, rgba(91, 140, 255, 0.18), transparent);
    filter: blur(40px);
}

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 100%;
    z-index: 100;
    background: var(--accent);
    transform-origin: 0 50%;
    transform: scaleX(0);
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 20px;
    font: 500 0.9375rem/1 var(--font-body);
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.2s var(--ease);
}

.btn svg,
.text-link svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.25s var(--ease);
}

.btn:hover svg,
.text-link:hover svg {
    transform: translateX(3px);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--text);
    color: var(--bg);
}

.btn-primary:hover {
    background: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--line-strong);
}

.btn-ghost:hover {
    border-color: var(--text);
}

.btn-sm {
    height: 36px;
    padding: 0 14px;
    font-size: 0.875rem;
}

/* ---------- Navigation ---------- */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    height: var(--nav-h);
    border-bottom: 1px solid transparent;
    transition: background-color 0.3s, border-color 0.3s;
}

.nav.scrolled {
    background: rgba(10, 10, 11, 0.75);
    border-bottom-color: var(--line);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
}

.nav-inner {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 32px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.brand-mark {
    display: grid;
    place-items: center;
    height: 30px;
    padding: 0 8px;
    font: 600 0.75rem/1 var(--font-mono);
    letter-spacing: 0.08em;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
}

.brand-name {
    font-size: 0.9375rem;
}

.nav-links {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.nav-links a {
    position: relative;
    padding: 6px 12px;
    font-size: 0.875rem;
    color: var(--muted);
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text);
}

.nav-links a::after {
    content: '';
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 0;
    height: 1px;
    background: var(--accent);
    transform: scaleX(0);
    transition: transform 0.3s var(--ease);
}

.nav-links a.active::after {
    transform: scaleX(1);
}

/* ---------- Hero ---------- */

.hero {
    padding: calc(var(--nav-h) + 96px) 0 96px;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 72px;
    align-items: center;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    margin-bottom: 28px;
    font-size: 0.8125rem;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
}

.status-dot {
    position: relative;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--live);
    flex: none;
}

.status-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--live);
    animation: pulse 2s var(--ease) infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(3); opacity: 0; }
}

.hero-title {
    font: 700 clamp(2.75rem, 6.5vw, 5rem)/1.02 var(--font-display);
    letter-spacing: -0.035em;
    margin-bottom: 20px;
}

.hero-role {
    font: 500 clamp(1.125rem, 2vw, 1.375rem)/1.4 var(--font-display);
    letter-spacing: -0.01em;
    color: var(--text);
    margin-bottom: 16px;
}

.hero-lede {
    max-width: 540px;
    color: var(--muted);
    margin-bottom: 36px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 56px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, auto);
    justify-content: start;
    gap: 0;
    border-top: 1px solid var(--line);
    padding-top: 24px;
}

.stats > div {
    padding-right: 40px;
    margin-right: 40px;
    border-right: 1px solid var(--line);
}

.stats > div:last-child {
    border-right: 0;
    margin-right: 0;
    padding-right: 0;
}

.stats dt {
    font: 400 0.75rem/1 var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 10px;
}

.stats dd {
    font: 600 1.75rem/1 var(--font-display);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

/* Portrait with corner brackets */
.portrait {
    position: relative;
    padding: 14px;
}

.portrait-frame {
    position: relative;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border-radius: 4px;
    background: var(--surface);
}

.portrait-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 20%;
    filter: grayscale(0.15) contrast(1.05);
    transform: scale(1.04);
    transition: transform 1.2s var(--ease), filter 0.6s;
}

.portrait:hover .portrait-frame img {
    transform: scale(1);
    filter: grayscale(0) contrast(1.05);
}

.portrait-frame::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(10, 10, 11, 0.7));
}

.corner {
    position: absolute;
    width: 18px;
    height: 18px;
    border: 0 solid var(--accent);
}

.corner.tl { top: 0; left: 0; border-top-width: 1px; border-left-width: 1px; }
.corner.tr { top: 0; right: 0; border-top-width: 1px; border-right-width: 1px; }
.corner.bl { bottom: 0; left: 0; border-bottom-width: 1px; border-left-width: 1px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 1px; border-right-width: 1px; }

.portrait figcaption {
    position: absolute;
    left: 30px;
    right: 30px;
    bottom: 30px;
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--text);
}

/* ---------- Sections ---------- */

.section {
    padding: 112px 0;
    border-top: 1px solid var(--line);
}

.section-tight {
    padding: 0 0 112px;
    border-top: 0;
}

.section-head {
    display: grid;
    grid-template-columns: 64px 1fr;
    align-items: baseline;
    column-gap: 16px;
    margin-bottom: 56px;
}

.section-index {
    font: 500 0.8125rem/1 var(--font-mono);
    color: var(--accent);
}

.section-head h2 {
    font: 600 clamp(1.875rem, 3.5vw, 2.5rem)/1.1 var(--font-display);
    letter-spacing: -0.03em;
}

.section-head p {
    grid-column: 2;
    margin-top: 10px;
    color: var(--muted);
}

/* Currently building */
.now-card {
    position: relative;
    padding: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        linear-gradient(var(--surface), var(--surface)) padding-box,
        linear-gradient(120deg, rgba(91, 140, 255, 0.6), var(--line) 40%, var(--line) 70%, rgba(61, 220, 151, 0.5)) border-box;
    border-color: transparent;
}

.now-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    font: 500 0.75rem/1.4 var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 4px;
}

.tag-live {
    color: var(--live);
    background: rgba(61, 220, 151, 0.08);
    border: 1px solid rgba(61, 220, 151, 0.25);
}

.now-card h2 {
    font: 600 clamp(1.5rem, 3vw, 2rem)/1.2 var(--font-display);
    letter-spacing: -0.025em;
    margin-bottom: 12px;
}

.now-card p {
    max-width: 760px;
    color: var(--muted);
    font-size: 1.0625rem;
}

/* Experience timeline */
.timeline {
    border-left: 1px solid var(--line);
    margin-left: 7px;
}

.job {
    position: relative;
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 32px;
    padding: 0 0 56px 40px;
}

.job:last-child {
    padding-bottom: 0;
}

.job::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 7px;
    width: 9px;
    height: 9px;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    transform: rotate(45deg);
    transition: background-color 0.3s, border-color 0.3s;
}

.job:first-child::before,
.job:hover::before {
    background: var(--accent);
    border-color: var(--accent);
}

.job-when {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.875rem;
}

.job-when .mono {
    color: var(--text);
}

.job-body h3 {
    font: 600 1.25rem/1.35 var(--font-display);
    letter-spacing: -0.015em;
    margin-bottom: 14px;
}

.job-body .at {
    color: var(--muted);
    font-weight: 400;
}

.job-body .company {
    color: var(--accent);
}

.job-body li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.9375rem;
}

.job-body li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.75em;
    width: 8px;
    height: 1px;
    background: var(--line-strong);
}

/* Projects */
.project-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.project {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.3s, transform 0.4s var(--ease);
}

.project:hover {
    border-color: var(--line-strong);
    transform: translateY(-3px);
}

/* Cursor-following glow (position set by JS) */
.spotlight::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 0%), rgba(91, 140, 255, 0.1), transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
}

.spotlight:hover::before {
    opacity: 1;
}

.project-no {
    color: var(--muted);
    margin-bottom: 40px;
}

.project h3 {
    font: 600 1.1875rem/1.3 var(--font-display);
    letter-spacing: -0.015em;
    margin-bottom: 12px;
}

.project p {
    color: var(--muted);
    font-size: 0.9375rem;
    margin-bottom: 24px;
    flex: 1;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chips li {
    padding: 4px 10px;
    font: 400 0.75rem/1.5 var(--font-mono);
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    transition: border-color 0.2s, color 0.2s;
}

.chips li:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Skills */
.skill-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
}

.skill-group {
    padding: 28px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    transition: background-color 0.3s;
}

.skill-group:hover {
    background: var(--surface);
}

.skill-group h3 {
    color: var(--muted);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    margin-bottom: 16px;
}

/* Education */
.edu-list {
    border-top: 1px solid var(--line);
}

.edu {
    display: grid;
    grid-template-columns: 200px 1fr auto;
    gap: 32px;
    align-items: baseline;
    padding: 24px 0;
    border-bottom: 1px solid var(--line);
}

.edu-degree {
    font: 600 1.125rem/1.3 var(--font-display);
}

.edu-school {
    color: var(--muted);
}

/* Contact */
.contact-card {
    max-width: 760px;
}

.contact-card .section-index {
    display: block;
    margin-bottom: 20px;
}

.contact-card h2 {
    font: 700 clamp(2.25rem, 5vw, 3.75rem)/1.05 var(--font-display);
    letter-spacing: -0.035em;
    margin-bottom: 20px;
}

.contact-card p {
    color: var(--muted);
    font-size: 1.0625rem;
    margin-bottom: 40px;
    max-width: 560px;
}

.contact-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.email-link {
    font: 500 clamp(1.25rem, 3vw, 1.75rem)/1.2 var(--font-display);
    letter-spacing: -0.02em;
    background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat;
    padding-bottom: 4px;
    transition: background-size 0.4s var(--ease), color 0.2s;
    word-break: break-all;
}

.email-link:hover {
    color: var(--accent);
    background-size: 100% 1px;
}

.text-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.9375rem;
    transition: color 0.2s;
}

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

/* Footer */
.footer {
    border-top: 1px solid var(--line);
    padding: 28px 0;
    font-size: 0.875rem;
    color: var(--muted);
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.footer a:hover {
    color: var(--text);
}

/* ---------- Reveal on scroll ---------- */

.js .reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
    transition-delay: var(--delay, 0ms);
}

.js .reveal.in {
    opacity: 1;
    transform: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
    .hero-grid {
        grid-template-columns: 1fr;
        gap: 56px;
    }

    .portrait {
        max-width: 420px;
        order: -1;
    }

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

    .nav-links {
        display: none;
    }

    .nav-inner > .btn {
        margin-left: auto;
    }
}

@media (max-width: 640px) {
    .hero {
        padding: calc(var(--nav-h) + 48px) 0 72px;
    }

    .section {
        padding: 80px 0;
    }

    .section-tight {
        padding: 0 0 80px;
    }

    .brand-name {
        display: none;
    }

    .portrait {
        max-width: 240px;
        padding: 10px;
    }

    .portrait figcaption {
        left: 20px;
        right: 20px;
        bottom: 18px;
        font-size: 0.75rem;
    }

    .stats > div {
        padding-right: 20px;
        margin-right: 20px;
    }

    .stats dd {
        font-size: 1.5rem;
    }

    .section-head {
        grid-template-columns: 1fr;
    }

    .section-head p {
        grid-column: 1;
    }

    .section-index {
        margin-bottom: 12px;
    }

    .now-card {
        padding: 28px 24px;
    }

    .now-meta {
        flex-direction: column;
        align-items: flex-start;
    }

    .job {
        grid-template-columns: 1fr;
        gap: 10px;
        padding-left: 28px;
    }

    .project-grid,
    .skill-grid {
        grid-template-columns: 1fr;
    }

    .edu {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }

    .js .reveal {
        opacity: 1;
        transform: none;
    }
}
