/* ==========================================================
  Top Space แผนที่ปักหมุด (1-2 ก.ย. 2569)
  ใช้ร่วมกัน 2 ที่: แถบแผนที่ในหน้าแรก (.tsm-strip) และหน้าแผนที่เต็ม (.tsm-full)
  แผนที่ = Leaflet + OpenStreetMap (ฟรี ไม่ต้องผูกบัตร)
  โทนสีเดินตาม --ink / --bd-1 ในไฟล์ main.css ตามบรีฟ 27 ส.ค. ที่ตัดม่วงออกจากการ์ด
  ========================================================== */

/* ---------- กล่องแผนที่ ---------- */
.tsm {
  position: relative;
  background: var(--bg-2, #ECEEF1);
  border-radius: var(--r-lg, 16px);
  overflow: hidden;
  isolation: isolate;
}
.tsm-canvas { width: 100%; height: 100%; background: var(--bg-2, #ECEEF1); }

/* ตอนยังไม่โหลดไลบรารี โชว์พื้นเทา + ตัวหมุนกันหน้ากระโดด */
.tsm-boot {
  position: absolute; inset: 0; display: grid; place-items: center;
  gap: .7rem; color: var(--tx-2, #574C63); font-size: .82rem; pointer-events: none;
  transition: opacity .3s;
}
.tsm-boot.gone { opacity: 0; }
.tsm-boot i {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--bd-1, #D9D5E0); border-top-color: var(--ink, #1E1B24);
  animation: tsmSpin .8s linear infinite;
}
@keyframes tsmSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tsm-boot i { animation: none; } }

/* ---------- หมุดราคา ---------- */
.leaflet-container .tsm-pin-wrap,
.leaflet-container .tsm-cluster-wrap { background: none; border: 0; width: auto !important; pointer-events: none; }
.tsm-pin, .tsm-cluster { pointer-events: auto; }
.tsm-pin {
  position: relative;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  background: #fff;
  border: 1px solid var(--ink-bd, #D9D5E0);
  border-radius: 100px;
  box-shadow: 0 3px 12px rgba(23, 20, 28, .18);
  font-family: var(--font, 'Prompt', sans-serif);
  font-size: 12.5px; font-weight: 600; color: var(--ink, #1E1B24);
  white-space: nowrap; cursor: pointer;
  transform: translate(-50%, -100%);
  transition: background .16s, color .16s, transform .16s, box-shadow .16s;
}
.tsm-pin::after {                       /* หางแหลมชี้พิกัดจริง */
  content: ''; position: absolute; left: 50%; top: 100%;
  width: 9px; height: 9px; margin-left: -4.5px; margin-top: -5px;
  background: inherit; border: inherit; border-top: 0; border-left: 0;
  transform: rotate(45deg);
}
.tsm-pin:hover,
.tsm-pin.on { background: var(--ink, #1E1B24); color: #fff; border-color: var(--ink, #1E1B24); }
.tsm-pin.on { transform: translate(-50%, -100%) scale(1.06); box-shadow: 0 8px 22px rgba(23, 20, 28, .3); }

/* กลุ่มหมุดที่ทับกัน (ลาดพร้าว 4 หลังอยู่โครงการเดียวกัน) */
.tsm-cluster {
  display: grid; place-items: center;
  width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: var(--ink, #1E1B24); color: #fff;
  border: 3px solid rgba(255, 255, 255, .92);
  box-shadow: 0 5px 18px rgba(23, 20, 28, .32);
  font-family: var(--font, 'Prompt', sans-serif);
  font-size: 14px; font-weight: 700; cursor: pointer;
  transition: transform .16s;
}
.tsm-cluster:hover { transform: scale(1.08); }
.tsm-pin:focus-visible, .tsm-cluster:focus-visible {
  outline: 3px solid var(--ink, #1E1B24); outline-offset: 3px;
}
.tsm-cluster small { display: block; font-size: 8.5px; font-weight: 500; opacity: .78; margin-top: -2px; }

/* ---------- ป๊อปการ์ด ---------- */
.tsm-pop .leaflet-popup-content-wrapper {
  padding: 0; border-radius: 14px; overflow: hidden;
  box-shadow: 0 16px 44px rgba(23, 20, 28, .26);
}
.tsm-pop .leaflet-popup-content { margin: 0; width: 236px !important; line-height: 1.5; }
.leaflet-popup-tip { box-shadow: none; }
.tsm-pop-img { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--bg-2, #ECEEF1); }
.tsm-pop-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tsm-pop-badge {
  position: absolute; left: 8px; top: 8px;
  background: rgba(23, 20, 28, .82); color: #fff;
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  padding: 3px 8px; border-radius: 100px;
}
.tsm-pop-body { display: block; padding: 10px 12px 12px; font-family: var(--font, 'Prompt', sans-serif); }
.tsm-pop-price { display: block; font-size: 16px; font-weight: 700; color: var(--ink, #1E1B24); }
.tsm-pop-price span { font-size: 11.5px; font-weight: 400; color: var(--tx-2, #574C63); }
.leaflet-container a.tsm-pop-name,
.tsm-pop-name {
  margin: 2px 0 3px; font-size: 13.5px; font-weight: 600; color: var(--tx-1, #241B2E);
  display: block; text-decoration: none;
}
.tsm-pop-name:hover { text-decoration: underline; }
.tsm-pop-loc { font-size: 11.5px; color: var(--tx-2, #574C63); margin: 0 0 8px; }
.tsm-pop-specs { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-bottom: 10px; }
.tsm-pop-specs span {
  font-size: 10.5px; color: var(--tx-2, #574C63);
  background: var(--bg-1, #F6F7F9); border: 1px solid var(--ink-bd, #D9D5E0);
  border-radius: 6px; padding: 2px 6px;
}
.leaflet-container a.tsm-pop-btn,
.tsm-pop-btn {
  display: block; text-align: center; text-decoration: none;
  background: var(--ink, #1E1B24); color: #fff;
  font-size: 12.5px; font-weight: 600; padding: 8px 10px; border-radius: 9px;
  transition: background .18s;
}
.tsm-pop-btn:hover { background: #000; }

/* ป๊อปแบบรายการ ใช้ตอนกดกลุ่มที่พิกัดซ้ำกันจนซูมเข้าก็ไม่แยก */
.tsm-pop-list { padding: 10px 12px 12px; font-family: var(--font, 'Prompt', sans-serif); }
.tsm-pop-list h4 { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--tx-1, #241B2E); }
.leaflet-container a.tsm-pop-row,
.tsm-pop-row {
  display: grid; grid-template-columns: 54px 1fr; gap: 9px; align-items: center;
  padding: 6px; border-radius: 9px; text-decoration: none; color: inherit;
  transition: background .16s;
}
.tsm-pop-row:hover { background: var(--bg-1, #F6F7F9); }
.tsm-pop-row img { width: 54px; height: 42px; object-fit: cover; border-radius: 6px; display: block; }
.tsm-pop-row b { display: block; font-size: 12px; font-weight: 600; color: var(--ink, #1E1B24); }
.tsm-pop-row span { font-size: 11px; color: var(--tx-2, #574C63); }

/* ---------- ปุ่มบนแผนที่ ---------- */
.tsm-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; color: var(--ink, #1E1B24);
  border: 1px solid var(--ink-bd, #D9D5E0); border-radius: 100px;
  font-family: var(--font, 'Prompt', sans-serif); font-size: 12.5px; font-weight: 600;
  padding: 8px 14px; cursor: pointer; text-decoration: none;
  box-shadow: 0 4px 14px rgba(23, 20, 28, .12);
  transition: background .18s, color .18s, box-shadow .18s;
}
.tsm-btn:hover { background: var(--ink, #1E1B24); color: #fff; border-color: var(--ink, #1E1B24); }
.tsm-btn svg { width: 14px; height: 14px; }

/* ตราที่มาของแผนที่ ของเดิมมาเป็นตัว 10px สีจาง วัดคอนทราสต์ได้ 4.2 ไม่ผ่านเกณฑ์
   และพื้นที่กดสูงแค่ 11px ต่ำกว่าขั้นต่ำ 24px ที่บังคับ */
.leaflet-control-attribution {
  font-size: 11px !important;
  color: var(--tx-2, #574C63) !important;
  background: rgba(255, 255, 255, .92) !important;
  padding: 3px 8px !important;
}
.leaflet-control-attribution a {
  display: inline-block; padding: 5px 2px;
  color: var(--tx-1, #241B2E) !important; text-decoration: underline;
}
.leaflet-control-zoom a {
  color: var(--ink, #1E1B24) !important;
  border-color: var(--ink-bd, #D9D5E0) !important;
}

/* ==========================================================
  1) แถบแผนที่ในหน้าแรก
  ========================================================== */
/* section อื่นในหน้าแรกขยายคอนเทนเนอร์เป็น 1440 กันหมด (ประกาศยอดฮิต ประกาศว่างล่าสุด
   ทำเลยอดนิยม บริการของเรา แบนเนอร์) ถ้าไม่ทำด้วย แถบแผนที่จะเยื้องเข้ามาข้างละ 100px
   ขอบซ้ายไม่ตรงกับการ์ดของ section บนล่าง */
@media (min-width: 1024px) {
  .tsm-strip > .container { max-width: 1440px; }
}
.tsm-strip-grid {
  display: grid; grid-template-columns: 1fr 336px; gap: 14px;
  align-items: stretch;
}
.tsm-strip .tsm-strip-grid { height: 500px; }
.tsm-strip-grid > * { min-height: 0; }
.tsm-strip .tsm { height: 100%; }
.tsm-side, .tsm-side-list { min-height: 0; }
.tsm-side {
  display: flex; flex-direction: column; min-width: 0;
  background: #fff; border: 1px solid var(--ink-bd, #D9D5E0);
  border-radius: var(--r-lg, 16px); overflow: hidden;
}
.tsm-side-head {
  padding: 12px 14px 10px; border-bottom: 1px solid var(--ink-bd, #D9D5E0);
  font-size: 12.5px; color: var(--tx-2, #574C63);
}
.tsm-side-head b { color: var(--ink, #1E1B24); }
.tsm-side-list { overflow-y: auto; padding: 10px; display: grid; gap: 9px; align-content: start; }

.tsm-card {
  display: grid; grid-template-columns: 104px 1fr; gap: 10px;
  padding: 7px; border: 1px solid transparent; border-radius: 12px;
  text-decoration: none; color: inherit; cursor: pointer;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.tsm-card:hover { border-color: var(--ink-bd, #D9D5E0); background: var(--bg-1, #F6F7F9); }
.tsm-card.on { border-color: var(--ink, #1E1B24); background: var(--bg-1, #F6F7F9); box-shadow: 0 4px 16px rgba(23, 20, 28, .1); }
.tsm-card img { width: 104px; height: 78px; object-fit: cover; border-radius: 9px; display: block; background: var(--bg-2, #ECEEF1); }
.tsm-card-b { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.tsm-card-price { display: block; font-size: 15px; font-weight: 700; color: var(--ink, #1E1B24); }
.tsm-card-price span { font-size: 11px; font-weight: 400; color: var(--tx-2, #574C63); }
.tsm-card-name {
  display: block; font-style: normal;
  font-size: 12.5px; font-weight: 600; color: var(--tx-1, #241B2E);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tsm-card-loc {
  display: block; font-style: normal;
  font-size: 11.5px; color: var(--tx-2, #574C63);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tsm-card-spec { display: block; font-style: normal; font-size: 10.5px; color: var(--tx-2, #574C63); margin-top: 2px; }

@media (max-width: 980px) {
  .tsm-strip-grid { grid-template-columns: 1fr; }
  .tsm-strip .tsm-strip-grid { height: auto; }
  .tsm-strip .tsm { height: 380px; }
  .tsm-side { border: 0; border-radius: 0; }
  .tsm-side-head { display: none; }
  .tsm-side-list {
    grid-auto-flow: column; grid-auto-columns: 264px;
    overflow-x: auto; overflow-y: hidden; padding: 4px 2px 10px;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  }
  .tsm-side-list .tsm-card {
    scroll-snap-align: start;
    border-color: var(--ink-bd, #D9D5E0); background: #fff;
  }
}
@media (max-width: 560px) {
  .tsm-strip .tsm { height: 360px; }
  .tsm-card-name { font-size: 13.5px; }
  .tsm-card-loc { font-size: 12px; }
  .tsm-card-spec { font-size: 11.5px; }
  .tsm-side-list { grid-auto-columns: 234px; }
  .tsm-card { grid-template-columns: 84px 1fr; }
  .tsm-card img { width: 84px; height: 66px; }
}

/* ==========================================================
  2) หน้าแผนที่เต็ม
  ========================================================== */
.tsm-full-wrap { background: var(--bg-1, #F6F7F9); }

.tsm-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 20px;
  background: #fff; border-bottom: 1px solid var(--ink-bd, #D9D5E0);
}
/* ปุ่มย้อนกลับ ซ้ายสุดของแถบ เจมส์ทัก 2 ก.ย. ว่ากดมาหน้าเต็มแล้วไม่มีทางถอยกลับ */
.tsm-back {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  min-height: 40px; padding: 0 15px 0 12px;
  margin-right: 2px;
  border: 1px solid var(--ink-bd, #D9D5E0); border-radius: 100px;
  background: #fff; color: var(--ink, #1E1B24);
  font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background .18s, color .18s, border-color .18s;
}
.tsm-back svg { width: 15px; height: 15px; }
.tsm-back:hover { background: var(--ink, #1E1B24); color: #fff; border-color: var(--ink, #1E1B24); }
.tsm-back:focus-visible { outline: 2px solid var(--ink, #1E1B24); outline-offset: 2px; }

.tsm-bar-crumb { font-size: 12px; color: var(--tx-2, #574C63); }
/* ลิงก์ในเส้นทางนำทาง เผื่อพื้นที่กดแนวตั้งให้ถึง 24px ตามเกณฑ์ */
.tsm-bar-crumb a { display: inline-block; padding: 4px 2px; color: var(--tx-2, #574C63); text-decoration: none; }
.tsm-bar-crumb a:hover { text-decoration: underline; }
.tsm-bar h1 { font-size: 1.02rem; font-weight: 600; color: var(--tx-1, #241B2E); margin: 0; }
.tsm-bar-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.tsm-sel {
  font-family: var(--font, 'Prompt', sans-serif); font-size: 12.5px; color: var(--ink, #1E1B24);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%231E1B24' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center;
  border: 1px solid var(--ink-bd, #D9D5E0); border-radius: 100px;
  padding: 8px 30px 8px 13px; cursor: pointer; appearance: none; min-height: 38px;
}
.tsm-sel:focus-visible, .tsm-btn:focus-visible, .tsm-chk:focus-within { outline: 2px solid var(--ink, #1E1B24); outline-offset: 2px; }
.tsm-chk {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none;
  font-size: 12.5px; color: var(--tx-1, #241B2E); min-height: 44px;
}
.tsm-chk input { width: 18px; height: 18px; accent-color: var(--ink, #1E1B24); cursor: pointer; }
.tsm-reset {
  background: none; border: 0; cursor: pointer; min-height: 38px; padding: 0 4px;
  font-family: var(--font, 'Prompt', sans-serif); font-size: 12.5px;
  color: var(--tx-2, #574C63); text-decoration: underline;
}
.tsm-reset:hover { color: var(--ink, #1E1B24); }

.tsm-tabs { display: none; gap: 6px; padding: 8px 16px 0; background: var(--bg-1, #F6F7F9); }
.tsm-tabs button {
  flex: 1; min-height: 40px; cursor: pointer;
  font-family: var(--font, 'Prompt', sans-serif); font-size: 13px; font-weight: 600;
  color: var(--tx-2, #574C63); background: #fff;
  border: 1px solid var(--ink-bd, #D9D5E0); border-radius: 100px;
}
.tsm-tabs button[aria-pressed="true"] { background: var(--ink, #1E1B24); color: #fff; border-color: var(--ink, #1E1B24); }

.tsm-split {
  display: grid; grid-template-columns: 1.28fr 1fr;
  height: calc(100vh - var(--tsm-chrome, 176px)); min-height: 520px;
}
/* ไม่ใส่บรรทัดนี้ รายการ 10 การ์ดจะดันแถวสูงตามเนื้อหา แผนที่เลยสูงเกินจอ
   แล้ว fitBounds ไปคำนวณจากกล่องที่สูงผิด หมุดกองอยู่มุมเดียว */
.tsm-split > * { min-height: 0; }
.tsm-panel, .tsm-panel-list, .tsm-mapcol { min-height: 0; }
.tsm-mapcol { min-width: 0; height: 100%; }
.tsm-split .tsm { border-radius: 0; height: 100%; }
.tsm-panel {
  display: flex; flex-direction: column; min-width: 0;
  background: #fff; border-left: 1px solid var(--ink-bd, #D9D5E0);
}
.tsm-panel-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--ink-bd, #D9D5E0); }
.tsm-panel-head h2 { margin: 0 0 2px; font-size: 1rem; font-weight: 600; color: var(--tx-1, #241B2E); }
.tsm-panel-head p { margin: 0; font-size: 12.5px; color: var(--tx-2, #574C63); }
.tsm-panel-list { overflow-y: auto; padding: 12px 14px 20px; display: grid; gap: 10px; align-content: start; }
.tsm-panel-list .tsm-card { grid-template-columns: 128px 1fr; border-color: var(--ink-bd, #D9D5E0); }
.tsm-panel-list .tsm-card img { width: 128px; height: 96px; }
.tsm-empty { padding: 34px 10px; text-align: center; color: var(--tx-2, #574C63); font-size: 13.5px; line-height: 1.9; }

@media (max-width: 900px) {
  .tsm-bar { padding: 10px 0 10px 16px; }
  /* ตัวกรองเรียงแถวเดียวเลื่อนข้าง ถ้าปล่อยให้ตัดบรรทัดจะกิน 3 แถว แผนที่เหลือนิดเดียว */
  .tsm-bar-tools {
    width: 100%; margin-left: 0; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 2px 16px 2px 0; scrollbar-width: none;
  }
  .tsm-bar-tools::-webkit-scrollbar { display: none; }
  .tsm-bar-tools > * { flex: 0 0 auto; }
  .tsm-sel { font-size: 16px; min-height: 44px; padding: 10px 32px 10px 14px; }
  .tsm-reset { min-height: 44px; font-size: 13.5px; }
  .tsm-btn { min-height: 44px; }
  .tsm-tabs { display: flex; }
  .tsm-split { grid-template-columns: 1fr; height: auto; }
  .tsm-split .tsm { height: 60vh; min-height: 340px; }
  .tsm-panel { border-left: 0; }
  .tsm-panel-list { overflow: visible; }
  .tsm-split[data-view="map"] .tsm-panel { display: none; }
  .tsm-split[data-view="list"] .tsm-mapcol { display: none; }
  .tsm-split[data-view="list"] .tsm-panel { min-height: 60vh; }
}

/* ==========================================================
  ป๊อปบนจอมือถือ วางรูปไว้ข้างซ้ายแทนวางบน
  ถ้าเรียงบนล่างเหมือนจอคอม ป๊อปจะสูงกว่ากล่องแผนที่ ปุ่มดูรายละเอียดโดนตัดหาย (เจอ 2 ก.ย.)
  ========================================================== */
@media (max-width: 600px) {
  .tsm-pop .leaflet-popup-content { width: 282px !important; display: flex; align-items: stretch; }
  .tsm-pop-img { flex: 0 0 104px; aspect-ratio: auto; }
  .tsm-pop-img img { height: 100%; }
  .tsm-pop-badge { left: 6px; top: 6px; font-size: 9.5px; padding: 2px 6px; }
  .tsm-pop-body { flex: 1 1 auto; min-width: 0; padding: 9px 11px 10px; }
  .tsm-pop-price { font-size: 15px; }
  .tsm-pop-name { font-size: 12.5px; }
  .tsm-pop-specs { gap: 3px 5px; margin-bottom: 8px; }
  .tsm-pop-btn { padding: 7px 10px; }
}
