/* T-0039 — หน้าแรก v3 (design-v3 แบบ ง): hero รูปจริงเต็มจอ + แท็บประเภทลูกค้า, การ์ด 5 ประเภท,
   แถบ Precast, ผลงานเด่น, ตัวช่วย 3 คำถาม, ขั้นตอน, บทความ
   โหลดหลัง style.css — ใช้ token --v3-* และ .v3-card / .v3-btn / data-reveal จาก style.css (T-0038) */

/* ---------- wrap (T-0060: ขอบตาม --gutter กลาง ให้ตรงแนวหัวเว็บ) ---------- */
.hm-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}

/* ---------- hero: รูปเต็มจอ + แท็บประเภทลูกค้าเป็นขอบล่าง ---------- */
.hm-hero {
  position: relative;
  height: clamp(560px, 86vh, 860px);
  overflow: hidden;
  background: var(--v3-navy-deep);
  color: #fff;
}
.hm-slide { position: absolute; inset: 0; opacity: 0; transition: opacity 1.1s ease; }
.hm-slide.is-on { opacity: 1; }
.hm-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.02);
  transition: transform 7s linear;
}
.hm-slide.is-on img { transform: scale(1.09); }
.hm-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(19, 53, 93, .92) 0%, rgba(19, 53, 93, .78) 38%, rgba(19, 53, 93, .25) 68%, rgba(19, 53, 93, .1) 100%),
    linear-gradient(180deg, rgba(19, 53, 93, 0) 55%, rgba(19, 53, 93, .85) 100%);
}
.hm-copy {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 118px;
  z-index: 2;
  text-shadow: 0 1px 12px rgba(19, 53, 93, .55);
}
.hm-eyebrow {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--v3-blue-tint);
  margin: 0 0 10px;
}
.hm-h1 {
  color: #fff; /* style.css ตั้งสีหัวข้อรวมเป็น navy-deep — บนรูปต้องขาว */
  font-size: clamp(34px, 5.4vw, 68px);
  line-height: 1.18;
  font-weight: 800;
  margin: 0;
  max-width: 15ch;
  text-wrap: balance;
  letter-spacing: -.01em;
}
.hm-sub { font-size: clamp(16px, 1.6vw, 20px); margin: 14px 0 0; opacity: .92; }
.hm-sub b { font-weight: 600; }
.hm-hero .v3-btns { margin-top: 26px; }
.hm-tabs { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding-bottom: 22px; }
.hm-tabs-in {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, .28);
  /* T-0060: กรอบ (เส้นบน) ต้องอยู่บนแนวเนื้อหา ไม่ใช่ขอบกล่อง 1200px — จึงรีเซ็ตค่า wrap ของตัวเอง */
  max-width: min(1136px, calc(100% - 2*var(--gutter)));
  margin-left: auto;
  margin-right: auto;
  padding-left: 0;
  padding-right: 0;
}
.hm-tab {
  position: relative;
  background: none;
  border: 0;
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 16px 14px 0 0;
  margin-right: 18px;
  opacity: .62;
  cursor: pointer;
  text-align: left;
  min-height: 44px;
}
.hm-tab:hover, .hm-tab.is-on { opacity: 1; }
.hm-tab .ln { position: absolute; left: 0; right: 0; top: -1px; height: 3px; background: transparent; overflow: hidden; }
.hm-tab.is-on .ln { background: rgba(255, 255, 255, .25); }
.hm-tab.is-on .ln i { display: block; height: 100%; width: 0; background: var(--v3-clay); animation: hm-fill 6s linear forwards; }
.hm-tab:focus-visible { outline: 2px solid #fff; outline-offset: 4px; border-radius: 4px; }
@keyframes hm-fill { to { width: 100%; } }
.hm-job {
  margin-left: auto;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  padding-top: 16px;
  text-align: right;
  opacity: .92;
  max-width: 48%;
}
.hm-job small { display: block; font-size: 12px; opacity: .75; }
.hm-job span { display: block; }
.hm-job:hover { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }

/* ---------- sections รวม ---------- */
.hm-sec { padding: 104px 0; }
.hm-sec--first { padding-top: 80px; }
.hm-soft { background: var(--v3-soft); }
.hm-h2 {
  color: var(--v3-navy);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.3;
  margin: 0 0 32px;
  font-weight: 700;
  text-wrap: balance;
}
.hm-lead { font-size: 17px; color: var(--v3-muted); margin: 0; max-width: 60ch; }

/* ---------- งานที่เราทำ: การ์ด 5 ประเภทลูกค้า ---------- */
.hm-types { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.hm-type { padding: 12px 12px 18px; text-decoration: none; color: var(--v3-navy-deep); display: block; min-width: 0; }
.hm-type-img { border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; background: var(--v3-soft); }
.hm-type-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hm-type h3 { font-size: 17px; color: var(--v3-navy); margin: 14px 2px 4px; }
.hm-type p { margin: 0 2px; color: var(--v3-muted); font-size: 14px; line-height: 1.6; }

/* ---------- แถบ Precast ---------- */
.hm-precast { display: grid; grid-template-columns: 1fr 1.1fr; gap: 56px; align-items: center; }
.hm-precast-img { border-radius: 18px; overflow: hidden; background: var(--v3-navy-deep); }
.hm-precast-img img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.hm-precast-title { margin-bottom: 20px; }
.hm-pts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 18px; padding: 0; list-style: none; }
.hm-pts li {
  background: #fff;
  border: 1px solid var(--v3-line);
  border-radius: 14px;
  padding: 14px 0;
  text-align: center;
  font-weight: 700;
  color: var(--v3-navy);
  font-size: 16px;
}
.hm-precast-note { margin: 0 0 26px; color: var(--v3-muted); font-size: 17px; }

/* ---------- ผลงานเด่น: rail เลื่อนแนวนอน ---------- */
.hm-work-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.hm-work-head .hm-h2 { margin: 0; }
.hm-more { color: var(--v3-navy); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.hm-more:hover { text-decoration: underline; text-underline-offset: 6px; }
.hm-rail {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 4px 0 24px;
  scrollbar-width: none;
}
.hm-rail::-webkit-scrollbar { display: none; }
.hm-pjc {
  flex: 0 0 340px;
  scroll-snap-align: start;
  text-decoration: none;
  color: var(--v3-navy-deep);
  border-radius: 18px;
  transition: transform .25s cubic-bezier(.2, .7, .2, 1), box-shadow .25s;
}
.hm-pjc:hover { transform: translateY(-3px); box-shadow: 0 16px 32px -18px rgba(19, 53, 93, .4); }
.hm-pjc-img { border-radius: 18px; overflow: hidden; aspect-ratio: 4 / 3; background: var(--v3-soft); }
.hm-pjc-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hm-pjc h3 { font-size: 18px; margin: 14px 0 2px; line-height: 1.45; color: var(--v3-navy); }
.hm-pjc-meta { font-size: 14px; color: var(--v3-muted); }

/* ---------- ขั้นตอน 3 ข้อ ---------- */
.hm-steps-lead { margin: 0 0 44px; }
.hm-steps {
  counter-reset: hm-s;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.hm-steps li { counter-increment: hm-s; display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; }
.hm-steps li::before {
  content: counter(hm-s);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--v3-navy);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.hm-steps b { color: var(--v3-navy); display: block; font-size: 18px; margin-bottom: 4px; }
.hm-steps span { grid-column: 2; color: var(--v3-muted); font-size: 16px; line-height: 1.7; }

/* ---------- บทความล่าสุด ---------- */
.hm-arts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.hm-art { padding: 12px; min-width: 0; }
.hm-art-thumb { display: block; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 10; background: var(--v3-soft); }
.hm-art-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hm-art-body { padding: 14px 6px 8px; }
.hm-art-meta { display: block; font-size: 13px; color: var(--v3-blue); font-weight: 600; margin-bottom: 6px; }
.hm-art h3 { font-size: 18px; line-height: 1.5; margin: 0 0 8px; }
.hm-art h3 a { color: var(--v3-navy); text-decoration: none; }
.hm-art h3 a:hover { text-decoration: underline; text-underline-offset: 5px; }
.hm-art p { margin: 0; color: var(--v3-muted); font-size: 15px; line-height: 1.7; }

/* การ์ดบทความไม่มีภาพ — แผ่นพื้นนุ่มแทนภาพ ยืดเต็มความสูงเท่าการ์ดอื่นในแถว (T-0049) */
.hm-art--plain { display: flex; flex-direction: column; }
.hm-art--plain .hm-art-body { flex: 1; border-radius: 12px; background: var(--v3-soft); padding: 18px 16px; }

/* ---------- จอ ≤1024px ---------- */
@media (max-width: 1024px) {
  .hm-types { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hm-arts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- จอ ≤900px ---------- */
@media (max-width: 900px) {
  .hm-precast { grid-template-columns: 1fr; gap: 32px; }
}

/* ---------- มือถือ ≤860px ---------- */
@media (max-width: 860px) {
  .hm-hero::after {
    background: linear-gradient(180deg, rgba(19, 53, 93, .35) 0%, rgba(19, 53, 93, .55) 35%, rgba(19, 53, 93, .93) 70%);
  }
  .hm-copy { bottom: 150px; }
  .hm-h1 { font-size: clamp(30px, 8.6vw, 40px); }
  .hm-tabs { padding-bottom: 14px; }
  .hm-tabs-in { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
  .hm-tabs-in::-webkit-scrollbar { display: none; }
  .hm-tab { flex: 0 0 auto; margin-right: 6px; font-size: 14px; }
  .hm-job {
    position: absolute;
    bottom: 64px;
    left: max(20px, env(safe-area-inset-left, 0px));
    right: auto;
    text-align: left;
    max-width: 80%;
    padding: 0;
  }
  .hm-sec { padding: 72px 0; }
  .hm-sec--first { padding-top: 56px; }
}

/* ---------- มือถือ ≤640px ---------- */
@media (max-width: 640px) {
  .hm-types { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hm-steps { grid-template-columns: 1fr; gap: 24px; }
  .hm-arts { grid-template-columns: 1fr; }
  .hm-pjc { flex-basis: 78%; }
  .hm-sec { padding: 64px 0; }
  .hm-sec--first { padding-top: 48px; }
}

/* ---------- T-0058 มือถือกระชับ (≤820px, เดสก์ท็อปไม่แตะ) ----------
   จังหวะ 24/16/14 ตาม style.css — บทความล่าสุดเหลือ 2 การ์ดผ่าน data-more-link
   (หัวข้อมีลิงก์ "ดูบทความทั้งหมด →" อยู่แล้ว จึงไม่ต้องมีปุ่มดูเพิ่ม) */
@media (max-width: 820px) {
  .hm-sec { padding: 24px 0; }
  .hm-sec--first { padding-top: 24px; }
  .hm-h2 { margin-bottom: 16px; }
  .hm-lead { font-size: 15px; }
  .hm-steps-lead { margin-bottom: 16px; }
  .hm-types { gap: 12px; }
  .hm-precast { gap: 20px; }
  .hm-precast-title { margin-bottom: 12px; }
  .hm-pts { gap: 8px; margin-bottom: 12px; }
  .hm-pts li { padding: 10px 0; font-size: 15px; }
  .hm-precast-note { margin-bottom: 16px; font-size: 15px; }
  .hm-work-head { margin-bottom: 16px; }
  .hm-arts { gap: 12px; }
  .hm-art { padding: 10px; }
  .hm-art-body { padding: 10px 4px 6px; }
  .hm-art h3 { font-size: 16px; }
  .hm-art p { font-size: 14px; }
  .hm-steps { gap: 16px; }
  .hm-steps b { font-size: 16px; }
  .hm-steps span { font-size: 14.5px; }
  .hm-rail { gap: 14px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .hm-slide, .hm-slide img { transition: none; }
  .hm-slide.is-on img { transform: scale(1.02); }
  .hm-tab.is-on .ln i { animation: none; width: 100%; }
  .hm-pjc { transition: none; }
  .hm-pjc:hover { transform: none; box-shadow: none; }
}
