/* ===== CSS Variables ===== */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #141822;
    --bg-tertiary: #1a1f2e;
    --text-primary: #e8eaed;
    --text-secondary: #a0a4b8;
    --accent-primary: #00d9ff;
    --accent-secondary: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #00d9ff 0%, #7c3aed 100%);
    --glass-bg: rgba(26, 31, 46, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --bg-overlay: rgba(10, 14, 23, 0.72);
    --section-alt-bg: rgba(10, 14, 23, 0.5);
}

[data-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e9ecef;
    --text-primary: #1a1f2e;
    --text-secondary: #6c757d;
    --accent-primary: #0099cc;
    --accent-secondary: #6610f2;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
    --bg-overlay: rgba(248, 249, 250, 0.78);
    --section-alt-bg: rgba(248, 249, 250, 0.55);
}


/* ===== Reset & Base Styles ===== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: clip;
    max-width: 100%;
    scroll-padding-top: 5rem;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: clip;
    max-width: 100%;
    position: relative;
}

body.theme-ready {
    transition: background 0.3s ease, color 0.3s ease;
}

img,
video,
svg {
    max-width: 100%;
    height: auto;
}

/* ===== Site-wide coding environment background ===== */
.code-env-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.code-env-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transform: scale(1.02);
    filter: saturate(0.95) contrast(1.02);
}

.code-env-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, var(--bg-overlay) 0%, color-mix(in srgb, var(--bg-overlay) 70%, transparent) 45%, var(--bg-overlay) 100%),
        radial-gradient(ellipse 70% 55% at 50% 40%, color-mix(in srgb, var(--bg-primary) 55%, transparent) 0%, transparent 75%);
    z-index: 1;
}

.hero-section,
.section {
    position: relative;
    z-index: 1;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
}


/* ===== Navbar Styles ===== */

.navbar-custom {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    padding: 0.85rem 0;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1030;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.navbar-custom.is-stuck {
    box-shadow: var(--shadow-md);
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.05rem, 4vw, 1.5rem);
    font-weight: 700;
    max-width: min(78vw, 340px);
    text-decoration: none;
}

.navbar-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 8px;
}

.navbar-brand-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-toggler {
    border: 1px solid var(--glass-border);
    padding: 0.4rem 0.55rem;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 0.15rem color-mix(in srgb, var(--accent-primary) 35%, transparent);
}

.navbar-toggler-icon {
    filter: invert(1);
    opacity: 0.9;
}

[data-theme="light"] .navbar-toggler-icon {
    filter: none;
    opacity: 0.75;
}

.nav-link {
    color: var(--text-primary) !important;
    font-weight: 500;
    margin: 0 0.5rem;
    position: relative;
    transition: color 0.3s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-gradient);
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

.theme-toggle {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.3);
    transform: rotate(180deg);
}


/* ===== Hero Section ===== */

.hero-section {
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 5rem 0 3rem;
}

.hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(
            105deg,
            color-mix(in srgb, var(--bg-primary) 88%, transparent) 0%,
            color-mix(in srgb, var(--bg-primary) 55%, transparent) 48%,
            color-mix(in srgb, var(--bg-primary) 35%, transparent) 100%
        ),
        url("Resource/hero-dual-monitor-bg.png") center / cover no-repeat;
    pointer-events: none;
    z-index: 0;
}

.hero-section > .container {
    position: relative;
    z-index: 1;
    width: 100%;
}

.hero-content {
    position: relative;
    z-index: 1;
    opacity: 0;
    animation: fadeInUp 1s ease forwards;
}

.hero-title {
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 700;
    margin-bottom: 2rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.hero-subtitle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.hero-typed-display {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.25rem, 3.2vw, 2.2rem);
    font-weight: 700;
    line-height: 1.4;
    min-height: 3.6em;
    max-width: 100%;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.hero-typed {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-typed-cursor {
    display: inline-block;
    width: 3px;
    height: 1em;
    margin-left: 4px;
    background: var(--accent-primary);
    vertical-align: text-bottom;
    animation: typedBlink 0.8s step-end infinite;
}

@keyframes typedBlink {
    50% { opacity: 0; }
}

.cta-button {
    background: var(--accent-gradient);
    color: white;
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 217, 255, 0.3);
}

.cta-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(0, 217, 255, 0.5);
    color: white;
}


/* ===== Hero Visual ===== */

.hero-visual {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    animation: fadeInUp 1s ease forwards 0.3s;
    min-height: 220px;
}


/* ===== Section Styles ===== */

.section {
    padding: 6rem 0;
    position: relative;
}

.section-alt {
    background: var(--section-alt-bg);
    backdrop-filter: blur(1px);
}

.section-title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    margin-bottom: 3rem;
    text-align: center;
    position: relative;
    display: block;
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding: 0 0.5rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: var(--accent-gradient);
    border-radius: 2px;
}


/* ===== About Section ===== */

.about-row {
    row-gap: 2.25rem;
}

@media (min-width: 992px) {
    .about-row {
        --bs-gutter-x: 4rem;
    }

    .about-media {
        padding-right: 2rem !important;
    }

    .about-copy {
        padding-left: 2rem !important;
    }
}

.about-img {
    width: 100%;
    max-width: 520px;
    aspect-ratio: 1;
    object-fit: cover;
    object-position: center;
    border-radius: 12px;
    border: 4px solid rgba(0, 217, 255, 0.25);
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
}

.about-img:hover {
    transform: translateY(-10px);
}

.about-story {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.about-text {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    margin: 0;
}

.about-text:first-child {
    color: var(--text-primary);
}


/* ===== Skills Section ===== */

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    gap: 1.5rem;
}

.skill-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
}

.skill-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 30px rgba(0, 217, 255, 0.2);
}

.skill-icon {
    font-size: 3rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.skill-name {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.skill-bar {
    background: var(--bg-tertiary);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 1rem;
}

.skill-progress {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    width: 0;
    transition: width 1s ease;
}


/* ===== Projects Section ===== */

.projects-grid,
.recent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 1.5rem;
}

.recent-carousel {
    background: var(--bg-tertiary);
}

.recent-img {
    width: 100%;
    height: clamp(180px, 45vw, 260px);
    object-fit: cover;
    object-position: top center;
    background: var(--bg-tertiary);
}

.recent-carousel .carousel-control-prev,
.recent-carousel .carousel-control-next {
    width: 14%;
    opacity: 0.75;
    transition: opacity 0.3s ease;
}

.project-card:hover .recent-carousel .carousel-control-prev,
.project-card:hover .recent-carousel .carousel-control-next {
    opacity: 0.95;
}

.recent-carousel .carousel-control-prev-icon,
.recent-carousel .carousel-control-next-icon {
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    padding: 1.1rem;
    background-size: 50% 50%;
}

.project-img,
.recent-img {
    cursor: zoom-in;
}


/* ===== Lightbox ===== */

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 2rem;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox-img {
    max-width: 95vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    cursor: default;
    animation: lightboxZoom 0.25s ease;
}

@keyframes lightboxZoom {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.lightbox-close {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: rotate(90deg);
}

.project-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.project-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-lg);
}

.project-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.project-content {
    padding: 1.5rem;
}

.project-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.project-desc {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tag {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
}

.project-links {
    display: flex;
    gap: 1rem;
}

.project-btn {
    flex: 1;
    padding: 0.7rem;
    border: 1px solid var(--accent-primary);
    background: transparent;
    color: var(--accent-primary);
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
}

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


/* ===== Contact Section ===== */

.contact-wrapper {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 3rem;
    align-items: center;
}

.contact-info {
    text-align: left;
}

.contact-info h3 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.contact-info p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.8;
}

.contact-form {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 2.5rem;
}

.form-group {
    position: relative;
    margin-bottom: 2rem;
}

.form-control-custom {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control-custom:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.2);
}

.form-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent-primary);
}

textarea.form-control-custom {
    min-height: 120px;
    resize: vertical;
}

.submit-btn {
    width: 100%;
    padding: 1rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(0, 217, 255, 0.4);
}

.form-status {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    display: none;
}

.form-status.success {
    display: block;
    background: rgba(0, 200, 83, 0.15);
    color: #00c853;
    border: 1px solid rgba(0, 200, 83, 0.3);
}

.form-status.error {
    display: block;
    background: rgba(255, 82, 82, 0.15);
    color: #ff5252;
    border: 1px solid rgba(255, 82, 82, 0.3);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}


/* ===== Footer ===== */

.footer {
    background: var(--bg-secondary);
    padding: 3rem 0;
    text-align: center;
    border-top: 1px solid var(--glass-border);
}

.social-icons {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.social-icon {
    width: 50px;
    height: 50px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-size: 1.2rem;
    transition: all 0.3s ease;
    text-decoration: none;
}

.social-icon:hover {
    background: var(--accent-gradient);
    color: white;
    transform: translateY(-5px);
}


/* ===== Animations ===== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}


/* ===== Responsive Styles ===== */

@media (max-width: 991px) {
    .navbar-custom .navbar-collapse {
        margin-top: 0.75rem;
        padding: 0.75rem 0.5rem 1rem;
        background: var(--glass-bg);
        border: 1px solid var(--glass-border);
        border-radius: 12px;
        backdrop-filter: blur(12px);
    }

    .navbar-custom .nav-item {
        width: 100%;
    }

    .navbar-custom .nav-link {
        margin: 0;
        padding: 0.7rem 0.85rem;
        border-radius: 8px;
    }

    .navbar-custom .nav-link::after {
        display: none;
    }

    .navbar-custom .nav-item.ms-3 {
        margin-left: 0 !important;
        margin-top: 0.5rem;
        display: flex;
        justify-content: flex-start;
        padding: 0 0.85rem;
    }

    .hero-section {
        text-align: center;
        min-height: auto;
        padding: 4.5rem 0 2.5rem;
    }

    .hero-content {
        text-align: center !important;
        margin-bottom: 1.5rem;
    }

    .hero-visual {
        min-height: 140px;
        margin-bottom: 0.5rem;
    }

    .hero-typed-display {
        text-align: center;
        max-width: 100%;
        margin: 0 auto;
        font-size: clamp(1.15rem, 4.5vw, 1.6rem);
        min-height: 3.2em;
    }

    .about-img {
        display: block;
        margin: 0 auto 2rem;
        max-width: min(420px, 88vw);
    }

    .section {
        padding: 3.5rem 0;
    }

    .section-title {
        font-size: clamp(1.6rem, 5vw, 2.2rem);
        margin-bottom: 2rem;
        max-width: 100%;
        padding: 0 0.5rem;
    }

    .code-env-bg::after {
        background:
            linear-gradient(180deg, var(--bg-overlay) 0%, color-mix(in srgb, var(--bg-overlay) 75%, transparent) 50%, var(--bg-overlay) 100%);
    }

    .contact-wrapper {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .contact-info {
        text-align: center;
    }

    .contact-info h3 {
        font-size: clamp(1.4rem, 5vw, 1.8rem);
    }
}

@media (max-width: 768px) {
    .hero-title {
        font-size: clamp(1.75rem, 8vw, 2.4rem);
        margin-bottom: 1.5rem;
    }

    .hero-name-cn {
        display: block;
    }

    .about-text {
        font-size: 1rem;
        line-height: 1.7;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .about-story {
        gap: 1rem;
    }

    .cta-button {
        padding: 0.85rem 1.75rem;
        font-size: 0.95rem;
    }

    .skills-grid,
    .projects-grid,
    .recent-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .skill-card {
        padding: 1.35rem 1.1rem;
    }

    .skill-icon {
        font-size: 2.4rem;
    }

    .project-content {
        padding: 1.15rem;
    }

    .project-title {
        font-size: 1.25rem;
    }

    .project-img {
        height: 180px;
    }

    .recent-img {
        height: 200px;
    }

    .contact-form {
        padding: 1.5rem 1.15rem;
    }

    .form-control-custom {
        padding: 0.9rem 0.9rem 0.9rem 2.75rem;
        font-size: 0.95rem;
    }

    .lightbox {
        padding: 1rem;
    }

    .lightbox-close {
        top: 0.75rem;
        right: 0.75rem;
    }

    .social-icons {
        gap: 1rem;
        flex-wrap: wrap;
    }

    .footer {
        padding: 2rem 0;
    }
}

@media (max-width: 480px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .hero-section {
        padding: 4rem 0 2rem;
    }

    .section {
        padding: 2.75rem 0;
    }

    .tag {
        font-size: 0.78rem;
        padding: 0.25rem 0.65rem;
    }

    .recent-carousel .carousel-control-prev,
    .recent-carousel .carousel-control-next {
        opacity: 0.9;
    }
}

@media (hover: none) {
    .project-card:hover,
    .skill-card:hover,
    .about-img:hover,
    .cta-button:hover,
    .social-icon:hover {
        transform: none;
    }

    .recent-carousel .carousel-control-prev,
    .recent-carousel .carousel-control-next {
        opacity: 0.85;
    }
}