/* ---------- Tokens ---------- */
:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --text: #0a0a0a;
    --muted: #5c5c5c;
    --faint: #8a8a8a;
    --line: #e4e4e4;
    --line-strong: #0a0a0a;
    --mark: #e2e2e2;
    --grid-dot: rgba(10, 10, 10, 0.07);
    --term-bg: #0d0d0d;
    --term-text: #e8e8e8;
    --term-muted: #8c8c8c;
    --term-line: #262626;
    --invert-bg: #0a0a0a;
    --invert-text: #fafafa;

    --font-display: "Space Grotesk", system-ui, sans-serif;
    --font-body: "Inter", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

    --wrap: 1120px;
    --radius: 14px;
    --radius-sm: 8px;
    --header-h: 64px;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0a0a0a;
        --surface: #121212;
        --text: #f2f2f2;
        --muted: #a3a3a3;
        --faint: #6e6e6e;
        --line: #232323;
        --line-strong: #f2f2f2;
        --mark: #2e2e2e;
        --grid-dot: rgba(255, 255, 255, 0.06);
        --term-bg: #151515;
        --term-line: #2a2a2a;
        --invert-bg: #f2f2f2;
        --invert-text: #0a0a0a;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0a0a0a;
    --surface: #121212;
    --text: #f2f2f2;
    --muted: #a3a3a3;
    --faint: #6e6e6e;
    --line: #232323;
    --line-strong: #f2f2f2;
    --mark: #2e2e2e;
    --grid-dot: rgba(255, 255, 255, 0.06);
    --term-bg: #151515;
    --term-line: #2a2a2a;
    --invert-bg: #f2f2f2;
    --invert-text: #0a0a0a;
    color-scheme: dark;
}

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

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

body {
    margin: 0;
    background-color: var(--bg);
    background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
    background-size: 24px 24px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    transition:
        background-color 0.3s ease,
        color 0.3s ease;
}

h1,
h2,
h3 {
    font-family: var(--font-display);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0;
}

p {
    margin: 0;
}

a {
    color: inherit;
}

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

ul,
ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

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

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

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

.skip {
    position: absolute;
    left: 16px;
    top: -100px;
    z-index: 100;
    padding: 8px 14px;
    background: var(--invert-bg);
    color: var(--invert-text);
    border-radius: var(--radius-sm);
    text-decoration: none;
}

.skip:focus {
    top: 12px;
}

mark {
    background: linear-gradient(transparent 58%, var(--mark) 58%);
    color: inherit;
    padding: 0 2px;
    font-weight: 500;
}

/* ---------- Header ---------- */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-h);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease;
}

.header.is-scrolled {
    border-bottom-color: var(--line);
}

.header-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
}

.brand-logo {
    width: 34px;
    height: 34px;
    padding: 2px;
    border: 1.5px solid var(--line-strong);
    border-radius: 9px;
    transition: transform 0.4s var(--ease);
}

.brand:hover .brand-logo {
    transform: rotate(-8deg);
}

.nav {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.nav a {
    text-decoration: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    transition:
        color 0.2s ease,
        background-color 0.2s ease;
}

.nav a:hover {
    color: var(--text);
    background: var(--mark);
}

.nav a span {
    color: var(--faint);
    margin-right: 6px;
}

.nav .nav-cta {
    margin-left: 8px;
    color: var(--invert-text);
    background: var(--invert-bg);
}

.nav .nav-cta:hover {
    color: var(--invert-text);
    background: var(--invert-bg);
    opacity: 0.85;
}

.theme-toggle {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin-left: 4px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.theme-toggle:hover {
    border-color: var(--line-strong);
}

/* ---------- Buttons ---------- */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: 1.5px solid var(--line-strong);
    transition:
        transform 0.2s var(--ease),
        box-shadow 0.2s var(--ease),
        background-color 0.2s ease;
}

.btn span {
    transition: transform 0.2s var(--ease);
}

.btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 3px 3px 0 var(--line-strong);
}

.btn:hover span {
    transform: translateX(2px);
}

.btn:active {
    transform: translate(0, 0);
    box-shadow: none;
}

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

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

.btn-sm {
    min-height: 38px;
    padding: 0 14px;
    font-size: 0.8125rem;
}

/* ---------- Hero ---------- */
.hero {
    padding: clamp(56px, 10vw, 120px) 0 clamp(48px, 7vw, 88px);
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
    gap: clamp(32px, 6vw, 80px);
    align-items: center;
}

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

.status-dot {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text);
}

.status-dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--text);
    animation: ping 2s ease-out infinite;
}

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

.hero h1 {
    font-size: clamp(2.6rem, 6.4vw, 5rem);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.02;
    margin-bottom: 28px;
}

.hero h1 em {
    font-style: normal;
    font-family: var(--font-mono);
    font-weight: 500;
    letter-spacing: -0.04em;
    padding: 0 0.12em;
    background: var(--invert-bg);
    color: var(--invert-text);
    border-radius: 6px;
}

.cursor {
    display: inline-block;
    width: 0.09em;
    height: 0.85em;
    margin-left: 0.08em;
    vertical-align: -0.06em;
    background: currentColor;
    animation: blink 1.1s steps(1) infinite;
}

.cursor-sm {
    width: 0.6em;
    height: 1.1em;
    margin: 0;
    vertical-align: -0.2em;
}

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

.lead {
    max-width: 36rem;
    font-size: 1.0625rem;
    color: var(--muted);
    margin-bottom: 32px;
}

.lead mark {
    color: var(--text);
}

.photo {
    margin: 0;
    justify-self: end;
    width: 100%;
    max-width: 380px;
}

.photo-frame {
    position: relative;
    aspect-ratio: 1 / 1;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: 10px 10px 0 var(--line-strong);
}

.photo-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(1) contrast(1.05);
    transition:
        filter 0.6s ease,
        transform 0.6s var(--ease);
}

.photo:hover .photo-frame img {
    filter: grayscale(0);
    transform: scale(1.03);
}

.photo figcaption {
    display: flex;
    justify-content: space-between;
    margin-top: 18px;
    padding-right: 10px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--faint);
}

/* ---------- About / terminal ---------- */
.about {
    padding: 0 0 clamp(64px, 9vw, 112px);
}

.about-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: 24px;
    align-items: stretch;
}

.terminal {
    background: var(--term-bg);
    color: var(--term-text);
    border-radius: var(--radius);
    border: 1px solid var(--term-line);
    overflow: hidden;
    box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.5);
}

.terminal-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 0 0 0 16px;
    height: 40px;
    border-bottom: 1px solid var(--term-line);
}

.terminal-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--term-muted);
}

.win-controls {
    display: flex;
    align-self: stretch;
}

.win-controls svg {
    width: 46px;
    height: 100%;
    padding: 0 18px;
    fill: none;
    stroke: var(--term-muted);
    stroke-width: 1;
    transition:
        background-color 0.2s ease,
        stroke 0.2s ease;
}

.win-controls svg:hover {
    background: var(--term-line);
    stroke: var(--term-text);
}

.win-controls svg:last-child:hover {
    background: var(--term-text);
    stroke: var(--term-bg);
}

.terminal-body {
    margin: 0;
    padding: 20px 22px 24px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.75;
    overflow-x: auto;
}

.t-prompt {
    color: var(--term-muted);
    user-select: none;
}

.t-user {
    color: var(--term-text);
    font-weight: 600;
}

.t-path {
    color: var(--term-text);
}

.t-key {
    color: #ffffff;
}

.t-str {
    color: var(--term-muted);
}

.traits {
    display: grid;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.traits li {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 16px;
    padding: 22px 24px;
    transition: background-color 0.25s ease;
}

.traits li + li {
    border-top: 1px solid var(--line);
}

.traits li:hover {
    background: var(--bg);
}

.trait-num {
    grid-row: span 2;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--faint);
    padding-top: 4px;
}

.traits h3 {
    font-size: 1.125rem;
    margin-bottom: 6px;
}

.traits p {
    font-size: 0.9375rem;
    color: var(--muted);
}

/* ---------- Sections ---------- */
.section {
    padding: clamp(64px, 9vw, 112px) 0;
    border-top: 1px solid var(--line);
}

.section-head {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: clamp(36px, 5vw, 56px);
}

.section-tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--faint);
    text-transform: lowercase;
}

.section-head h2 {
    font-size: clamp(2rem, 4.4vw, 3.25rem);
    font-weight: 700;
}

#experience .section-head h2 {
    font-family: var(--font-mono);
    font-weight: 600;
    letter-spacing: -0.05em;
}

/* ---------- Experience log ---------- */
.log {
    position: relative;
}

.commit {
    position: relative;
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 40px;
    padding-bottom: 48px;
}

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

/* vertical rail */
.commit::before {
    content: "";
    position: absolute;
    left: 220px;
    top: 10px;
    bottom: -10px;
    width: 1.5px;
    background: var(--line);
}

.commit:last-child::before {
    display: none;
}

/* node */
.commit::after {
    content: "";
    position: absolute;
    left: 214px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1.5px solid var(--line-strong);
    background: var(--bg);
}

.commit.is-head::after {
    background: var(--line-strong);
    box-shadow: 0 0 0 5px var(--mark);
}

.commit-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--muted);
}

.commit-ref {
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--invert-bg);
    color: var(--invert-text);
    font-size: 0.6875rem;
    font-weight: 600;
}

.commit-body {
    padding-left: 24px;
}

.commit-body h3 {
    font-size: 1.375rem;
}

.commit-company {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--muted);
    margin: 6px 0 16px;
}

.commit-body ul {
    display: grid;
    gap: 8px;
}

.commit-body li {
    position: relative;
    padding-left: 22px;
    color: var(--muted);
    font-size: 0.9688rem;
}

.commit-body li::before {
    content: "+";
    position: absolute;
    left: 0;
    font-family: var(--font-mono);
    color: var(--text);
    font-weight: 600;
}

/* ---------- Project / repo ---------- */
.repo {
    border: 1.5px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    transition:
        transform 0.3s var(--ease),
        box-shadow 0.3s var(--ease);
}

.repo:hover {
    transform: translate(-3px, -3px);
    box-shadow: 6px 6px 0 var(--line-strong);
}

.repo-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 28px;
    border-bottom: 1px solid var(--line);
}

.repo-name {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.repo-name:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.repo-owner {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 400;
    color: var(--faint);
}

.badge {
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--muted);
}

.repo-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
}

.repo-grid > div {
    padding: 28px;
}

.repo-desc {
    font-size: 1.0625rem;
    color: var(--muted);
    margin-bottom: 24px;
    max-width: 38rem;
}

.repo-desc mark {
    color: var(--text);
}

.repo-side {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 24px;
    border-left: 1px solid var(--line);
    background: var(--bg);
}

.repo-side dl {
    margin: 0;
    display: grid;
    gap: 14px;
}

.repo-side dl div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 14px;
    border-bottom: 1px dashed var(--line);
}

.repo-side dt {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--faint);
}

.repo-side dd {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: right;
}

.repo-side .btn {
    align-self: flex-start;
}

/* ---------- Tags ---------- */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tags li {
    padding: 5px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.4;
    transition:
        border-color 0.2s ease,
        transform 0.2s var(--ease);
}

.tags li:hover {
    border-color: var(--line-strong);
    transform: translateY(-1px);
}

.tags .tag-strong {
    background: var(--invert-bg);
    color: var(--invert-text);
    border-color: var(--invert-bg);
}

/* ---------- Stack tree ---------- */
.tree {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 24px 28px;
}

.tree-root {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.tree-row {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    padding: 12px 0;
}

.tree-row + .tree-row {
    border-top: 1px dashed var(--line);
}

.tree-key {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--muted);
    white-space: pre;
}

.facts {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 24px;
    margin-top: 24px;
}

.fact {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fact h3 {
    font-size: 1.25rem;
    margin-top: 4px;
}

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

.fact-meta {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--faint);
}

.fact-meta strong {
    color: var(--text);
    font-weight: 600;
}

.lang {
    display: grid;
    gap: 10px;
    margin-top: 6px;
}

.lang li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--line);
    font-weight: 500;
}

.lang li:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

/* ---------- Contact ---------- */
.contact {
    padding: clamp(72px, 10vw, 128px) 0;
    background: var(--invert-bg);
    color: var(--invert-text);
}

.contact-inner {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
}

.contact .section-tag {
    color: color-mix(in srgb, var(--invert-text) 55%, transparent);
}

.contact h2 {
    font-size: clamp(2.4rem, 6vw, 4.5rem);
    font-weight: 700;
    letter-spacing: -0.035em;
}

.contact .actions {
    margin-top: 12px;
}

.contact .btn-invert {
    background: var(--invert-text);
    color: var(--invert-bg);
    border-color: var(--invert-text);
}

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

.contact .btn:hover {
    box-shadow: 3px 3px 0 var(--invert-text);
}

/* ---------- Footer ---------- */
.footer {
    padding: 24px 0;
    background: var(--invert-bg);
    color: color-mix(in srgb, var(--invert-text) 55%, transparent);
    border-top: 1px solid color-mix(in srgb, var(--invert-text) 15%, transparent);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

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

.footer a {
    text-decoration: none;
}

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

/* ---------- Boot screen ---------- */
.boot {
    display: none;
}

.booting {
    overflow: hidden;
}

.booting .boot {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 200;
    padding: clamp(20px, 5vw, 48px);
    background: #0a0a0a;
    color: #8c8c8c;
    cursor: pointer;
    transition:
        opacity 0.5s ease,
        visibility 0.5s;
}

.booting .boot.is-done {
    opacity: 0;
    visibility: hidden;
}

.boot-log {
    margin: 0;
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1.6vw, 0.875rem);
    line-height: 1.8;
    white-space: pre-wrap;
}

.boot-log b {
    color: #f2f2f2;
    font-weight: 600;
}

.boot-log .cursor {
    color: #f2f2f2;
    width: 0.6em;
    height: 1.1em;
    vertical-align: -0.2em;
}

/* ---------- Reveal ---------- */
.js .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition:
        opacity 0.7s var(--ease),
        transform 0.7s var(--ease);
}

.js .reveal.is-visible {
    opacity: 1;
    transform: none;
}

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

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

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

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    .hero-grid,
    .about-grid {
        grid-template-columns: 1fr;
    }

    .photo {
        justify-self: start;
        max-width: 320px;
    }

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

    .commit::before {
        left: 6px;
    }

    .commit::after {
        left: 0;
    }

    .commit-meta {
        flex-direction: row;
        align-items: center;
    }

    .commit-body {
        padding-left: 0;
    }
}

@media (max-width: 760px) {
    .nav a:not(.nav-cta) {
        display: none;
    }

    .nav .nav-cta {
        margin-left: 0;
    }

    .repo-grid,
    .facts {
        grid-template-columns: 1fr;
    }

    .repo-side {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .tree-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .wrap {
        padding: 0 16px;
    }

    .brand-name {
        display: none;
    }

    .repo-head,
    .repo-grid > div,
    .tree,
    .fact {
        padding-left: 20px;
        padding-right: 20px;
    }

    .terminal-body {
        padding: 16px;
        font-size: 0.75rem;
    }

    .footer-inner {
        flex-direction: column;
    }
}
