/* Design tokens */
:root {
    --primary: hsl(127 55% 56%);
    --primary-light: hsl(127 58% 72%);
    --primary-container: hsl(127 36% 22%);
    --on-primary-container: hsl(127 70% 88%);
    --bg: hsl(0 0% 8%);
    --surface: hsl(0 0% 11%);
    --surface-2: hsl(0 0% 13%);
    --surface-3: hsl(0 0% 16%);
    --outline: hsl(0 0% 30%);
    --outline-variant: hsl(0 0% 23%);
    --text: hsl(0 0% 95%);
    --muted: hsl(0 0% 76%);
    --state-hover: hsl(127 58% 72% / 0.1);
    --state-focus: hsl(127 58% 72% / 0.16);
    --font-body: 'Manrope', 'Inter', system-ui, sans-serif;
    --font-display: 'Sora', 'Manrope', 'Inter', system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

*::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

html,
body,
main {
    width: 100%;
    min-height: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--text);
    background: linear-gradient(180deg, hsl(0 0% 10%), var(--bg) 30%);
    overflow-x: hidden;
}

main {
    padding-bottom: 0;
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Page + scroll behavior */
html.lenis,
html.lenis body {
    height: auto;
}

html:not(.lenis) {
    scroll-behavior: smooth;
}

.lenis.lenis-smooth {
    scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
    overscroll-behavior: contain;
}

.lenis.lenis-stopped {
    overflow: hidden;
}

.lenis.lenis-scrolling iframe {
    pointer-events: none;
}

/* Shared section shell */
.window {
    width: min(1380px, 100%);
    margin-inline: auto;
    padding: clamp(56px, 10vh, 120px) clamp(20px, 4.6vw, 72px);
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-margin-top: 20px;
    position: relative;
    transform: translateZ(0);
    backface-visibility: hidden;
}

#home {
    position: relative;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    justify-content: center;
}

#home .home-grid {
    position: relative;
    z-index: 2;
}

.window#technologies {
    padding-bottom: clamp(18px, 3vh, 34px);
}

.window:not(#home) {
    padding-top: clamp(36px, 6.6vh, 80px);
}

.window + .window::before {
    content: '';
    width: 100%;
    height: 1px;
    margin-bottom: 8px;
    background: linear-gradient(90deg, transparent, hsl(0 0% 30% / 0.75), transparent);
}

/* Hero background */
.hero-background {
    position: absolute;
    top: 0;
    left: 50%;
    width: 100vw;
    height: 100%;
    z-index: 0;
    opacity: calc(var(--hero-bg-opacity, 0) * 0.18);
    pointer-events: none;
    transform: translateX(-50%);
    transition: opacity 0.2s linear;
}

.hero-background.active {
    --hero-bg-opacity: 1;
}

/* Grid layouts */
.home-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
    gap: clamp(18px, 2.4vw, 36px);
    align-items: start;
}

.home-copy {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.project-grid,
.blog-grid,
.work-grid {
    display: grid;
    gap: 20px;
    margin-top: 10px;
}

.project-grid,
.blog-grid {
    grid-template-columns: 1fr;
}

.project-grid {
    max-width: 1220px;
    margin-inline: auto;
}

.work-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

:is(#projects, #blog, #work, #technologies) {
    align-items: stretch;
}

.site-footer {
    width: min(1380px, 100%);
    margin: 0 auto;
    padding: 6px clamp(20px, 4.6vw, 72px) 112px;
    text-align: center;
    color: var(--muted);
    display: block;
}

.site-footer-line {
    margin: 0;
    font-family: var(--mono);
    font-size: 0.76rem;
    letter-spacing: 0.04em;
    line-height: 1.4;
}

/* Shared typography */
.window h1,
.window h2 {
    font-family: var(--font-display);
    font-weight: 700;
}

.window h1 {
    font-size: clamp(2.6rem, 5.1vw, 4rem);
    color: var(--primary);
    line-height: 1.02;
    letter-spacing: -0.01em;
}

.window h3 {
    font-size: 0.98rem;
    color: var(--muted);
    letter-spacing: 0;
    font-weight: 500;
}

.hero-kicker {
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    font-family: var(--mono);
}

.description {
    max-width: 70ch;
    color: var(--muted);
    line-height: 1.74;
    font-size: 1rem;
}

/* Home section typography */
#home .hero-kicker {
    margin-bottom: -4px;
}

#home .window-title {
    font-size: clamp(2.9rem, 5.8vw, 4.5rem);
    line-height: 1;
    letter-spacing: -0.015em;
}

#home .window-subtitle {
    font-family: var(--font-body);
    font-size: 1.02rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: hsl(0 0% 82%);
    line-height: 1.35;
    margin-top: -2px;
}

#home .description {
    max-width: 60ch;
    margin-top: 8px;
    line-height: 1.68;
}

#home .window-title,
#home .window-subtitle,
#home .hero-kicker,
#home .description {
    text-align: left;
}

:is(#projects, #blog, #work, #technologies) .description {
    max-width: 84ch;
}

/* Card typography */
.project-title,
.blog-title,
.work-title {
    font-size: clamp(1.16rem, 1.5vw, 1.36rem);
    font-family: var(--font-display);
    font-weight: 650;
    line-height: 1.22;
    letter-spacing: 0;
    color: var(--text);
}

.project-description,
.work-description {
    font-size: 0.96rem;
    line-height: 1.7;
    color: var(--muted);
    max-width: 66ch;
}

.blog-meta,
.work-meta {
    font-size: 0.66rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    font-family: var(--mono);
}

.blog-excerpt {
    font-size: 0.98rem;
    line-height: 1.72;
    color: var(--muted);
    max-width: 78ch;
}

/* Tech name */
.tech-name {
    font-size: 0.74rem;
    color: var(--muted);
    font-family: var(--mono);
    letter-spacing: 0.02em;
}

.tech-group-label {
    padding-top: 8px;
    border-top: 1px solid var(--outline-variant);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* Card base styles */
.project-card,
.blog-card,
.work-card {
    border: 1px solid var(--outline-variant);
    border-radius: 16px;
    background: var(--surface-2);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    overflow: hidden;
    box-shadow:
        inset 0 1px 0 hsl(0 0% 100% / 0.02),
        0 10px 28px hsl(0 0% 0% / 0.16);
    transition: none;
}

.project-header,
.blog-header,
.work-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 2px;
}

.work-heading {
    display: grid;
    gap: 2px;
}

/* Tags */
.project-tags,
.blog-tags,
.work-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 2px;
    align-items: center;
    order: 2;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid hsl(127 34% 34% / 0.9);
    background: hsl(127 26% 18%);
    color: hsl(127 42% 80%);
    font-size: 0.66rem;
    line-height: 1;
    letter-spacing: 0.045em;
    font-family: var(--mono);
    min-height: 24px;
    box-shadow: inset 0 1px 0 hsl(0 0% 100% / 0.03);
}

/* Project specific */
.project-media {
    width: 100%;
    aspect-ratio: 16 / 6.5;
    min-height: 120px;
    max-height: 220px;
    border-radius: 12px;
    border: 1px solid hsl(0 0% 100% / 0.06);
    background: var(--surface-3);
    position: relative;
    order: 3;
    overflow: hidden;
    box-shadow:
        inset 0 1px 0 hsl(0 0% 100% / 0.02),
        inset 0 0 0 1px hsl(0 0% 0% / 0.15);
}

.project-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    display: block;
}

.project-media:empty::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, hsl(0 0% 100% / 0.02) 1px, transparent 1px),
        linear-gradient(0deg, hsl(0 0% 100% / 0.02) 1px, transparent 1px);
    background-size: 18px 18px;
    opacity: 0.55;
}

.project-media:empty::after {
    content: 'Image';
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font: 500 0.72rem/1 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: hsl(0 0% 74%);
    text-shadow: 0 1px 0 hsl(0 0% 0% / 0.35);
}

.project-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: auto;
    padding: 8px 12px;
    font: 600 0.72rem/1 var(--font-body);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text);
    text-decoration: none;
    border: 1px solid var(--outline);
    border-radius: 999px;
    background: var(--surface-3);
    transition:
        color 0.2s ease,
        background 0.2s ease,
        border-color 0.2s ease;
}

a.project-link:hover {
    color: var(--on-primary-container);
    background: var(--primary-container);
    border-color: transparent;
}

a.project-link:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 3px;
}

.project-link-inline {
    margin-top: 0;
    white-space: nowrap;
    align-self: flex-start;
    box-shadow: inset 0 1px 0 hsl(0 0% 100% / 0.02);
}

.project-link-muted {
    color: var(--muted);
}

/* Highlights (shared between projects & work) */
.project-highlights,
.work-highlights {
    list-style: none;
    display: grid;
    gap: 10px;
    margin-top: 6px;
    padding-top: 14px;
    border-top: 1px solid var(--outline);
}

.project-highlights li,
.work-highlights li {
    position: relative;
    padding-left: 16px;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.56;
}

.project-highlights li::before,
.work-highlights li::before {
    content: '';
    position: absolute;
    top: 0.58em;
    left: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
}

/* Interactive card states */
.project-card:focus-within,
.blog-card:focus-within,
.work-card:focus-within {
    border-color: hsl(127 30% 38%);
    background: var(--surface-3);
    box-shadow:
        inset 0 1px 0 hsl(0 0% 100% / 0.03),
        0 0 0 1px hsl(127 38% 34% / 0.18),
        0 12px 28px hsl(0 0% 0% / 0.2);
}

/* Contact panel */
.contact-panel {
    border-radius: 16px;
    background: var(--surface-2);
    padding: 18px 16px;
    transition: border-color 0.2s ease;
}

.contact-panel:focus-within {
    border-color: var(--outline);
    background: var(--surface-3);
}

.contact-title {
    font-family: var(--font-display);
    font-size: 0.98rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text);
    margin-bottom: 12px;
}

.contact-list {
    list-style: none;
    display: grid;
    gap: 10px;
}

.contact-item {
    display: grid;
    grid-template-columns: 102px minmax(0, 1fr);
    align-items: center;
    gap: 10px 12px;
    padding: 9px 12px;
    border-radius: 12px;
    background: var(--surface-3);
}

.contact-item:focus-within {
    border-color: var(--outline);
    background: hsl(150 8% 20%);
}

.contact-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: hsl(0 0% 80%);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    font-family: var(--font-body);
    font-weight: 600;
}

.contact-icon {
    width: 14px;
    height: 14px;
}

.contact-link {
    display: block;
    color: var(--text);
    font-size: 0.9rem;
    text-decoration: none;
    line-height: 1.34;
    overflow-wrap: anywhere;
    min-width: 0;
    transition: color 0.15s ease;
}

.contact-link:hover,
.contact-link:focus {
    color: var(--primary-light);
}

.contact-link:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Navigation */
.dockbar {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%) translateZ(0);
    z-index: 30;
    display: flex;
    gap: 6px;
    padding: 8px;
    border-radius: 20px;
    border: 1px solid var(--outline-variant);
    background: var(--surface-2);
    will-change: transform;
    backface-visibility: hidden;
}

.nav-button {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease;
}

.nav-button::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--state-hover);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.nav-button::after {
    content: '';
    position: absolute;
    inset: 7px 6px;
    border-radius: 999px;
    background: var(--primary-container);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.nav-button:hover,
.nav-button:focus {
    color: var(--text);
}

.nav-button:hover::before,
.nav-button:focus::before {
    opacity: 1;
}

.nav-button:focus-visible::before {
    opacity: 1;
    background: var(--state-focus);
}

.nav-button:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

.nav-button[aria-current='location'] {
    color: var(--on-primary-container);
}

.nav-button[aria-current='location']::after {
    opacity: 1;
}

.icon {
    width: 19px;
    height: 19px;
    stroke: currentColor;
    position: relative;
    z-index: 1;
}

/* Technologies */
.technology-groups {
    margin-top: 10px;
    display: grid;
    gap: 14px;
}

.tech-group {
    display: grid;
    gap: 10px;
}

.tech-group:first-child .tech-group-label {
    padding-top: 0;
    border-top: 0;
}

.technologies-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.technology-card {
    display: grid;
    place-items: center;
    gap: 8px;
    text-align: center;
    flex: 0 1 128px;
    min-height: 96px;
    border-radius: 14px;
    background: var(--surface-2);
    padding: 14px 10px;
}

.contact-panel,
.contact-item,
.technology-card {
    border: 1px solid var(--outline-variant);
}

.contact-item,
.technology-card {
    transition:
        border-color 0.2s ease,
        background 0.2s ease;
}

.technology-card i {
    font-size: 33px;
}

/* Responsive */
@media (max-width: 1240px) {
    .home-grid {
        grid-template-columns: 1fr;
    }

    #home {
        min-height: 100vh;
        min-height: 100svh;
        min-height: 100dvh;
    }

    #home .window-title,
    #home .window-subtitle,
    #home .hero-kicker,
    #home .description {
        text-align: center;
        margin-inline: auto;
    }

    .contact-panel {
        max-width: 820px;
        margin-inline: auto;
    }

    .contact-list {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .contact-item {
        grid-template-columns: 1fr;
        align-items: start;
        gap: 5px;
    }

    .work-grid {
        grid-template-columns: 1fr;
    }

}

@media (min-width: 1100px) {
    .project-card {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(300px, 0.8fr);
        grid-template-areas:
            'header header'
            'tags tags'
            'media media'
            'description highlights';
        column-gap: 22px;
        row-gap: 14px;
    }

    .project-header {
        grid-area: header;
        margin-bottom: 0;
    }

    .project-media {
        grid-area: media;
        min-height: clamp(120px, 13vw, 170px);
        max-height: 190px;
    }

    .project-description {
        grid-area: description;
    }

    .project-highlights {
        grid-area: highlights;
        margin-top: 0;
        padding: 0 0 0 16px;
        border-top: 0;
        border-left: 1px solid var(--outline-variant);
    }

    .project-tags {
        grid-area: tags;
    }

    .work-card {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-areas:
            'header'
            'description'
            'tags'
            'highlights';
        row-gap: 12px;
    }

    .work-header {
        grid-area: header;
        margin-bottom: 0;
    }

    .work-description {
        grid-area: description;
    }

    .work-tags {
        grid-area: tags;
    }

    .project-description,
    .work-description {
        max-width: none;
    }

    .project-tags,
    .work-tags {
        margin: 0;
    }

    .work-highlights {
        grid-area: highlights;
        margin-top: 2px;
        padding: 12px 0 0;
        border-top: 1px solid var(--outline-variant);
        border-left: 0;
    }
}

@media (min-width: 1200px) {
    :is(#projects, #blog, #work) {
        min-height: 78dvh;
        justify-content: center;
    }
}

@media (max-width: 900px) {
    .window {
        padding: 44px 20px;
    }

    .contact-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .technology-card {
        flex-basis: 116px;
    }
}

@media (max-width: 768px) {
    .dockbar {
        bottom: calc(14px + env(safe-area-inset-bottom, 0px));
        transform: translateX(-50%);
        width: calc(100% - 24px);
        max-width: 420px;
        gap: 8px;
        padding: 8px 10px;
    }

    .nav-button {
        flex: 1;
        width: auto;
        height: 44px;
    }

    .window h1 {
        font-size: clamp(2.1rem, 9vw, 3rem);
    }

    .window h3 {
        font-size: 0.9rem;
        letter-spacing: 0.01em;
    }

    .description {
        font-size: 0.92rem;
    }

    .project-card,
    .blog-card,
    .work-card {
        padding: 16px;
    }

    .project-header,
    .work-header {
        flex-wrap: wrap;
        gap: 6px 10px;
    }

    .technology-card {
        flex-basis: 104px;
    }

    .contact-link {
        font-size: 0.82rem;
    }

}

@media (max-width: 560px) {
    .contact-list {
        grid-template-columns: 1fr;
    }
}

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

    html,
    body {
        scroll-behavior: auto !important;
    }

    main,
    nav {
        will-change: auto !important;
    }
}
