/* ============================================================
   KUBOTA BAANDUNG — Home Rails v4 (เดสก์ท็อปเต็มรูปแบบ)
   โจทย์เจ้าของร้าน 2026-11-02 รอบ 3 "เอาการ์ดแม็กออก เหลือแต่รูปเซลล์ส่วนบน":
   - ซ้าย  = ตัวละครล้วน + หัวเรื่องลอย "เพราะอะไร?" (ส่วนบนอย่างเดียว)
             เรื่องเล่า KUBOTA MAX ถูกเอาออกแล้วตามสั่ง (§13)
   - ขวา   = แผงการ์ดเซลล์ 3 ใบ sticky หมุนเฟด 8–10 วิ (§2)
   - กลาง  = ป้ายโฆษณาวิ่ง (marquee) แทนจุดแทรกเดิม — เดสก์ท็อปเท่านั้น
             (เจ้าของร้านจะส่งป้ายจริงมาทีหลัง — เปลี่ยนได้ที่ HTML ใน rails.js)
   - แท็บเล็ต/iPad (768–1365px): ไม่มีแรลทั้งสองข้าง ไม่มีป้ายวิ่ง
     (การ์ดแทรก in-feed ตามโจทย์ภาพ 1: 3 คัน แล้วแทรกใต้แถว 3)
   ธีม "ห้องโชว์เดียวกันคนละมุม" เดียวกับ kb-if: ดำเหล็ก+ขอบส้ม+ไฟส้ม
   โชว์: ป้ายซ้าย ≥1366px · แผงขวา ≥1366px · ป้ายวิ่ง ≥1024px
   ============================================================ */

:root {
  --kb-rail-bg: #0d1014;
  --kb-rail-border: rgba(255, 122, 26, .38);
  --kb-rail-orange: #ff5a00;
  --kb-rail-soft: #ffb27a;
}

/* ---------- ตัวแปรความกว้างแรล: ซ้ายซ่อนตามโจทย์ล่าสุด ---------- */
.sr-zone#tractors { --kb-lw: 0px; --kb-rw: 0px; }

@media (min-width: 1366px) {
  .sr-zone#tractors {
    --kb-lw: 0px;
    --kb-rw: max(112px, min(296px, calc((100% - 1104px) / 2 - 14px)));
  }
}

/* ---------- แรลซ้าย: คนล้วนบนพื้นเพจ + หัวเรื่องลอย (§13 ตัดฉากที่ 2 ออกแล้ว)
              (sticky คู่ขวา — ตำแหน่งเดียวกัน สไลด์ตามกันเป็นคู่) ---------- */
.kb-rail-left-wrap {
  display: none;
  position: absolute;
  top: 150px;
  bottom: 40px;
  left: 0;
  width: var(--kb-lw);
  z-index: 5;
  pointer-events: none;
}
.kb-rail-left {
  position: sticky;
  top: 104px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  pointer-events: auto;
  container-type: inline-size;
}

/* ── ฉากที่ 1: ตัวละครล้วน — ไม่มีกรอบ ไม่มีกล่อง
      คนตัดพื้นลอยบนพื้นเพจ กลายเป็นส่วนหนึ่งของพื้นหลัง ── */
.kb-char-stage {
  position: relative;
  height: clamp(240px, 96cqw + 96px, 470px);
}
/* แสงอุ่น "สีที่อุปโลกขึ้นมา" หลอมคนเข้ากับพื้นขาว */
.kb-stage-glow {
  position: absolute;
  inset: -6% -10%;
  background:
    radial-gradient(92% 64% at 62% 70%, rgba(255, 138, 0, .17), rgba(255, 191, 121, .085) 46%, transparent 72%),
    radial-gradient(64% 42% at 26% 26%, rgba(24, 42, 82, .06), transparent 72%);
  pointer-events: none;
}
/* เงาพื้นกรมท่าจางๆ ให้คนยืนลงพื้นจริง */
.kb-stage-floor {
  position: absolute;
  left: 2%;
  right: 6%;
  bottom: 0;
  height: 24px;
  background: radial-gradient(52% 100% at 52% 50%, rgba(24, 42, 82, .18), transparent 74%);
  filter: blur(2px);
  pointer-events: none;
}
.kb-char-person {
  position: absolute;
  bottom: 0;
  right: -2%;
  height: min(97cqw, 92%);
  width: auto;
  max-width: 112%;
  display: block;
  filter:
    drop-shadow(0 16px 22px rgba(23, 21, 15, .15))
    drop-shadow(0 0 36px rgba(255, 138, 0, .10));
}

/* ประกายเหลืองลูกเล่น — วางรอบนิ้วโป้ง/หัวเรื่อง */
.kb-char-spark {
  position: absolute;
  z-index: 3;
  color: #ffd400;
  font-size: clamp(9px, 4.8cqw, 14px);
  line-height: 1;
  text-shadow: 0 0 12px rgba(255, 214, 64, .95);
  animation: kb-twinkle 2.8s ease-in-out infinite;
  pointer-events: none;
}
.kb-spark-1 { top: 4%; right: 7%; }
.kb-spark-2 { bottom: 24%; left: 4%; font-size: clamp(7px, 3.4cqw, 10px); animation-delay: 1.3s; }
@keyframes kb-twinkle {
  0%, 100% { opacity: .25; transform: scale(.8) rotate(0deg); }
  50%      { opacity: 1;   transform: scale(1.18) rotate(18deg); }
}

/* ── หัวเรื่องลอยในพื้นที่ว่างระหว่างนิ้วโป้งกับตัวคน
      ส้ม-เหลือง-แดง-กรมท่า เฉิดฉาย — ลอยบนพื้นเพจ ไม่มีแผงรอง ── */
.kb-why-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  pointer-events: none;
}
/* ชิปกระตุ้น "เพราะอะไร?" — กรมท่าตัวเหลือง เอียงเล่น */
.kb-why-tag {
  transform: rotate(-2.5deg);
  font-family: Prompt, sans-serif;
  font-weight: 800;
  font-size: clamp(10px, 4.8cqw, 14px);
  letter-spacing: .05em;
  color: #ffe66d;
  padding: 3px 10px 4px;
  border-radius: 9px 10px 9px 2px;
  background: linear-gradient(135deg, #182a52 0%, #101726 100%);
  box-shadow: 0 5px 14px rgba(24, 42, 82, .32), inset 0 0 0 1px rgba(255, 230, 109, .28);
}
/* ทำไมถึงต้องเป็นรถไถมือสอง — ไล่ส้มเหลืองมีแสงกวาด + ขอบขาวกันพื้น */
.kb-why-l1 {
  font-family: 'Barlow Condensed', Prompt, sans-serif;
  font-style: italic;
  font-weight: 800;
  font-size: clamp(17px, 9.6cqw, 29px);
  line-height: 1.1;
  letter-spacing: .012em;
  background: linear-gradient(100deg, #ff4d00 0%, #ffd400 30%, #fff7cf 46%, #ffd400 62%, #ff4d00 92%);
  background-size: 240% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter:
    drop-shadow(0 2px 7px rgba(255, 77, 0, .4))
    drop-shadow(0 0 6px rgba(252, 251, 248, .95));
  animation: kb-shine 4.6s linear infinite;
}
@keyframes kb-shine {
  0%   { background-position: 130% 0; }
  100% { background-position: -70% 0; }
}
/* คูโบต้าบ้านดุง — ชิปแดง-ส้มเอียงเล่น เหมือนตราประทับ */
.kb-why-l2 {
  align-self: flex-start;
  transform: rotate(-1.6deg);
  font-family: Prompt, sans-serif;
  font-weight: 800;
  font-size: clamp(11.5px, 6.2cqw, 18px);
  line-height: 1.3;
  letter-spacing: .02em;
  color: #fff;
  padding: 5px 13px 6px;
  border-radius: 11px 13px 11px 3px;
  background: linear-gradient(135deg, #ff2d1a 0%, #ff4d00 55%, #ff8a00 100%);
  box-shadow: 0 7px 18px rgba(255, 45, 26, .42), inset 0 0 0 1px rgba(255, 255, 255, .22);
}

/* ---------- แรลขวา: แผงการ์ดเซลล์ 3 ใบ (sticky) ---------- */
.kb-rail-right-wrap {
  display: none;
  position: absolute;
  top: 150px;
  bottom: 40px;
  right: 0;
  width: var(--kb-rw);
  z-index: 6;
  pointer-events: none;
}
.kb-rail-right {
  position: sticky;
  top: 104px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  pointer-events: auto;
}

.kb-rc {
  position: relative;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  background: var(--kb-rail-bg);
  border: 1px solid var(--kb-rail-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 14px 30px rgba(255, 77, 0, .14), 0 2px 10px rgba(0, 0, 0, .35);
  transition: transform .25s ease, box-shadow .25s ease;
}
.kb-rc:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 38px rgba(255, 77, 0, .22), 0 2px 10px rgba(0, 0, 0, .35);
}

.kb-rc-media {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  aspect-ratio: 2 / 1;
  overflow: hidden;
  background: #15191e;
}
.kb-rc-seller,
.kb-rc-vehicle {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.kb-rc-seller {
  background: #f3eee7;
}
.kb-rc-face,
.kb-rc-post {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: auto;
  object-position: center;
  object-fit: contain;
}
.kb-rc-vehicle { background: #15191e; }
.kb-rc-seller-name {
  position: absolute;
  right: 4px;
  bottom: 4px;
  left: 4px;
  overflow: hidden;
  padding: 3px 4px;
  border-radius: 5px;
  background: rgba(13, 16, 20, .84);
  color: #fff;
  font-family: Prompt, sans-serif;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kb-rc-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 11px 12px;
}
.kb-rc-name {
  font-family: Prompt, sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
}
.kb-rc-chip {
  display: -webkit-box;
  overflow: hidden;
  font-family: Prompt, sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  color: #ffd9c0;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.kb-rc-btn {
  margin-top: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--kb-rail-orange);
  color: #fff;
  font-family: Prompt, sans-serif;
  font-size: 11.5px;
  font-weight: 700;
}
.kb-rc-sticker {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  font-family: 'Barlow Condensed', Prompt, sans-serif;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: .02em;
  color: #fff;
  padding: 4px 7px;
  border-radius: 7px 7px 2px 7px;
  background: linear-gradient(135deg, #ff4d00, #ff2d55);
  box-shadow: 0 6px 14px rgba(255, 77, 0, .45);
}

/* ── LOCK-025: วาร์ปแบบคุณหนู — เดิมเฟดแสกน .3s ดูถูกๆ ตามโจทย์ล่าสุด
   ต้อง "มีชั้นเชิง มีความหรูหรา" → ออกด้วยเบลอลอยช้า ๆ กลับเข้าช้ากว่า ── */
.kb-rc.kb-fading .kb-rc-face,
.kb-rc.kb-fading .kb-rc-post,
.kb-rc.kb-fading .kb-rc-seller-name,
.kb-rc.kb-fading .kb-rc-name,
.kb-rc.kb-fading .kb-rc-chip,
.kb-rc.kb-fading .kb-rc-sticker {
  opacity: 0;
  filter: blur(9px);
  transform: translateY(7px) scale(.985);
  transition: opacity .78s cubic-bezier(.5, .06, .35, 1),
              filter .78s cubic-bezier(.5, .06, .35, 1),
              transform .78s cubic-bezier(.5, .06, .35, 1);
}
.kb-rc .kb-rc-face,
.kb-rc .kb-rc-post,
.kb-rc .kb-rc-seller-name,
.kb-rc .kb-rc-name,
.kb-rc .kb-rc-chip,
.kb-rc .kb-rc-sticker {
  opacity: 1;
  transition: opacity 1.05s cubic-bezier(.22, 1, .36, 1),
              filter 1.05s cubic-bezier(.22, 1, .36, 1),
              transform 1.05s cubic-bezier(.22, 1, .36, 1);
}

/* ---------- ป้ายโฆษณาวิ่ง (marquee) แทนจุดแทรกเดิม — เดสก์ท็อปเท่านั้น ---------- */
.kb-marquee {
  display: none;
  position: relative;
  overflow: hidden;
  margin: 22px 0 4px;
  border: 1px solid var(--kb-rail-border);
  border-radius: 14px;
  background: linear-gradient(90deg, #12100c 0%, #1b150e 50%, #12100c 100%);
  box-shadow: 0 10px 26px rgba(255, 77, 0, .12);
}
.kb-marquee-track {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 11px 0;
  animation: kb-marquee-run 34s linear infinite;
  will-change: transform;
}
.kb-marquee:hover .kb-marquee-track { animation-play-state: paused; }
.kb-marquee-seq-wrap {
  display: inline-flex;
  align-items: center;
}
.kb-marquee-seq {
  display: inline-flex;
  align-items: center;
  font-family: Prompt, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #ffd9c0;
}
.kb-marquee-seq b {
  color: var(--kb-rail-orange);
  font-weight: 700;
}
.kb-marquee-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 18px;
  border-radius: 50%;
  background: var(--kb-rail-orange);
  opacity: .8;
}
@keyframes kb-marquee-run {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ---------- เปิดตามเบรกพอยต์ ---------- */
@media (min-width: 1024px) {
  .kb-marquee { display: block; }
  /* v21 (14 พ.ย. 2026): เซลล์นิ้วโป้ง (kb-rail-left) ถูกเลิกใช้ถาวรตามสั่งเจ้าของร้าน
     "เอาออกทั้งข้อความ" — พื้นที่ในกรอบวัวแดงให้แถบสินค้าแนะนำ + พื้นหลังสีต่อเนื่อง (kubota-colorway.css) */
  .kb-rail-left-wrap { display: none !important; }
}
@media (min-width: 1366px) {
  .kb-rail-right-wrap { display: block; }
}

/* ---------- เคารพผู้ใช้ที่ตั้งค่าลดการเคลื่อนไหว ---------- */
@media (prefers-reduced-motion: reduce) {
  .kb-why-l1 { animation: none !important; }
  .kb-char-spark { animation: none !important; }
  .kb-marquee-track { animation: none !important; }
  .kb-rc .kb-rc-face,
  .kb-rc .kb-rc-post,
  .kb-rc .kb-rc-seller-name,
  .kb-rc .kb-rc-name,
  .kb-rc .kb-rc-chip,
  .kb-rc .kb-rc-sticker { transition: none; }
}

/* Home finish: flatter cards, cleaner orange accents, and the harvester promo header. */
.sr-head {
  border-radius: 8px;
  box-shadow: none;
}

#products .sr-card-h,
#products .sr-card-v {
  overflow: hidden;
  border: 1px solid #eee5d9;
  border-radius: 10px;
  box-shadow: 0 3px 12px rgba(34, 29, 22, .08);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

@media (hover: hover) {
  #products .sr-card-h:hover,
  #products .sr-card-v:hover {
    transform: translateY(-2px);
    border-color: rgba(224, 105, 35, .38);
    box-shadow: 0 7px 18px rgba(34, 29, 22, .12);
  }
}

#harvesters #shw-sec-all > .sr-head {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 164px;
  margin: 0 0 20px;
  padding: 22px 26px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 10px;
  background-image:
    linear-gradient(90deg, rgba(18, 24, 30, .92) 0%, rgba(18, 24, 30, .77) 43%, rgba(18, 24, 30, .18) 100%),
    radial-gradient(ellipse at 84% 78%, rgba(241, 130, 54, .24), transparent 42%),
    url('/images/kubota-harvesters-promo.jpg');
  background-size: cover, cover, cover;
  background-position: center, center, center 68%;
  background-repeat: no-repeat;
  box-shadow: 0 5px 16px rgba(30, 34, 38, .14);
}

#harvesters #shw-sec-all > .sr-head::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  height: 2px;
  background: linear-gradient(90deg, transparent 4%, #d96a27 28%, #f5b04c 56%, transparent 92%);
  content: '';
}

#harvesters #shw-sec-all > .sr-head .sr-head-left,
#harvesters #shw-sec-all > .sr-head .sr-more {
  position: relative;
  z-index: 1;
}

#harvesters #shw-sec-all > .sr-head .sr-head-line h2 {
  max-width: 100%;
  color: #fffaf3;
  font-size: clamp(22px, 2.6vw, 34px);
  line-height: 1.2;
  text-shadow: 0 2px 10px rgba(12, 16, 20, .56);
}

#harvesters #shw-sec-all > .sr-head .sr-count {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid rgba(255, 244, 229, .26);
  border-radius: 4px;
  background: rgba(20, 26, 31, .56);
  color: #fff0dc;
  line-height: 1.2;
}

#harvesters #shw-sec-all > .sr-head .sr-bar {
  width: 42px;
  height: 2px;
  border-radius: 0;
  background: #e5843d;
}

#harvesters #shw-sec-all > .sr-head .sr-more {
  flex: 0 0 auto;
  padding: 8px 13px;
  border: 1px solid rgba(255, 247, 235, .54);
  border-radius: 6px;
  background: rgba(22, 28, 33, .78);
  box-shadow: 0 2px 7px rgba(12, 16, 20, .18);
  color: #fffaf3;
}

.kb-if {
  border-color: rgba(201, 111, 55, .28);
  border-radius: 10px;
  box-shadow: 0 5px 16px rgba(20, 25, 30, .14), 0 2px 6px rgba(20, 25, 30, .06);
}

.kb-if-cta {
  border-radius: 5px;
  background: #e96308;
  box-shadow: 0 2px 6px rgba(116, 55, 17, .18);
}

.kb-rc {
  border-color: rgba(204, 119, 65, .34);
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(13, 16, 20, .18);
}

.kb-rc:hover {
  box-shadow: 0 8px 19px rgba(13, 16, 20, .22);
}

.kb-rc-btn {
  border-radius: 6px;
  background: #e96308;
  box-shadow: 0 2px 6px rgba(116, 55, 17, .18);
}

.kb-rc-sticker {
  border-radius: 5px 5px 2px 5px;
  box-shadow: 0 3px 8px rgba(13, 16, 20, .2);
}

@media (max-width: 600px) {
  #harvesters #shw-sec-all > .sr-head {
    min-height: 138px;
    gap: 10px;
    padding: 16px 14px;
    background-position: center, center, center 100%;
    background-size: cover, cover, auto 240%;
  }

  #harvesters #shw-sec-all > .sr-head .sr-more {
    padding: 7px 10px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #products .sr-card-h,
  #products .sr-card-v {
    transition: none;
  }
}

/* ── การ์ดลอย "ดูทั้งหมด" ท้ายแถวสินค้าแนะนำ (2026-11-07) ── */
.sr-rec-more{
  grid-column:1/-1;
  display:flex;align-items:center;justify-content:space-between;gap:14px;
  margin-top:2px;padding:16px 22px;
  border-radius:14px;
  background:linear-gradient(108deg,#1e2b3a 0%,#22402f 62%,#1c3327 100%);
  border:1px solid rgba(255,255,255,.14);
  box-shadow:0 10px 24px rgba(20,32,26,.18), inset 0 1px 0 rgba(255,255,255,.12);
  color:#fff;text-decoration:none;
  transition:transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.sr-rec-more:hover{transform:translateY(-2px);filter:brightness(1.07);
  box-shadow:0 14px 30px rgba(20,32,26,.24), inset 0 1px 0 rgba(255,255,255,.12);}
.sr-rec-more:focus-visible{outline:3px solid #ed7622;outline-offset:3px;}
.srm-txt{display:flex;flex-direction:column;gap:2px;min-width:0;}
.srm-txt b{font-size:19px;line-height:1.2;letter-spacing:-.01em;color:#fff;}
.srm-txt i{font-style:normal;font-size:12.5px;color:rgba(255,255,255,.78);}
.srm-arrow{
  flex:none;width:38px;height:38px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  background:#ed7622;color:#fff;font-size:24px;line-height:1;
  box-shadow:0 4px 12px rgba(237,118,34,.4);
  transition:transform .18s ease;
}
.sr-rec-more:hover .srm-arrow{transform:translateX(3px);}
@media (max-width:767px){
  .sr-rec-more{padding:13px 16px;border-radius:12px;gap:10px;}
  .srm-txt b{font-size:16.5px;}
  .srm-txt i{font-size:11.5px;}
  .srm-arrow{width:32px;height:32px;font-size:20px;}
}
@media (prefers-reduced-motion: reduce){
  .sr-rec-more,.sr-rec-more .srm-arrow{transition:none !important;}
  .sr-rec-more:hover{transform:none;}
}
/* คันเกิน 6 คันของแถวแนะนำ (M108S-B ฟรีดาวน์) ดู "ข้างใน" ผ่านปุ่มดูทั้งหมดเท่านั้น
   ซ่อนเฉพาะหน้าแรก (#sr-sec-rec) — หน้า /all-used/ ดึงการ์ดนี้ไปแสดงได้ปกติ */
#sr-sec-rec .sr-grid-h > .sr-card-inside{display:none;}
