@charset "utf-8";
/* ========================================================
   1. สไตล์เริ่มต้น (Global Reset & Font)
   ======================================================== */
#nav {
    font-family: 'thsarabunnew', 'TH Sarabun New', Tahoma, sans-serif;
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

#nav *, #nav *::before, #nav *::after {
    box-sizing: border-box;
}

/* ซ่อนปุ่มเปิด-ปิดเมนูเป็นค่าเริ่มต้น */
#nav .menu-open,
#nav .menu-close {
    display: none;
}

#nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#nav a {
    color: #333333;
    text-decoration: none;
    display: block;
    transition: all 0.3s ease;
    font-family: 'thsarabunnew', 'TH Sarabun New', Tahoma, sans-serif;
}

#nav a:active {
    background-color: #F0D202 !important;
}


/* ========================================================
   2. เวอร์ชันคอมพิวเตอร์จอใหญ่ (ขยับช่วงหน้าจอเพิ่มเป็น 1101px ขึ้นไป)
   ======================================================== */
@media screen and (min-width: 1101px) {
    #nav .menu-open, #nav .menu-close { display: none !important; }
    #nav .menu-wrapper { position: relative !important; left: 0 !important; width: 100% !important; height: auto !important; background: none !important; padding: 0 !important; }

    #nav .menu-wrapper > ul {
        height: 45px;
        background-color: #F0D202;
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: flex-start;
        align-items: center;
    }
    #nav .menu-wrapper > ul > li { position: relative; height: 100%; }
    
    #nav .menu-wrapper > ul > li > a {
        padding: 0 18px; 
        height: 100%;
        font-size: 1.6rem; 
 
        display: flex;
        align-items: center;
        white-space: nowrap;
    }
    #nav .menu-wrapper > ul > li > a::after {
        content: ''; position: absolute; bottom: 0; left: 50%; width: 0; height: 3px;
        background-color: #cc470d; transition: all 0.3s ease; transform: translateX(-50%);
    }
    #nav .menu-wrapper > ul > li:hover > a::after { width: 80%; }
    #nav .menu-wrapper > ul > li:hover > a { color: #cc470d; background-color: rgba(255, 255, 255, 0.15); }

    /* Dropdown บนคอม */
    #nav li ul {
        background-color: #FDE424; position: absolute; top: 100%; left: 0; min-width: 220px; z-index: 99;
        display: block; opacity: 0; visibility: hidden; transform: translateY(15px); transition: all 0.3s ease;
    }
    #nav li:hover ul { opacity: 1; visibility: visible; transform: translateY(0); }
    #nav li ul a { font-size: 19px; padding: 10px 20px; border-bottom: 1px solid rgba(204, 102, 0, 0.2); text-align: left; }
    #nav li ul li a:hover { background-color: #cc470d; color: #ffffff !important; padding-left: 25px; }
}


/* ========================================================
   3. เวอร์ชันแท็บเล็ตและหน้าจอกึ่งกลางคอมพิวเตอร์ (ขยายช่วงเป็น 768px ถึง 1100px)
   แก้ไขสไตล์ตรงนี้เพื่อดักจับหน้าจอช่วง 1030px ไม่ให้ล้นจอ
   ======================================================== */
@media screen and (min-width: 768px) and (max-width: 1100px) {
    #nav .menu-open, #nav .menu-close { display: none !important; }
    #nav .menu-wrapper { position: relative !important; left: 0 !important; width: 100% !important; height: auto !important; background: none !important; padding: 0 !important; }

    #nav .menu-wrapper > ul {
        height: 42px; 
        background-color: #F0D202;
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap; /* ล็อกไว้แน่นหนาห้ามตกบรรทัดเด็ดขาด */
        justify-content: space-between; 
        align-items: center;
    }
    #nav .menu-wrapper > ul > li { position: relative; height: 100%; flex-grow: 1; }
    
    /* ใช้ช่องไฟแบบยืดหยุ่นอัตโนมัติ (Flexible Padding) เพื่อลดขนาดตามหน้าจอ */
    #nav .menu-wrapper > ul > li > a {
        padding: 0 calc(4px + 0.5vw); /* ยิ่งจอแคบลง ช่องไฟระหว่างเมู่จะหดสเปซลงเอง */
        height: 100%;
        font-size: 1.4rem; /* ล็อกขนาดฟอนต์ให้กระชับขึ้นเพื่อรองรับช่วงหน้าจอ 1030px */
   
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap; 
    }
    #nav .menu-wrapper > ul > li:hover > a { color: #cc470d; background-color: rgba(255, 255, 255, 0.15); }

    /* Dropdown บนหน้าจอระดับนี้ */
    #nav li ul {
        background-color: #FDE424; position: absolute; top: 100%; left: 0; min-width: 190px; z-index: 99;
        display: block; opacity: 0; visibility: hidden; transform: translateY(10px); transition: all 0.3s ease;
    }
    #nav li:hover ul { opacity: 1; visibility: visible; transform: translateY(0); }
    #nav li ul a { font-size: 16px; padding: 9px 15px; border-bottom: 1px solid rgba(204, 102, 0, 0.2); text-align: left; }
    #nav li ul li a:hover { background-color: #cc470d; color: #ffffff !important; }
}


/* ========================================================
   4. เวอร์ชันมือถือเต็มจอ (หน้าจอเล็กกว่า 767px)
   ======================================================== */
@media screen and (max-width: 767px) {
    #nav .menu-open {
	display: block !important;
	width: 45px;
	height: 45px;
	background-color: #FDE424;
	text-indent: -9999px;
	position: relative;
	border-radius: 4px;
	cursor: pointer;
	margin-top: 0px;
	margin-right: 10px;
	margin-bottom: 10px;
	margin-left: 10px;
    }
    #nav .menu-open::before, #nav .menu-open::after {
        position: absolute; left: 25%; right: 25%; height: 4px; background-color: #333333; content: '';
    }
    #nav .menu-open::before { top: 35%; box-shadow: 0 6px 0 #333333; }
    #nav .menu-open::after { top: 62%; }

    #nav .menu-wrapper {
        position: fixed !important;
        top: 0 !important;
        left: -100% !important; 
        width: 100% !important;
        height: 100% !important;
        background-color: #F0D202 !important;
        z-index: 99999 !important;
        padding: 80px 25px 25px 25px !important;
        overflow-y: auto;
        transition: left 0.4s cubic-bezier(0.77, 0, 0.175, 1) !important;
    }

    #nav:target .menu-wrapper { left: 0 !important; }

    #nav .menu-close {
        display: block !important;
        position: absolute !important;
        top: 20px !important;
        right: 25px !important;
        font-size: 28px !important;
        color: #333333 !important;
        font-weight: bold !important;
        line-height: 1 !important;
        cursor: pointer;
    }
    #nav .menu-close:hover { transform: rotate(90deg); color: #cc470d; }

    #nav .menu-wrapper > ul { display: block !important; height: auto !important; background: none !important; }
    #nav .menu-wrapper > ul > li { width: 100% !important; border-bottom: 1px solid rgba(204, 71, 13, 0.25); }
    #nav .menu-wrapper > ul > li > a { padding: 14px 10px !important; font-size: 32px !important;  text-align: left !important; }
    #nav .menu-wrapper > ul > li > a:hover { padding-left: 20px !important; background-color: rgba(255, 255, 255, 0.25); color: #cc470d; }

    #nav li ul {
        position: static !important; background-color: rgba(253, 228, 36, 0.4) !important;
        padding-left: 20px !important; display: block !important; opacity: 1 !important; visibility: visible !important; transform: none !important;
    }
    #nav li ul a { font-size: 20px !important; padding: 10px !important; }
}