/* Layout: strict monochrome, one wide column, hairline rules, big type; color only appears in project logos on hover */
:root {
    --bg: #0a0a0a;
    --bg-2: #111111;
    --fg: #f5f5f5;
    --muted: #9a9a9a;
    --faint: #5c5c5c;
    --line: #242424;
    --invert-bg: #f5f5f5;
    --invert-fg: #0a0a0a;
    --live: #f5f5f5;
    --discord: #5865f2;
    --discord-ink: #8b94ff;
    --github: #24292f;
    --github-ink: #ffffff;
    --fun: #f5b83d;
    --invert-muted: #5f5f5f;

    --font: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
    --wrap: 1200px;
    --ease: cubic-bezier(.2, .8, .2, 1);
    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #ffffff;
        --bg-2: #f4f4f4;
        --fg: #0a0a0a;
        --muted: #5e5e5e;
        --faint: #a3a3a3;
        --line: #e4e4e4;
        --invert-bg: #0a0a0a;
        --invert-fg: #ffffff;
        --live: #0a0a0a;
        --discord-ink: #4752c4;
        --github: #ffffff;
        --github-ink: #24292f;
        --fun: #8a5a0c;
        --invert-muted: #9a9a9a;
        color-scheme: light;
    }
}

:root[data-theme="light"] {
    --bg: #ffffff;
    --bg-2: #f4f4f4;
    --fg: #0a0a0a;
    --muted: #5e5e5e;
    --faint: #a3a3a3;
    --line: #e4e4e4;
    --invert-bg: #0a0a0a;
    --invert-fg: #ffffff;
    --live: #0a0a0a;
    --discord-ink: #4752c4;
    --github: #ffffff;
    --github-ink: #24292f;
    --fun: #8a5a0c;
    --invert-muted: #9a9a9a;
    color-scheme: light;
}

/* ==================== BASE ==================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: inherit; }
svg { display: block; flex-shrink: 0; }
img { max-width: 100%; }

:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--fg); color: var(--bg); }

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding-left: max(24px, env(safe-area-inset-left, 0px));
    padding-right: max(24px, env(safe-area-inset-right, 0px));
}

.skip-link {
    position: absolute; left: 16px; top: -60px; z-index: 100;
    padding: 10px 16px; background: var(--fg); color: var(--bg); font-weight: 600; border-radius: 6px;
}
.skip-link:focus { top: 12px; }

.dot {
    position: relative;
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--live);
}

.label {
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 50px;
    padding: 0 22px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: background .2s, color .2s, border-color .2s, transform .15s;
    white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-sm { min-height: 38px; padding: 0 16px; font-size: 14px; }
.btn-solid { background: var(--invert-bg); color: var(--invert-fg); }
.btn-solid:hover { background: var(--muted); }
.btn-line { border-color: var(--line); color: var(--fg); }
.btn-line:hover { border-color: var(--fg); }

/* ==================== NAV ==================== */
body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    height: env(safe-area-inset-top, 0px);
    z-index: 60;
    background: var(--bg);
}

.nav {
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 50;
    border-bottom: 1px solid transparent;
    transition: background .3s, border-color .3s;
}
.nav.scrolled {
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-bottom-color: var(--line);
}

.nav-inner { display: flex; align-items: center; gap: 24px; height: 68px; }

.logo { font-weight: 700; font-size: 20px; letter-spacing: -0.04em; }
.logo-dot { color: var(--muted); }

.nav-links { position: relative; display: flex; gap: 2px; margin-left: auto; font-size: 15px; }
.nav-links a { position: relative; z-index: 1; padding: 7px 14px; color: var(--muted); transition: color .2s; }
.nav-links a:hover, .nav-links a.active { color: var(--fg); }
.nav-indicator {
    position: absolute; top: 0; left: 0; height: 100%; width: 0;
    border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line);
    opacity: 0;
    transition: transform .45s var(--ease), width .45s var(--ease), opacity .3s;
}

.nav-actions { display: flex; align-items: center; gap: 8px; }
.lang-btn {
    height: 38px; min-width: 44px; padding: 0 12px;
    border-radius: 999px; border: 1px solid var(--line);
    font-family: var(--mono); font-size: 13px; color: var(--muted);
    transition: color .2s, border-color .2s;
}
.lang-btn:hover { color: var(--fg); border-color: var(--fg); }

/* ==================== HERO ==================== */
/* Behind the headline: a slow terrain of square "blocks" drawn in code (script.js, initField).
   It is plain monochrome geometry, no footage; the gradient keeps the type side calm. */
.hero { position: relative; margin-top: -68px; }
.hero-stage {
    position: relative;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}
.hero-content { position: relative; z-index: 1; padding-block: calc(68px + clamp(40px, 7vw, 96px)) clamp(48px, 7vw, 88px); }

.hero-field { position: absolute; inset: 0; }
/* Background loop: moonlit sea rendered as LED squares. Black footage, so "screen" drops the black
   on dark theme; on light theme it is inverted and multiplied, giving dark squares on white. */
.hero-field video {
    position: absolute; top: 0; left: 38%; width: 70%; height: 100%;
    object-fit: cover; object-position: 50% 50%;
    mix-blend-mode: screen; opacity: 0; transition: opacity 1.6s var(--ease);
}
.hero-field video.ready { opacity: .7; }
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .hero-field video { filter: invert(1); mix-blend-mode: multiply; }
}
:root[data-theme="light"] .hero-field video { filter: invert(1); mix-blend-mode: multiply; }
@media (max-width: 900px) {
    .hero-field video { left: 0; width: 100%; }
}
.hero-field::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 70%, transparent) 30%, transparent 62%),
        linear-gradient(0deg, var(--bg) 0%, transparent 22%);
}
@media (max-width: 900px) {
    .hero-field::after { background: linear-gradient(0deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 55%, transparent) 60%, color-mix(in srgb, var(--bg) 30%, transparent) 100%); }
}

.eyebrow { display: inline-flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 13px; color: var(--muted); }

.hero-title {
    margin-top: 28px;
    font-size: clamp(56px, 11.5vw, 168px);
    font-weight: 700;
    line-height: .92;
    letter-spacing: -0.06em;
}
.hero-title .line { display: block; overflow: hidden; padding-bottom: .06em; margin-bottom: -.06em; }
.hero-title .line > span { display: inline-block; }
.hero-title .line:last-child > span { color: var(--muted); }

.hero-bottom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 32px 64px;
    align-items: end;
    margin-top: clamp(32px, 5vw, 56px);
    padding-top: clamp(24px, 3vw, 32px);
    border-top: 1px solid var(--line);
}
.hero-lead { max-width: 46ch; font-size: clamp(18px, 1.7vw, 21px); line-height: 1.5; color: var(--muted); text-wrap: pretty; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }

/* ==================== STATS ==================== */
.stats { border-block: 1px solid var(--line); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-block: clamp(24px, 3.5vw, 40px);
    padding-inline: clamp(16px, 2.5vw, 32px);
    border-left: 1px solid var(--line);
}
.stat:first-child { border-left: 0; padding-left: 0; }
.stat-num {
    font-size: clamp(36px, 4.6vw, 60px);
    font-weight: 700;
    letter-spacing: -0.05em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 14px; color: var(--muted); }

/* ==================== SECTIONS ==================== */
.section { padding-block: clamp(72px, 9vw, 128px); border-bottom: 1px solid var(--line); }
.section-head { display: grid; gap: 14px; margin-bottom: clamp(32px, 5vw, 56px); }
.section-title {
    font-size: clamp(34px, 5vw, 64px);
    font-weight: 700;
    line-height: 1.02;
    letter-spacing: -0.05em;
    max-width: 16ch;
    text-wrap: balance;
}
.section-lead { max-width: 40ch; color: var(--muted); }

/* ==================== WORK ==================== */
.work { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

.project {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    background: var(--bg);
    transition: border-color .3s, transform .4s var(--ease);
}
.project:hover { border-color: var(--faint); transform: translateY(-4px); }

.project-lg { grid-column: 1 / -1; flex-direction: row; }
.project-lg .project-media { flex: 1.1 1 0; aspect-ratio: auto; min-height: 340px; border-bottom: 0; border-right: 1px solid var(--line); }
.project-lg .project-body { flex: 1 1 0; justify-content: center; padding: clamp(28px, 4vw, 56px); }
.project-lg .project-title { font-size: clamp(30px, 3.4vw, 44px); }

.project-media {
    position: relative;
    aspect-ratio: 16 / 10;
    max-width: 100%;
    background:
        radial-gradient(color-mix(in srgb, var(--fg) 10%, transparent) 1px, transparent 1.5px) 0 0 / 18px 18px,
        var(--bg-2);
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}
.project-media img {
    position: absolute;
    inset: 18%;
    width: 64%;
    height: 64%;
    object-fit: contain;
    filter: drop-shadow(0 14px 28px rgba(0, 0, 0, .35));
    transition: transform .6s var(--ease);
}
.project-media img.pixel { image-rendering: pixelated; inset: 26%; width: 48%; height: 48%; }
.project:hover .project-media img { transform: scale(1.05) rotate(-1deg); }

/* Cover art: an LED-dot scene behind the logo, same square-dot language as the hero field. */
.project-media.has-cover { background: #0a0a0a; }
.project-media img.cover {
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: none;
    transition: transform 1.2s var(--ease), filter .6s var(--ease);
}
.project-media.has-cover::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(0, 0, 0, .62) 0%, rgba(0, 0, 0, .25) 45%, transparent 70%);
    pointer-events: none;
}
.project-media img.logo,
.project-media img.logo.pixel {
    z-index: 1;
    inset: 22% auto 22% 7%;
    width: 36%;
    height: 56%;
    object-fit: contain;
    object-position: left center;
}
.project-media img.logo.pixel { width: 30%; }
/* the TotemSMP scene already is the logo, so it shows without an overlay or darkening */
.project-media.has-cover:has(.cover-solo)::after { display: none; }
.project-media img.cover-solo { object-position: 70% 50%; }
.project:hover .project-media img.cover { transform: scale(1.04); }
.project:hover .project-media img.logo { transform: scale(1.04) rotate(-1deg); }

.project-body { display: flex; flex-direction: column; gap: 12px; padding: 24px 24px 28px; flex: 1; }
.project-meta {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
    font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.tag { display: inline-flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 13px; }
.tag .dot { width: 6px; height: 6px; }
.project-title { font-size: clamp(24px, 2.4vw, 30px); font-weight: 700; letter-spacing: -0.04em; line-height: 1.1; }
.project-desc { color: var(--muted); max-width: 46ch; }

.stack { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.stack li {
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
}

.link-arrow {
    display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
    margin-top: auto; padding-top: 12px;
    font-size: 15px; font-weight: 600;
}
.link-arrow span { background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .35s var(--ease); }
.link-arrow:hover span { background-size: 100% 1px; }
.link-arrow svg { transition: transform .3s var(--ease); }
.link-arrow:hover svg { transform: translate(2px, -2px); }

/* ==================== SKILLS ==================== */
.skills {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
}
.skill {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 16px;
    align-items: center;
    padding: 22px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    transition: background .25s;
}
.skill:hover { background: var(--bg-2); }
.skill-icon {
    grid-row: span 2;
    width: 44px;
    height: 44px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    fill: var(--fg);
    transition: background .25s, fill .25s, border-color .25s, transform .3s var(--ease);
}
.skill:hover .skill-icon { background: var(--invert-bg); fill: var(--invert-fg); border-color: var(--invert-bg); transform: rotate(-4deg); }
.skill-name { font-weight: 600; font-size: 16px; line-height: 1.3; }
.skill-note { font-size: 14px; color: var(--muted); line-height: 1.35; }

/* ==================== SERVICES ==================== */
.services-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 40px clamp(40px, 7vw, 120px); align-items: start; }
.sticky-head { position: sticky; top: 110px; margin-bottom: 0; }
.services { border-top: 1px solid var(--line); }
.service {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px 16px;
    padding-block: 28px;
    border-bottom: 1px solid var(--line);
    transition: padding-left .35s var(--ease);
}
.service h3 { font-size: clamp(20px, 2vw, 24px); font-weight: 600; letter-spacing: -0.03em; }
.service p { color: var(--muted); max-width: 48ch; }
.service:hover { padding-left: 10px; }

/* ==================== CONTACT ==================== */
.contact { background: var(--invert-bg); color: var(--invert-fg); padding-block: clamp(72px, 10vw, 140px); }
.contact .label { color: var(--invert-muted); }
.contact-title {
    margin-top: 16px;
    font-size: clamp(40px, 7vw, 104px);
    font-weight: 700;
    line-height: .98;
    letter-spacing: -0.055em;
    max-width: 14ch;
    text-wrap: balance;
}
.contact-rows { margin-top: clamp(40px, 6vw, 72px); border-top: 1px solid color-mix(in srgb, var(--invert-fg) 20%, var(--invert-bg)); }
.contact-row {
    width: 100%;
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding-block: 22px;
    border-bottom: 1px solid color-mix(in srgb, var(--invert-fg) 20%, var(--invert-bg));
    transition: padding-left .35s var(--ease);
}
.contact-row:hover { padding-left: 12px; }
.row-label { font-family: var(--mono); font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--invert-muted); }
.row-value { font-size: clamp(22px, 3vw, 36px); font-weight: 600; letter-spacing: -0.04em; overflow-wrap: anywhere; }
.row-action {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--invert-fg) 30%, var(--invert-bg));
    font-size: 14px;
    font-weight: 600;
    transition: background .2s, color .2s;
}
.contact-row:hover .row-action { background: var(--invert-fg); color: var(--invert-bg); }

/* ==================== FOOTER ==================== */
.footer { padding-block: 28px 36px; font-size: 14px; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px; }
.footer a:hover { color: var(--fg); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
    .hero-bottom { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat:nth-child(3) { border-left: 0; padding-left: 0; }
    .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
    .project-lg { flex-direction: column; }
    .project-lg .project-media { min-height: 0; aspect-ratio: 16 / 10; border-right: 0; border-bottom: 1px solid var(--line); flex: none; }
    .skills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .services-grid { grid-template-columns: 1fr; }
    .sticky-head { position: static; }
}

@media (max-width: 640px) {
    body { font-size: 16px; }
    .wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
    .nav-links { display: none; }
    .nav-actions { margin-left: auto; }
    .hero-cta .btn { flex: 1 1 100%; }
    .work { grid-template-columns: 1fr; }
    .skills { grid-template-columns: 1fr; }
    .contact-row { grid-template-columns: minmax(0, 1fr) auto; }
    .row-label { grid-column: 1 / -1; }
}

/* ==================== MOTION ==================== */
@media (prefers-reduced-motion: no-preference) {
    @keyframes up { from { transform: translateY(105%); } to { transform: none; } }
    @keyframes fade { from { opacity: .001; transform: translateY(12px); } to { opacity: 1; transform: none; } }

    .hero-title .line > span { animation: up 1s var(--ease) both; }
    .hero-title .line:nth-child(2) > span { animation-delay: .09s; }
    .eyebrow { animation: fade .6s var(--ease) both; }
    .hero-bottom { animation: fade .8s var(--ease) .35s both; }
    .stats .stat { animation: fade .8s var(--ease) both; }
    .stats .stat:nth-child(1) { animation-delay: .45s; }
    .stats .stat:nth-child(2) { animation-delay: .52s; }
    .stats .stat:nth-child(3) { animation-delay: .59s; }
    .stats .stat:nth-child(4) { animation-delay: .66s; }

    .dot::after {
        content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--live);
        animation: ping 2.4s cubic-bezier(0, 0, .2, 1) infinite;
    }
    @keyframes ping { 0% { transform: scale(1); opacity: .5; } 80%, 100% { transform: scale(2.8); opacity: 0; } }

    /* Scroll reveal, applied by script only below the first screen */
    .pre > * {
        opacity: .001;
        transform: translateY(20px);
        transition: opacity .8s var(--ease), transform .8s var(--ease);
        transition-delay: calc(var(--i, 0) * 70ms);
    }
    .pre.in > * { opacity: 1; transform: none; }

    .section-title .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .08em; margin-bottom: -.08em; }
    .section-title .w > span { display: inline-block; }
    .title-pre .w > span { transform: translateY(105%); transition: transform .9s var(--ease); transition-delay: calc(var(--w) * 45ms); }
    .title-pre.in .w > span { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ==================== BRAND COLOR ==================== */
.btn-discord { background: var(--discord); color: #ffffff; }
.btn-discord:hover { background: #4752c4; }
.link-discord { color: var(--discord-ink); }
.tag-fun {
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--fun) 45%, transparent);
    background: color-mix(in srgb, var(--fun) 12%, transparent);
    color: var(--fun);
}

/* Contact rows: brand tile + name */
.contact-row { grid-template-columns: auto minmax(0, 1fr) auto; gap: 20px; }
.row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    transition: transform .35s var(--ease);
}
.contact-row:hover .row-icon { transform: rotate(-6deg) scale(1.05); }
.row-icon-discord { background: var(--discord); color: #ffffff; }
.row-icon-github { background: var(--github); color: var(--github-ink); }
.contact-discord .row-action { background: var(--discord); border-color: var(--discord); color: #ffffff; }
.contact-discord:hover .row-action { background: #4752c4; border-color: #4752c4; color: #ffffff; }
.contact-github .row-action { background: var(--github); border-color: var(--github); color: var(--github-ink); }
.contact-github:hover .row-action { background: var(--github); color: var(--github-ink); opacity: .85; }
@media (max-width: 640px) {
    .contact-row { grid-template-columns: auto minmax(0, 1fr) auto; }
    .row-label { grid-column: auto; }
    .row-icon { width: 48px; height: 48px; border-radius: 12px; }
}

.link-row { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: auto; padding-top: 12px; }
.link-row .link-arrow { margin-top: 0; padding-top: 0; }
