/* --- VARIABLES & RESET --- */
:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --secondary: #64748b;
    --dark: #0f172a;
    --light: #f8fafc;
    --white: #ffffff;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --transition: all 0.3s ease;
    --font-main: 'Outfit', sans-serif;
    --font-code: 'Space Mono', monospace;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-main);
    color: var(--dark);
    background-color: var(--light);
    line-height: 1.6;
    overflow-x: hidden;
}

/* --- ANIMATED BACKGROUND --- */
#gridCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.3;
}

/* --- UTILITIES --- */
.section {
    padding: 100px 20px;
}

.section-container {
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    display: inline-block;
    left: 50%;
    transform: translateX(-50%);
    color: var(--dark);
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    margin: 15px auto 0;
    border-radius: 2px;
}

.btn {
    display: inline-block;
    padding: 14px 32px;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    font-size: 0.95rem;
    border: none;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: var(--white);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    margin-left: 10px;
}

.btn-secondary:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-3px);
}

/* --- NAVBAR --- */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    z-index: 1000;
    box-shadow: var(--shadow-md);
    padding: 15px 0;
    transition: var(--transition);
}

.navbar.scrolled {
    padding: 10px 0;
    box-shadow: var(--shadow-lg);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.nav-logo {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1px;
    text-decoration: none;
    transition: var(--transition);
}

.nav-logo:hover {
    color: var(--primary-light);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 35px;
    align-items: center;
}

.nav-link {
    text-decoration: none;
    color: var(--dark);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
    position: relative;
    padding: 5px 0;
}

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

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

.nav-link:hover,
.nav-link.active {
    color: var(--primary);
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    z-index: 1001;
}

.menu-toggle span {
    display: block;
    width: 28px;
    height: 3px;
    background: var(--dark);
    margin: 6px 0;
    transition: 0.4s;
    border-radius: 3px;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(-45deg) translate(-8px, 6px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(45deg) translate(-8px, -6px);
}

/* --- HERO SECTION --- */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    padding: 120px 20px 80px;
}

.hero-content {
    max-width: 800px;
}

.profile-image-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 40px;
}

.profile-image {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 5px solid var(--white);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 2;
}

.profile-ring {
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    border-radius: 50%;
    border: 3px dashed var(--primary);
    animation: spin 15s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.hero-title {
    font-size: 4rem;
    line-height: 1.1;
    margin-bottom: 15px;
    color: var(--dark);
    font-weight: 700;
}

.title-line {
    display: block;
}

.hero-subtitle {
    font-family: var(--font-code);
    color: var(--primary);
    font-size: 1.3rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.hero-location {
    color: var(--secondary);
    margin-bottom: 35px;
    font-size: 1.05rem;
}

.hero-cta {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* --- PROJECTS GRID --- */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 35px;
}

.project-card {
    background: var(--white);
    padding: 35px;
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    border: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.project-card:hover::before {
    transform: scaleX(1);
}

.project-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary);
}



.project-card:hover .project-icon {
    filter: grayscale(0);
    transform: scale(1.1);
}

.project-card h3 {
    font-size: 1.5rem;
    margin-bottom: 12px;
    color: var(--dark);
    font-weight: 700;
}

.project-role {
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.project-date {
    color: var(--secondary);
    font-size: 0.85rem;
    margin-bottom: 15px;
    font-family: var(--font-code);
}

.project-desc {
    color: var(--secondary);
    margin-bottom: 20px;
    flex-grow: 1;
    line-height: 1.7;
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.tag {
    background: linear-gradient(135deg, #e0f2fe, #dbeafe);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.project-link {
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.project-link:hover {
    gap: 12px;
    color: var(--primary-dark);
}

/* --- IMAGE GALLERY --- */
.gallery {
    margin-top: 40px;
}

.gallery h3 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.5rem;
    color: var(--dark);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    height: 320px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-item::after {
    
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.gallery-item:hover::after {
    opacity: 1;
}

/* Image Modal/Lightbox */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        transform: scale(0.7);
    }
    to {
        transform: scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 25px;
    right: 35px;
    color: var(--white);
    font-size: 45px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    z-index: 2001;
}

.modal-close:hover {
    color: var(--primary-light);
    transform: rotate(90deg);
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--white);
    font-size: 3rem;
    cursor: pointer;
    padding: 20px;
    user-select: none;
    transition: var(--transition);
    z-index: 2001;
}

.modal-nav:hover {
    color: var(--primary-light);
}

.modal-prev {
    left: 20px;
}

.modal-next {
    right: 20px;
}

/* --- TIMELINE (ACTIVITIES) --- */
.timeline {
    position: relative;
    border-left: 3px solid var(--gray-200);
    margin-left: 30px;
    padding-left: 40px;
}

.timeline-item {
    margin-bottom: 50px;
    position: relative;
}

.timeline-dot {
    position: absolute;
    left: -50px;
    top: 8px;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    border: 4px solid var(--white);
    box-shadow: 0 0 0 3px var(--primary), var(--shadow-md);
    z-index: 1;
}

.timeline-content {
    background: var(--white);
    padding: 25px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    border: 1px solid var(--gray-200);
}

.timeline-content:hover {
    transform: translateX(10px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.timeline-content h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: var(--dark);
}

.timeline-date {
    font-family: var(--font-code);
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 10px;
    display: inline-block;
}

.timeline-role {
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.timeline-content > p {
    color: var(--secondary);
    line-height: 1.7;
}

.timeline-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    text-decoration: none;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--transition);
}

.timeline-link:hover {
    gap: 12px;
    color: var(--primary-dark);
}

/* --- SKILLS (Updated to Tags/Chips style) --- */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 40px;
}

.skill-category {
    background: var(--white);
    padding: 30px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
    transition: var(--transition);
}

.skill-category:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.skill-category h3 {
    margin-bottom: 25px;
    color: var(--dark);
    font-size: 1.3rem;
    border-bottom: 3px solid var(--primary);
    padding-bottom: 12px;
}

/* New Container for Tags */
.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* New Tag Style */
.skill-tag {
    background: linear-gradient(135deg, #e0f2fe, #dbeafe);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 50px; /* ทำให้มนกว่า tag ปกติ */
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid rgba(37, 99, 235, 0.2);
    transition: var(--transition);
    cursor: default;
    display: inline-block;
}


/* --- EDUCATION --- */
.education-card {
    background: var(--white);
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    transition: var(--transition);
}

.education-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.education-header {
    display: flex;
    align-items: center;
    gap: 25px;
    margin-bottom: 25px;
}



.education-header h3 {
    font-size: 1.8rem;
    color: var(--dark);
    margin-bottom: 5px;
}

.education-major {
    color: var(--primary);
    font-weight: 600;
    font-size: 1.1rem;
}

.education-details {
    margin-bottom: 20px;
}

.education-details p {
    color: var(--secondary);
    margin-bottom: 5px;
    line-height: 1.7;
}

.education-institution {
    font-weight: 600;
    color: var(--dark) !important;
    font-size: 1.1rem;
}

.education-highlights ul {
    list-style: none;
    padding-left: 0;
}

.education-highlights li {
    color: var(--secondary);
    margin-bottom: 10px;
    padding-left: 30px;
    position: relative;
    line-height: 1.7;
}

.education-highlights li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: bold;
    font-size: 1.2rem;
}

/* --- CONTACT --- */
.contact-content {
    max-width: 800px;
    margin: 0 auto;
}

.contact-info h3 {
    font-size: 2rem;
    margin-bottom: 15px;
    color: var(--dark);
}

.contact-info > p {
    color: var(--secondary);
    margin-bottom: 35px;
    font-size: 1.1rem;
}

.contact-methods {
    display: grid;
    gap: 25px;
}

.contact-method {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--white);
    padding: 25px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    border: 1px solid var(--gray-200);
}

.contact-method:hover {
    transform: translateX(10px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.contact-icon {
    font-size: 1.8rem;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #e0f2fe, #dbeafe);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.contact-method div {
    flex: 1;
}

.contact-label {
    font-size: 0.85rem;
    color: var(--secondary);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
}

.contact-method a {
    color: var(--dark);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.contact-method a:hover {
    color: var(--primary);
}

/* --- FOOTER --- */
.footer {
    background: var(--dark);
    color: var(--white);
    text-align: center;
    padding: 30px 20px;
    margin-top: 80px;
}

.footer p {
    font-size: 0.95rem;
}

/* --- RESPONSIVE DESIGN --- */
@media (max-width: 1024px) {
    .section-title {
        font-size: 2.2rem;
    }

    .hero-title {
        font-size: 3.2rem;
    }

    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 25px;
    }

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

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

    .section {
        padding: 60px 15px;
    }

    .menu-toggle {
        display: block;
    }

    .nav-menu {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 70px);
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(15px);
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding-top: 50px;
        transition: left 0.4s ease;
        box-shadow: var(--shadow-lg);
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-menu li {
        margin: 15px 0;
    }

    .nav-link {
        font-size: 1.2rem;
    }

    .hero-section {
        padding: 100px 15px 60px;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1.1rem;
    }

    .hero-cta {
        flex-direction: column;
        gap: 12px;
    }

    .btn {
        width: 100%;
        max-width: 300px;
    }

    .btn-secondary {
        margin-left: 0;
    }

    .profile-image-container {
        width: 160px;
        height: 160px;
    }

    .section-title {
        font-size: 1.8rem;
    }

    .projects-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .project-card {
        padding: 25px;
    }

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

    .gallery-item {
        height: 250px;
    }

    .timeline {
        margin-left: 15px;
        padding-left: 25px;
    }

    .timeline-dot {
        left: -30px;
    }

    .education-header {
        flex-direction: column;
        text-align: center;
    }

    .education-icon {
        font-size: 3rem;
        padding: 15px;
    }

    .modal-nav {
        font-size: 2rem;
        padding: 10px;
    }

    .modal-prev {
        left: 10px;
    }

    .modal-next {
        right: 10px;
    }

    .modal-close {
        top: 15px;
        right: 20px;
        font-size: 35px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2rem;
    }

    .section-title {
        font-size: 1.6rem;
    }

    .project-card {
        padding: 20px;
    }

    .education-card {
        padding: 25px;
    }

    .contact-method {
        flex-direction: column;
        text-align: center;
    }

    .gallery-item {
        height: 200px;
    }
}

/* Scroll to top button (optional enhancement) */
.scroll-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    z-index: 999;
}

.scroll-top.visible {
    display: flex;
}

.scroll-top:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

/* Loading animation for images */
.lazy-load {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.lazy-load.loaded {
    opacity: 1;
}

/* Print styles */
@media print {
    .navbar,
    .hero-cta,
    .footer,
    .scroll-top {
        display: none;
    }

    .section {
        padding: 20px 0;
        page-break-inside: avoid;
    }
}