html, body {
  height: 100%;
  overscroll-behavior-y: none;
}

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --text-primary: #000000;
    --text-secondary: #aaa;
    --accent: #a855f7;
    --accent-hover: #9333ea;
    --border: rgba(168, 85, 247, 0.2);
    --shadow: rgba(168, 85, 247, 0.15);
    --card-bg: rgba(255, 255, 255, 0.8);
    --name-color: var(--accent);
}

[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --text-primary: #ffffff;
    --text-secondary: #999999;
    --accent: #22c55e;
    --accent-hover: #16a34a;
    --border: rgba(34, 197, 94, 0.2);
    --shadow: rgba(34, 197, 94, 0.15);
    --card-bg: rgba(10, 10, 10, 0.8);
    --name-color: #22c55e;  
}

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

::selection {
    background: var(--accent);
    color: white;
}

::-moz-selection {
    background: var(--accent);
    color: white;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;

}

#webgl-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.container {
    display: flex;
    flex-direction: column;
    max-width: 600px;
    margin: 10vh auto;
    padding: 0rem 0.5rem;
    position: relative;
    z-index: 1;
}

/* Intro Section */
.intro-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-bottom: 0;
    animation: fadeInUp 1s ease-out;
}

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

.intro-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0rem;
}

.name {
    font-size: 1.125rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--name-color);
    animation: fadeInUp 1s ease-out 0.2s both;
}

.header-controls {
    display: flex;
    gap: 0.75rem;
    animation: fadeInUp 1s ease-out 0.4s both;
}

.icon-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
    color: var(--accent);
    transform: scale(1.1);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.sun-icon {
    display: none;
}

.moon-icon {
    display: block;
}

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

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

.role {
    font-size: 1.125rem;
    font-weight: 350;
    color: var(--text-primary);
    margin-bottom: 2.5rem;
    animation: fadeInUp 1s ease-out 0.6s both;
}

.bio {
    font-size: clamp(0.95rem, 1.5vw, 1.05rem);
    max-width: 700px;
    margin-bottom: 1rem;
    line-height: 1.6;
    animation: fadeInUp 1s ease-out 0.8s both;
}

.experience {
    font-size: clamp(0.95rem, 1.5vw, 1.05rem);
    color: var(--text-primary);
    max-width: 700px;
    margin-bottom: 2rem;
    animation: fadeInUp 1s ease-out 1s both;
}

.links {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    animation: fadeInUp 1s ease-out 1.2s both;
}

.link {
    font-size: 0.95rem;
    color: var(--text-primary);
    text-decoration: underline;
    position: relative;
    padding: 0.25rem 0;
    transition: color 0.3s ease;
    text-underline-offset: .25rem;
    text-decoration-color: var(--text-secondary);
}

.link:hover {
    color: var(--accent);
}

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

.email-link {
    transition: all 0.3s ease;
}

.email-link:hover {
    color: var(--accent);
}

.email-link::before {
    content: 'Email';
}

.email-link:hover::before {
    content: 'abrandonwang@gmail.com';
}

/* Work Section */
.work-section {
    padding: 10rem 0 4rem 0;
    animation: fadeInUp 1s ease-out 1.4s both;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
}

.section-header {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    cursor: pointer;
    width: fit-content;
    transition: all 0.3s ease;
    max-width: 600px;
    margin-left: max(0.5rem + calc((100vw - 600px) / 2));
    margin-right: auto;
}

.section-header:hover .section-title {
    color: var(--accent);
}

.section-header:hover .arrow {
    transform: translateX(8px);
}

.section-title {
    font-size: 1.125rem;
    font-weight: 350;
    transition: color 0.3s ease;
}

.count {
    font-size: 1.125rem;
    color: var(--text-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    background: var(--card-bg);
    border: none;
    padding-left: 1rem;
    padding-right: 0;
}

.arrow {
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

/* Gallery */
.full-bleed {
    width: 100%;
}

.gallery {
    display: flex;
    gap: 4rem;
    padding: 1rem 0;
    padding-left: max(1rem + calc((100vw - 600px) / 2));
    padding-right: max(1rem + calc((100vw - 600px) / 2));
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    overscroll-behavior: auto;
}

.gallery::-webkit-scrollbar {
    display: none;
}

.gallery-item {
    flex: 0 0 auto;
    width: 360px;
    opacity: 0;
    animation: fadeInScale 0.6s ease-out forwards;
}

.gallery-spacer {
    display: none;
}

.gallery-item:nth-child(1) { animation-delay: 0.1s; }
.gallery-item:nth-child(2) { animation-delay: 0.2s; }
.gallery-item:nth-child(3) { animation-delay: 0.3s; }
.gallery-item:nth-child(4) { animation-delay: 0.4s; }
.gallery-item:nth-child(5) { animation-delay: 0.5s; }
.gallery-item:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.project-card {
    position: relative;
    border-radius: 1.5rem;
    overflow: hidden;
    aspect-ratio: 5/4;
    height: 320px;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border);
    background: var(--card-bg);
}

.project-card::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, var(--accent), transparent);
    border-radius: 1.5rem;
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: -1;
}

.project-card:hover {
    transform: scale(1.05) translateY(-10px);
}

.project-card:hover::before {
    opacity: 0.3;
}

.project-card::after {
    display: none;
}

.project-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

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

.project-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.85) 0%,
        rgba(0, 0, 0, 0.4) 40%,
        transparent 100%
    );
}

.project-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.25rem;
    z-index: 2;
}

.project-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: #ffffff;
}

.project-type {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 0.5rem;
}

.project-year {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    font-size: 0.85rem;
    color: #ffffff;
    padding: 0.4rem 0.8rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.gallery-controls {
    display: none;
}



/* Project Modal - Updated to match screenshot */
.project-modal {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.project-modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-close {
    position: absolute;
    top: 2rem;
    left: 2rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    z-index: 10;
    font-weight: 400;
}

.modal-close:hover {
    color: var(--accent);
    transform: translateX(-5px);
}

.modal-close svg {
    width: 16px;
    height: 16px;
}

.modal-content {
    width: 100%;
    height: 100%;
    padding: 4rem 2rem 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-header {
    max-width: 602px;
    width: 100%;
    margin-bottom: 3rem;
    position: relative;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--accent);
}

.modal-subtitle {
    font-size: 1.125rem;
    font-weight: 350;
    color: var(--text-primary);
    margin-bottom: 0;
}

.modal-year {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 1.125rem;
    font-weight: 350;
    color: var(--text-primary);
}

.modal-description, .modal-description1 {
    max-width: 602px;
    width: 100%;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.modal-quote {
    max-width: 602px;
    width: 100%;
    margin-bottom: 3rem;
}

.modal-quote p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.modal-quote-author {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.modal-image {
    max-width: 520px;
    width: 520px;
    border-radius: 8px;
    margin-bottom: 3rem;
    object-fit: cover;
}

/* Hide old modal styles */
.modal-meta {
    display: none;
}

.modal-details {
    display: none;
}

.modal-info {
    display: none;
}

/* Chat Section */
.chat-section {
    padding: 10rem 0 4rem 0;
    width: 100%;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: white;
}

.chat-info {
    flex: 1;
}

.chat-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.chat-status {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.chat-messages {
    min-height: 300px;
    max-height: 450px;
    overflow-y: auto;
    padding: 1.25rem;
    background: var(--card-bg);
    border-radius: 1.5rem;
    border: 1px solid var(--border);
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: slideIn 0.3s ease-out;
}

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

.bot-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
}

.message-bubble {
    padding: 0.85rem 1rem;
    border-radius: 1.25rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.bot-message .message-bubble {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 0.25rem;
}

.user-message .message-bubble {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    padding: 0 0.5rem;
}

.chat-input-container {
    display: flex;
    gap: 0.85rem;
    background: var(--card-bg);
    padding: 0.85rem;
    border-radius: 1.5rem;
    border: 1px solid var(--border);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    font-family: inherit;
}

.chat-input::placeholder {
    color: var(--text-secondary);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-send-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--shadow);
}

.chat-send-btn:active {
    transform: translateY(0);
}

.chat-send-btn svg {
    width: 18px;
    height: 18px;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1.5rem 1rem;
    }

    .intro-section {
        padding-top: 1rem;
    }

    .name {
        font-size: 1.5rem;
    }

    .role {
        font-size: 1rem;
    }

    .gallery {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .gallery-item {
        width: 300px;
    }
    
    .project-card {
        height: 260px;
    }

    .links {
        gap: 1.5rem;
    }

    .modal-close {
        top: 1rem;
        left: 1rem;
    }

    .modal-title {
        font-size: 1rem;
    }

    .message {
        max-width: 90%;
    }
    
    .section-header {
        margin-left: 1rem;
    }
    
    .modal-year {
        position: static;
        display: block;
        margin-top: 0.5rem;
    }
}