/* ---------- CSS VARIABLES ---------- */
:root {
    --bg: #0e0f13;
    /* base background */
    --bg-2: #12131a;
    /* elevated bg */
    --text: #e6f1ff;
    /* main text */
    --muted: #8aa2c0;
    /* muted text */
    --primary: #63ffc6;
    /* neon mint */
    --accent: #7aa2ff;
    /* retro blue */
    --warn: #ffdd57;
    /* amber */
    --danger: #ff6b6b;
    /* candy red */
    --grid: rgba(99, 255, 198, .08);
    /* pixel grid overlay */

    --radius: 16px;
    --pad: 18px;
    --shadow: 0 0 0 1px rgba(99, 255, 198, .24), 0 8px 24px rgba(0, 0, 0, .45);

    --font-title: "Press Start 2P", system-ui, -apple-system, Segoe UI, Roboto, Arial;
    --font-ui: "VT323", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --font-body: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
}

/* ---------- RESET ---------- */
*,
*::before,
*::after {
    box-sizing: border-box
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--primary);
    text-decoration: none
}

a:hover {
    text-decoration: underline
}

h1,
h2,
h3,
h4 {
    text-wrap: balance;
}

/* ---------- GLOBAL BACKDROPS (CRT + GRID) ---------- */
.stage {
    position: relative;
    min-height: 100dvh;
    overflow-x: clip;
    isolation: isolate;
}

.stage::before {
    /* subtle gradient */
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background: radial-gradient(1200px 800px at 10% 10%, #1a1d29 0%, transparent 60%),
        radial-gradient(1200px 800px at 90% 90%, #121421 0%, transparent 60%),
        linear-gradient(180deg, #0b0c10 0%, #0e0f13 100%);
}

.stage::after {
    /* pixel-grid overlay */
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(#0000 31px, var(--grid) 32px),
        linear-gradient(90deg, #0000 31px, var(--grid) 32px);
    background-size: 32px 32px;
    mix-blend-mode: lighten;
    opacity: .25;
}

/* Scanlines + vignette (toggled) */
.crt-on .crt {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(to bottom,
            rgba(255, 255, 255, .03) 0px, rgba(255, 255, 255, .03) 1px,
            rgba(0, 0, 0, .03) 2px, rgba(0, 0, 0, .03) 3px);
    box-shadow: inset 0 0 100px rgba(0, 0, 0, .6);
    filter: contrast(1.02) saturate(1.05);
}

/* ---------- LAYOUT ---------- */
.container {
    width: min(1100px, 92vw);
    margin: 0 auto;
    padding: 24px 0;
}

header {
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(6px);
    background: linear-gradient(#1118, #1114);
    border-bottom: 1px solid #1f2937;
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand .logo {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: var(--primary);
    box-shadow: 0 0 0 2px #0b0c10, 0 0 16px var(--primary);
    image-rendering: pixelated;
    position: relative;
}

.brand .logo::after {
    content: "";
    position: absolute;
    inset: 6px;
    background: #0e0f13;
    box-shadow: inset 0 0 0 2px #0b0c10;
}

.brand h1 {
    font-family: var(--font-title);
    font-size: clamp(12px, 2.6vw, 18px);
    margin: 0;
    letter-spacing: 1px
}

.nav a {
    font-family: var(--font-ui);
    font-size: 22px;
    padding: 6px 10px;
    border-radius: 10px;
}

.nav a:hover {
    background: #1a2130;
    text-decoration: none
}

.nav .active {
    outline: 2px solid var(--accent);
    border-radius: 8px;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    font-family: var(--font-ui);
    font-size: 20px;
    border: 1px solid #2b3445;
    padding: 6px 12px;
    border-radius: 10px;
    background: linear-gradient(#141826, #0f1320);
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--shadow);
}

.btn:hover {
    filter: brightness(1.08)
}

/* ---------- CARDS & TYPO ---------- */
.card {
    background: linear-gradient(180deg, #141826, #0f1320);
    border: 1px solid #2b3445;
    border-radius: var(--radius);
    padding: clamp(14px, 2.4vw, 24px);
    box-shadow: var(--shadow);
}

.title {
    font-family: var(--font-title);
    font-size: clamp(18px, 3.6vw, 28px);
    line-height: 1.35;
    margin: 0 0 12px;
}

.subtitle {
    color: var(--muted);
    margin-top: 8px;
}

.chiprow {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.chip {
    font-family: var(--font-ui);
    font-size: 20px;
    padding: 4px 10px;
    background: #101522;
    border: 1px dashed #394764;
    border-radius: 8px;
}

/* ---------- GRID ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
}

.span-4 {
    grid-column: span 4;
}

.span-6 {
    grid-column: span 6;
}

.span-12 {
    grid-column: 1 / -1;
}

/* ---------- PIXEL BORDER ---------- */
.pixel-border {
    position: relative;
}

.pixel-border::before,
.pixel-border::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 0;
    pointer-events: none;
}

.pixel-border::before {
    outline: 2px solid #63ffc6;
    clip-path: polygon(0% 8px, 8px 8px, 8px 0%, calc(100% - 8px) 0%, calc(100% - 8px) 8px, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 8px), 0% calc(100% - 8px));
    opacity: .45
}

.pixel-border::after {
    outline: 2px dashed #2b3445;
    opacity: .7;
    mix-blend-mode: screen
}

/* ---------- HERO ---------- */
.hero {
    padding: 48px 0 16px;
}

.hero-wrap {
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    gap: 20px;
    align-items: center;
}

.avatar-card {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 16px;
    align-items: center;
}

.avatar {
    width: 96px;
    height: 96px;
    border-radius: 8px;
    background: #0b0c10;
    border: 2px solid var(--primary);
    box-shadow: 0 0 18px rgba(99, 255, 198, .35);
    image-rendering: pixelated;
    position: relative;
    overflow: hidden;
}

.avatar::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(#63ffc633 1px, #0000 1px) 0 0/12px 12px, linear-gradient(90deg, #63ffc633 1px, #0000 1px) 0 0/12px 12px;
    mix-blend-mode: screen;
}

.avatar::after {
    content: "🧑‍💻";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 54px;
    filter: saturate(1.1);
}

/* ---------- PROJECTS LIST ---------- */
.project h3 {
    margin: 0 0 6px;
    font-family: var(--font-ui);
    font-size: 26px
}

.project p {
    margin: 0;
    color: var(--muted)
}

.media {
    height: 180px;
    border-radius: 10px;
    background: linear-gradient(#0b0c10, #121421);
    border: 1px solid #222a3a;
    margin-bottom: 10px;
    display: grid;
    place-items: center;
    image-rendering: pixelated;
    position: relative;
}

.media::after {
    content: "320×180";
    font-family: var(--font-ui);
    font-size: 24px;
    color: #2fce9c44
}

/* ---------- SKILLS ---------- */
.bar {
    height: 16px;
    background: #0d1322;
    border: 1px solid #2b3445;
    border-radius: 6px;
    overflow: clip;
}

.fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--primary));
    width: 0%;
    box-shadow: 0 0 18px rgba(122, 162, 255, .35);
}

/* ---------- PAGES ---------- */
main>section {
    display: none
}

main>section.active {
    display: block;
    animation: fadeIn .25s steps(8, end)
}

@keyframes fadeIn {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}

/* ---------- FOOTER ---------- */
footer {
    margin-top: 32px;
    padding: 24px 0 48px;
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 20px
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
    .hero-wrap {
        grid-template-columns: 1fr;
    }

    .span-4 {
        grid-column: span 12
    }

    .span-6 {
        grid-column: span 12
    }
}

@media (max-width: 640px) {
    .grid {
        grid-template-columns: repeat(6, 1fr)
    }

    .nav a[data-route] {
        display: none
    }
}

/* ---------- ACCESSIBILITY ---------- */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important
    }
}

/* --- Mobile nav (drawer) additions --- */
.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid #2b3445;
    border-radius: 10px;
    background: linear-gradient(#141826, #0f1320);
    cursor: pointer
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    position: relative
}

.hamburger span::before,
.hamburger span::after {
    content: "";
    position: absolute;
    left: 0;
    width: 22px;
    height: 2px;
    background: var(--text)
}

.hamburger span::before {
    top: -7px
}

.hamburger span::after {
    top: 7px
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s linear;
    z-index: 9997
}

.mobile-drawer {
    position: fixed;
    top: 0;
    right: -280px;
    width: 260px;
    height: 100dvh;
    background: linear-gradient(180deg, #141826, #0f1320);
    border-left: 1px solid #2b3445;
    box-shadow: var(--shadow);
    padding: 16px;
    z-index: 9998;
    transition: right .2s steps(8, end)
}

.mobile-drawer a {
    display: block;
    font-family: var(--font-ui);
    font-size: 22px;
    padding: 10px 12px;
    border-radius: 10px;
    margin: 6px 0
}

.mobile-drawer a.active {
    outline: 2px solid var(--accent)
}

.drawer-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto
}

.drawer-open .mobile-drawer {
    right: 0
}

/* --- Responsive refinements --- */
:root {
    --container: 1100px
}

.container {
    width: min(var(--container), 92vw)
}

.title {
    font-size: clamp(20px, 3.8vw, 30px)
}

.nav a {
    line-height: 1
}

@media (max-width: 1024px) {
    .hero-wrap {
        grid-template-columns: 1fr
    }
}

@media (max-width: 720px) {
    .grid {
        grid-template-columns: repeat(6, 1fr)
    }

    .nav a[data-route] {
        display: none
    }

    .hamburger {
        display: flex
    }

    .media {
        height: 160px
    }

    .chip {
        font-size: 18px
    }

    .btn {
        min-height: 44px
    }
}

@media (max-width:480px) {
    .title {
        font-size: clamp(18px, 5.2vw, 26px)
    }

    .media {
        height: 140px
    }

    .avatar {
        width: 80px;
        height: 80px
    }
}