/* Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
    margin: 0;
}

ul[role='list'],
ol[role='list'] {
    list-style: none;
    margin: 0;
    padding: 0;
}

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

button {
    font: inherit;
}

input,
textarea {
    font: inherit;
}

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

:root {
    --bg: #0b1220;
    --bg-elev: #0f172a;
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --brand: #7c3aed;
    --brand-2: #06b6d4;
    --accent: #22c55e;
    --border: #1f2a44;
    --card: #0f172a;
    --surface: rgba(148, 163, 184, 0.08);
    --shadow: 0 10px 30px rgba(2, 6, 23, 0.5);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 20px;
    --container: 1200px;
    --space-1: 6px;
    --space-2: 10px;
    --space-3: 14px;
    --space-4: 18px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;
    --space-9: 96px;
}

/* Light theme variables */
:root.light {
    --bg: #f8fafc;
    --bg-elev: #ffffff;
    --text: #0f172a;
    --text-dim: #475569;
    --border: #e2e8f0;
    --card: #ffffff;
    --surface: rgba(15, 23, 42, 0.06);
    --shadow: 0 10px 30px rgba(2, 6, 23, 0.08);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    background: radial-gradient(1200px 600px at 10% -10%, rgba(124, 58, 237, 0.12), transparent),
        radial-gradient(1200px 800px at 110% 10%, rgba(6, 182, 212, 0.10), transparent),
        var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    width: min(100% - 2rem, var(--container));
    margin-inline: auto;
}

.section {
    padding: var(--space-8) 0;
}

.section h2 {
    font-size: clamp(24px, 3.2vw, 36px);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-5);
}

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

.eyebrow {
    font-weight: 600;
    color: var(--brand-2);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: var(--space-2);
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: saturate(150%) blur(8px);
    background: color-mix(in oklab, var(--bg-elev) 70%, transparent);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 700;
}

.brand img {
    filter: drop-shadow(0 4px 16px rgba(124, 58, 237, 0.5));
}

.nav {
    position: relative;
}

.nav-toggle {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
}

.nav-toggle .bar {
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
}

.nav-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3);
    min-width: 220px;
    box-shadow: var(--shadow);
    list-style: none;
}

.nav-menu li a {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-dim);
}

.nav-menu li {
    list-style: none;
}

.nav-menu li a:hover {
    color: var(--text);
    background: var(--surface);
}

.nav.open .nav-menu {
    display: block;
}

@media (min-width: 900px) {
    .nav-toggle {
        display: none;
    }

    .nav-menu {
        all: unset;
        display: flex;
        gap: var(--space-1);
    }

    .nav-menu li a {
        padding: 10px 14px;
        color: var(--text-dim);
    }

    .nav-menu li a:hover {
        color: var(--text);
        background: transparent;
    }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
}

.theme-toggle .icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid transparent;
    transition: transform 0.1s ease, background 0.2s ease, color 0.2s ease;
    font-weight: 600;
}

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

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: white;
    box-shadow: 0 10px 20px rgba(124, 58, 237, 0.25), 0 8px 14px rgba(6, 182, 212, 0.15);
}

.btn-primary:hover {
    filter: brightness(1.05);
}

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

/* Hero */
.hero {
    padding: var(--space-9) 0 var(--space-8);
}

.grid-2 {
    display: grid;
    gap: var(--space-7);
    grid-template-columns: 1fr;
    align-items: center;
}

@media (min-width: 900px) {
    .grid-2 {
        grid-template-columns: 1.15fr 0.85fr;
    }
}

.hero h1 {
    font-size: clamp(30px, 5vw, 54px);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-4);
}

.hero .cta-group {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.socials {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-5);
    list-style: none;
    padding-left: 0;
    align-items: center;
}

.socials li {
    list-style: none;
    display: flex;
}

.socials img {
    width: 20px;
    height: 20px;
    opacity: 0.9;
}

.socials a {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
}

.socials a:hover {
    background: var(--surface);
}

.profile {
    position: relative;
    width: min(420px, 90%);
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: 30px;
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    background: radial-gradient(120% 120% at 10% 10%, rgba(124, 58, 237, 0.25), transparent), radial-gradient(120% 120% at 90% 10%, rgba(6, 182, 212, 0.25), transparent), var(--card);
}

.profile .glow {
    position: absolute;
    inset: -20%;
    background: radial-gradient(50% 50% at 50% 50%, rgba(124, 58, 237, 0.25), transparent);
    filter: blur(40px);
    pointer-events: none;
}

.profile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    mix-blend-mode: screen;
    opacity: 0.9;
}

/* Tags & stats */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: var(--space-4);
    list-style: none;
    padding-left: 0;
}

.tags li {
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-dim);
    font-weight: 600;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-4);
}

.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
    box-shadow: var(--shadow);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 112px;
    gap: 6px;
}

.stat .num {
    font-size: clamp(28px, 6vw, 44px);
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1;
}

.stat .label {
    color: var(--text-dim);
    margin-top: 0;
}

/* Projects */
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: var(--bg-elev);
    padding: 8px;
    border-radius: 14px;
    border: 1px solid var(--border);
    max-width: 100%;
}

.filters .filter {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    color: var(--text-dim);
    background: transparent;
    cursor: pointer;
}

.filters .filter.active {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border);
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: var(--space-5);
}

@media (min-width: 700px) {
    .projects-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1100px) {
    .projects-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.card {
    overflow: hidden;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transform: translateY(0);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(2, 6, 23, 0.45);
}

.card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #0b1220;
}

.card-body {
    padding: var(--space-4);
}

.card-body h3 {
    font-size: 18px;
    margin-bottom: 6px;
}

.card-body p {
    color: var(--text-dim);
}

.card-actions {
    display: flex;
    gap: 8px;
    margin-top: var(--space-3);
}

/* Timeline */
.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

.timeline>li {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: var(--space-4);
    padding: var(--space-4) 0;
    border-top: 1px dashed var(--border);
}

.timeline>li:first-child {
    border-top: none;
}

.timeline .time {
    color: var(--text-dim);
    font-weight: 600;
}

.timeline .content h3 {
    font-size: 18px;
    margin-bottom: 6px;
}

.timeline .content p {
    color: var(--text-dim);
}

/* Contact */
.contact-list {
    display: grid;
    gap: 10px;
    margin-top: var(--space-4);
}

.contact-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dim);
}

.contact-list li i {
    font-size: 20px;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.contact-list li svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.contact-form {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
    box-shadow: var(--shadow);
}

.field {
    display: grid;
    gap: 6px;
    margin-bottom: var(--space-4);
}

.field label {
    color: var(--text-dim);
    font-weight: 600;
}

.field input,
.field textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
    outline: none;
}

.field input:focus,
.field textarea:focus {
    border-color: color-mix(in oklab, var(--brand), var(--brand-2));
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 20%, transparent);
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    padding: var(--space-6) 0;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.to-top .icon {
    width: 20px;
    height: 20px;
    fill: var(--text-dim);
}

.to-top:hover .icon {
    fill: var(--text);
}

/* Skip link */
.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.skip-link:focus {
    position: fixed;
    left: 20px;
    top: 20px;
    width: auto;
    height: auto;
    padding: 8px 12px;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    z-index: 100;
}

/* Animations */
.reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive tweaks */
@media (max-width: 600px) {
    .section {
        padding: var(--space-7) 0;
    }

    .hero {
        padding: var(--space-8) 0 var(--space-7);
    }

    .hero h1 {
        font-size: clamp(26px, 8vw, 40px);
    }

    .cta-group {
        gap: var(--space-2);
    }

    .projects-grid {
        gap: var(--space-4);
    }

    .card img {
        height: 150px;
    }

    .profile {
        width: min(360px, 100%);
        border-radius: 22px;
    }

    .socials {
        gap: var(--space-2);
    }

    .btn {
        padding: 10px 14px;
        border-radius: 10px;
    }

    .nav-toggle {
        width: 36px;
        height: 36px;
    }

    .nav-menu {
        min-width: min(90vw, 280px);
        right: 8px;
        left: auto;
    }

    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-4);
    }

    .stat {
        padding: var(--space-4);
    }

    .stat .label {
        font-size: 14px;
        line-height: 1.3;
    }

    /* Header: allow wrapping and keep alignment tidy */
    .header-inner {
        flex-wrap: wrap;
        row-gap: var(--space-3);
    }

    .brand {
        white-space: nowrap;
    }

    .header-actions {
        margin-left: auto;
        flex-basis: 100%;
        display: flex;
        justify-content: flex-end;
    }

    .header-actions .btn {
        min-width: 112px;
    }
}

@media (max-width: 360px) {
    .container {
        width: min(100% - 1.5rem, var(--container));
    }

    .btn {
        padding: 9px 12px;
    }

    .card img {
        height: 130px;
    }

    .nav-menu {
        min-width: 88vw;
    }

    /* On very small phones, place the CTA on its own line full width */
    .header-actions {
        flex-basis: 100%;
        justify-content: stretch;
    }

    .header-actions .btn-primary {
        width: 100%;
    }

    /* Alignment fixes for filters and contact list */
    .filters {
        align-items: center;
        flex-wrap: wrap;
        padding: 8px;
        /* was 6px; give a bit more breathing room */
    }

    .filters .filter {
        display: inline-flex;
        align-items: center;
        line-height: 1;
    }

    .filters .filter {
        padding: 6px 10px;
        font-size: 14px;
    }

    .contact-list li {
        align-items: flex-start;
        /* top-align icon with multi-line text */
    }
}

@media (min-width: 600px) and (max-width: 899px) {
    .section {
        padding: calc(var(--space-8) - 8px) 0;
    }

    .projects-grid {
        gap: calc(var(--space-5) - 6px);
    }

    .card img {
        height: 160px;
    }
}

@media (max-width: 380px) {
    .stats {
        grid-template-columns: 1fr;
    }
}

/* Safe area support for notched devices */
body {
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

/* Filters focus handling to avoid overflow/misalignment */
.filters {
    overflow: visible;
    /* allow pills to wrap to next line without clipping */
}

.filters .filter {
    vertical-align: middle;
}

.filters .filter:focus {
    outline: none;
}

.filters .filter:focus-visible {
    box-shadow: 0 0 0 2px color-mix(in oklab, var(--brand-2) 60%, transparent) inset;
}

/* Ensure filter buttons don't shrink too small when wrapping */
.filters .filter {
    flex: 0 0 auto;
}

/* Encourage last item to wrap when tight */
@media (max-width: 420px) {
    .filters {
        row-gap: 6px;
    }
}