:root {
    --text-color-light: #ffffff;
    --text-color-dim: #bbbbbb; /* สีใหม่สำหรับลิงก์ย่อย */
    --text-color-dark: #222222;
    --background-overlay: rgba(20, 20, 20, 0.95);
    /* เปลี่ยน Font ให้ตรงกับดีไซน์ */
    /* --font-family: 'IBM Plex Sans Thai Looped', sans-serif; */
}

body {
    margin: 0;
    font-family: var(--font-family);
    color: var(--text-color-light);
}

html.overlay-open {
    overflow: hidden;
}

/* แก้ไขกฎเดิมนี้ */
body.overlay-open {
    overflow: hidden;
    /* เพิ่ม 2 บรรทัดนี้เข้าไป */
    position: fixed;
    width: 100%;
    /* 'top' จะถูกกำหนดค่าโดย JavaScript */
}

/* --- Main Header --- */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 12.5rem; /* ลด Padding ด้านข้างเล็กน้อย */
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* === เพิ่มส่วนนี้เข้าไปครับ === */
.header-left, .logo-desktop {
    pointer-events: auto; /* สั่งเปิดให้ฝั่งซ้าย (โลโก้) คลิกได้ */
}

/* .header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
} */

.menu-button, .search-link, .lang-link {
    background: none;
    border: none;
    color: #ffffff;
    font-family: var(--font-family);
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.9;
    transition: opacity 0.3s ease;
    
}

.menu-button:hover, .search-link:hover, .lang-link:hover {
    opacity: 1;
    color: #ff0000;
}

.search-link svg {
    stroke-width: 0.094rem;
}

/* --- Overlay Menu --- */
.overlay-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-overlay);
    z-index: 200;
    display: flex;
    flex-direction: column;
    /* justify-content: space-between; */
    align-items: flex-start;
    padding: 10vh 6.25rem 2.5rem 12.5rem;
    box-sizing: border-box;

    /* --- การเปลี่ยนแปลงเริ่มที่นี่ --- */
    opacity: 0;
    visibility: hidden;
    transform: translateX(-100%); /* ซ่อนไว้ทางซ้าย */
    /* ปรับ Transition ให้เนียนขึ้นด้วย cubic-bezier */
    transition: transform 0.5s cubic-bezier(0.215, 0.610, 0.355, 1), 
                opacity 0.4s ease, 
                visibility 0s 0.5s;
}

.overlay-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0); /* สไลด์กลับเข้ามาในจอ */

    /* ===== โค้ดที่ปรับปรุงแล้ว ===== */
    /* ลบ delay ทิ้งเมื่อเมนูทำงาน เพื่อให้แสดงผลทันที */
    transition-delay: 0s;
}

.close-button {
    position: fixed; /* <--- แก้ไขเป็น 'fixed' */
    top: 2.5rem;
    right: 12.5rem;
    /* เปลี่ยนพื้นหลังเป็นสีขาวทึบ */
    background-color: #ffffff;
    /* เปลี่ยนสีไอคอน 'x' เป็นสีเข้ม */
    color: #000000;
    border: none;
    width: 1.875rem;
    height: 1.875rem;
    border-radius: 50%;
    font-size: 1.75rem;
    cursor: pointer;
    /* เพิ่ม flex เพื่อจัดไอคอนให้อยู่ตรงกลางสมบูรณ์แบบ */
    display: flex;
    align-items: center;
    justify-content: center;
    /* เพิ่ม Transition เพื่อให้ Animation นุ่มนวล */

    /* --- ↓↓↓ ส่วนที่เพิ่มเข้ามา --- */
    opacity: 0; /* 1. ซ่อนไว้เป็นค่าเริ่มต้น */
    visibility: hidden; /* 2. ซ่อนไว้เป็นค่าเริ่มต้น */
    z-index: -1; /* 3. กันเผลอคลิกโดน (ส่งไปไว้ข้างหลัง) */
        
    transition: transform 0.3s ease, background-color 0.3s ease;
}

body.overlay-open .close-button {
    opacity: 1;
    visibility: visible;
    z-index: 201; /* ให้อยู่เหนือทุก Overlay */
}

.overlay-content {
    /* ไม่ต้องใช้ max-width อีกต่อไป */
}

.overlay-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.overlay-nav ul li a {
    color: #008D87;
    text-decoration: none;
    /* เพิ่มขนาด Font ให้ใหญ่และโดดเด่น */
    font-size: 2vw;
    font-weight: 500;
    line-height: 1.3;
    display: inline-block;
}

/* --- Social Links (ใน Overlay) --- */
.social-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 16.25rem; /* เพิ่มระยะห่างจากเมนูหลัก */
}

.social-links a {
    color: #ffffff;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.3s ease;
}

.social-links a:hover {
    color: var(--text-color-light);
}

/* --- Bottom Bar (Copyright & Lang) --- */
.overlay-bottom-bar {
    width: 87%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: #ffffff;
}

.legal-links a, .overlay-lang a {
    color: #ffffff;
    text-decoration: none;
    transition: color 0.3s ease;
}

.legal-links a:hover, .overlay-lang a:hover {
    color: var(--text-color-light);
}

/* --- Background Content --- */
.background-content {
    /* width: 100%;
    height: 100vh; */
    overflow: hidden;
    position: relative; /* เพิ่ม position */
}

.background-content img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.8); /* ทำให้รูปมืดลงเล็กน้อย */
}

/* Style สำหรับ "Wirut House" */
.project-title {
    position: absolute;
    bottom: 10%;
    right: 10%;
    font-size: 6vw;
    font-weight: 600;
    color: white;
    text-shadow: 2px 2px 10px rgba(0,0,0,0.5);
}

/* --- Divider Line in Overlay --- */
.divider {
    width: 88%;
    border: none;
    height: 0.063rem;
    background-color: #ffffff; /* สีขาวโปร่งแสง */
    margin: 1.25rem 0 1.25rem 0; /* ระยะห่างด้านล่าง 20px ก่อนถึง footer */
}

/* --- Search Overlay --- */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-overlay); 
    z-index: 199;
    display: flex;
    justify-content: center;
    align-items: center;

    /* --- การเปลี่ยนแปลงเริ่มที่นี่ --- */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-100%); /* ซ่อนไว้ด้านบน */

    /* Animation แบบสไลด์ + Fade พร้อมหน่วงเวลาตอนปิด */
    transition: transform 0.5s cubic-bezier(0.215, 0.610, 0.355, 1), 
                opacity 0.4s ease, 
                visibility 0s 0.5s;
}

.search-overlay.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0); /* สไลด์ลงมากลางจอ */

    /* ลบ delay ทิ้งเมื่อทำงาน เพื่อให้แสดงผลทันที */
    transition-delay: 0s;
}

.search-container {
    position: relative;
    width: 60%;
    max-width: 31.25rem;
}

#search-input {
    width: 100%;
    background: none;
    border: none;
    border-bottom: 0.063rem solid #008D87;
    color: var(--text-color-light);
    font-family: var(--font-family);
    font-size: 2vw;
    padding: 0px 2.5rem 0px 0; /* เพิ่ม padding ด้านขวาสำหรับไอคอน */
    outline: none;
    transition: border-color 0.3s ease;
}

#search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
}

#search-input:focus {
    border-bottom-color: var(--text-color-light);
}

.search-submit {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 0.313rem;
}

.mobile-overlay-footer {
    display: none;
}

.divider-phone {
    display: none;
}

.logo-mobile {
    display: none; /* ซ่อนโลโก้มือถือไว้เป็นค่าเริ่มต้น */
}

.search-link-mobile{
    display: none;
}

/* --- Responsive adjustments --- */
@media screen and (max-width: 768px) {
    /* 1. Header หลัก */

    .search-link span, .lang-link {
        display: none; /* ซ่อนข้อความ "Search" และ "EN" */
    }

    .header-left, .header-right {
        display: contents;
    }

    .menu-button {
        grid-column: 1 / 2; /* คอลัมน์ 1 (ซ้าย) - เหมือนเดิม */
        justify-self: start;
        padding: 0; 
    }
    
    .logo {
        grid-column: 4 / 5;   /* << ย้ายไปคอลัมน์ 4 (ขวาสุด) */
        justify-self: end;    
        display: flex;         
        align-items: center;
    }

    .search-link {
        display: none;
        margin-right: 0.938rem; /* << เพิ่มระยะห่างระหว่าง Search กับ Logo */
    }

    /* --- ซ่อนองค์ประกอบที่ไม่ต้องการ --- */
    .search-link span, .lang-link, .menu-button span {
        display: none;
    }

    /* 2. ปุ่มปิด */
    .close-button {
        top: 1.25rem;
        right: 1.25rem;
        width: 2.5rem;
        height: 2.5rem;
    }

    /* 3. Menu Overlay */
    .overlay-menu {
        padding: 15vh 2.5rem 0.313rem 2.5rem; /* ปรับระยะห่างโดยรวม */
        /* justify-content: space-between; */
        background-color: var(--background-overlay);
    }

    .menu-main-content {
        display: flex;
        width: 100%;
        gap: 0.938rem;
        align-items: flex-start;
    }

    .overlay-nav { flex: 2; }
    .overlay-nav ul li a {
        font-size: 5vw; /* เพิ่มขนาดฟอนต์เมนูให้ใหญ่ขึ้น */
        line-height: 2;
    }
    .social-links { display: none; }
    .social-links a { font-size: 0.875rem; color: var(--text-color-dim); }
    .divider { width: 90%; align-self: center; }
    .overlay-bottom-bar { width: 90%; align-self: center; flex-direction: column; align-items: flex-start; gap: 0.938rem; }

    .search-content-wrapper {
        grid-template-columns: 1fr; /* เปลี่ยนเป็น 1 คอลัมน์ */
        gap: 60px;
    }
    .main-search-input { font-size: 8vw; }
    .search-right-col { padding-top: 0; }
    .project-title { font-size: 10vw; right: 5%; bottom: 5%; }
    
    #search-input {
        font-size: 5vw;
        padding: 0rem 0.625rem 0rem 0;
    }
    :root {
        --background-overlay: rgba(20, 20, 20, 0.7); /* <-- ปรับเป็น 90% เพื่อให้จางลง */
    }
    
    .search-link svg {
        width: 1.875rem;
        height: 1.875rem;
    }

    /* ทำให้ Overlay Menu ดัน Footer ไปอยู่ล่างสุด */
    .overlay-menu {
        justify-content: space-between;
    }

    /* ทำให้ Footer ของมือถือแสดงผล */
    .mobile-overlay-footer {
        display: block; /* สั่งให้แสดงผล */
        width: 100%;
        margin-top: auto; /* ดันตัวเองลงไปอยู่ล่างสุด */
        padding-bottom: 1.25rem;
    }

    .mobile-overlay-footer .footer-top-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .mobile-overlay-footer .footer-social-icons {
        display: flex;
        gap: 0.938rem;
    }

    .mobile-overlay-footer .footer-logo img {
        height: 2.188rem;
        width: auto;
    }

    .mobile-overlay-footer .footer-bottom-row p {
        font-size: 0.75rem;
        color: #ffffff;
        text-align: center;
        margin: 0;
    }

    /* ซ่อน Footer เดิมของ Desktop และเส้นคั่นที่ไม่ต้องการแล้ว */
    .overlay-bottom-bar, 
    .divider {
        display: none;
    }
    .divider-phone {
    display: block;
    width: 100%;
    border: none;
    height: 0.063rem;
    background-color: #ffffff; /* สีขาวโปร่งแสง */
    margin: 0.625rem 0 0.625rem 0; /* ระยะห่างด้านล่าง 20px ก่อนถึง footer */
    }
    .logo-desktop {
        display: none; /* ซ่อนโลโก้ Desktop เมื่อเป็นมือถือ */
    }
    .logo-mobile {
        display: block; /* แสดงโลโก้มือถือ */
    }
    .search-link-mobile{
    display: block;
    background: none;
    border: none;
    color: var(--text-color-light);
    font-family: var(--font-family);
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.9;
    transition: opacity 0.3s ease;
    }

    .search-link-mobile svg{
        width: 1.875rem;
        height: 1.875rem;
        color: #ffffff;
    }

    .header-mobile-right{
        display: flex;
        align-items: center;
        gap: 0.938rem;
    }
}

/* //////////////////////////////////////////           NEW       ////////////////////////////////////////////////////////// */

/* --- Desktop Nav Styles (เพิ่มเข้าไปใหม่) --- */
.desktop-nav ul {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.desktop-nav ul li a {
    color: #008D87;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

.desktop-nav ul li a:hover {
    color: #ff0000;
}

/* ซ่อนปุ่ม Menu บน Desktop */
.menu-button {
    display: none;
}


/* --- Vertical Sidebar (Desktop Only) --- */
.side-navigation {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    padding: 9rem 0 0 5rem;
    display: flex;
    flex-direction: column;
    gap: 13rem; /* เพิ่มระยะห่างระหว่างก้อนเมนูหลักกับก้อนติดต่อ */
    z-index: 101;
}

.side-logo img {
    height: 40px;
    width: auto;
}

.side-nav-links ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem; /* ระยะห่างระหว่างเมนูแต่ละอัน */
}

.side-nav-links ul li a {
    color: #008D87;
    text-decoration: none;
    font-size: 1.7rem;
    font-weight: 500;
    text-transform: uppercase;
    transition: color 0.3s ease;
}

.side-nav-links ul li a:hover {
    color: #ff0000;
}

/* ปรับปรุง Site Header เดิมให้เหลือแต่ปุ่มด้านขวา */
.site-header {
    background-color: transparent;
    pointer-events: none; /* เพื่อให้คลิกทะลุช่องว่างไปยังเนื้อหาได้ */
    background-color: rgba(0, 0, 0, 0.56);
}

.header-right {
    pointer-events: auto; /* ให้ปุ่ม Search กลับมาคลิกได้ */
}

/* header.css - ส่วน Global หรือ Desktop */

.mobile-controls {
    display: none; /* ซ่อนไว้ก่อนเสมอเมื่ออยู่หน้าจอปกติ */
}

/* --- สไตล์ก้อนที่ 1: เมนูหลัก (About, Projects, etc.) --- */
.main-nav-group ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.main-nav-group ul li a {
    color: #ffffff;
    /*color: #008D87;*/
    text-decoration: none;
    font-size: 1.7rem; /* ขนาดใหญ่พิเศษตามที่คุณต้องการ */
    /*font-weight: 600;*/
    text-transform: uppercase;
    transition: color 0.3s ease;
}

/* --- สไตล์ก้อนที่ 2: ข้อมูลติดต่อ (Facebook, Line, etc.) --- */
.contact-nav-group ul {
    list-style: none;
    /*padding: 0;*/
    /*margin: 0;*/
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/*.contact-nav-group ul li{*/
/*    margin-top:1rem;*/
/*}*/

.contact-nav-group ul li a {
    /*color: #ffffff;*/
    /*text-decoration: none;*/
    /*font-size: 1rem;*/
    /*font-weight: 400;*/
    /*transition: color 0.3s ease;*/
    
    display: flex;           /* ใช้ Flexbox เพื่อจัดระเบียบ */
    align-items: center;     /* สั่งให้ ไอคอน กับ ข้อความ อยู่กึ่งกลางแนวตั้งตรงกัน */
    gap: 0.5rem;               /* ระยะห่างระหว่าง ไอคอน กับ ข้อความ */
    
    color: #ffffff;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 400;
    transition: color 0.3s ease;
    
}

/* Hover Effect สำหรับทั้งสองก้อน */
.main-nav-group ul li a:hover,
.contact-nav-group ul li a:hover {
    color: #008D87;
}

.contact-icon {
    width: 1.5rem;
    height: 1.5rem;
}

.contact-icon img{
    margin-top: 1rem;
}

/* เปลี่ยนสีข้อความ Placeholder ในช่อง Search */
#search-input::placeholder {
    color: #008D87; /* ใส่สีที่คุณต้องการตรงนี้ (ตัวอย่างคือสีเขียวที่คุณใช้) */
    opacity: 1;      /* สำหรับ Firefox เพื่อให้สีแสดงผลชัดเจน */
}

.lang-link {
    color: #ffffff; /* สีปกติ (เช่น สีขาว) */
    text-decoration: none;
    opacity: 0.5;
    transition: 0.3s;
}

.lang-link.active {
    color: #008D87; /* สีเขียวที่คุณต้องการเมื่อถูกเลือก */
    opacity: 1;
    font-weight: bold;
}

.lang-switcher-mobile {
    display: none; /* ซ่อนเวอร์ชันมือถือบนคอม */
}

.lang-switcher-mobile .lang-link.active {
    color: #008D87; /* สีเขียว */
    text-decoration: none;
    font-size: 0.85rem; /* ปรับขนาดเล็กลงหน่อยให้เหมาะกับมือถือ */
    font-weight: 600;
    border: 1px solid #008D87;
    padding: 2px 6px;
    border-radius: 4px;
}


.lang-link-toggle {
    text-decoration: none;
    color: #008D87; /* สีเขียว */
    font-weight: 600;
    border: 1px solid #008D87;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: 0.3s;
}

.lang-link-toggle:hover {
    background: #008D87;
    color: #fff;
}

.lang-toggle-btn {
    text-decoration: none;
    color: #ffffff;
    font-size: 1rem;
    border: 1px solid #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
}
.lang-toggle-btn:hover {
    background: #008D87;
    color: #ffffff;
}

.desktop-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}


/* ซ่อน Sidebar เมื่ออยู่ในมือถือ */
@media screen and (max-width: 768px) {
    .side-navigation {
        display: none;
    }
    
    .site-header {
        padding: 10px 15px !important; /* ลด Padding มหาศาลจากหน้าคอมออก */
        justify-content: space-between;
    }
    .logo-desktop, 
    .desktop-controls {
        display: none !important;
    }
    .mobile-controls {
        display: flex;
        align-items: center;
        gap: 12px; 
        pointer-events: auto;
    }
    .header-left {
        display: flex;
        align-items: center;
    }

    .header-right {
        display: block !important; /* มั่นใจว่า header-right ไม่ถูกซ่อน */
    }

    /* ปรับขนาดโลโก้มือถือให้พอดี */
    .logo-mobile-link img {
        display: block;
        height: 35px !important;
    }
    .side-navigation {
        display: none; /* ซ่อน Sidebar ทั้งหมดในมือถือ */
    }
    
    .lang-switcher-desktop {
        display: none;
    }

    .lang-switcher-mobile {
        display: block; /* มั่นใจว่าแสดงผลแน่นอน */
        margin-left: 10px; /* ระยะห่างจากหลัง Logo */
    }

    .lang-switcher-mobile {
        order: 2; /* ให้ภาษาอยู่หลังโลโก้ */
    }
    .logo {
        order: 1; /* ให้โลโก้อยู่ก่อน */
    }

    .header-left {
        display: flex;
        align-items: center;
        width: 100%;
    }
    /* ซ่อนเมนู Desktop บนมือถือ */
    .desktop-nav {
        display: none;
    }

    /* กลับมาแสดงปุ่ม Menu บนมือถือเพื่อให้กดเปิด Overlay ได้เหมือนเดิม */
    .menu-button {
        display: block;
        grid-column: 1 / 2;
        justify-self: start;
        pointer-events: auto;
    }
    
    .lang-toggle-btn {
        font-size: 1rem;
    }
}

/* สำหรับ iPad และ Tablet (หน้าจอขนาดไม่เกิน 1180px) */
@media screen and (min-width: 769px) and (max-width: 1180px) {

    .site-header {
        padding: 1.563rem 6.25rem; /* ลด Padding ด้านข้างเล็กน้อย */
    }
    .side-navigation {
        padding: 11rem 0 0 4.5rem; /* ลด Padding ด้านซ้ายของ Sidebar */
        width: 350px;
    }

    .main-nav-group ul li a {
        font-size: 3rem; /* ลดขนาดฟอนต์เมนูหลักเล็กน้อย */
    }
    .contact-icon {
        width: 2.2rem;
        height: 2.2rem;
    }
    .contact-nav-group ul li a {
        font-size: 1.5rem; /* ลดขนาดฟอนต์เมนูติดต่อเล็กน้อย */
    }
    .side-navigation {
        gap: 20rem;
    }
    .lang-toggle-btn {
        font-size: 1.5rem;
        /* padding: 0.8rem 0.8rem; */
    }
    .search-link{
        font-size: 1.5rem;
    }
    .search-link svg {
    stroke-width: 0.094rem;
    }
    .logo-desktop img {
        height: 5rem;
    }
    #search-input {
        font-size: 3vw;
    }
}
/* //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */

