/* v2.css — โครงใหม่แบบ scroll ยาวหน้าเดียว (ต้นแบบ ยังไม่ใช่ของจริง)
   โหลดต่อจาก styles.css เพื่อ "ปลดล็อก" กฎที่ผูกกับโครง snap grid เดิม
   แล้วใช้สไตล์ของการ์ด/ปุ่ม/ตาราง ฯลฯ จาก styles.css ต่อได้เหมือนเดิม

   ค่าที่ปรับได้จากหน้า preview (ส่งมาทาง CSS variable):
     --sec-gap   ระยะห่างระหว่างหัวข้อ
     --spy-off   จุดที่ถือว่า "เลื่อนถึงหัวข้อนี้แล้ว" (แถบบนจะไฮไลต์ตาม) */

:root {
  --sec-gap: 72px;
  --spy-off: 96px;
  --hdr-h: 64px;
}

/* ── ปลดล็อกโครงเดิม ─────────────────────────────────────────── */
html, body, #root {
  height: auto; min-height: 100%;
  overflow: visible;
  overscroll-behavior: auto;   /* คืน pull-to-refresh ของเบราว์เซอร์ */
}
body { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { body { scroll-behavior: auto; } }

/* คอมโพเนนต์เนื้อหาเดิมถูกออกแบบให้อยู่ในกล่องเต็มจอ — คลายออกให้ไหลตามเนื้อหา */
.v2 .page-inner {
  flex: none; min-height: 0;
  overflow: visible;
  max-width: none; margin: 0;
  width: 100%;
}
.v2 .page-inner > :first-child { margin-top: 0; }
.v2 .page-inner > :last-child { margin-bottom: 0; }
.v2 .page-inner.scroll-y { overflow: visible; }

/* ── แถบหัวข้อด้านบน ─────────────────────────────────────────── */
/* แถบบนใช้สไตล์ชุดเดิมทั้งหมด (คลาส .header) เปลี่ยนแค่จาก fixed เป็น sticky
   เพราะโครงใหม่ไม่มี .stage ที่ position:fixed มาครอบแล้ว */
.v2-header.header {
  position: sticky;
  left: auto; right: auto;
}
.v2-header .mark { cursor: pointer; }

/* ปุ่มของหัวข้อที่กำลังอยู่ = โชว์ทั้งไอคอนและคำ (ของเดิมซ่อนไอคอนแล้วเหลือแต่คำ)
   ทำเฉพาะใน .v2 เว็บจริงยังเป็นแบบเดิม */
.v2 .header .index .pill.active .cat-ico { display: inline-grid; }
.v2 .header .index .pill.active { gap: 6px; }

/* แถวไอคอนเลื่อนได้เองเมื่อล้น — วางเป็นลูก flex ตรงกลางระหว่างโลโก้ KP กับปุ่มโทร
   จึงไม่มีทางทับกัน (คนละกล่องใน flex เดียวกัน ไม่ได้ซ้อนทับแบบ absolute) */
.v2 .header .index {
  margin-left: 8px;
  flex: 1 1 auto; min-width: 0;
  overflow-x: auto; overflow-y: hidden;
  justify-content: flex-start;
  /* จัดกลางด้วย auto margin แทน justify-content: center
     เพราะ center ในกล่องที่เลื่อนได้ จะดันของต้นแถวออกนอกกรอบจนเลื่อนกลับไปดูไม่ได้
     (เคสเดียวกับที่เคยเจอในหน้า Q&A) — auto margin ยุบเป็น 0 เองเมื่อของล้น */
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding-block: 2px;
}
.v2 .header .index::-webkit-scrollbar { display: none; }
.v2 .header .index .pill { flex: 0 0 auto; scroll-snap-align: center; }
.v2 .header .index > .pill:first-child { margin-left: auto; }
.v2 .header .index > .pill:last-child { margin-right: auto; }
/* ปุ่มโทรติดขวาสุดเสมอ ไม่ถูกบีบและไม่เลื่อนหายไปกับแถวไอคอน */
.v2 .header .hdr-contact { flex: 0 0 auto; margin-left: 8px; }
.v2 .header .mark { flex: 0 0 auto; }

/* ── ตัวหน้า ─────────────────────────────────────────────────── */
.v2-main { width: 100%; }
.v2-sec {
  width: 100%; max-width: 1200px; margin: 0 auto;
  padding: var(--sec-gap) calc(20px + var(--safe-right)) var(--sec-gap) calc(20px + var(--safe-left));
  scroll-margin-top: var(--spy-off);
}
/* หน้าแรกเต็มจอเสมอทุกขนาดจอ แล้วค่อยเลื่อนลงไปหัวข้อถัดไป */
.v2-sec.is-hero {
  /* หักความสูงแถบบนออก (วัดจริงจาก JS) หน้าแรกจะได้สูงเต็มจอพอดี ไม่ดันให้เลื่อนเกิน */
  min-height: calc(100dvh - var(--hdr-h));
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding-top: var(--sec-gap); padding-bottom: var(--sec-gap);
}
.v2-sec.is-hero .home-stack { width: 100%; max-width: 100%; margin: auto; }
/* ของเดิมตั้งความกว้างเป็นหน่วย ch ซึ่งกว้างกว่าจอมือถือได้
   โครงเก่ามี overflow:hidden ครอบไว้เลยไม่เห็นปัญหา พอเปลี่ยนเป็น scroll ปกติจะดันหน้าให้กว้างเกิน */
.v2 .lead { max-width: min(46ch, 100%); }
.v2 .home-blocks { max-width: 100%; }

/* เส้นกั้นระหว่างหัวข้อ */
.v2-div {
  width: 100%; max-width: 1200px; margin: 0 auto;
  border: 0; border-top: 2px solid var(--ink);
  opacity: .85;
}

.v2-sec-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: clamp(16px, 2.4vh, 26px);
}
.v2-sec-head h2 {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(26px, 4.4vw, 40px); line-height: 1.05; letter-spacing: -0.01em;
}
.v2-sec-head .en {
  font-family: var(--font-display); font-size: 13px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3);
}

/* ── โหมด "แยกหน้า" (link) ────────────────────────────────────── */
.v2 a.v2-link { text-decoration: none; color: inherit; display: block; }

.v2-foot {
  padding: 28px 20px calc(40px + var(--safe-bottom));
  text-align: center; font-size: 13px; color: var(--ink-3);
  border-top: 1px solid rgba(31,31,53,.08);
}

/* จอเล็ก — ลดระยะขอบซ้ายขวา ไม่แตะ --sec-gap เพราะเป็นค่าที่ผู้ใช้ปรับเอง */
@media (max-width: 640px) {
  .v2-sec { padding-left: calc(14px + var(--safe-left)); padding-right: calc(14px + var(--safe-right)); }
}



/* ═══ กรอบที่กางออก — ทุกหมวดใช้กติกาเดียวกัน ═══════════════════
   หลักคิด: กดแล้ว "กรอบเดิมขยาย" ไม่ใช่มีกล่องใหม่โผล่ข้างล่าง
   จึงไม่มีกรอบซ้อนกรอบ และตำแหน่งที่กดไม่หาย */

/* ส่วนเนื้อหาที่กางออกมาข้างในกรอบเดิม */
.v2-inner {
  position: relative;
  border-top: 2px solid var(--ink);
  padding: clamp(14px, 2.2vw, 22px);
  background: #fff;
  animation: panel-in .22s ease;
  scroll-margin-top: calc(var(--hdr-h) + 10px);
}
.v2-panel-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 30px; height: 30px; padding: 0;
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 20px; line-height: 1;
  border: 1.5px solid var(--ink); border-radius: 8px;
  background: #fff; color: var(--ink); cursor: pointer;
}
.v2-panel-close:hover { background: var(--bg-blush); }

/* คอมโพเนนต์เนื้อหาเดิมใส่จำนวนคอลัมน์เป็น inline style ไว้ (สมัยยังห้าม scroll ต้องบีบ 2 คอลัมน์)
   ตอนนี้เลื่อนได้แล้วจึงคลายเป็นคอลัมน์เดียว — inline style ทับด้วย CSS ปกติไม่ได้ ต้อง !important */
.v2-inner .grid.grid-2,
.v2-inner .grid.grid-3,
.v2-inner .grid.grid-4 { grid-template-columns: 1fr !important; }
.v2-inner .tutor-detail,
.v2-inner .td-body { display: block; }
.v2-inner .td-body > * + * { margin-top: clamp(12px, 2.2vh, 20px); }
.v2-inner .section-head {
  flex-direction: column; align-items: flex-start;
  border-bottom: 0;                 /* ไม่เอาขีดดำใต้หัวข้อ */
  padding-bottom: 6px; margin-bottom: 12px;
  padding-right: 34px;              /* เว้นที่ให้ปุ่มกากบาท */
}
/* หน้าติวเตอร์: ชื่อกับคณะที่จบอยู่บรรทัดเดียวกัน คณะชิดขวาสุด — ประหยัดบรรทัด */
.v2-inner .tutor-page .section-head {
  flex-direction: row; flex-wrap: nowrap;
  align-items: flex-end; justify-content: space-between;
  gap: 10px; padding-right: 0;
}
.v2-inner .tutor-page .section-head .title-block { min-width: 0; }
.v2-inner .tutor-page .section-head .chip {
  flex-shrink: 1; min-width: 0;
  font-size: clamp(11px, 2.6vw, 13px);
  padding: 4px 10px; text-align: right; line-height: 1.35;
}
.v2-inner .price-table { max-width: 460px; }
.v2-inner .line-frame { max-width: 560px; }
.v2-inner .page-inner { gap: 0; }

/* ── คอร์ส: กล่องหมวดที่ถูกกดขยายเต็มความกว้าง ─────────────────── */
/* กล่องที่กดขยายเต็มความกว้าง อยู่ตำแหน่งเดิมไม่เด้งขึ้นบน
   เนื้อหางอกลงล่าง แล้วให้ผู้ใช้เลื่อนดูต่อเอง (ตัว JS ดึง scroll ให้กรอบค้างที่จุดเดิมบนจอ) */
.course-group.is-expanded { grid-column: 1 / -1; }
.v2 .course-group { transition: none; }
.v2 .course-chip2.is-open { box-shadow: inset 0 0 0 2px var(--ink); }

/* ── แถวยาวเต็มความกว้าง (ติวเตอร์ / บทความ) ───────────────────── */
.v2-list { display: flex; flex-direction: column; gap: 12px; }
.v2-row {
  scroll-margin-top: calc(var(--hdr-h) + 10px);   /* เลื่อนมาแล้วหัวแถวไม่โดนแถบบนบัง */
  border: 2px solid var(--ink); border-radius: var(--r-md);
  background: #fff; box-shadow: 4px 4px 0 var(--ink);
  overflow: hidden;
}
.v2-row-head {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px; cursor: pointer;
}
.v2-row-head:hover { background: var(--bg-blush); }
.v2-row-head .tc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.v2-row-head .avatar.tutor-face { width: 62px; height: 62px; flex-shrink: 0; }
.v2-row-head .num {
  font-family: var(--font-display); font-weight: 600; font-size: 28px;
  color: var(--c-pink); width: 46px; flex-shrink: 0;
}
.v2-row-title {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(15px, 2vw, 18px); line-height: 1.25; letter-spacing: -0.01em;
}
.v2-row-head .meta-line {
  font-family: var(--font-display); font-size: 11px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .1em;
}
.v2-exp {
  flex-shrink: 0; font-family: var(--font-display); font-weight: 600;
  font-size: 24px; line-height: 1; color: var(--c-pink); width: 22px; text-align: center;
}
.v2-row.is-open .v2-exp { color: var(--ink); }

/* ── เนื้อความบทความ ─────────────────────────────────────────── */
.v2-article-lead {
  font-size: clamp(15px, 1.8vw, 18px); line-height: 1.6;
  color: var(--ink-2); margin: 0 0 14px;
}
.v2-inner .article-body { margin: 0 0 12px; max-width: none; }
.v2-inner .article-body:last-child { margin-bottom: 0; }

/* ── Q&A: ไม่เอาขีดดำใต้หัวข้อ ──────────────────────────────── */
.v2 .qna-list { margin-top: 0; }


/* ═══ บทความ: คำตอบสั้น (bubble) / คำตอบยาว ═══════════════════════ */
.v2-bubble {
  background: var(--bg-blush);
  border: 1.5px solid rgba(31,31,53,.12);
  border-radius: 14px;
  padding: clamp(12px, 2vw, 16px) clamp(14px, 2.2vw, 18px);
  margin-bottom: clamp(16px, 2.6vh, 22px);
}
.v2-bubble .rich-p { margin: 0; color: var(--ink); font-weight: 500; }
.v2-bubble .rich-p + .rich-p { margin-top: 8px; }

/* ตัวอักษรบทความ — อ่านง่ายขึ้น: ใหญ่ขึ้น บรรทัดห่างขึ้น สีเข้มขึ้น */
.v2-rich { font-size: clamp(15.5px, 1.9vw, 17.5px); line-height: 1.85; color: var(--ink); }
.v2-rich .rich-p { margin: 0 0 1em; }
.v2-rich .rich-p:last-child { margin-bottom: 0; }
.v2-rich .rich-h1 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.28em; line-height: 1.3; margin: 1.2em 0 .5em; color: var(--ink);
}
.v2-rich .rich-h2 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.12em; line-height: 1.35; margin: 1.1em 0 .45em; color: var(--ink-2);
}
.v2-rich .rich-h1:first-child, .v2-rich .rich-h2:first-child { margin-top: 0; }
.v2-rich .rich-ul { margin: 0 0 1em 1.15em; padding: 0; }
.v2-rich .rich-ul li { margin-bottom: .4em; }
.v2-rich .rich-ul li::marker { color: var(--c-pink); }
.v2-rich strong { font-weight: 700; }
.v2-rich em { font-style: italic; }
