/* Optimize font loading: add font-display: swap */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    text-decoration: none;
    border: none;
    outline: none;
}

html {
    font-size: 62.5%;
    scroll-behavior: smooth;
}

body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    background: #0a0a0a;
    color: #e5e5e5;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#particle-background {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: -1;
    background: #0a0a0a;
    opacity: 0.3;
    pointer-events: none;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 2rem 6%;
    background: rgba(10, 10, 10, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

header.scrolled {
    padding: 1.5rem 6%;
    backdrop-filter: blur(25px) saturate(200%);
    -webkit-backdrop-filter: blur(25px) saturate(200%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.logo {
    font-size: 1.6rem;
    color: #ffffff;
    font-weight: 600;
    letter-spacing: -0.5px;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.logo:hover {
    opacity: 0.7;
}

nav {
    display: flex;
    gap: 3rem;
}

nav a {
    font-size: 1.4rem;
    color: #a0a0a0;
    font-weight: 500;
    position: relative;
    transition: color 0.3s ease;
}

nav a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: #ffffff;
    transition: width 0.3s ease;
}

nav a:hover {
    color: #ffffff;
}

nav a:hover::after {
    width: 100%;
}

nav a.active {
    color: #ffffff;
}

nav a.active::after {
    width: 100%;
}

section {
    min-height: 100vh;
    padding: 3rem 6% 5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    user-select: none;
}

.home-content {
    flex: 1;
    max-width: 600px;
    user-select: none;
}

.home-img {
    flex-shrink: 0;
}

.home-content h1 {
    font-size: 7rem;
    font-weight: 700;
    line-height: 1.2;
    color: #ffffff;
    letter-spacing: -2px;
    margin-bottom: 2rem;
}

.home-content p {
    color: #909090;
    font-size: 2.2rem;
    font-weight: 400;
    margin-bottom: 2.5rem;
    letter-spacing: -0.3px;
}

span {
    color: #ffffff;
    position: relative;
    display: inline-block;
}

span::after {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 0;
    width: 100%;
    height: 3px;
    background: #ffffff;
    opacity: 0.3;
}

.home-img {
    flex-shrink: 0;
}

.home-img img {
    width: 28rem;
    height: 28rem;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.home-img img:hover {
    transform: scale(1.05) rotate(5deg);
}

.social-icon {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.social-icon a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 4.5rem;
    height: 4.5rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 50%;
    color: #fff;
    font-size: 2.2rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1), color 0.3s;
    cursor: pointer;
    box-shadow: none;
    margin-bottom: 0.2rem;
}

.social-icon a:hover {
    background: #222;
    color: #fff;
    border-color: #ffffff80;
    transform: translateY(-3px) scale(1.08) rotate(-5deg);
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.12);
}

iframe {
    display: flex;
    margin-top: 10rem;
    top: 10rem;
}

.icons {
    position: fixed;
    bottom: 4rem;
    right: 4rem;
    z-index: 50;
}

.icons a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 5rem;
    height: 5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: #ffffff;
    font-size: 2.4rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.icons a:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-5px);
}

.home-content iframe {
    width: 80vh;
    height: 20vw;
}

.project-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 3.5rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 0;
    user-select: none;
}

.project-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    position: relative;
    user-select: none;
}

.project-card:hover {
    transform: translateY(-6px);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
}

.project-card.js-animate,
.video-card.js-animate {
    opacity: 0;
    transform: translateY(40px);
    transition: none;
}

.project-image {
    width: 100%;
    height: 260px;
    object-fit: contain;
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    background: #181818;
    position: relative;
    z-index: 1;
}

.project-card:hover .project-image {
    transform: scale(1.08);
}

.project-content {
    padding: 2.8rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.project-title {
    font-size: 1.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #ffffff;
    letter-spacing: -0.5px;
    line-height: 1.3;
}

.project-desc {
    font-size: 1.4rem;
    color: #909090;
    margin-bottom: 2rem;
    line-height: 1.7;
    flex-grow: 1;
}

.project-links {
    display: flex;
    gap: 1.2rem;
    flex-wrap: wrap;
    margin-top: auto;
}

.project-link {
    display: inline-block;
    text-decoration: none;
    padding: 1.1rem 2rem;
    border-radius: 8px;
    background: #ffffff;
    color: #0a0a0a;
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.project-link:hover {
    background: transparent;
    color: #ffffff;
    border-color: #ffffff;
}

.project-repo {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    text-decoration: none;
    padding: 1.1rem 2rem;
    border-radius: 8px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 1.3rem;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
}

.project-repo:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.project-repo i {
    font-size: 1.4rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    html {
        font-size: 58%;
    }

    .home {
        gap: 5rem;
    }

    .project-list {
        grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
        gap: 3rem;
    }

    .video-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 2.5rem;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 55%;
    }

    header {
        padding: 2rem 4%;
    }

    nav {
        gap: 2rem;
    }

    nav a {
        font-size: 1.3rem;
    }

    section {
        padding: 8rem 4% 4rem;
    }

    .home {
        flex-direction: column;
        gap: 4rem;
        text-align: center;
        align-items: center;
    }

    /* Reorder: Avatar first, then content */
    .home-img {
        margin-top: 50px;
        order: 1;
        display: flex;
        justify-content: center;
        width: 100%;
    }

    .home-content {
        order: 2;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        /* Loại bỏ flex: 1 để chiều cao sát nội dung */
        flex: unset;
        min-height: unset;
        height: unset;
    }

    .home-content h1 {
        font-size: 5.5rem;
    }

    .home-content p {
        font-size: 2rem;
    }

    .home-img img {
        width: 22rem;
        height: 22rem;
    }

    .social-icon {
        justify-content: center;
    }

    .home-project {
        padding-top: 10rem;
        gap: 6rem;
    }

    .title1 h1 {
        font-size: 3.5rem;
        text-align: center;
    }

    .project-list {
        grid-template-columns: 1fr;
        gap: 2.5rem;
        padding: 1rem 0;
    }

    .video-list {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        padding: 1rem 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .video-card {
        width: 100% !important;
        min-width: 0 !important;
    }

    .icons {
        bottom: 2rem;
        right: 2rem;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 52%;
    }

    .home-content h1 {
        font-size: 5.5rem;
    }

    .home-content p {
        font-size: 2.2rem;
    }

    .home-img img {
        width: 22rem;
        height: 22rem;
    }

    .title1 h1 {
        font-size: 3rem;
    }

    .project-links,
    .video-links {
        flex-direction: column;
    }

    .project-link,
    .project-repo,
    .video-link {
        width: 100%;
        justify-content: center;
    }

    .home {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1.2rem;
        text-align: center;
        min-height: 80vh;
        margin-top: 1.5rem;
    }

    .home-content {
        align-items: center;
        justify-content: center;
        width: 100%;
        margin-top: 0.5rem;
        /* Loại bỏ flex: 1 để chiều cao sát nội dung */
        flex: unset;
        min-height: unset;
        height: unset;
    }

    .home-img {
        margin-top: 0.5rem;
        margin-bottom: 1.5rem;
        display: flex;
        justify-content: center;
        width: 100%;
    }
}

#copyright {
    color: #606060;
    font-size: 1.2rem;
    font-weight: 400;
}

/* Footer for index page (fixed) */
.home~footer {
    position: fixed;
    left: 0;
    bottom: 2rem;
    width: 100%;
    text-align: center;
    z-index: 10;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
}

/* Footer for project page (normal) */
footer {
    padding: 3rem 6%;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: 10rem;
}

footer #copyright {
    color: #606060;
    font-size: 1.3rem;
}

body::-webkit-scrollbar {
    width: var(--scroll-size, 10px);
    height: var(--scroll-size, 10px);
}

body::-webkit-scrollbar-track {
    background-color: var(--scroll-track, transparent);
    border-radius: var(--scroll-track-radius, var(--scroll-radius));
}

body::-webkit-scrollbar-thumb {
    background-color: var(--scroll-thumb-color, grey);
    background-image: var(--scroll-thumb, none);
    border-radius: var(--scroll-thumb-radius, var(--scroll-radius));
}

:root {
    --scroll-size: 10px;
    --scroll-radius: 0px;
    --scroll-track: rgba(0, 0, 0, 0.61);
    --scroll-thumb-color: #3a3a3adc;
}

.home-project {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-top: 12rem;
    gap: 8rem;
    max-width: 1400px;
    margin: 0 auto;
}

.title1 {
    width: 100%;
    margin-bottom: 2rem;
}

.title1 h1 {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1.2;
    color: #ffffff;
    letter-spacing: -1.5px;
}

.video-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 0;
}

.video-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.video-card:hover {
    transform: translateY(-6px);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
}

.video-thumbnail {
    width: 100%;
    height: 220px;
    object-fit: cover;
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.video-card:hover .video-thumbnail {
    transform: scale(1.08);
}

.video-content {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.video-title {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #ffffff;
    text-decoration: none;
    display: block;
    letter-spacing: -0.3px;
    line-height: 1.3;
    transition: opacity 0.3s ease;
}

.video-title:hover {
    opacity: 0.7;
}

.video-desc {
    font-size: 1.3rem;
    color: #909090;
    margin-bottom: 1.8rem;
    line-height: 1.6;
}

.video-link {
    display: inline-block;
    text-decoration: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 1.3rem;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
    margin-top: auto;
}

.video-link:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}