/* ==========================================================================
   Design tokens
   ========================================================================== */

:root {
    --bg: #ffffff;
    --bg-alt: #f5f5f7;
    --surface: #ffffff;
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #a1a1a6;
    --border: rgba(0, 0, 0, 0.09);
    --border-strong: rgba(0, 0, 0, 0.18);
    --accent: #0066cc;
    --accent-hover: #004c99;
    --shadow-card-hover: 0 32px 64px -16px rgba(0, 0, 0, 0.14);
    --header-bg: rgba(255, 255, 255, 0.72);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --radius-card: 18px;
}

[data-theme="dark"] {
    --bg: #0a0a0a;
    --bg-alt: #161617;
    --surface: #161617;
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #6e6e73;
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.24);
    --accent: #2997ff;
    --accent-hover: #66b3ff;
    --shadow-card-hover: 0 32px 64px -16px rgba(0, 0, 0, 0.65);
    --header-bg: rgba(10, 10, 10, 0.72);
}

/* ==========================================================================
   Base
   ========================================================================== */

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    font-size: 1.0625rem;
    overflow-x: hidden;
    transition: background-color 0.45s ease, color 0.45s ease;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

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

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

section {
    scroll-margin-top: 72px;
}

.hidden {
    display: none !important;
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 clamp(1.25rem, 4vw, 2rem);
}

.container-sm {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 clamp(1.25rem, 4vw, 2rem);
}

.skip-link {
    position: absolute;
    top: -48px;
    left: 1rem;
    z-index: 200;
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 0 0 8px 8px;
    text-decoration: none;
    font-size: 0.875rem;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
}

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

/* ==========================================================================
   Header
   ========================================================================== */

#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: transparent;
    transition: background-color 0.4s ease, box-shadow 0.4s ease;
}

#header.scrolled {
    background: var(--header-bg);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    box-shadow: inset 0 -1px 0 var(--border);
}

.header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 clamp(1.25rem, 4vw, 2rem);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.wordmark {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.wordmark:hover {
    opacity: 0.7;
}

.desktop-nav {
    display: none;
    gap: 2.25rem;
}

.desktop-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 450;
    transition: color 0.3s ease;
}

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

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    transition: color 0.3s ease, background-color 0.3s ease;
}

.icon-btn:hover {
    color: var(--text);
    background: var(--bg-alt);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
:root:not([data-theme="dark"]) .icon-sun { display: none; }
:root:not([data-theme="dark"]) .icon-moon { display: block; }

.menu-btn {
    width: 36px;
    height: 36px;
    display: none;
    place-items: center;
    align-content: center;
    gap: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
}

.menu-btn span {
    display: block;
    width: 18px;
    height: 1.5px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.35s var(--ease-out);
}

.menu-btn[aria-expanded="true"] span:first-child {
    transform: translateY(3.75px) rotate(45deg);
}

.menu-btn[aria-expanded="true"] span:last-child {
    transform: translateY(-3.75px) rotate(-45deg);
}

.mobile-nav {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    background: var(--bg);
    padding: 2rem clamp(1.25rem, 4vw, 2rem);
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.35s var(--ease-out), transform 0.35s var(--ease-out);
}

.mobile-nav.open {
    opacity: 1;
    pointer-events: auto;
    transform: none;
}

.mobile-nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    padding: 1.1rem 0;
    border-bottom: 1px solid var(--border);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.45s var(--ease-out), transform 0.45s var(--ease-out);
}

.mobile-nav.open a {
    opacity: 1;
    transform: none;
}

.mobile-nav.open a:nth-child(1) { transition-delay: 0.05s; }
.mobile-nav.open a:nth-child(2) { transition-delay: 0.1s; }
.mobile-nav.open a:nth-child(3) { transition-delay: 0.15s; }
.mobile-nav.open a:nth-child(4) { transition-delay: 0.2s; }

@media (min-width: 820px) {
    .desktop-nav { display: flex; }
    .menu-btn, .mobile-nav { display: none !important; }
}

@media (max-width: 819px) {
    .menu-btn { display: grid; }
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    padding: 7rem 0 6rem;
}

.hero-eyebrow {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: 1.75rem;
}

.hero h1 {
    font-size: clamp(2.5rem, 7vw, 4.75rem);
    font-weight: 700;
    letter-spacing: -0.032em;
    line-height: 1.04;
    max-width: 17ch;
}

.hero-lede {
    margin-top: 1.75rem;
    font-size: clamp(1.125rem, 2vw, 1.3125rem);
    line-height: 1.55;
    color: var(--text-secondary);
    max-width: 34em;
}

.hero-actions {
    margin-top: 2.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.scroll-cue {
    position: absolute;
    bottom: 2.25rem;
    left: 50%;
    width: 1px;
    height: 56px;
    background: linear-gradient(var(--text-tertiary), transparent);
    overflow: hidden;
}

.scroll-cue::after {
    content: '';
    position: absolute;
    left: 0;
    top: -50%;
    width: 100%;
    height: 50%;
    background: var(--accent);
    animation: cue 2.4s var(--ease-out) infinite;
}

@keyframes cue {
    0% { top: -50%; }
    60%, 100% { top: 110%; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.6rem;
    border-radius: 980px;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: transform 0.35s var(--ease-out), background-color 0.3s ease, color 0.3s ease, box-shadow 0.35s var(--ease-out);
}

.btn svg {
    width: 15px;
    height: 15px;
    transition: transform 0.35s var(--ease-out);
}

.btn:hover svg {
    transform: translate(2px, -2px);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}

.btn-ghost:hover {
    background: var(--bg-alt);
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.arrow-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

.arrow-link svg {
    width: 14px;
    height: 14px;
    transition: transform 0.35s var(--ease-out);
}

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

.arrow-link:hover svg {
    transform: translate(2px, -2px);
}

/* ==========================================================================
   Sections
   ========================================================================== */

.section {
    padding: clamp(5rem, 11vw, 8.5rem) 0;
}

.section-alt {
    background: var(--bg-alt);
    transition: background-color 0.45s ease;
}

.eyebrow {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 1.25rem;
}

.section-title {
    font-size: clamp(1.875rem, 4.5vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.028em;
    line-height: 1.1;
    max-width: 22ch;
}

.section-lede {
    margin-top: 1.25rem;
    color: var(--text-secondary);
    max-width: 38em;
}

/* ==========================================================================
   About
   ========================================================================== */

.about-grid {
    margin-top: 3.5rem;
    display: grid;
    gap: 3rem;
}

.about-prose p {
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    max-width: 36em;
}

.about-prose p:first-child {
    color: var(--text);
    font-size: 1.1875rem;
    line-height: 1.6;
}

.fact-list {
    align-self: start;
    border-top: 1px solid var(--border);
}

.fact-list div {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.fact-list dt {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    white-space: nowrap;
}

.fact-list dd {
    color: var(--text);
    font-size: 0.9375rem;
    text-align: right;
    font-weight: 500;
}

@media (min-width: 900px) {
    .about-grid {
        grid-template-columns: 1.5fr 1fr;
        gap: 5rem;
    }
}

/* ==========================================================================
   Projects
   ========================================================================== */

.project-grid {
    margin-top: 4rem;
    display: grid;
    gap: 1.75rem;
}

@media (min-width: 900px) {
    .project-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .project-card.span-2 {
        grid-column: span 2;
    }
}

.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.5s var(--ease-out), box-shadow 0.5s var(--ease-out), border-color 0.4s ease;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-card-hover);
    border-color: transparent;
}

.project-media {
    display: block;
    overflow: hidden;
    background: var(--bg-alt);
}

.project-media img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    object-position: top left;
    transition: transform 0.8s var(--ease-out);
}

.span-2 .project-media img {
    aspect-ratio: 21 / 9;
}

.project-card:hover .project-media img {
    transform: scale(1.025);
}

.project-body {
    padding: 1.75rem 1.75rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    flex: 1;
}

.project-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.project-head h3 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.project-head h3 a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.3s ease;
}

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

.project-index {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.project-body > p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.tag-row {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-row li {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.71875rem;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
    padding: 0.28rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 980px;
}

.project-body .arrow-link {
    margin-top: auto;
    padding-top: 0.5rem;
}

.side-works {
    margin-top: 4.5rem;
}

.side-title {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 0.75rem;
}

.work-list {
    list-style: none;
    border-top: 1px solid var(--border);
}

.work-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 2rem;
    padding: 1.4rem 0;
    border-bottom: 1px solid var(--border);
    transition: padding-left 0.4s var(--ease-out);
}

.work-list li:hover {
    padding-left: 0.5rem;
}

.work-list h4 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.work-list p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.2rem;
    max-width: 52ch;
}

.work-tags {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.71875rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* ==========================================================================
   Skills
   ========================================================================== */

.skill-columns {
    margin-top: 3.5rem;
    display: grid;
    gap: 2.5rem;
}

@media (min-width: 820px) {
    .skill-columns {
        grid-template-columns: repeat(3, 1fr);
    }
}

.skill-group h3 {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 1.1rem;
}

.skill-group ul {
    list-style: none;
}

.skill-group li {
    padding: 0.85rem 0;
    border-top: 1px solid var(--border);
    transition: color 0.3s ease, padding-left 0.4s var(--ease-out);
}

.skill-group li:hover {
    padding-left: 0.4rem;
    color: var(--accent);
}

/* ==========================================================================
   Philosophy
   ========================================================================== */

.philosophy blockquote p {
    font-size: clamp(1.5rem, 3.5vw, 2.25rem);
    font-weight: 600;
    letter-spacing: -0.024em;
    line-height: 1.3;
    max-width: 26ch;
}

.method-steps {
    list-style: none;
    margin-top: 3.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 2.5rem;
}

.method-steps li {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
}

.method-steps span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent);
}

/* ==========================================================================
   Contact
   ========================================================================== */

.contact-grid {
    margin-top: 3.5rem;
    display: grid;
    gap: 3.5rem;
}

@media (min-width: 900px) {
    .contact-grid {
        grid-template-columns: 1.2fr 1fr;
        gap: 5rem;
    }
}

.field {
    margin-bottom: 1.4rem;
}

.field label {
    display: block;
    font-size: 0.84375rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
}

.field input,
.field textarea {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(41, 151, 255, 0.15);
}

[data-theme="dark"] .field input:focus,
[data-theme="dark"] .field textarea:focus {
    box-shadow: 0 0 0 3px rgba(41, 151, 255, 0.22);
}

.field textarea {
    resize: vertical;
    min-height: 130px;
}

.contact-side > p {
    color: var(--text-secondary);
    max-width: 30em;
}

.contact-links {
    list-style: none;
    margin-top: 1.75rem;
    border-top: 1px solid var(--border);
}

.contact-links a {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    transition: padding-left 0.4s var(--ease-out);
}

.contact-links a:hover {
    padding-left: 0.5rem;
}

.contact-links .label {
    font-weight: 600;
    color: var(--text);
}

.contact-links .value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78125rem;
    color: var(--accent);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
    border-top: 1px solid var(--border);
    padding: 3.5rem 0;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
}

.footer-brand p {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    max-width: 26ch;
}

.footer-nav {
    display: flex;
    gap: 1.75rem;
}

.footer-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.3s ease;
}

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

.footer-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

.admin-dot {
    color: var(--text-tertiary);
    text-decoration: none;
    opacity: 0.6;
}

.admin-dot:hover {
    opacity: 1;
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    left: 2rem;
    max-width: 380px;
    margin-left: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.35rem;
    box-shadow: var(--shadow-card-hover);
    z-index: 150;
    animation: toast-in 0.5s var(--ease-out);
}

.toast-content h4 {
    font-size: 0.9375rem;
    font-weight: 600;
}

.toast-content p {
    color: var(--text-secondary);
    font-size: 0.84375rem;
    margin-top: 0.15rem;
}

@keyframes toast-in {
    from {
        transform: translateY(16px);
        opacity: 0;
    }
    to {
        transform: none;
        opacity: 1;
    }
}

/* ==========================================================================
   Reveal animations
   ========================================================================== */

.js .reveal {
    opacity: 0;
    transform: translateY(26px);
    transition: opacity 0.85s var(--ease-out), transform 0.85s var(--ease-out);
    will-change: opacity, transform;
}

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

.delay-1 { transition-delay: 0.08s; }
.delay-2 { transition-delay: 0.16s; }
.delay-3 { transition-delay: 0.24s; }
.delay-4 { transition-delay: 0.32s; }

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *,
    *::before,
    *::after {
        animation-duration: 0.001s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001s !important;
        transition-delay: 0s !important;
    }
    .reveal,
    .js .reveal {
        opacity: 1;
        transform: none;
    }
}

