/* ============================================================
   หน้าบ้าน — เว็บอสังหาริมทรัพย์
   ============================================================ */

:root {
  /* น้ำเงินเข้มอมเขียว = ความน่าเชื่อถือ, ทองอุ่น = ความพรีเมียม */
  /* โทนสีอ้างอิงจากโลโก้ Peacock Property (teal #356a6e) */
  --brand-900:   #0a1f21;
  --brand-800:   #102e30;
  --brand-700:   #1c4a4e;
  --brand:       #356a6e;
  --brand-600:   #2a585c;
  --brand-400:   #63999d;
  --brand-tint:  #eaf2f2;
  --brand-tint-2:#d3e5e5;

  --accent:      #d99433;
  --accent-600:  #c07f22;
  --accent-tint: #fdf4e5;

  --ink:         #12222c;
  --ink-2:       #3f5766;
  --ink-3:       #74899a;
  --ink-4:       #9cadba;
  --line:        #e3eaef;
  --line-2:      #f0f4f7;
  --bg:          #f4f7f9;
  --card:        #ffffff;

  --ok:          #12805a;
  --ok-tint:     #e2f4ec;
  --warn:        #a9711a;
  --warn-tint:   #fdf1dc;
  --danger:      #bb3a2c;
  --danger-tint: #fbeae7;

  --radius-xs:   8px;
  --radius-sm:   11px;
  --radius:      16px;
  --radius-lg:   22px;

  --shadow-xs:   0 1px 2px rgba(10, 34, 48, .05);
  --shadow-sm:   0 1px 3px rgba(10, 34, 48, .06), 0 2px 8px rgba(10, 34, 48, .04);
  --shadow:      0 4px 16px rgba(10, 34, 48, .08);
  --shadow-lg:   0 14px 40px rgba(10, 34, 48, .13);
  --shadow-xl:   0 24px 60px rgba(10, 34, 48, .18);

  --font:         'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Kanit', var(--font);

  --ease:        cubic-bezier(.4, 0, .2, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.8;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--brand-tint-2); color: var(--brand-900); }

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -.005em;
  margin: 0 0 .6em;
  color: var(--ink);
  overflow-wrap: break-word;
}
h1 { font-size: clamp(1.85rem, 4vw, 2.85rem); line-height: 1.3; }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
h3 { font-size: 1.12rem; }

p { margin: 0 0 1em; overflow-wrap: break-word; }
a { color: var(--brand); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--brand-400); }
img { max-width: 100%; display: block; }
ul { margin: 0; padding: 0; list-style: none; }
hr { border: 0; border-top: 1px solid var(--line); margin: 26px 0; }

:focus-visible { outline: 2px solid var(--brand-400); outline-offset: 2px; border-radius: 4px; }

.container { width: min(1220px, 100% - 36px); margin-inline: auto; }
.muted   { color: var(--ink-3); }
.small   { font-size: .875rem; }
.center  { text-align: center; }
.nowrap  { white-space: nowrap; }

/* ============================================================
   Header
   ============================================================ */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(227, 234, 239, .9);
}
.header-inner { display: flex; align-items: center; gap: 22px; min-height: 74px; }

.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); flex: none; }
/* โลโก้นกยูง — ไฟล์ PNG พื้นหลังโปร่งใส วางบนพื้นสีอะไรก็ได้ */
.brand-mark {
  width: 44px; height: 44px; flex: none;
  object-fit: contain; display: block;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; letter-spacing: -.01em; }
.brand-text small  { color: var(--ink-3); font-size: .72rem; letter-spacing: .01em; }

.site-nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.site-nav > a {
  position: relative; padding: 9px 15px; border-radius: 999px; color: var(--ink-2);
  font-size: .94rem; font-weight: 500; transition: background .18s var(--ease), color .18s var(--ease);
}
.site-nav > a:hover { background: var(--brand-tint); color: var(--brand); }
.site-nav > a.active { color: var(--brand); font-weight: 600; }
.site-nav > a.active::after {
  content: ''; position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%);
  width: 18px; height: 3px; border-radius: 3px; background: var(--accent);
}
.nav-cta { margin-left: 10px; }
.site-nav > a.nav-cta { color: #fff; }
.site-nav > a.nav-cta:hover { background: var(--brand-600); color: #fff; }
.site-nav > a.nav-cta::after { display: none; }

.nav-toggle {
  display: none; margin-left: auto; width: 44px; height: 44px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  cursor: pointer; padding: 12px 11px; flex-direction: column; justify-content: space-between;
}
.nav-toggle span { display: block; height: 2px; background: var(--ink); border-radius: 2px; transition: .22s var(--ease); }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 12px; border: 1px solid transparent;
  font-family: var(--font); font-size: .95rem; font-weight: 600; line-height: 1.3;
  cursor: pointer; white-space: nowrap;
  transition: background .18s var(--ease), border-color .18s var(--ease),
              color .18s var(--ease), transform .12s var(--ease), box-shadow .18s var(--ease);
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  color: #fff; box-shadow: 0 4px 14px rgba(15, 85, 112, .26);
}
.btn-primary:hover { color: #fff; box-shadow: 0 7px 20px rgba(15, 85, 112, .34); transform: translateY(-1px); }

.btn-accent {
  background: linear-gradient(135deg, #eaa845, var(--accent));
  color: #3a2606; box-shadow: 0 4px 14px rgba(217, 148, 51, .32);
}
.btn-accent:hover { color: #3a2606; box-shadow: 0 7px 20px rgba(217, 148, 51, .42); transform: translateY(-1px); }

.btn-outline { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-outline:hover { border-color: var(--brand-400); color: var(--brand); background: var(--brand-tint); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--brand-tint); color: var(--brand); }

.btn-light { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .3); }
.btn-light:hover { background: rgba(255, 255, 255, .24); color: #fff; }

.btn-sm { padding: 8px 15px; font-size: .87rem; border-radius: 9px; }
.btn-lg { padding: 15px 30px; font-size: 1.02rem; border-radius: 13px; }
.btn-block { width: 100%; }

/* ============================================================
   Flash
   ============================================================ */
.flash-wrap { margin-top: 18px; display: grid; gap: 9px; }
.flash {
  padding: 13px 18px; border-radius: var(--radius-sm); font-size: .93rem;
  border: 1px solid transparent; display: flex; gap: 9px; align-items: flex-start;
  animation: slideDown .35s var(--ease);
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.flash-success { background: var(--ok-tint);     border-color: #bde5d5; color: #0b5c40; }
.flash-error   { background: var(--danger-tint); border-color: #f2c9c3; color: #8c281c; }
.flash-info    { background: var(--brand-tint);  border-color: var(--brand-tint-2); color: var(--brand-700); }
.flash-warning { background: var(--warn-tint);   border-color: #efdcb4; color: #78500f; }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  color: #fff; padding: 86px 0 130px; text-align: center;
  background: linear-gradient(160deg, var(--brand-900) 0%, var(--brand-700) 55%, #10617f 100%);
}
/* แสงนวล 2 จุด ทำให้พื้นหลังไม่แบน */
.hero::before {
  content: ''; position: absolute; inset: 0; z-index: -2;
  background:
    radial-gradient(58% 70% at 82% 8%,  rgba(217, 148, 51, .30), transparent 62%),
    radial-gradient(52% 62% at 10% 88%, rgba(45, 135, 172, .42), transparent 66%);
}
/* ตารางบาง ๆ ให้มีพื้นผิว */
.hero::after {
  content: ''; position: absolute; inset: 0; z-index: -1; opacity: .5;
  background-image:
    linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(75% 75% at 50% 40%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(75% 75% at 50% 40%, #000 30%, transparent 100%);
}

.hero-inner { max-width: 780px; margin-inline: auto; }
.hero h1 { color: #fff; margin-bottom: .3em; text-wrap: balance; }
.hero h1 em { font-style: normal; color: #f3c477; }
.hero-lead {
  color: rgba(255, 255, 255, .8); font-size: clamp(1rem, 1.5vw, 1.1rem);
  max-width: 610px; margin-inline: auto; text-wrap: pretty;
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .78rem; font-weight: 600; letter-spacing: .11em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 12px;
}
.hero .eyebrow {
  color: #f3c477; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .17);
  padding: 6px 16px; border-radius: 999px; letter-spacing: .08em; backdrop-filter: blur(6px);
}

.hero-stats {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 34px;
}
.hero-stat {
  min-width: 132px; padding: 14px 20px; border-radius: 14px;
  background: rgba(255, 255, 255, .09); border: 1px solid rgba(255, 255, 255, .15);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.hero-stat:hover { background: rgba(255, 255, 255, .15); transform: translateY(-2px); }
.hero-stat b {
  display: block; font-family: var(--font-display); font-size: 1.75rem;
  font-weight: 600; color: #fff; line-height: 1.25;
}
.hero-stat span { color: rgba(255, 255, 255, .68); font-size: .82rem; }

/* ============================================================
   กล่องค้นหา (ลอยทับ hero)
   ============================================================ */
.search-card {
  background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  padding: 12px 24px 24px; margin-top: -74px; position: relative; z-index: 5;
  border: 1px solid rgba(255, 255, 255, .7);
}

.search-tabs { display: flex; gap: 4px; margin: 0 0 18px; padding-top: 12px; }
.search-tabs a {
  padding: 9px 24px; border-radius: 999px; font-weight: 600; font-size: .93rem;
  color: var(--ink-3); transition: background .18s var(--ease), color .18s var(--ease);
}
.search-tabs a:hover { background: var(--brand-tint); color: var(--brand); }
.search-tabs a.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-600)); color: #fff;
  box-shadow: 0 3px 10px rgba(15, 85, 112, .26);
}

.search-row { display: grid; grid-template-columns: 2.2fr 1.3fr 1.3fr auto; gap: 14px; align-items: end; }
.search-row .field { margin: 0; }
.search-row .btn { height: 48px; }

/* ============================================================
   Form
   ============================================================ */
.field { margin-bottom: 18px; }
.field > label, .field-label {
  display: block; font-size: .84rem; font-weight: 600; color: var(--ink-2); margin-bottom: 7px;
}
input[type="text"], input[type="number"], input[type="email"], input[type="tel"],
input[type="password"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; height: 48px; padding: 0 14px;
  font-family: var(--font); font-size: .95rem; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2374899a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; cursor: pointer;
}
textarea { height: auto; min-height: 130px; padding: 13px 14px; resize: vertical; line-height: 1.8; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-4); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-400); background: #fff;
  box-shadow: 0 0 0 4px rgba(45, 135, 172, .13);
}
input::placeholder, textarea::placeholder { color: var(--ink-4); }
.field-hint  { font-size: .8rem; color: var(--ink-3); margin-top: 6px; }
.field-error { font-size: .8rem; color: var(--danger); margin-top: 6px; font-weight: 500; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); background: #fffafa; }

.checkbox, .radio {
  display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .92rem;
  padding: 3px 0; transition: color .15s var(--ease);
}
.checkbox:hover, .radio:hover { color: var(--brand); }
.checkbox input, .radio input { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; flex: none; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 20px; }

/* ============================================================
   Section
   ============================================================ */
.section { padding: 66px 0; }
.section-alt { background: #fff; border-block: 1px solid var(--line); }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 22px; margin-bottom: 32px; flex-wrap: wrap;
}
.section-head h2 { margin: 0; }
.section-head p  { margin: 6px 0 0; color: var(--ink-3); max-width: 560px; }

/* ============================================================
   Property card
   ============================================================ */
/* auto-fit (ไม่ใช่ auto-fill) เพื่อให้คอลัมน์ที่ไม่มีการ์ดยุบตัว
   แถวที่มี 3 ใบจะขยายเต็มความกว้าง ไม่เหลือช่องว่างค้างด้านขวา */
.property-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(278px, 1fr)); gap: 24px; }

.property-card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); border: 1px solid var(--line);
  display: flex; flex-direction: column;
  transition: transform .26s var(--ease), box-shadow .26s var(--ease), border-color .26s var(--ease);
}
.property-card:hover {
  transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--brand-tint-2);
}

.card-media { position: relative; aspect-ratio: 4 / 3; background: #dfe7ec; overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.property-card:hover .card-media img { transform: scale(1.06); }
/* ไล่สีมืดด้านล่างรูป ทำให้ป้ายอ่านง่ายและรูปดูมีมิติ */
.card-media::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(5, 32, 44, .38) 0%, transparent 42%);
}

.card-badges {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 24px);
}
.card-photos {
  position: absolute; bottom: 12px; right: 12px; z-index: 2;
  background: rgba(5, 32, 44, .6); color: #fff; font-size: .76rem; font-weight: 500;
  padding: 4px 11px; border-radius: 999px; backdrop-filter: blur(6px);
}

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 11px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; line-height: 1.5; letter-spacing: .01em;
  box-shadow: 0 2px 6px rgba(5, 32, 44, .16);
}
.badge-sale   { background: linear-gradient(135deg, var(--brand), var(--brand-600)); color: #fff; }
.badge-rent   { background: linear-gradient(135deg, #4a63d8, #3a4fbd); color: #fff; }
.badge-both   { background: linear-gradient(135deg, #6f49cf, #5837b0); color: #fff; }
.badge-hot    { background: linear-gradient(135deg, #eaa845, var(--accent)); color: #3a2606; }
.badge-ok     { background: var(--ok-tint);    color: #0b5c40; box-shadow: none; }
.badge-warn   { background: var(--warn-tint);  color: #78500f; box-shadow: none; }
.badge-muted  { background: rgba(255,255,255,.92); color: var(--ink-2); }
.badge-draft  { background: var(--danger-tint); color: #8c281c; box-shadow: none; }
.badge-info   { background: #e6ecfb;            color: #2b47a8; box-shadow: none; }
.badge-outline{ background: #fff; border: 1px solid var(--line); color: var(--ink-2); box-shadow: none; }

.card-body { padding: 17px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.card-price {
  font-family: var(--font-display); font-size: 1.32rem; font-weight: 600;
  color: var(--brand); line-height: 1.35; letter-spacing: -.01em;
}
.card-title {
  font-family: var(--font-display); font-size: 1rem; font-weight: 500; margin: 5px 0 4px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-title a { color: var(--ink); }
.card-title a:hover { color: var(--brand); }
.card-address {
  color: var(--ink-3); font-size: .85rem; margin: 0 0 14px;
  display: flex; gap: 5px; align-items: flex-start;
}
.card-address span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-specs {
  display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: auto;
  padding-top: 13px; border-top: 1px solid var(--line-2);
  color: var(--ink-2); font-size: .85rem;
}
.card-specs span { display: inline-flex; align-items: center; gap: 5px; }
.card-specs .spec-type { color: var(--ink-3); }

.property-card.horizontal { flex-direction: row; }
.property-card.horizontal .card-media { aspect-ratio: auto; width: 300px; flex: none; }
@media (max-width: 700px) {
  .property-card.horizontal { flex-direction: column; }
  .property-card.horizontal .card-media { width: 100%; aspect-ratio: 4 / 3; }
}

/* ============================================================
   Layout ค้นหา
   ============================================================ */
.search-layout { display: grid; grid-template-columns: 296px 1fr; gap: 28px; align-items: start; }
.filter-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm); position: sticky; top: 92px;
  max-height: calc(100vh - 116px); overflow-y: auto; scrollbar-width: thin;
}
.filter-panel::-webkit-scrollbar { width: 6px; }
.filter-panel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.filter-panel h3 {
  font-size: .98rem; margin: 0 0 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.filter-group { margin-bottom: 22px; }
.filter-group > .field-label { margin-bottom: 9px; }
.filter-group input, .filter-group select { height: 44px; }
.range-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 9px; }
.range-row > span { color: var(--ink-4); }

.result-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.result-bar .count b { font-family: var(--font-display); font-size: 1.2rem; color: var(--ink); }
.sort-box { display: flex; align-items: center; gap: 9px; }
.sort-box select { width: auto; min-width: 178px; height: 40px; }

.active-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px;
  background: var(--brand-tint); color: var(--brand-700); border: 1px solid var(--brand-tint-2);
  border-radius: 999px; font-size: .83rem; font-weight: 500;
}
.chip a { color: var(--brand); font-weight: 700; line-height: 1; opacity: .65; }
.chip a:hover { opacity: 1; }

/* ============================================================
   Empty state
   ============================================================ */
.empty {
  text-align: center; padding: 72px 26px; background: var(--card);
  border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--ink-3);
}
.empty .emoji { font-size: 3.2rem; display: block; margin-bottom: 12px; opacity: .8; }
.empty h3 { color: var(--ink-2); }

/* ============================================================
   Pagination
   ============================================================ */
.pagination { display: flex; justify-content: center; gap: 7px; margin-top: 38px; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 42px; height: 42px; padding: 0 13px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--line); color: var(--ink-2);
  font-size: .92rem; font-weight: 500;
  transition: border-color .18s var(--ease), color .18s var(--ease), transform .12s var(--ease);
}
.pagination a:hover { border-color: var(--brand-400); color: var(--brand); transform: translateY(-1px); }
.pagination .current {
  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 3px 10px rgba(15, 85, 112, .26);
}
.pagination .gap { border: none; background: none; min-width: 26px; }

/* ============================================================
   หน้ารายละเอียด
   ============================================================ */
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; align-items: start; }

.breadcrumb {
  font-size: .85rem; color: var(--ink-3); padding: 20px 0;
  display: flex; gap: 9px; flex-wrap: wrap; align-items: center;
}
.breadcrumb a { color: var(--ink-3); }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb > span:not(:last-child) { opacity: .5; }

.gallery {
  border-radius: var(--radius); overflow: hidden;
  background: #0a1e28; box-shadow: var(--shadow-lg);
}
/* กำหนดความสูงตรง ๆ แทน aspect-ratio + max-height
   (คู่นั้นทำให้เบราว์เซอร์ย่อ "ความกว้าง" ตามสัดส่วน จนเหลือแถบดำข้างรูป)
   ใช้ cover เพื่อให้รูปเต็มกรอบเสมอไม่ว่าสัดส่วนต้นฉบับจะเป็นอะไร */
.gallery-main { position: relative; height: clamp(300px, 50vh, 580px); background: #12303d; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255, 255, 255, .92); color: var(--ink); font-size: 1.3rem;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
  transition: background .18s var(--ease), transform .18s var(--ease);
}
.gallery-nav:hover { background: #fff; transform: translateY(-50%) scale(1.07); }
.gallery-prev { left: 16px; }
.gallery-next { right: 16px; }
.gallery-counter {
  position: absolute; bottom: 16px; right: 16px; z-index: 2;
  background: rgba(5, 32, 44, .68); color: #fff; padding: 5px 14px;
  border-radius: 999px; font-size: .8rem; backdrop-filter: blur(6px);
}
.gallery-thumbs {
  display: flex; gap: 9px; padding: 11px; overflow-x: auto; background: #112b38;
  scrollbar-width: thin;
}
.gallery-thumbs::-webkit-scrollbar { height: 6px; }
.gallery-thumbs::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); border-radius: 3px; }
.gallery-thumbs button {
  flex: none; width: 96px; aspect-ratio: 4 / 3; border-radius: 9px; overflow: hidden;
  border: 2px solid transparent; padding: 0; cursor: pointer; background: none; opacity: .55;
  transition: opacity .2s var(--ease), border-color .2s var(--ease);
}
.gallery-thumbs button img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs button.active, .gallery-thumbs button:hover { opacity: 1; border-color: var(--accent); }

.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow-sm); margin-bottom: 24px;
}
.panel > h2, .panel > h3 { margin-top: 0; }
.panel > h2 { padding-bottom: 14px; border-bottom: 1px solid var(--line-2); margin-bottom: 20px; }

.detail-title { font-family: var(--font-display); font-size: clamp(1.45rem, 2.8vw, 2rem); margin: 0 0 8px; }
.detail-price {
  font-family: var(--font-display); font-size: clamp(1.7rem, 3.2vw, 2.3rem);
  font-weight: 600; color: var(--brand); line-height: 1.3; letter-spacing: -.015em;
}
.detail-meta {
  display: flex; gap: 8px 18px; flex-wrap: wrap;
  color: var(--ink-3); font-size: .88rem; margin-bottom: 6px;
}

/* มี 6 ช่องเสมอ จึงล็อกเป็น 2 หรือ 3 คอลัมน์ (หารลงตัวทั้งคู่)
   ถ้าใช้ auto-fit จะได้ 4 คอลัมน์ แล้วเหลือช่องว่างสีเทาค้าง 2 ช่อง */
.spec-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px; background: var(--line); border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--line);
}
@media (min-width: 520px) { .spec-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.spec-item { background: #fff; padding: 18px 14px; text-align: center; transition: background .18s var(--ease); }
.spec-item:hover { background: var(--brand-tint); }
.spec-item .icon { font-size: 1.45rem; display: block; line-height: 1.5; }
.spec-item b { display: block; font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; }
.spec-item span { font-size: .8rem; color: var(--ink-3); }

.info-table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.info-table th, .info-table td { padding: 12px 4px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.info-table th { color: var(--ink-3); font-weight: 500; width: 42%; }
.info-table tr:last-child th, .info-table tr:last-child td { border-bottom: none; }

.amenity-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 10px; }
.amenity-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font-size: .9rem; transition: background .18s var(--ease), border-color .18s var(--ease);
}
.amenity-item:hover { background: var(--brand-tint); border-color: var(--brand-tint-2); }
.amenity-item .icon { font-size: 1.1rem; }

.map-box {
  height: 360px; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--line); background: var(--bg);
}
.map-box.tall { height: 520px; }

.sticky-side { position: sticky; top: 92px; }

.agent-card { text-align: center; }
.agent-avatar {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 12px;
  background: linear-gradient(140deg, var(--brand-tint), var(--brand-tint-2)); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 1.85rem;
  box-shadow: inset 0 0 0 1px rgba(15, 85, 112, .1);
}
.contact-methods { display: grid; gap: 9px; margin-top: 16px; }

/* ============================================================
   ประเภทอสังหาฯ (หน้าแรก)
   ============================================================ */
/* มี 8 ประเภทพอดี จึงล็อกจำนวนคอลัมน์เป็นตัวหารลงตัว (8 / 4 / 2)
   ถ้าปล่อยให้ auto-fit จัดเอง จะเหลือเศษตกบรรทัดสุดท้ายใบเดียว */
.type-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (min-width: 620px)  { .type-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1140px) { .type-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 12px; } }
.type-card {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 12px 20px; text-align: center; box-shadow: var(--shadow-xs);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  min-height: 152px;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease);
}
.type-card::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 3px;
  background: linear-gradient(90deg, var(--brand-400), var(--accent));
  transform: scaleX(0); transform-origin: left; transition: transform .28s var(--ease);
}
.type-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--brand-tint-2); }
.type-card:hover::before { transform: scaleX(1); }
.type-card .icon { font-size: 2rem; display: block; margin-bottom: 8px; line-height: 1; }
.type-card b {
  display: block; font-family: var(--font-display); font-weight: 500; font-size: .92rem;
  color: var(--ink); line-height: 1.4; margin-bottom: 2px;
}
.type-card span { font-size: .78rem; color: var(--ink-3); }
@media (min-width: 1140px) {
  .type-card { padding: 22px 8px 18px; min-height: 146px; }
  .type-card b { font-size: .87rem; }
}

/* ============================================================
   CTA
   ============================================================ */
.cta-band {
  position: relative; overflow: hidden;
  background: linear-gradient(125deg, var(--brand-900), var(--brand-700) 62%, #12617f);
  border-radius: var(--radius-lg); padding: 48px 40px; color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 28px; flex-wrap: wrap;
  box-shadow: var(--shadow-lg);
}
.cta-band::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(46% 78% at 88% 20%, rgba(217, 148, 51, .3), transparent 62%);
}
.cta-band > * { position: relative; }
.cta-band h2 { color: #fff; margin: 0 0 8px; }
.cta-band p { color: rgba(255, 255, 255, .8); margin: 0; max-width: 520px; }
.cta-actions { display: flex; gap: 11px; flex-wrap: wrap; }

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  background: var(--brand-900); color: rgba(255, 255, 255, .68);
  margin-top: 70px; padding: 62px 0 24px; font-size: .92rem;
  border-top: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--brand-400), var(--accent)) 1;
}
.site-footer h4 { color: #fff; font-size: .98rem; margin-bottom: 16px; }
.site-footer a { color: rgba(255, 255, 255, .68); }
.site-footer a:hover { color: #fff; }
.site-footer .muted { color: rgba(255, 255, 255, .5); }
.footer-grid { display: grid; grid-template-columns: 1.7fr 1fr 1fr 1.5fr; gap: 38px; }
.footer-brand { color: #fff; margin-bottom: 14px; }
.footer-brand strong { font-family: var(--font-display); font-size: 1.05rem; }
/* โลโก้เป็น teal เข้ม จะจมบนฟุตเตอร์สีเข้ม — กลับเป็นขาว */
.footer-brand .brand-mark { filter: brightness(0) invert(1); opacity: .9; }
.footer-legal {
  font-size: .78rem; line-height: 1.6; color: rgba(255, 255, 255, .5);
  margin: 6px 0 0; max-width: 34ch;
}
.footer-links li { margin-bottom: 9px; }
.footer-bottom {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 42px; padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, .1); font-size: .85rem;
}

/* ============================================================
   ค่อย ๆ ปรากฏตอนเลื่อนถึง
   ============================================================ */
/* ซ่อนไว้เฉพาะตอนที่ JS พร้อมทำงานจริง — ถ้า JS พัง เนื้อหาจะยังแสดงตามปกติ */
.js-reveal .reveal > * { opacity: 0; transform: translateY(16px); }
.js-reveal .reveal.in > * {
  opacity: 1; transform: none;
  transition: opacity .55s var(--ease), transform .55s var(--ease);
}
.js-reveal .reveal.in > *:nth-child(2) { transition-delay: .06s; }
.js-reveal .reveal.in > *:nth-child(3) { transition-delay: .12s; }
.js-reveal .reveal.in > *:nth-child(4) { transition-delay: .18s; }
.js-reveal .reveal.in > *:nth-child(5) { transition-delay: .24s; }
.js-reveal .reveal.in > *:nth-child(6) { transition-delay: .30s; }
.js-reveal .reveal.in > *:nth-child(7) { transition-delay: .36s; }
.js-reveal .reveal.in > *:nth-child(n+8) { transition-delay: .42s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .js-reveal .reveal > * { opacity: 1; transform: none; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1080px) {
  .search-layout { grid-template-columns: 1fr; }
  .filter-panel { position: static; max-height: none; }
  .detail-layout { grid-template-columns: 1fr; }
  .sticky-side { position: static; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 30px; }
}

@media (max-width: 900px) {
  .search-row { grid-template-columns: 1fr 1fr; }
  .search-row .btn { grid-column: 1 / -1; width: 100%; }
}

@media (max-width: 780px) {
  .nav-toggle { display: flex; }
  .site-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px; padding: 14px 18px 20px;
    background: #fff; border-bottom: 1px solid var(--line); box-shadow: var(--shadow-lg);
  }
  .site-nav.open { display: flex; animation: slideDown .25s var(--ease); }
  .site-nav > a { padding: 12px 16px; border-radius: 10px; }
  .site-nav > a.active::after { display: none; }
  .site-nav > a.active { background: var(--brand-tint); }
  .nav-cta { margin: 10px 0 0; }

  .hero { padding: 56px 0 108px; }
  .hero-stats { gap: 9px; }
  .hero-stat { min-width: calc(50% - 5px); flex: 1; padding: 12px 14px; }
  .hero-stat b { font-size: 1.45rem; }

  .search-card { padding: 8px 16px 18px; margin-top: -66px; border-radius: var(--radius); }
  .search-row { grid-template-columns: 1fr; }
  .section { padding: 44px 0; }
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .panel { padding: 20px; }
  .cta-band { padding: 32px 24px; }
  .detail-layout { gap: 22px; }
  .gallery-thumbs button { width: 80px; }
}

@media print {
  .site-header, .site-footer, .gallery-thumbs, .sticky-side, .nav-toggle, .breadcrumb { display: none !important; }
  .panel { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}

/* ============================================================
   ระบบไอคอน SVG (แทนอีโมจิ)
   ============================================================ */
/* ขนาดกำหนดจาก attribute width/height ของแต่ละไอคอน จึงไม่ตั้งใน CSS */
.ic { display: inline-block; vertical-align: -.15em; flex: none; stroke: currentColor; }
a .ic, button .ic, label .ic, .btn .ic { pointer-events: none; }

/* จุดที่เคยเป็นอีโมจิตัวใหญ่ */
.brand-mark .ic { color: #fff; }
.type-card .icon { display: flex; justify-content: center; margin-bottom: 10px; color: var(--brand); line-height: 1; }
.type-card:hover .icon { color: var(--brand-600); }
.spec-item .icon { display: flex; justify-content: center; margin-bottom: 4px; color: var(--brand); }
.amenity-item .icon { display: flex; color: var(--brand); }
.empty .emoji { display: flex; justify-content: center; margin-bottom: 14px; color: var(--ink-4); opacity: .75; }
.agent-avatar .ic { color: var(--brand); }
.card-photos { display: inline-flex; align-items: center; gap: 5px; }
.card-address .ic { margin-top: 2px; color: var(--ink-4); }
.card-specs .ic { color: var(--ink-4); }
.badge .ic { margin-right: 1px; }
.breadcrumb .ic { vertical-align: middle; }
.gallery-nav { display: inline-flex; align-items: center; justify-content: center; }
.footer-links .ic { color: rgba(255, 255, 255, .55); margin-right: 4px; }
.footer-bottom .ic { vertical-align: -.2em; }
.info-table th .ic { color: var(--ink-4); margin-right: 4px; }
.detail-meta .ic { color: var(--ink-4); margin-right: 3px; }
.chip a .ic { vertical-align: middle; }
.filter-panel h3 .ic { color: var(--brand); vertical-align: -.2em; margin-right: 5px; }

/* ============================================================
   ปุ่มสลับภาษา
   ============================================================ */
.lang-switch {
  display: inline-flex; align-items: center; gap: 2px; margin-left: 8px;
  padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: #fff;
}
.lang-switch .lang-icon { display: inline-flex; color: var(--ink-4); padding: 0 4px 0 6px; }
.lang-switch a {
  padding: 5px 11px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  color: var(--ink-3); letter-spacing: .04em; line-height: 1.2;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.lang-switch a:hover { background: var(--brand-tint); color: var(--brand); }
.lang-switch a.active { background: var(--brand); color: #fff; }

/* ============================================================
   ช่องค้นหาหน้าแรก — เพิ่มช่องงบประมาณ
   ============================================================ */
.search-card { padding-bottom: 36px; }
.search-row { grid-template-columns: 1.9fr 1.1fr 1.1fr 1.5fr auto; }
.budget-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 7px; }
.budget-row > span { color: var(--ink-4); }
.search-row .field-hint { font-size: .74rem; color: var(--ink-4); margin-top: 5px; position: absolute; }
.search-row .field-budget { position: relative; }
.search-row .btn .ic { margin-right: 2px; }

@media (max-width: 1080px) {
  .search-row { grid-template-columns: 1fr 1fr; }
  .search-row .field-budget { grid-column: 1 / -1; }
  .search-row .field-submit { grid-column: 1 / -1; }
  .search-row .btn { width: 100%; }
  .search-row .field-hint { position: static; }
}
@media (max-width: 780px) {
  .search-row { grid-template-columns: 1fr; }
  .lang-switch { margin: 10px 0 0; align-self: flex-start; }
}
