/* --- 1. GLOBAL SCROLLBAR --- */
::-webkit-scrollbar {
    width: 10px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #0f172a;
}

::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 10px;
    border: 2px solid #0f172a;
}

::-webkit-scrollbar-thumb:hover {
    background: #fb923c;
}

/* --- 2. BASE STYLES --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
    background-color: #0f172a;
}

.pixel-brand {
    font-family: 'Jersey 10', sans-serif;
}

/* --- 3. NAVBAR & ANIMATED MENU --- */
.navbar {
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background-color: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 85rem;
    margin: 0 auto;
    padding: 0 2rem;
    height: 5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-section {
    display: flex;
    align-items: center;
    text-decoration: none;
    cursor: pointer;
}

.logo-img {
    width: 2.5rem;
    height: 2.5rem;
    object-fit: contain;
    margin-bottom: 0.3rem;
    filter: drop-shadow(0 0 5px rgba(34, 211, 238, 0.2));
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.logo-section:hover .logo-img {
    transform: scale(1.15) rotate(-8deg);
}

/* --- สไตล์แบบ Text ซ้อนกัน (Stacked) ที่คุณชอบ --- */
.brand-text {
    display: flex;
    flex-direction: column;
    /* บังคับให้ซ้อนกันบน-ล่าง */
    justify-content: center;
    margin-left: 0.8rem;
    line-height: 0.9;
    /* บีบระยะบรรทัดให้ชิดกันดูเท่ */
}

.brand-title {
    font-size: 1.6rem;
    color: white;
    display: block;
    margin: 0;
    letter-spacing: 0.05em;
}

.brand-subtitle {
    font-size: 0.8rem;
    color: #22d3ee;
    /* สี Cyan */
    display: block;
    letter-spacing: 0.25em;
    margin-top: 2px;
    /* ระยะห่างนิดเดียวพอให้ดูเป็นระเบียบ */
}

.nav-menu {
    display: flex;
    gap: 3.5rem;
    list-style: none;
}

/* Stagger Animation for Menu Items */
.nav-item-anim {
    opacity: 0;
    animation: navSlideUp 0.6s ease-out forwards;
}

.nav-item-anim:nth-child(1) {
    animation-delay: 0.1s;
}

.nav-item-anim:nth-child(2) {
    animation-delay: 0.2s;
}

.nav-item-anim:nth-child(3) {
    animation-delay: 0.3s;
}

.nav-link {
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.6rem;
    font-family: 'Jersey 10', sans-serif;
    text-decoration: none;
    transition: 0.3s;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background-color: #fb923c;
    transition: width 0.3s ease;
}

.nav-link:hover {
    color: white;
    transform: translateY(-3px);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.nav-link.active {
    color: white;
}

.nav-action-anim {
    opacity: 0;
    animation: navSlideUp 0.6s ease-out 0.5s forwards;
}

.btn-contact {
    font-size: 1.3rem;
    background-color: #fb923c;
    color: white;
    padding: 0.6rem 1.6rem;
    border-radius: 0.4rem;
    text-decoration: none;
    box-shadow: 4px 4px 0px 0px rgba(255, 255, 255, 0.15);
    transition: 0.2s;
}

.btn-contact:hover {
    transform: scale(1.05) translate(-2px, -2px);
    box-shadow: 6px 6px 0px 0px rgba(255, 255, 255, 0.2);
}

.btn-contact:active {
    box-shadow: 0px 0px 0px transparent;
    transform: translate(2px, 2px);
}

/* --- 4. HERO SECTION --- */
.hero-section {
    position: relative;
    height: 80vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0;
    filter: blur(15px);
    transition: opacity 2s ease-in-out;
}

.slide.active {
    opacity: 1;
}

.overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(15, 23, 42, 0.4), #0f172a);
    z-index: 2;
}

.hero-content {
    position: relative;
    z-index: 10;
    text-align: center;
}

.main-title {
    font-size: 6rem;
    line-height: 0.95;
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.hero-subtitle {
    font-size: 1.4rem;
    margin-top: 1.8rem;
}

/* --- 5. PROJECTS & CARDS --- */
.projects-section {
    padding: 6rem 0;
}

.container-wide {
    max-width: 95rem;
    margin: 0 auto;
    padding: 0 2.5rem;
}

.section-heading {
    font-size: 3rem;
    color: #22d3ee;
    margin-bottom: 3.5rem;
}

.slider-wrapper {
    overflow-x: auto;
    padding-bottom: 3rem;
}

.project-slider {
    display: flex;
    gap: 2.5rem;
    width: max-content;
}

.project-card {
    min-width: 380px;
    height: 480px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 1.2rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: 0.3s;
}

.project-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(34, 211, 238, 0.3);
}

.card-media {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: 0.5s;
}

.project-card:hover .card-img {
    transform: scale(1.1);
}

.card-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.3rem 0.7rem;
    border-radius: 0.3rem;
    font-size: 0.75rem;
    color: white;
}

.card-body {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-title {
    font-size: 1.8rem;
}

.card-description {
    font-size: 0.9rem;
    color: #94a3b8;
    line-height: 1.5;
}

.card-footer {
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
}

.btn-card-primary {
    flex: 1;
    background: #fb923c;
    color: white;
    text-align: center;
    padding: 0.6rem;
    border-radius: 0.4rem;
    text-decoration: none;
    transition: 0.3s;
}

.btn-card-secondary {
    padding: 0.6rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border-radius: 0.4rem;
    text-decoration: none;
}

.project-card-empty {
    min-width: 380px;
    height: 480px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Jersey 10', sans-serif;
    font-size: 1.8rem;
    color: rgba(255, 255, 255, 0.1);
}

/* --- 6. FOOTER --- */
.footer-section {
    background-color: #0b1120;
    padding: 5rem 0 2rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 4rem;
    margin-bottom: 4rem;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 1rem;
}

.footer-links a {
    color: #94a3b8;
    text-decoration: none;
    transition: 0.3s;
}

.footer-links a:hover {
    color: #fb923c;
    padding-left: 5px;
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    color: white;
    text-decoration: none;
    font-size: 0.8rem;
    transition: 0.3s;
}

.social-icon:hover {
    background: #fb923c;
    transform: translateY(-3px);
}

.footer-bottom {
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* --- 7. KEYFRAMES & ANIMATIONS --- */
@keyframes navSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.anim-fade-down {
    animation: fadeDown 0.8s ease-out forwards;
}

.anim-reveal-1 {
    animation: revealUp 0.8s ease-out 0.3s forwards;
    opacity: 0;
}

.anim-reveal-2 {
    animation: revealUp 0.8s ease-out 0.5s forwards;
    opacity: 0;
}

.anim-reveal-3 {
    animation: revealUp 1s ease-out 0.8s forwards;
    opacity: 0;
}

@keyframes fadeDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes revealUp {
    from {
        transform: translateY(40px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr;
    }

    .main-title {
        font-size: 3.5rem;
    }
}

/* --- 1. Interaction สำหรับหัวข้อ (Header) --- */
.project-header-group {
    text-decoration: none;
    display: block;
    margin-bottom: 3rem;
    width: fit-content;
}

.project-header-group .section-heading {
    margin-bottom: 0.2rem;
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 1rem;
    color: white;
}

.header-arrow {
    opacity: 0;
    transform: translateX(-15px);
    transition: 0.4s;
    color: #fb923c;
}

.view-all-text {
    font-size: 0.9rem;
    color: #94a3b8;
    opacity: 0.6;
    transition: 0.3s;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Hover Effect สำหรับหัวข้อ */
.project-header-group:hover .section-heading {
    color: #fb923c;
    transform: translateX(5px);
}

.project-header-group:hover .header-arrow {
    opacity: 1;
    transform: translateX(0);
}

.project-header-group:hover .view-all-text {
    color: #22d3ee;
    opacity: 1;
    padding-left: 5px;
}

/* --- 2. Interaction สำหรับ Project Cards ใน Slider --- */
.project-card {
    width: 300px;
    transition: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

.project-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(34, 211, 238, 0.5);
}

.card-img {
    transition: 0.6s;
}

.project-card:hover .card-img {
    transform: scale(1.1) rotate(1deg);
    filter: brightness(1.1);
}

/* เอฟเฟกต์สำหรับ Empty Card */
.project-card-empty {
    transition: 0.3s;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    /* สไตล์เดิมของคุณ... */
}

.project-card-empty:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #fb923c;
    color: #fb923c;
}

/* --- อัปเกรด Modal พร้อม Transition --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(0px);
    /* เริ่มต้นที่ 0 */

    /* ส่วนสำคัญที่ทำให้มี Transition */
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease-out;

    display: flex;
    /* ใช้ flex ค้างไว้เลยแต่คุมด้วย opacity แทน */
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* เมื่อสั่ง active ให้จางขึ้นมา */
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    backdrop-filter: blur(8px);
    /* ค่อยๆ เบลอ */
}

/* เพิ่มลูกเล่นให้ตัวกล่องข้อความ (Modal Content) เด้งขึ้นมานิดๆ */
.modal-content {
    background: #1e293b;
    border: 2px solid rgba(34, 211, 238, 0.2);
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 450px;

    /* เริ่มต้นให้ตัวกล่องตกลงไปข้างล่างหน่อยและเล็กลง */
    transform: translateY(30px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* เมื่อ active ให้ตัวกล่องเด้งกลับมาที่เดิม */
.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 2.5rem;
    cursor: pointer;
}

.close-btn:hover {
    color: #ef4444;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.7rem;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 4px;
}

/* ============================================================
   COMBINED MOBILE RESPONSIVE (ยุบรวมส่วนที่ซ้ำซ้อน)
   ============================================================ */

/* 1. ปุ่ม Hamburger (ใช้ชื่อคลาส .mobile-btn ให้ตรงกับ HTML) */
.mobile-btn {
    display: none;
    /* ซ่อนบนคอม */
    flex-direction: column;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 2001;
    /* ให้อยู่เหนือเมนู */
    padding: 5px;
}

.mobile-btn span {
    width: 28px;
    height: 3px;
    background: #22d3ee;
    transition: 0.3s;
    display: block;
}

/* แอนิเมชันปุ่มตอนเปลี่ยนเป็นตัว X */
.mobile-btn.open span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.mobile-btn.open span:nth-child(2) {
    opacity: 0;
}

.mobile-btn.open span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* 2. ซ่อนปุ่ม Contact พิเศษ (Mobile Only) เมื่ออยู่บนจอคอม */
.mobile-only {
    display: none;
}

/* ============================================================
   MEDIA QUERY (สำหรับหน้าจอมือถือ 768px ลงไป)
   ============================================================ */
@media (max-width: 768px) {

    /* โชว์ปุ่ม Hamburger */
    .mobile-btn {
        display: flex;
    }

    /* ซ่อนปุ่ม Contact ตัวนอก และส่วนประกอบที่ไม่จำเป็น */
    .hide-on-mobile,
    .nav-action-anim {
        display: none !important;
    }

    /* จัดการเมนูให้เป็นแบบ Full Screen */
    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        /* ซ่อนไว้ทางขวา */
        width: 100%;
        height: 100vh;
        background: rgba(15, 23, 42, 0.98);
        /* พื้นหลังเข้มขึ้นให้มองเห็นชัด */
        backdrop-filter: blur(10px);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        gap: 2rem !important;
        /* เว้นระยะห่างเมนู */
    }

    .nav-menu.active {
        right: 0;
        /* เลื่อนเข้ามาเมื่อกดปุ่ม */
    }

    /* โชว์ปุ่ม Contact ภายในเมนู */
    .mobile-only {
        display: block;
        width: 80%;
    }

    .mobile-contact-link {
        display: block;
        text-align: center;
        padding: 1rem;
        background: #fb923c;
        border-radius: 8px;
        color: white;
        text-decoration: none;
        font-size: 1.5rem;
    }

    /* ปรับแต่งหน้าตา Hero ให้เข้ากับจอมือถือ */
    .main-title {
        font-size: 3rem !important;
        line-height: 1.1;
    }

    .hero-subtitle {
        font-size: 1.1rem;
        padding: 0 1rem;
    }

    /* ปรับ Project Slider จากแนวนอนเป็นแนวตั้ง */
    .project-slider {
        flex-direction: column !important;
        align-items: center;
        width: 100% !important;
    }

    .project-card {
        min-width: 100% !important;
        width: 100%;
    }

    .project-card-empty {
        display: none;
        /* ซ่อนการ์ดว่างบนมือถือ */
    }

    /* จัด Footer ให้สมดุล */
    .footer-grid {
        grid-template-columns: 1fr !important;
        text-align: center;
        gap: 3rem;
    }

    .footer-col {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .social-links {
        justify-content: center;
    }
}

/* --- ป้องกันหน้าจอดิ้น (แก้สไลด์ข้างใน Mobile) --- */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
    /* ห้ามเลื่อนซ้ายขวาเด็ดขาด */
    position: relative;
}

/* --- แก้ไข Modal (Contact Button Pop-up) --- */
.modal-overlay {
    position: fixed;
    /* ต้องเป็น fixed เสมอเพื่อให้ลอยทับทุกอย่าง */
    top: 0;
    left: 0;
    width: 100vw;
    /* เต็มความกว้างจอ */
    height: 100vh;
    /* เต็มความสูงจอ */
    display: flex;
    justify-content: center;
    /* กึ่งกลางแนวนอน */
    align-items: center;
    /* กึ่งกลางแนวตั้ง */
    z-index: 9999;
    /* ต้องสูงที่สุดในหน้าเว็บ */
    padding: 20px;
    /* กันขอบจอเวลาอยู่บนมือถือ */
}

.modal-content {
    margin: auto;
    /* ช่วยให้บีบอยู่ตรงกลาง */
    position: relative;
    max-width: 450px;
    width: 100%;
    /* ให้ขยายตามหน้าจอมือถือแต่ไม่เกิน 450px */
}

@media (max-width: 768px) {

    /* ปรับให้ Card ไม่ดันขอบจนหน้าเว็บเลื่อน */
    .project-card {
        min-width: unset !important;
        /* ยกเลิกค่าเดิมที่อาจจะกว้างเกินไป */
        width: 100% !important;
    }

    .container-wide {
        padding: 0 1.5rem;
        /* ลด Padding ข้างๆ ลงหน่อยให้พอดีจอมือถือ */
        overflow: hidden;
        /* กันลูกหลานทำหน้าพัง */
    }
}