/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
    --bg: #f6f5f1;
    --bg-elev: #ffffff;
    --surface: #ecebe5;
    --text: #141413;
    --text-muted: #5f5e58;
    --border: rgb(20 20 19 / 0.1);
    --accent: #e8552d;
    --accent-ink: #ffffff;
    --glow-a: rgb(232 85 45 / 0.22);
    --glow-b: rgb(110 120 255 / 0.18);
    --nav-bg: rgb(246 245 241 / 0.72);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 12px 32px -12px rgb(0 0 0 / 0.12);

    --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-serif: "Instrument Serif", ui-serif, Georgia, serif;

    --radius: 28px;
    --radius-sm: 999px;
    --gutter: clamp(16px, 4vw, 40px);
    --max: 1200px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d0d0c;
        --bg-elev: #171715;
        --surface: #1c1c1a;
        --text: #f1f0ea;
        --text-muted: #9c9b93;
        --border: rgb(241 240 234 / 0.1);
        --accent: #ff6a3d;
        --accent-ink: #0d0d0c;
        --glow-a: rgb(255 106 61 / 0.18);
        --glow-b: rgb(110 120 255 / 0.16);
        --nav-bg: rgb(13 13 12 / 0.66);
        --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 16px 40px -16px rgb(0 0 0 / 0.6);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0d0d0c;
    --bg-elev: #171715;
    --surface: #1c1c1a;
    --text: #f1f0ea;
    --text-muted: #9c9b93;
    --border: rgb(241 240 234 / 0.1);
    --accent: #ff6a3d;
    --accent-ink: #0d0d0c;
    --glow-a: rgb(255 106 61 / 0.18);
    --glow-b: rgb(110 120 255 / 0.16);
    --nav-bg: rgb(13 13 12 / 0.66);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 16px 40px -16px rgb(0 0 0 / 0.6);
    color-scheme: dark;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 96px;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 17px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s, color 0.3s;
}

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

a {
    color: inherit;
}

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

h1,
h2,
h3,
p {
    margin: 0;
}

em {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    letter-spacing: -0.01em;
}

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

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

.container {
    width: 100%;
    max-width: var(--max);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.icon {
    width: 1em;
    height: 1em;
    flex: none;
}

.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-ink);
    text-decoration: none;
}

.skip-link:focus {
    top: 16px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    padding: 14px 24px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: 500 15px/1 var(--font-sans);
    text-decoration: none;
    transition: transform 0.3s var(--ease), background-color 0.2s, border-color 0.2s;
}

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

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

.btn-primary:hover {
    background: var(--accent);
    color: var(--accent-ink);
}

.btn-ghost {
    border-color: var(--border);
    background: var(--bg-elev);
}

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

.btn-sm {
    padding: 11px 18px;
    font-size: 14px;
}

.btn .icon {
    transition: transform 0.3s var(--ease);
}

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

/* ==========================================================================
   Navigation
   ========================================================================== */
.nav-wrap {
    position: fixed;
    inset: 16px 0 auto;
    z-index: 50;
    display: flex;
    justify-content: center;
    padding-inline: 16px;
    pointer-events: none;
}

.nav {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--nav-bg);
    backdrop-filter: blur(16px) saturate(1.6);
    -webkit-backdrop-filter: blur(16px) saturate(1.6);
    box-shadow: var(--shadow);
    pointer-events: auto;
}

.nav-brand {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--text);
    color: var(--bg);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 2px;
}

.nav-links a {
    display: block;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s, background-color 0.2s;
}

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

.theme-toggle {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
}

.theme-toggle:hover {
    background: var(--surface);
    color: var(--text);
}

.icon-sun {
    display: none;
}

:root[data-theme="dark"] .icon-sun {
    display: block;
}

:root[data-theme="dark"] .icon-moon {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-sun {
        display: block;
    }

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

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 100svh;
    padding-block: 140px 80px;
    overflow: hidden;
}

.hero-glow {
    position: absolute;
    inset: -20% -10% auto auto;
    width: min(900px, 120vw);
    aspect-ratio: 1;
    background:
        radial-gradient(closest-side at 35% 40%, var(--glow-a), transparent),
        radial-gradient(closest-side at 65% 60%, var(--glow-b), transparent);
    filter: blur(40px);
    pointer-events: none;
    animation: drift 18s ease-in-out infinite alternate;
}

@keyframes drift {
    to {
        transform: translate(-8%, 6%) rotate(20deg);
    }
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    padding: 7px 14px 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elev);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px var(--glow-a);
}

.hero-title {
    font-size: clamp(56px, 13vw, 168px);
    font-weight: 600;
    line-height: 0.92;
    letter-spacing: -0.055em;
}

.hero-title em {
    color: var(--accent);
    letter-spacing: -0.03em;
}

.hero-sub {
    max-width: 32ch;
    margin-top: 28px;
    color: var(--text-muted);
    font-size: clamp(19px, 2.2vw, 24px);
    line-height: 1.4;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 40px;
}

.stack {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    margin-top: 72px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 14px;
}

.stack li::before {
    content: "+";
    margin-right: 8px;
    color: var(--accent);
}

/* ==========================================================================
   Projects
   ========================================================================== */
.projects {
    padding-block: 80px 120px;
}

.section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 48px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.section-head h2 {
    font-size: clamp(40px, 7vw, 88px);
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.045em;
}

.section-head p {
    color: var(--text-muted);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.project {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    align-items: center;
    gap: clamp(24px, 5vw, 72px);
    padding: clamp(20px, 3vw, 32px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elev);
    box-shadow: var(--shadow);
}

.project + .project {
    margin-top: 24px;
}

.project:nth-of-type(even) .project-media {
    order: 2;
}

.project-media {
    display: grid;
    place-items: center;
    min-width: 0;
    margin: 0;
    padding: clamp(20px, 4vw, 48px);
    border-radius: calc(var(--radius) - 10px);
    background:
        radial-gradient(120% 80% at 50% 0%, var(--glow-a), transparent 60%),
        var(--surface);
    overflow: hidden;
}

.project-media img {
    transition: transform 0.8s var(--ease);
}

.project:hover .project-media img {
    transform: scale(1.04) translateY(-4px);
}

.project-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.project-meta span {
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.project h3 {
    margin-top: 12px;
    font-size: clamp(32px, 4vw, 52px);
    font-weight: 600;
    line-height: 1.02;
    letter-spacing: -0.04em;
}

.project h3 small {
    display: inline-block;
    margin-left: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

.project-text {
    max-width: 46ch;
    margin-top: 16px;
    color: var(--text-muted);
}

.project-text a {
    color: var(--text);
    text-decoration-color: var(--accent);
    text-underline-offset: 3px;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 20px;
}

.tags li {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
}

.project-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 20px;
    margin-top: 28px;
}

.team {
    color: var(--text-muted);
    font-size: 14px;
}

.team a {
    color: var(--text);
    text-decoration: none;
    background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat;
    transition: background-size 0.3s var(--ease);
}

.team a:hover {
    background-size: 100% 1px;
}

/* ==========================================================================
   Contact
   ========================================================================== */
.contact {
    padding-bottom: 80px;
}

.contact-card {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    padding: clamp(32px, 6vw, 72px);
    border-radius: var(--radius);
    background: var(--text);
    color: var(--bg);
    overflow: hidden;
}

.contact-card::before {
    content: "";
    position: absolute;
    inset: auto -10% -60% auto;
    width: 520px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(closest-side, var(--accent), transparent);
    opacity: 0.5;
    filter: blur(30px);
    pointer-events: none;
}

.contact-card h2 {
    position: relative;
    font-size: clamp(44px, 8vw, 104px);
    font-weight: 600;
    line-height: 0.95;
    letter-spacing: -0.05em;
}

.socials {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.socials a {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 22px;
    border: 1px solid color-mix(in srgb, var(--bg) 22%, transparent);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s, transform 0.3s var(--ease);
}

.socials a:hover {
    background: var(--bg);
    color: var(--text);
    transform: translateY(-2px);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
    padding-block: 32px 48px;
    color: var(--text-muted);
    font-size: 14px;
}

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

.footer ul {
    display: flex;
    gap: 20px;
}

.footer a {
    text-decoration: none;
}

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

/* ==========================================================================
   Reveal on scroll
   ========================================================================== */
.js .reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}

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

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 860px) {
    .project {
        grid-template-columns: minmax(0, 1fr);
    }

    .project:nth-of-type(even) .project-media {
        order: 0;
    }
}

@media (max-width: 560px) {
    body {
        font-size: 16px;
    }

    .nav-links a {
        padding: 9px 10px;
        font-size: 13px;
    }

    .nav-links li:nth-child(1) {
        display: none;
    }

    .stack {
        margin-top: 48px;
    }
}

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

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

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