/* ============================================================
   OWNEST — 06. RESPONSIVE  (phone ≤760px · tablet 761–1024px)
   ------------------------------------------------------------
   The other stylesheets make the layout *fit* on small screens.
   This file makes it *work* on them. Loaded last on purpose, so
   everything here wins over the earlier sheets.

   §1  PHONE   ≤ 760px   — hero reordered so the photo lands in
                           the first screen, swipe rows that pin
                           and slide, vertical process timeline,
                           sticky call/LINE bar.
   §2  TABLET  761–1024  — three-up grids become two-up, the
                           hero stacks with a controlled measure,
                           split sections stay side by side.

   Desktop (≥1025px) is never touched by this file.
============================================================ */

/* Phone-only elements: hidden by default, enabled inside the breakpoint */
.m-bar{ display:none; }

@media (max-width: 760px){

  /* --------------------------------- ความลื่นตอนเลื่อน ---- */
  /* backdrop-filter: blur() บน header และแถบล่างทำให้ GPU ต้อง
     เบลอพื้นหลังใหม่ทุกเฟรมที่เลื่อน เป็นสาเหตุหลักของอาการกระตุก
     บนมือถือกลาง ๆ — บนจอเล็กเปลี่ยนเป็นพื้นทึบไปเลย ลื่นกว่ามาก */
  .site-header{
    background:var(--cream);
    backdrop-filter:none;
    -webkit-backdrop-filter:none;
  }
  .m-bar{
    background:var(--cream);
    backdrop-filter:none;
    -webkit-backdrop-filter:none;
  }

  /* ------------------------------------------- rhythm ---- */
  :root{ --gutter:20px; }
  section{ padding:52px 0; }
  .section-head{ margin-bottom:26px; }
  .section-head h2{ font-size:26px; }
  .section-head p{ font-size:15px; margin-top:10px; }
  body{ padding-bottom:calc(64px + env(safe-area-inset-bottom, 0px)); } /* room for .m-bar */

  /* ------------------------------------------- hero ------- */
  .hero{ padding:28px 0 16px; }
  /* align-items:stretch — the desktop grid centres its two columns vertically,
     which in a column flex would shrink-wrap every child horizontally */
  .hero-grid{ display:flex; flex-direction:column; align-items:stretch; gap:22px; }

  /* Let the copy's children reorder around the photo: text and
     buttons first, photo second, the four trust points last.   */
  .hero-copy{ display:contents; }
  .hero-copy .eyebrow{ order:0; font-size:12px; }
  .hero-copy h1{ order:1; font-size:34px; max-width:none; margin-top:-8px; }
  .hero-sub{ order:2; font-size:15.5px; line-height:1.65; margin-top:-6px; }
  .hero-actions{ order:3; margin-top:0; display:grid; grid-template-columns:1fr 1fr; gap:10px; }
  .hero-actions .btn{ width:100%; padding:14px 8px; font-size:13.5px; white-space:nowrap; }
  .hero-visual{ order:4; }
  .hero-stats{ order:5; margin-top:0; }

  .hero-visual .frame{ aspect-ratio:4/3; border-radius:var(--radius-lg); }

  /* Trust points: 2×2, icon beside label, small and calm */
  .hero-stats{
    grid-template-columns:1fr 1fr; gap:10px; max-width:none;
  }
  .hero-stat{
    flex-direction:row; align-items:center; gap:10px;
    background:var(--white); border:1px solid var(--line);
    border-radius:var(--radius-md); padding:10px 12px;
  }
  .hero-stat .icon-circle{ width:34px; height:34px; }
  .hero-stat .icon-circle svg{ width:16px; height:16px; }
  .hero-stat span{ font-size:12.5px; line-height:1.35; }

  /* Float card → three-up strip under the photo */
  .float-card{ margin-top:12px; padding:18px 16px 16px; }
  .float-card h3{ font-size:19px; }
  .float-card .th{ font-size:13px; margin-bottom:12px; }
  .float-list{ flex-direction:row; gap:8px; }
  .float-item{ flex:1; flex-direction:column; align-items:center; text-align:center; gap:8px; }
  .float-item .icon-circle{ width:34px; height:34px; }
  .float-item strong{ font-size:11.5px; line-height:1.3; }
  .float-item p{ display:none; }

  /* ------------------------------------- swipe rows ------- */
  /* Any grid marked .m-scroll becomes a snap-scrolling row that
     bleeds to the screen edges, with the next card peeking in. */
  .m-scroll{
    display:flex !important;
    grid-template-columns:none !important;
    gap:14px;
    overflow-x:auto;
    overscroll-behavior-x:contain;
    scroll-snap-type:x mandatory;
    scroll-padding-left:var(--gutter);
    margin:0 calc(-1 * var(--gutter));
    padding:6px var(--gutter) 16px;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
  }
  .m-scroll::-webkit-scrollbar{ display:none; }
  .m-scroll > *{ flex:0 0 82%; max-width:340px; scroll-snap-align:start; }
  .m-scroll > .empty-state{ flex-basis:100%; max-width:none; }

  /* ---------------------------------- แถวไถลเอง ----------- */
  /* การ์ดในแถวถูกห่อด้วย .m-drift-track (สร้างโดย initDriftRows)
     แล้วเลื่อน track ด้วย CSS scroll-driven animation ซึ่งรันบน
     compositor เหมือนการปัดนิ้ว จึงลื่นเท่ากัน ไม่ผ่าน main thread
     ถ้าเบราว์เซอร์ไม่รองรับ JS จะถอยไปขับ scrollLeft แทน (ลื่นน้อยกว่า)

     พอลูกค้าแตะเพื่อปัดเอง JS จะแปลงระยะที่ไถลไปแล้วเป็น scrollLeft
     แล้วถอด animation ออก (.is-manual) — ภาพไม่กระตุก และจากนั้น
     เป็นการเลื่อนแบบ native ล้วน ๆ                                   */
  .m-scroll.is-drift{
    scroll-snap-type:none;
    scroll-behavior:auto;
  }
  .m-drift-track{
    display:flex;
    gap:14px;
    flex:0 0 auto;
    max-width:none;
  }
  .m-drift-track > *{ flex:0 0 82%; max-width:340px; }

  /* บนมือถือจำกัดไม่เกิน 3 ใบต่อแถว — ถ้ามากกว่านี้ระยะไถล (เช่น 6 ใบ
     = 1,650px) จะยาวเกินกว่าระยะ scroll ที่มีตอนแถวอยู่ในจอ ทำให้ไถล
     ไม่ทันก่อนแถวเลื่อนพ้นไป  ใบที่เหลือดูต่อได้จากปุ่ม "ดูทั้งหมด"     */
  .m-scroll > *:nth-child(n+4),
  .m-drift-track > *:nth-child(n+4){ display:none; }

  /* แถวถูกล็อกค้างไว้ด้วย position:sticky ระหว่างที่การ์ดไถล
     .m-pin       = ตัวกันที่ สูง = ความสูงแถว + ระยะที่ใช้ไถล
     .m-pin-inner = ตัวที่ล็อกค้าง (ความสูง/ตำแหน่งตั้งจาก JS)        */
  .m-pin{ position:relative; }
  .m-pin-inner{ position:sticky; }

  @supports (animation-timeline: view()){
    /* timeline ต้องอยู่บน .m-pin ซึ่งไม่ใช่ scroll container
       (ใส่บน .m-scroll ไม่ได้ เพราะมันมี overflow-x:auto ซึ่งตามสเปก
        ทำให้ overflow-y เป็น auto ด้วย กลายเป็น scroll container
        เสียเอง แล้ว view() จะไปวัดกับตัวมันเอง ค้างที่ ~50% ตลอด)    */
    .m-pin{
      view-timeline-name:--m-drift;
      view-timeline-axis:block;
    }
    .m-scroll.is-drift:not(.is-manual) > .m-drift-track{
      animation:m-drift linear both;
      animation-timeline:--m-drift;
      /* animation-range ตั้งจาก JS เพราะต้องคำนวณจากความสูงจอ ความสูง
         แถว และตำแหน่งที่ล็อก ให้ไถลครบพอดีตอนปลดล็อกเป๊ะ ๆ          */
    }
  }
  @keyframes m-drift{
    from{ transform:translateX(0); }
    to  { transform:translateX(calc(-1 * var(--drift-x, 0px))); }
  }

  /* Cards inside rows: tighter */
  .feature-card{ padding:24px 20px; }
  .feature-card h3{ font-size:18.5px; }
  .feature-card > p{ font-size:14px; }
  .prop-body{ padding:16px 16px 18px; }
  .prop-body h3{ font-size:17px; }
  .value-card{ padding:24px 20px; }

  /* ---------------------------------- process → timeline -- */
  .process-strip{
    display:flex; flex-direction:column; gap:0;
    position:relative; padding-left:4px;
  }
  .process-strip::before{
    display:block; top:26px; bottom:26px; left:29px; right:auto;
    width:1px; height:auto;
  }
  .process-step{
    display:grid; grid-template-columns:52px 1fr; column-gap:16px;
    grid-template-rows:auto auto; align-content:start;
    text-align:left; padding:0 0 26px;
  }
  .process-step:last-child{ padding-bottom:0; }
  /* icon spans both rows; title and copy stack in the text column */
  .process-step .num-circle{ margin:0; grid-column:1; grid-row:1 / span 2; }
  .process-step h4{ grid-column:2; grid-row:1; font-size:15px; margin:14px 0 4px; }
  .process-step p{ grid-column:2; grid-row:2; font-size:13px; }

  /* ---------------------------------------- stat tiles ----- */
  .stat-row{ grid-template-columns:1fr 1fr; gap:12px; }
  .stat{ padding:18px 16px; }
  .stat .num{ font-size:27px; }
  .stat .num span{ font-size:15px; }
  .stat .cap{ font-size:12.5px; margin-top:8px; }

  /* ------------------------------------------ CTA band ----- */
  .cta-band{ padding:28px 22px; }
  .cta-band h2{ font-size:23px; }
  .cta-band p{ font-size:14px; }
  .cta-band-actions{ width:100%; flex-direction:column; gap:10px; }
  .cta-band-actions .btn{ width:100%; }

  .testimonial{ padding:30px 22px; }
  .testimonial blockquote{ font-size:21px; }
  .testimonial .quote-mark{ font-size:52px; }

  /* ------------------------------------ page banner -------- */
  .page-banner{ padding:34px 0 30px; }
  .page-banner h1{ font-size:28px; }
  .page-banner p{ font-size:15px; }
  .page-banner--media .banner-media{ height:340px; }
  .page-banner--media h1{ font-size:27px; }
  .page-banner--media p{ font-size:14.5px; }

  /* ------------------------------------- split blocks ------ */
  .split .media{ aspect-ratio:16/11; }
  .split h2{ font-size:25px; }
  .split p{ font-size:14.5px; }
  .split .hero-actions{ grid-template-columns:1fr; }

  /* ---------------------------------- listing page --------- */
  .results-head{ gap:10px; }
  .results-sort{ width:100%; }
  .results-sort .select{ flex:1; }
  .results-count{ width:100%; order:3; font-size:13px; }
  .filter-rail{ padding:18px; margin-bottom:6px; }

  /* ---------------------------------- property detail ------ */
  .detail-title h1{ font-size:24px; }
  .detail-block{ margin-top:30px; }
  .detail-block > h2{ font-size:21px; }
  .key-specs{ margin:20px 0; }
  .key-spec{ padding:14px 14px; }
  .key-spec .v{ font-size:18px; }
  .price-card{ padding:20px 18px; }
  .price-card .price{ font-size:30px; }
  /* JS moves #priceCard up under the key specs on phones */
  #detailMain > .price-card{ margin:0 0 6px; }
  .detail-aside{ gap:14px; }

  /* ---------------------------------- contact -------------- */
  .contact-panel{ padding:22px 18px; }
  .contact-tile{ padding:18px; }
  .submit-specs{ grid-template-columns:1fr 1fr; gap:14px; }
  .submit-loc{ grid-template-columns:1fr; }
  .photo-list{ grid-template-columns:repeat(3,1fr); }

  /* ---------------------------------- article -------------- */
  .article-body p, .article-body ul li{ font-size:15px; }
  .article-body h2{ font-size:22px; margin-top:32px; }
  .toc{ position:static; }

  /* ---------------------------------- footer --------------- */
  .site-footer{ padding:44px 0 22px; }
  .footer-grid{ gap:26px; padding-bottom:28px; }
  .footer-bottom{ flex-direction:column; align-items:flex-start; gap:12px; }

  /* the floating "to top" button would collide with the bar */
  .to-top{ display:none; }
}

/* ============================================================
   STICKY ACTION BAR  (phones only)
   Injected by every page's footer template. On property.html
   page-property.js swaps the buttons for price + "นัดชมทรัพย์".
============================================================ */

@media (max-width: 760px){
  .m-bar{
    position:fixed; left:0; right:0; bottom:0; z-index:55;
    display:grid; grid-template-columns:1fr 1.6fr; gap:8px;   /* โทร | ปรึกษาฟรี — LINE เอาออกจนกว่าจะมีบัญชีจริง */
    padding:10px var(--gutter) calc(10px + env(safe-area-inset-bottom, 0px));
    background:rgba(247,242,232,.96);
    backdrop-filter:blur(10px);
    -webkit-backdrop-filter:blur(10px);
    border-top:1px solid var(--line);
    box-shadow:0 -10px 30px -18px rgba(43,33,25,.35);
  }
  .m-bar-btn{
    display:inline-flex; align-items:center; justify-content:center; gap:7px;
    height:44px; padding:0 10px;
    border:1px solid var(--ink); border-radius:var(--radius-md);
    background:var(--white); color:var(--ink);
    font-size:13.5px; font-weight:600; line-height:1; white-space:nowrap;
  }
  .m-bar-btn svg{ width:16px; height:16px; flex-shrink:0; }
  .m-bar-btn.is-primary{ background:var(--ink); color:var(--cream); }

  /* property page variant: price block + one big CTA */
  /* cookie banner: full width, lifted above the sticky bar */
  .cookie-banner{
    left:12px; right:12px; width:auto;
    bottom:calc(64px + env(safe-area-inset-bottom, 0px) + 10px);
    padding:16px; gap:12px;
  }
  .cookie-banner-actions{ display:grid; grid-template-columns:1fr 1fr; }
  .cookie-banner-actions .btn{ min-width:0; }
  .cookie-banner-actions [data-c="accept"]{ grid-column:1 / -1; grid-row:1; }
  .cookie-dialog{ padding:20px 18px; }
  .cookie-dialog-actions{ display:grid; grid-template-columns:1fr 1fr; }
  .cookie-dialog-actions [data-c="accept"]{ grid-column:1 / -1; grid-row:1; }
  .m-bar.is-price{ grid-template-columns:1fr auto; align-items:center; }
  .m-bar-price .k{ font-size:11px; color:var(--ink-soft); line-height:1; }
  .m-bar-price .v{ font-family:var(--font-display); font-size:20px; line-height:1.15; margin-top:3px; }
  .m-bar-price .s{ font-size:11.5px; color:var(--taupe-dark); font-weight:600; margin-top:2px; }
  .m-bar.is-price .m-bar-btn{ padding:0 22px; }
}

/* ============================================================
   §2  TABLET — 761px ถึง 1024px
   ------------------------------------------------------------
   ช่วงนี้เดิมใช้ breakpoint ของมือถือปนกับเดสก์ท็อป ทำให้การ์ด
   3 ใบกลายเป็นคอลัมน์เดียวยืดเต็มจอ และ hero แตกบรรทัดแปลก ๆ
   บล็อกนี้ทำให้สัดส่วนกลับมาพอดีกับขนาดจอแท็บเล็ต
============================================================ */

@media (min-width: 761px) and (max-width: 1024px){

  /* ---------------------------------------- จังหวะหน้า ---- */
  :root{ --gutter:40px; }
  section{ padding:72px 0; }
  .section-head{ margin-bottom:40px; }
  .section-head h2{ font-size:clamp(28px,3.4vw,34px); }

  /* ------------------------------------------- hero ------- */
  /* ซ้อนแนวตั้ง แต่คุมความกว้างข้อความไม่ให้บรรทัดยาวเกินอ่าน */
  .hero{ padding:48px 0 30px; }
  .hero-grid{ grid-template-columns:1fr; gap:36px; }
  .hero-copy h1{ font-size:clamp(42px,5.6vw,54px); max-width:13ch; }
  .hero-sub{ font-size:17px; max-width:56ch; }
  .hero-actions{ margin-top:26px; }

  .hero-visual .frame{ aspect-ratio:2/1; }

  /* จุดเด่น 4 ข้อเรียงเดียวได้สบายในความกว้างนี้ */
  .hero-stats{
    grid-template-columns:repeat(4,1fr);
    max-width:none; gap:22px; margin-top:34px;
  }

  /* การ์ดลอยกลับมาอยู่ในแถว ไม่ทะลุขอบรูปอีก */
  .float-card{
    position:static; width:100%; margin-top:16px;
    padding:22px 26px 20px;
  }
  .float-list{ flex-direction:row; gap:22px; }
  .float-item{ flex:1; }

  /* ------------------------------ กริด 3 ใบ → 2 ใบ -------- */
  .feature-grid,
  .value-grid,
  .prop-grid,
  .prop-grid.cols-4,
  .article-grid{ grid-template-columns:repeat(2,1fr); gap:24px; }

  .feature-card{ padding:30px 26px; }
  .value-card{ padding:28px 24px; }

  /* ------------------------------ split ยังอยู่ 2 คอลัมน์ -- */
  .split{ grid-template-columns:1fr 1fr; gap:34px; }
  .split.narrow-gap{ gap:28px; }
  .split h2{ font-size:clamp(25px,3.2vw,31px); }
  .split p{ font-size:15px; line-height:1.8; }
  .split .media{ aspect-ratio:4/3; }

  /* ------------------------------ ขั้นตอน 5 ช่อง → 3+2 ---- */
  .process-strip{ grid-template-columns:repeat(3,1fr); gap:38px 22px; }
  .process-strip::before{ display:none; }

  /* ------------------------------------------- สถิติ ------ */
  .stat-row{ grid-template-columns:repeat(4,1fr); gap:18px; }
  .stat{ padding:22px 18px; }
  .stat .num{ font-size:27px; }
  .stat .num span{ font-size:16px; }
  .stat .cap{ font-size:12.5px; }

  /* ------------------------------------------ แบนเนอร์ ---- */
  .page-banner{ padding:48px 0 40px; }
  .page-banner h1{ font-size:clamp(30px,4.4vw,38px); }
  .page-banner--media .banner-media{ height:380px; }

  /* -------------------------------------- รายละเอียดทรัพย์ - */
  .key-specs{ grid-template-columns:repeat(4,1fr); }
  .amenity-grid{ grid-template-columns:repeat(3,1fr); }
  .detail-gallery{ grid-template-columns:2fr 1fr; }
  .detail-gallery .side{ grid-template-rows:1fr 1fr; grid-template-columns:none; }

  /* ------------------------------------------ CTA / คำคม -- */
  .cta-band{ padding:42px 36px; }
  .testimonial{ padding:44px 38px; }

  /* ----------------------------------------- ท้ายหน้า ----- */
  .footer-grid{ grid-template-columns:1.5fr 1fr 1fr 1.2fr; gap:32px; }
}
