/* ---------------------------------------------------------------------------
   Overrides for the static build. Everything the original page rendered from
   JavaScript lives here: hamburger, mobile drawer, cookie bar.
   Loaded last, so it wins over site.css.
   --------------------------------------------------------------------------- */

/* The JS-driven side navigations of the original build never initialise here. */
#header-sidenav-menu-mobile,
#header-sidenav-menu {
  display: none !important;
}

/* ปุ่มสลับภาษา: แสดงภาษาที่จะสลับไป (อยู่ไทยเห็น EN / อยู่อังกฤษเห็น TH) */
.lang-switch {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.lang-switch .label-lang {
  line-height: 1;
}

.lang-switch::after {
  display: none !important;
}

/* ------------------------------------------------------------------ hamburger */
#ham-btn {
  display: none;
  background: none;
  border: 0;
  padding: 8px 12px;
  font-size: 22px;
  line-height: 1;
  color: rgba(var(--tpc-1), 100%);
  cursor: pointer;
}

/* Below the desktop breakpoint the original build swaps to a bar with the
   hamburger on the left and the logo centred, sitting above the hero instead
   of floating over it. Reproduced here in CSS. */
@media (max-width: 1199.98px) {
  #ham-btn {
    display: inline-flex;
    align-items: center;
  }

  /* the horizontal bar is measured in JS upstream; the drawer replaces it */
  #comp-HEADER_WIDGET_MENU,
  #top-mb {
    display: none;
  }

  #section-header .comp-HEADER.over-section:not(.sticky) {
    position: relative !important;
  }

  #section-header .comp-HEADER.over-section:not(.sticky) #comp-HEADER_AREA,
  #section-header .comp-HEADER.over-section:not(.sticky) #comp-HEADER_AREA > div,
  #section-header .comp-HEADER.over-section:not(.sticky) #header-background {
    background: #760021 !important;
  }

  #top-sticky-container > .d-flex {
    flex-wrap: nowrap !important;
    align-items: center;
  }

  /* hamburger block first, logo takes the rest and centres itself */
  #top-sticky-container > .d-flex > .d-flex.w-100 {
    order: 1;
    width: auto !important;
    flex: 0 0 auto;
  }

  #top-sticky-container > .d-flex > .col-12 {
    order: 2;
    flex: 1 1 auto;
    text-align: center;
  }

  #ham-btn:focus {
    outline: none;
  }

  #ham-btn:focus-visible {
    outline: 2px solid rgba(var(--tpc-1), 100%);
    outline-offset: 2px;
  }
}

/* บนมือถือ เว็บเดิมย่อโลโก้เหลือ 40px (ตั้งค่าไว้คนละค่ากับจอใหญ่ แล้ว JS เป็นคนสลับให้)
   ต้องใส่ !important เพราะค่า 125px ถูกเขียนเป็น inline style มากับ HTML */
@media (max-width: 767.98px) {
  #top-sticky-container .header-logo {
    --width-img-logo: 40px !important;
    --height-img-logo: 40px !important;
    --max-width-img-logo: 40px !important;
    --max-height-img-logo: 40px !important;
  }

  #top-sticky-container .header-logo img {
    width: 40px !important;
    height: 40px !important;
  }

  #top-sticky-container {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
  }

  /* โลโก้อยู่กึ่งกลางจอพอดีเหมือนเว็บเดิม ส่วนปุ่มแฮมเบอร์เกอร์ลอยชิดซ้าย */
  #top-sticky-container > .d-flex {
    position: relative;
  }

  #top-sticky-container > .d-flex > .d-flex.w-100 {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    /* คอลัมน์โลโก้กว้างเต็มจอและอยู่หลังใน DOM ถ้าไม่ยก z-index มันจะทับปุ่มนี้
       จนกดแฮมเบอร์เกอร์ไม่ได้ */
    z-index: 3;
  }

  #top-sticky-container > .d-flex > .col-12 {
    flex: 1 1 100%;
    text-align: center;
  }
}

/* -------------------------------------------------------------- mobile drawer */
#mobile-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 1040;
}

#mobile-drawer-overlay.open {
  opacity: 1;
}

/* เว็บเดิมเมนูมือถือเลื่อนออกมาจาก "ซ้าย" กว้าง 315px และมีแถวภาษาอยู่ก้นเมนู */
#mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: min(315px, 85vw);
  height: 100%;
  background: #760021;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  transform: translate3d(-100%, 0, 0);
  transition: transform 0.25s ease;
  z-index: 1050;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 8px 0 16px;
}

#mobile-drawer ul {
  flex: 1 1 auto;
}

#mobile-drawer-lang {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: Poppins, Tahoma, sans-serif;
  font-size: 14px;
  text-decoration: none;
}

#mobile-drawer-lang:hover {
  background: #8f0404;
  color: #fff;
  text-decoration: none;
}

#mobile-drawer-lang .ml-auto {
  margin-left: auto;
}

#mobile-drawer.open {
  transform: translate3d(0, 0, 0);
}

#mobile-drawer-close {
  background: none;
  border: 0;
  color: #fff;
  font-size: 20px;
  padding: 8px 20px;
  margin-left: auto;
  display: block;
  flex: 0 0 auto;
  cursor: pointer;
}

#mobile-drawer ul {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

#mobile-drawer li a {
  display: block;
  padding: 14px 24px;
  color: #fff;
  font-family: Inter, "Tahoma", sans-serif;
  font-size: 16px;
  text-decoration: none;
}

#mobile-drawer li a:hover,
#mobile-drawer li.active a {
  background: #8f0404;
  color: #fff;
}

/* ------------------------------------------------------------- blog listing */
/* Upstream sets this column count from JS per breakpoint; do it in CSS instead,
   otherwise grid-template-columns is invalid and every card spans full width. */
.wrapper-box-blog-layout03 {
  --blog-render-content-layout-03: 3;
}

@media (max-width: 991.98px) {
  .wrapper-box-blog-layout03 {
    --blog-render-content-layout-03: 2;
  }
}

@media (max-width: 575.98px) {
  .wrapper-box-blog-layout03 {
    --blog-render-content-layout-03: 1;
  }
}

/* ------------------------------------------------------- contact page block */
/* หน้า contact ของเว็บเดิมเรนเดอร์ฟอร์มกับแผนที่ด้วย JS ทั้งหมด ส่วนนี้จึงเขียนใหม่
   โดยใช้ตัวแปร --input-* / --label-* / --button-submit-* ที่ธีมเดิมกำหนดไว้บน
   #comp-section_page_contact อยู่แล้ว หน้าตาจึงออกมาเหมือนของเดิม */
.contact-block {
  padding: 0 0 64px;
  color: rgba(var(--tpc-11), 100%);
}

.contact-block .container {
  max-width: 1140px;
}

.contact-info {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 32px;
  padding: 0;
  margin: 0 0 24px;
  font-family: var(--detail-family), Tahoma, sans-serif;
  font-size: var(--detail-size);
  color: var(--detail-color);
}

.contact-info li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.contact-info a {
  color: inherit;
  text-decoration: none;
}

.contact-info a:hover {
  text-decoration: underline;
}

.contact-map {
  position: relative;
  padding-top: 21%;
  margin-bottom: 32px;
  background: #e9e9e9;
}

.contact-map iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.contact-form label {
  display: block;
  font-family: var(--label-family), Tahoma, sans-serif;
  font-size: var(--label-size);
  font-weight: var(--label-fw);
  color: var(--label-color);
  margin-bottom: 20px;
}

.contact-form label .req {
  color: #ff4d4f;
}

.contact-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 30px;
}

.contact-row.contact-row--half {
  grid-template-columns: 1fr;
  max-width: calc(50% - 15px);
}

.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form input[type="tel"],
.contact-form select,
.contact-form textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 12px;
  border: var(--input-border) var(--input-border-color);
  border-radius: var(--input-border-radius);
  background: var(--input-bg-color);
  color: var(--input-color);
  font-family: var(--detail-family), Tahoma, sans-serif;
  font-size: var(--detail-size);
}

.contact-form textarea {
  resize: vertical;
  min-height: 150px;
}

.contact-captcha {
  font-family: var(--detail-family), Tahoma, sans-serif;
}

.contact-captcha input {
  max-width: 160px;
}

.contact-captcha small {
  display: block;
  margin-top: 6px;
  color: var(--label-captcha-color);
  font-size: 12px;
}

.contact-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-weight: normal;
}

.contact-consent input {
  margin-top: 5px;
}

.contact-consent a {
  color: var(--link-color);
}

.contact-hp {
  position: absolute;
  left: -9999px;
}

.contact-submit {
  border: 1px solid var(--button-submit-border-color);
  border-radius: var(--button-submit-border-radius);
  background: var(--button-submit-bg-color);
  color: var(--button-submit-color);
  padding: var(--button-submit-padding-y) var(--button-submit-padding-x);
  font-family: var(--button-submit-family), Tahoma, sans-serif;
  font-size: var(--button-submit-size);
  cursor: pointer;
  transition: background-color 0.2s;
}

.contact-submit:hover {
  background: var(--button-submit-bg-color-hover);
  color: var(--button-submit-color-hover);
  border-color: var(--button-submit-border-color-hover);
}

.contact-alert {
  border-radius: 4px;
  padding: 12px 16px;
  margin-bottom: 24px;
  font-family: var(--detail-family), Tahoma, sans-serif;
}

.contact-alert--ok {
  background: #1f7a3f;
  color: #fff;
}

.contact-alert--error {
  background: #fff;
  color: #8f0404;
}

.contact-alert ul {
  margin: 0;
  padding-left: 20px;
}

@media (max-width: 767.98px) {
  .contact-row,
  .contact-row.contact-row--half {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .contact-map {
    padding-top: 75%;
  }
}

/* --------------------------------------------------- blog listing (blog.php) */
/* คอลัมน์ของหน้ารวมบทความก็มาจาก JS เหมือนกัน: การ์ดแรกเป็นแบบรูปซ้าย-ข้อความขวา
   ที่เหลือเรียงเป็น 3 คอลัมน์ */
.wrapper-box-all-blog {
  --all-blog-list-display: 3;
  --all-blog-display-content: 2;
}

@media (max-width: 991.98px) {
  .wrapper-box-all-blog {
    --all-blog-list-display: 2;
  }
}

@media (max-width: 575.98px) {
  .wrapper-box-all-blog {
    --all-blog-list-display: 1;
    --all-blog-display-content: 1;
  }
}

/* ------------------------------------------- related posts (blog-XXXX.php) */
.wrapper-blog-relate {
  --detail-grid-render: 3;
}

@media (max-width: 991.98px) {
  .wrapper-blog-relate {
    --detail-grid-render: 2;
  }
}

@media (max-width: 575.98px) {
  .wrapper-blog-relate {
    --detail-grid-render: 1;
  }
}

/* --------------------------------------------------------------- cookie bar */
#pdpa-wrapper.accepted {
  display: none !important;
}

/* บนจอแคบ ข้อความกับปุ่มของแถบคุกกี้เดิมล้นออกนอกจอจนกดปุ่ม "ยอมรับทั้งหมด" ไม่ได้
   จัดใหม่ให้เรียงลงมาเป็นแถวและอยู่ในจอเสมอ */
@media (max-width: 767.98px) {
  #pdpa-wrapper .pad-row-pdpa {
    flex-direction: column;
    align-items: stretch;
    margin: 0;
  }

  #pdpa-wrapper .pad-row-pdpa > .col-12,
  #pdpa-wrapper .col-md-9,
  #pdpa-wrapper .colbtn {
    display: block !important;
    position: static !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    transform: none !important;
  }

  #pdpa-wrapper .colbtn {
    display: flex !important;
    gap: 8px;
    justify-content: center;
    margin-top: 12px !important;
  }

  #pdpa-wrapper .colbtn .btnAcceptPd {
    flex: 1 1 auto;
    margin: 0 !important;
    white-space: nowrap;
  }

  #pdpa-wrapper .txt-pdconsent {
    display: block;
    text-align: left;
  }
}

/* The original disabled text selection through a Vue directive; keep the page
   selectable instead by dropping that class' effect. */
.content-view.disable-right-click {
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}
