/* ============================================================
   Peaberry Place Hotel — Custom Styles
   Brand Colors:
   Primary Brown   #5A3E29
   Secondary Brown #8B5D3D
   Cream           #F1ECE2
   Soft Green      #D1D8A3
   Fresh Olive     #85A331
   Dark Olive      #59681B
   ============================================================ */

html {
  scroll-behavior: smooth;
}

/* กันหน้าเลื่อนซ้าย-ขวา (horizontal scroll) บนมือถือ
   สาเหตุหลัก: transform ของ scroll-reveal (.reveal-left/-right) ดันเนื้อหา
   ออกนอกจอชั่วคราว ใช้ overflow-x: clip ตัดส่วนล้นแนวนอนทิ้ง
   — เลือก clip แทน hidden เพราะ clip ไม่สร้าง scroll container จึงไม่ทำลาย
   sticky header (hidden ไว้เป็น fallback ให้เบราว์เซอร์เก่า) */
html,
body {
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  background-color: #f1ece2;
  color: #5a3e29;
  font-family: 'Noto Sans Thai', 'Kanit', sans-serif;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background-color: #85a331;
  color: #ffffff;
}

/* ============================================================
   ปุ่มแบบ Pill Button
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 9999px;
  padding: 0.75rem 1.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.3s ease-out;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  border: none;
}

.btn-primary {
  background-color: #5a3e29;
  color: #ffffff;
}

.btn-primary:hover {
  background-color: #8b5d3d;
  box-shadow: 0 12px 40px rgba(90, 62, 41, 0.14);
  transform: translateY(-2px);
}

.btn-olive {
  background-color: #85a331;
  color: #ffffff;
}

.btn-olive:hover {
  background-color: #8b5d3d;
  box-shadow: 0 12px 40px rgba(90, 62, 41, 0.14);
  transform: translateY(-2px);
}

.btn-outline {
  background-color: transparent;
  border: 2px solid currentColor;
  color: inherit;
}

.btn-outline:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.btn-white {
  background-color: #ffffff;
  color: #5a3e29;
}

.btn-white:hover {
  background-color: #d1d8a3;
  box-shadow: 0 12px 40px rgba(90, 62, 41, 0.14);
  transform: translateY(-2px);
}

/* ============================================================
   การ์ด
   ============================================================ */
.card {
  overflow: hidden;
  border-radius: 20px;
  background-color: #ffffff;
  box-shadow: 0 4px 24px rgba(90, 62, 41, 0.08);
  transition: all 0.3s ease-out;
}

.card-hover:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 40px rgba(90, 62, 41, 0.14);
}

/* ============================================================
   ฟอร์ม Input
   ============================================================ */
.input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0; /* ให้ช่องหดได้ในกริด/เฟล็กซ์ ไม่ดันล้นขอบ */
  border-radius: 1rem;
  border: 1px solid rgba(90, 62, 41, 0.15);
  background-color: #ffffff;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: #5a3e29;
  outline: none;
  transition: all 0.2s;
}

/* iOS Safari: <input type="date"> ใช้สไตล์ native ที่ดันเนื้อหาล้นกรอบ
   ปิด appearance แล้วบังคับให้อยู่ในกล่อง .input เหมือน input ปกติ */
.input[type='date'],
.input[type='time'],
.input[type='datetime-local'] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 2.875rem; /* สูงเท่า input/select อื่น */
  line-height: 1.2;
}

/* ค่าวันที่ที่แสดง: ชิดซ้าย ไม่มี margin ที่ทำให้ล้น */
.input[type='date']::-webkit-date-and-time-value {
  margin: 0;
  text-align: left;
}

.input::-webkit-datetime-edit {
  padding: 0;
  line-height: 1.2;
}

/* ไอคอนปฏิทินให้ชิดขวาในกรอบ ไม่ดันล้น */
.input::-webkit-calendar-picker-indicator {
  margin: 0;
  margin-inline-start: auto;
}

.input::placeholder {
  color: rgba(90, 62, 41, 0.4);
}

.input:focus {
  border-color: #85a331;
  box-shadow: 0 0 0 2px rgba(133, 163, 49, 0.3);
}

.input.error {
  border-color: #8b5d3d;
  box-shadow: 0 0 0 2px rgba(139, 93, 61, 0.3);
}

.input-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #5a3e29;
}

.error-text {
  margin-top: 0.375rem;
  font-size: 0.75rem;
  color: #8b5d3d;
}

/* ============================================================
   Header / Navigation
   ============================================================ */
.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: #5a3e29;
  text-decoration: none;
  transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
  color: #85a331;
}

.mobile-nav-link {
  display: block;
  border-radius: 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #5a3e29;
  text-decoration: none;
  transition: background-color 0.2s;
}

.mobile-nav-link:hover {
  background-color: rgba(209, 216, 163, 0.4);
}

.mobile-nav-link.active {
  background-color: rgba(209, 216, 163, 0.6);
  color: #59681b;
}

/* เส้นแฮมเบอร์เกอร์ */
.hamburger-line {
  display: block;
  height: 2px;
  width: 24px;
  background-color: #5a3e29;
  transition: all 0.3s;
}

#hamburger.open .hamburger-line:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

#hamburger.open .hamburger-line:nth-child(2) {
  opacity: 0;
}

#hamburger.open .hamburger-line:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* เมนูมือถือ */
#mobile-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

#mobile-menu.open {
  max-height: 24rem;
  border-top: 1px solid rgba(90, 62, 41, 0.1);
}

/* Header เงาเมื่อเลื่อนลง */
#site-header.scrolled {
  box-shadow: 0 4px 24px rgba(90, 62, 41, 0.08);
}

/* ============================================================
   หัวข้อ Section
   ============================================================ */
.section-label {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: #85a331;
  text-align: center;
}

/* เส้นเขียวขนาบทั้งซ้ายและขวาของหัวข้อ (กึ่งกลางทุกตัว) */
.section-label::before,
.section-label::after {
  content: '';
  display: block;
  height: 1px;
  width: 2.5rem;
  flex-shrink: 0;
  background-color: #85a331;
}

/* ============================================================
   มือถือ: หัวข้อ h2 / h3 ในเนื้อหา (ใน <main>) จัดกึ่งกลาง
   - text-wrap: balance = ถ้าหัวข้อยาวจนตกบรรทัด จะแตกเป็น 2 บรรทัด
     แบบสมดุล (สองบรรทัดยาวใกล้กัน) อ่านง่ายกว่าปล่อยตกคำเดียว
   - ไม่แตะ footer / booking modal เพราะอยู่นอก <main>
   ============================================================ */
@media (max-width: 767px) {
  main h2,
  main h3 {
    text-align: center;
    text-wrap: balance;
  }
}

/* ============================================================
   ปุ่ม Filter
   ============================================================ */
.filter-btn {
  border-radius: 9999px;
  border: none;
  padding: 0.625rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  background-color: #ffffff;
  color: #5a3e29;
  box-shadow: 0 4px 24px rgba(90, 62, 41, 0.08);
  transition: all 0.3s;
}

.filter-btn:hover {
  background-color: rgba(209, 216, 163, 0.6);
}

.filter-btn.active {
  background-color: #59681b;
  color: #ffffff;
}

/* ============================================================
   ปุ่มลอย Floating Contact
   ============================================================ */
#floating-options {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  opacity: 0;
  transform: translateY(1rem);
  pointer-events: none;
  transition: all 0.3s;
}

#floating-options.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#floating-toggle {
  transition: all 0.3s;
}

#floating-toggle.open {
  transform: rotate(45deg);
  background-color: #8b5d3d !important;
}

/* ============================================================
   Lightbox
   ============================================================ */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background-color: rgba(90, 62, 41, 0.9);
  backdrop-filter: blur(4px);
  padding: 1rem;
}

#lightbox.open {
  display: flex;
}

.lightbox-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 9999px;
  border: none;
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s;
}

.lightbox-btn:hover {
  background-color: #85a331;
}

/* ============================================================
   Gallery Masonry Grid
   ============================================================ */
.masonry {
  columns: 1;
  column-gap: 1.25rem;
}

@media (min-width: 640px) {
  .masonry {
    columns: 2;
  }
}

@media (min-width: 1024px) {
  .masonry {
    columns: 3;
  }
}

.masonry-item {
  position: relative;
  display: block;
  width: 100%;
  margin-bottom: 1.25rem;
  overflow: hidden;
  border-radius: 20px;
  border: none;
  padding: 0;
  cursor: pointer;
  break-inside: avoid;
  box-shadow: 0 4px 24px rgba(90, 62, 41, 0.08);
  transition: all 0.3s;
  background: none;
}

.masonry-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(90, 62, 41, 0.14);
}

.masonry-item img {
  width: 100%;
  display: block;
  transition: transform 0.5s;
}

.masonry-item:hover img {
  transform: scale(1.05);
}

.masonry-item .overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.25rem;
  background: linear-gradient(to top, rgba(89, 104, 27, 0.8), rgba(89, 104, 27, 0.2) 50%, transparent);
  opacity: 0;
  transition: opacity 0.3s;
  text-align: left;
}

.masonry-item:hover .overlay {
  opacity: 1;
}

/* ============================================================
   รูปภาพ Zoom เมื่อ Hover
   ============================================================ */
.img-zoom {
  overflow: hidden;
}

.img-zoom img {
  transition: transform 0.5s;
}

.img-zoom:hover img {
  transform: scale(1.05);
}

/* ============================================================
   Calendar Mockup
   ============================================================ */
.calendar-day {
  border-radius: 9999px;
  border: none;
  padding: 0.375rem 0;
  font-size: 0.75rem;
  font-family: inherit;
  background: none;
  color: #5a3e29;
  cursor: pointer;
  transition: all 0.2s;
}

.calendar-day:hover {
  background-color: rgba(209, 216, 163, 0.6);
}

.calendar-day.selected {
  background-color: #85a331;
  color: #ffffff;
  font-weight: 600;
}

/* วันที่อยู่ระหว่างช่วงเช็คอิน–เช็คเอาท์ */
.calendar-day.in-range {
  background-color: rgba(133, 163, 49, 0.18);
  color: #59681b;
  border-radius: 0;
  font-weight: 500;
}

/* ============================================================
   Animation: Fade In
   ============================================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.5s ease-out;
}

/* ============================================================
   Scroll Reveal — เด้งเข้ามาจากซ้าย/ขวา/ล่าง เมื่อเลื่อนถึง
   - ใส่คลาส .reveal + ทิศทาง แล้ว main.js จะเติม .reveal-visible
     ให้เองตอนเลื่อนมาเห็น (ผ่าน IntersectionObserver)
   - cubic-bezier ปลายทาง > 1 ทำให้ "เด้ง" เกินนิดแล้วเข้าที่
   ============================================================ */
.reveal {
  opacity: 0;
  transition: opacity 0.7s ease-out,
              transform 0.7s cubic-bezier(0.22, 1.18, 0.36, 1);
  will-change: opacity, transform;
}

.reveal-left {
  transform: translateX(-56px);
}

.reveal-right {
  transform: translateX(56px);
}

.reveal-up {
  transform: translateY(44px);
}

/* เด้งขึ้นแรงกว่าปกติ — สำหรับบล็อกที่อยากให้พุ่งขึ้นจากก้นจอ */
.reveal-up-far {
  transform: translateY(110px);
}

.reveal.reveal-visible {
  opacity: 1;
  transform: translateX(0) translateY(0);
}

/* ผู้ใช้ที่ตั้งค่า "ลดการเคลื่อนไหว" — แสดงทันที ไม่ขยับ */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ============================================================
   Footer Accordion (มือถือ = dropdown เลื่อนนุ่ม / จอใหญ่ = คอลัมน์)
   ============================================================ */
.footer-acc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
  font-family: inherit;
}

.footer-acc-chevron {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.5);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}

/* --- มือถือ: พับ-กางพร้อม animation --- */
@media (max-width: 767px) {
  .footer-acc {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
    padding-bottom: 0.25rem;
  }

  .footer-acc:first-of-type {
    border-top: 0;
    padding-top: 0;
  }

  .footer-acc-header {
    padding: 0.625rem 0;
    cursor: pointer;
  }

  .footer-acc-content {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding-top: 0;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease,
                padding-top 0.3s ease;
  }

  .footer-acc.open .footer-acc-content {
    max-height: 600px;
    opacity: 1;
    padding-top: 0.875rem;
  }

  .footer-acc.open .footer-acc-chevron {
    transform: rotate(180deg);
    color: #d1d8a3;
  }
}

/* --- จอใหญ่: กางเป็นคอลัมน์เสมอ ไม่มีลูกศร --- */
@media (min-width: 768px) {
  .footer-acc-chevron {
    display: none;
  }
  .footer-acc-content {
    max-height: none;
    opacity: 1;
  }
  .footer-acc-header {
    cursor: default;
  }
}

/* ============================================================
   Booking Modal — หน้าต่างจองที่เด้งขึ้นเมื่อกดปุ่ม Book Now
   ============================================================ */
.booking-modal {
  position: fixed;
  inset: 0;
  z-index: 110; /* สูงกว่าปุ่มลอย (50) และ lightbox (100) */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.booking-modal.open {
  display: flex;
}

.booking-modal-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(90, 62, 41, 0.55);
  backdrop-filter: blur(4px);
}

.booking-modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0; /* flex item หดได้ตามจอ ไม่ล้นขอบ */
  max-width: 30rem;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 24px;
  background-color: #ffffff;
  padding: 1.75rem;
  box-shadow: 0 24px 64px rgba(90, 62, 41, 0.28);
  animation: bookingModalIn 0.3s ease-out;
}

@keyframes bookingModalIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.booking-modal-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 9999px;
  background-color: rgba(90, 62, 41, 0.06);
  color: #5a3e29;
  cursor: pointer;
  transition: background-color 0.2s;
}

.booking-modal-close:hover {
  background-color: rgba(90, 62, 41, 0.14);
}

/* ล็อกการเลื่อนพื้นหลังขณะเปิด modal */
body.booking-modal-open {
  overflow: hidden;
}
