:root {
    --bg-color: #f7f7f7;
    --text-color: #000000;
    --text-secondary: #878787;
    --border-color: #E5E7EB;
    --card-shadow: rgba(0,0,0,0.04);
    --card-shadow-hover: rgba(0,0,0,0.12);
}

[data-theme="dark"] {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --text-secondary: #9e9e9e;
    --border-color: #2a2a2a;
    --card-shadow: rgba(0,0,0,0.2);
    --card-shadow-hover: rgba(0,0,0,0.4);
}

*, *::before, *::after {
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;  /* 确保所有元素都使用 Inter */
}


html {
    scroll-behavior: smooth;  /* Smooth scrolling */
}

html, body {
    margin: 0;
    padding: 0;
}

/* Page transition animation */
@keyframes pageFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    animation: pageFadeIn 0.4s ease-in-out;
    transition: background-color 0.3s ease, color 0.3s ease;
}


.section {
    padding-top: 80px;
    padding-bottom: 80px;
}

.section-nav {
    padding-top: 80px;
    padding-bottom: 0;
}

/* Set scroll-margin for sections with id to ensure correct anchor jump position */
#about,
#projects,
#contact {
    scroll-margin-top: 80px;  /* Compensate for section padding-top */
}

.section-last {
    padding-bottom: 0 !important;  /* Last section has no bottom padding */
    margin-bottom: 0 !important;   /* Ensure no margin */
}

.container {
    margin: 0 160px;  
    display: flex;
    justify-content: flex-start; 
}

.project-section-container {
    flex-direction: column;
}

.nav-container {
    display: flex;
    gap: 32px;
    justify-content: flex-start;
    width: 100%;
}

.nav-button {
    background-color: transparent;
    width: fit-content; 
    height: fit-content;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;  /* Remove link underline */
    color: inherit;  /* Inherit text color */
    cursor: pointer;  /* Pointer cursor style */
}

.nav-button:hover {
    text-decoration: underline;
}

.nav-font {
    font-size: 16px;
    font-weight: 500;
    letter-spacing: -0.04em;
}

.theme-toggle {
    background: transparent;
    border: none;
    margin-left: auto;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: -0.04em;
    color: inherit;
    padding: 0;
    line-height: 1;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.theme-toggle .icon-moon {
    display: none;
}

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

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

.theme-toggle:hover {
    opacity: 0.6;
}


.hero {
    display: flex;
    flex-direction: column;  
    gap: 20px;  
}

/* Project page: main title and right caption on same line, aligned */
.hero-title-row {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.hero-title {
    font-size: 36px;
    font-weight: 550;  /* semi-bold */
    letter-spacing: -0.04em;
    margin: 0;  /* Remove default margin */
}

.hero-caption {
    font-size: 20px;
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: -0.04em;
    margin: 0;
    flex-shrink: 0;
}

.hero-subtitle {
    font-size: 20px;
    font-weight: 400;
    margin: 0;  /* Remove default margin */
    letter-spacing: -0.04em;
}

.hover-word-cycle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border-radius: 0.3em;
    white-space: nowrap;
    overflow: hidden;
    transition: background-color 0.2s ease, color 0.2s ease, font-weight 0.2s ease, box-shadow 0.2s ease;
}

.hover-word-cycle:hover {
    width: 4.3ch;
    padding: 0 0.12em;
    background-color: #2b7cff;
    color: transparent;
    font-weight: 700;
    box-shadow: 0 0 0 1px rgba(43, 124, 255, 0.18), 0 6px 14px rgba(43, 124, 255, 0.28);
    background-image: linear-gradient(115deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.28) 50%, rgba(255, 255, 255, 0.1) 100%);
    background-size: 240% 100%;
    animation: hoverWordWidth 6s ease-in-out infinite, hoverWordGlow 3s ease-in-out infinite, hoverWordShimmer 3.3s linear infinite;
}

.hover-word-cycle:hover::after {
    content: "Ship";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #ffffff;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    will-change: transform, opacity, filter;
    animation: hoverWordCycle 6s steps(1, end) infinite, hoverWordFade 6s ease-in-out infinite;
}

@keyframes hoverWordCycle {
    0%, 24.99% { content: "Ship"; }
    25%, 49.99% { content: "Build"; }
    50%, 74.99% { content: "Fix"; }
    75%, 100% { content: "Explore"; }
}

@keyframes hoverWordWidth {
    0%, 18% { width: 4.3ch; }      /* Ship hold */
    25%, 43% { width: 5.2ch; }     /* Build hold */
    50%, 68% { width: 3.2ch; }     /* Fix hold */
    75%, 93% { width: 7.0ch; }     /* Explore hold */
    100% { width: 4.3ch; }         /* Loop back to Ship */
}

@keyframes hoverWordFade {
    0%, 18%, 25%, 43%, 50%, 68%, 75%, 93%, 100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
        text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    }
    20.5%, 45.5%, 70.5%, 95.5% {
        opacity: 0.35;
        transform: translateY(-0.06em) scale(0.97);
        filter: blur(0.8px);
        text-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
    }
    22.5%, 47.5%, 72.5%, 97.5% {
        opacity: 0.88;
        transform: translateY(0.02em) scale(1.02);
        filter: blur(0);
        text-shadow: 0 0 8px rgba(255, 255, 255, 0.26);
    }
}

@keyframes hoverWordGlow {
    0%, 100% {
        box-shadow: 0 0 0 1px rgba(43, 124, 255, 0.18), 0 6px 14px rgba(43, 124, 255, 0.28);
    }
    50% {
        box-shadow: 0 0 0 1px rgba(43, 124, 255, 0.28), 0 8px 20px rgba(43, 124, 255, 0.38);
    }
}

@keyframes hoverWordShimmer {
    from {
        background-position: 0% 50%;
    }
    to {
        background-position: 100% 50%;
    }
}

.hero-text {
    font-size: 16px;
    font-weight: 300;
    margin: 0;  /* Remove default margin */
    line-height: 1.5;
    letter-spacing: -0.04em;
}

.project-container {
    display: grid;
    gap: 16px;
    width: 100%; 
}

/* Container with featured and featured-secondary cards: 7:5 ratio */
.project-container:has(.project-card-featured) {
    grid-template-columns: 7fr 5fr;
}

/* Container with three normal cards: equal thirds */
.project-container:has(.project-card-normal):not(:has(.project-card-featured)) {
    grid-template-columns: repeat(3, 1fr);
}

.project-card-featured {
    display: flex;
    flex-direction: column;  
    height: 400px;
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 16px;
    justify-content: flex-start;
    gap: 8px;
    text-decoration: none;  /* Remove link underline */
    color: inherit;  /* Inherit text color */
    cursor: pointer;  /* Pointer cursor style */
    transition: transform 0.3s ease, box-shadow 0.3s ease;  /* Add transition effect */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--card-shadow);
}

/* Use pseudo-element for smooth background image transition */
.project-card-featured::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--hover-bg-image, url('path/to/your/image.jpg'));
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.4s ease;
    border-radius: 16px;
    z-index: 0;
}

.project-card-featured:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--card-shadow-hover);
}

.project-card-featured:hover::before {
    opacity: 1;
}

/*
.project-card-featured:hover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3);  
    z-index: 0;
    border-radius: 16px;
}
*/

.project-card-featured .card-title,
.project-card-featured .card-subtitle {
    position: relative;
    z-index: 1;  /* Ensure text is above overlay */
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.project-card-featured:hover .card-title {
    transform: translateY(-2px);
}

.project-card-featured:hover .card-subtitle {
    opacity: 0.9;
}

.project-card-featured-secondary {
    display: flex;
    height: 400px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    border-radius: 16px;
    justify-content: flex-start;
    gap: 8px;
    flex-direction: column;
    text-decoration: none;  /* Remove link underline */
    color: inherit;  /* Inherit text color */
    cursor: pointer;  /* Pointer cursor style */
    transition: transform 0.3s ease, box-shadow 0.3s ease;  /* Add transition effect */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--card-shadow);
}

/* Use pseudo-element for smooth background image transition */
.project-card-featured-secondary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--hover-bg-image, url('path/to/your/image.jpg'));
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.4s ease;
    border-radius: 16px;
    z-index: 0;
}

.project-card-featured-secondary:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--card-shadow-hover);
}

.project-card-featured-secondary:hover::before {
    opacity: 1;
}

/*
.project-card-featured-secondary:hover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3); 
    z-index: 0;
    border-radius: 16px;
}
*/

.project-card-featured-secondary .card-title,
.project-card-featured-secondary .card-subtitle {
    position: relative;
    z-index: 1;  /* Ensure text is above overlay */
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.project-card-featured-secondary:hover .card-title {
    transform: translateY(-2px);
}

.project-card-featured-secondary:hover .card-subtitle {
    opacity: 0.9;
}


.project-card-normal {
    display: flex;
    height: 400px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    border-radius: 16px;
    justify-content: flex-start;
    gap: 8px;
    flex-direction: column;
    text-decoration: none;  /* Remove link underline */
    color: inherit;  /* Inherit text color */
    cursor: pointer;  /* Pointer cursor style */
    transition: transform 0.3s ease, box-shadow 0.3s ease;  /* Add transition effect */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--card-shadow);
}

/* Use pseudo-element for smooth background image transition */
.project-card-normal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--hover-bg-image, url('path/to/your/image.jpg'));
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.4s ease;
    border-radius: 16px;
    z-index: 0;
}

.project-card-normal:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--card-shadow-hover);
}

.project-card-normal:hover::before {
    opacity: 1;
}

/*
.project-card-normal:hover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 0;
    border-radius: 16px;
}
*/


.project-card-normal .card-title,
.project-card-normal .card-subtitle {
    position: relative;
    z-index: 1;  /* Ensure text is above overlay */
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.project-card-normal:hover .card-title {
    transform: translateY(-2px);
}

.project-card-normal:hover .card-subtitle {
    opacity: 0.9;
}


.project-card-gap {
    height: 16px;
}

.project-title {
    font-size: 20px;
    font-weight: 400;
    margin: 0;  
    letter-spacing: -0.04em;
}

.card-title {
    font-size: 16px;
    font-weight: 400;
    margin: 0;   
}

.card-subtitle {
    font-size: 14px;
    font-weight: 300;
    margin: 0;
    color: var(--text-secondary);
}

.connect-title {
    font-size: 20px;
    font-weight: 500;
    margin: 0;
}

.connect-logo {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    flex-shrink: 0;
}

.connect-logo svg {
    width: 100%;
    height: 100%;
}

.connnect-text {
    font-size: 16px;
    font-weight: 300px;
}

.connect-button {
    display: flex;
    gap: 12px;
    justify-content: flex-start;
    align-items: center;
    text-decoration: none;  /* Remove link underline */
    color: inherit;  /* Inherit text color */
    cursor: pointer;  /* Pointer cursor style */
}

.connect-container {
    display: flex;
    gap: 16px;
    flex-direction: column;
}

.footer-container {
    display: flex;
    justify-content: center;
}

.footer-text {
    font-size: 14px;
    font-weight: 300;
    margin: 0;
    color: var(--text-secondary);
}

.link-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: flex-start;
    align-items: flex-start;
}

.link-title {
    font-size: 22px;
    font-weight: 500;
    letter-spacing: -0.04em;
    color: var(--text-color);
    margin-left: 0;
    margin-right: 0;
    margin-top: 0;
    margin-bottom: 6px;
    line-height: 1.2;
}


.link-item-logo {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    flex-shrink: 0;
}

.link-item {
    display: flex;
    gap: 12px;
    justify-content: flex-start; 
    align-items: center;
    text-decoration: none;  /* Prevent underline on the link container itself */
}

.link-item:link,
.link-item:visited {
    text-decoration: none; /* Remove underline by default */
}
.link-item {
    position: relative;
    display: inline-flex;
}

.link-item-text {
    position: relative; /* Ensure ::after is relative to text only */
}

.link-item-text::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 2px;
    background: #000;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s cubic-bezier(.4,0,.2,1);
    pointer-events: none;
}

.link-item-text:hover::after,
.link-item-text:focus::after {
    transform: scaleX(1);
}

.link-item-logo svg {
    width: 100%;
    height: 100%;
}

.link-icon-canva {
    background: #000;
    border-radius: 4px;
}
.link-icon-canva rect {
    fill: #000;
}
.link-icon-canva path {
    stroke: #fff;
}
[data-theme="dark"] .link-icon-canva {
    background: var(--text-color);
}
[data-theme="dark"] .link-icon-canva rect {
    fill: var(--text-color);
}
[data-theme="dark"] .link-icon-canva path {
    stroke: var(--bg-color);
}

.link-icon-weixin {
    background: #000;
    border-radius: 4px;
}
.link-icon-weixin rect {
    fill: #000;
}
.link-icon-weixin path {
    fill: #fff;
}
[data-theme="dark"] .link-icon-weixin {
    background: var(--text-color);
}
[data-theme="dark"] .link-icon-weixin rect {
    fill: var(--text-color);
}
[data-theme="dark"] .link-icon-weixin path {
    fill: var(--bg-color);
}

.link-item-text {
    font-size: 16px;
    font-weight: 400;
    letter-spacing: -0.04em;
    color: var(--text-color);
    margin-left: 0;
    margin-right: 0;
    margin-top: 0;
    margin-bottom: 0;
    line-height: 1.2;
}


/* ========== Responsive: under 768px (tablet) ========== */
@media (max-width: 768px) {
    .container {
        margin: 0 24px;
    }

    .section {
        padding-top: 48px;
        padding-bottom: 48px;
    }

    .section-nav {
        padding-top: 48px;
    }

    #about,
    #projects,
    #contact {
        scroll-margin-top: 48px;
    }

    .nav-container {
        gap: 24px;
    }

    .nav-button,
    .nav-font {
        font-size: 14px;
    }

    .hero {
        gap: 16px;
    }

    .hero-title-row {
        gap: 12px;
    }

    .hero-title {
        font-size: 28px;
    }

    .hero-caption {
        font-size: 18px;
    }

    .hero-subtitle {
        font-size: 18px;
    }

    .hero-text {
        font-size: 15px;
    }

    /* Featured + secondary: stack vertically on tablet */
    .project-container:has(.project-card-featured) {
        grid-template-columns: 1fr;
    }

    /* Three normal cards: 2 columns on tablet */
    .project-container:has(.project-card-normal):not(:has(.project-card-featured)) {
        grid-template-columns: repeat(2, 1fr);
    }

    .project-card-featured,
    .project-card-featured-secondary,
    .project-card-normal {
        height: 320px;
        padding: 12px;
    }

    .project-title {
        font-size: 18px;
    }

    .card-title {
        font-size: 15px;
    }

    .card-subtitle {
        font-size: 13px;
    }

    .connect-title {
        font-size: 18px;
    }

    .connect-logo {
        width: 28px;
        height: 28px;
    }

    .connnect-text {
        font-size: 15px;
    }

    .footer-text {
        font-size: 13px;
    }
}

/* ========== Responsive: under 520px (mobile) ========== */
@media (max-width: 520px) {
    .container {
        margin: 0 16px;
    }

    .section {
        padding-top: 32px;
        padding-bottom: 32px;
    }

    .section-nav {
        padding-top: 32px;
    }

    #about,
    #projects,
    #contact {
        scroll-margin-top: 32px;
    }

    .nav-container {
        gap: 16px;
    }

    .nav-button,
    .nav-font {
        font-size: 13px;
    }

    .hero {
        gap: 12px;
    }

    .hero-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .hero-title {
        font-size: 24px;
    }

    .hero-caption {
        font-size: 16px;
    }

    .hero-subtitle {
        font-size: 16px;
    }

    .hero-text {
        font-size: 14px;
    }

    .project-container {
        gap: 12px;
    }

    /* All project grids: single column on mobile */
    .project-container:has(.project-card-featured) {
        grid-template-columns: 1fr;
    }

    .project-container:has(.project-card-normal):not(:has(.project-card-featured)) {
        grid-template-columns: 1fr;
    }

    .project-card-featured,
    .project-card-featured-secondary,
    .project-card-normal {
        height: 280px;
        padding: 12px;
        border-radius: 12px;
    }

    .project-card-featured::before,
    .project-card-featured-secondary::before,
    .project-card-normal::before {
        border-radius: 12px;
    }

    .project-title {
        font-size: 16px;
    }

    .card-title {
        font-size: 14px;
    }

    .card-subtitle {
        font-size: 12px;
    }

    .connect-title {
        font-size: 16px;
    }

    .connect-logo {
        width: 24px;
        height: 24px;
    }

    .connect-button {
        gap: 12px;
    }

    .connect-container {
        gap: 12px;
    }

    .connnect-text {
        font-size: 14px;
    }

    .footer-text {
        font-size: 12px;
    }
}

