/* หน้าบทความ — fork โครงและสัดส่วนจาก takra-site ArticleView.vue (แถบหัว · ปก 16:9 คร่อมแถบ · แชร์ 100 + เนื้อหา 710 · sidebar 300 · วงแหวน %)
   เปลี่ยนเป็นธีมสว่าง + สีของ myfolio (ชมพู/ม่วงแทนส้ม) · navbar ของ myfolio ไม่ลอย → แถบหัวเตี้ยกว่าต้นทาง */
.ap {
  --primary-color: var(--tp-text); --text-color: var(--tp-text-2); --secondary-color: var(--tp-surface-2); --divider-color: var(--tp-border);
  --accent-color: var(--tp-brand); --accent-secondary-color: var(--tp-brand-2);
  color: var(--text-color); font-family: Inter, "Google Sans", sans-serif;
}
.ap a { text-decoration: none; }
.ap .ic { width: 1em; height: 1em; flex: none; }
.ap-container { max-width: var(--tp-container, 1200px); margin: 0 auto; padding: 0 24px; }   /* = grid หลักของเว็บ → ขอบซ้ายตรงโลโก้ */
.section.blog-post .container-medium-652px { display: none; }   /* "Latest articles" เดิม — แทนด้วย อ่านเพิ่มเติม + sidebar */
.section.blog-post { padding-top: 0; }

/* ── แถบหัว ── */
.ap-band { background: var(--secondary-color); border-bottom: 1px solid var(--divider-color); padding: 64px 0 110px; }
.ap-head { max-width: 970px; }
.ap-tags { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.ap-tag { display: inline-flex; align-items: center; padding: 6px 11px; border-radius: 5px; background: var(--accent-color); color: var(--tp-on-brand); font-weight: 600; font-size: 12px; letter-spacing: .5px; text-transform: uppercase; line-height: 1.2; }
.ap-tag:hover { color: var(--tp-on-brand); filter: brightness(1.08); }
.ap-tag--ghost { background: var(--tp-surface); color: var(--tp-text-2); box-shadow: inset 0 0 0 1px var(--tp-border-strong); }  /* พื้นขาว ไม่จมไปกับแถบเทา */
.ap-tag--ghost:hover { color: var(--primary-color); filter: none; }
.ap-title { margin: 0 0 16px; color: var(--primary-color); font-family: "Google Sans", Inter, sans-serif; font-size: 34px; line-height: 1.35; font-weight: 600; text-wrap: balance; }
.ap-meta { display: flex; flex-wrap: wrap; gap: 16px; margin: 0; font-size: 14px; color: var(--text-color); }
.ap-meta span { display: inline-flex; align-items: center; gap: 6px; }

/* ── เนื้อหา 850 + sidebar 300 · ปกคร่อมขอบล่างแถบ 50 ── */
.ap-grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 35px; margin-top: -50px; padding-bottom: 100px; }
.ap-main { min-width: 0; }
.ap-cover { margin: 0 0 45px; aspect-ratio: 1280 / 672; /* = ขนาดปกจริง ไม่มีแถบเบลอบน-ล่าง */ border-radius: 16px; overflow: hidden; background: var(--secondary-color); }
.ap-cover > img { display: block; width: 100%; height: 100%; object-fit: cover; }

.ap-row { display: flex; align-items: flex-start; }
.ap-share { position: sticky; top: 120px; flex: none; width: 100px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.ap-share-title { font-size: 13px; letter-spacing: 1px; color: var(--text-color); margin-bottom: 4px; }
.ap-share-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--divider-color); background: var(--tp-surface); color: var(--primary-color); font-size: 17px; cursor: pointer; transition: border-color .2s, color .2s; }
.ap-share-btn:hover, .ap-share-btn.ok { border-color: var(--accent-color); color: var(--accent-color); }
.ap-body { flex: 1; min-width: 0; max-width: 710px; }

/* ── ในเนื้อหา (vertical rhythm ต้นทาง: ย่อหน้า 20 · รายการ 24 · H2 56/16 · H3 40/12 · บล็อกใหญ่ 40) ── */
.ap-content { font-size: 17px; line-height: 1.8; color: var(--text-color); overflow-wrap: anywhere; }
.ap-content > :first-child { margin-top: 0; }
.ap .ap-content p { margin: 0 0 20px; font-size: 17px; line-height: 1.8; color: var(--text-color); max-width: none; }
.ap .ap-content :is(h2, h3, h4, h5) { font-family: "Google Sans", Inter, sans-serif; color: var(--primary-color); font-size: 26px; line-height: 1.35; font-weight: 700; margin: 56px 0 16px; max-width: none; scroll-margin-top: 110px; }
.ap .ap-content :is(ul, ol) { margin: 0 0 24px; padding-left: 24px; max-width: none; }
.ap .ap-content li { font-size: 17px; line-height: 1.8; color: var(--text-color); }
.ap .ap-content li + li { margin-top: 8px; }
.ap .ap-content li::marker { color: var(--accent-color); }
.ap .ap-content :is(b, strong) { color: var(--primary-color); }
.ap .ap-content a { color: var(--accent-color); text-decoration: underline; }
.ap .ap-content figure { margin: 40px 0; }
.ap .ap-content figure img { border-radius: 12px; }
.ap .ap-content figcaption { margin-top: 12px; font-size: 14px; color: var(--text-color); text-align: center; }
/* คำพูดทุกแบบ (คำโปรยหัวบทความ .ap-lead · blockquote ทั่วไป · .ap-say) = บับเบิลส้มแบบเดียวกัน — ผู้ใช้ 2 ธ.ค. 2026 */
.ap .ap-content blockquote { width: fit-content; max-width: 88%; margin: 28px 0; padding: 14px 22px; border: 0; border-radius: 22px 22px 22px 6px; background: #FFF1E6; color: var(--tp-text); font-size: 19px; font-weight: 600; line-height: 1.55; font-style: normal; font-family: inherit; }
.ap .ap-content blockquote + blockquote { margin: -14px 0 28px auto; border-radius: 22px 22px 6px 22px; background: #FFE0C7; } /* คนตอบ = ชิดขวา */
.ap .ap-content blockquote.ap-lead { margin: 0 0 40px; }
.ap .ap-content blockquote p { margin: 0; }
.ap .ap-content blockquote::before, .ap-quote { display: none; content: none; }

/* สารบัญ — กล่องเส้นขอบ หัวข้อกลาง bullet สีแบรนด์ */
.ap .ap-toc { margin: 0 0 48px; padding: 20px 40px; border: 1px solid var(--divider-color); border-radius: 12px; background: var(--secondary-color); }
.ap .ap-toc-title { margin: 0 !important; text-align: center; font-size: 16px !important; font-weight: 700; color: var(--primary-color) !important; }
.ap .ap-toc ol { margin: 16px 0 0; padding-left: 20px; list-style: disc; }
.ap .ap-toc li { color: var(--accent-color); line-height: 1.75; font-size: 16px; margin: 0; }
.ap .ap-toc li::marker { color: var(--accent-color); }
.ap .ap-toc a { color: var(--accent-color); text-decoration: none; }
.ap .ap-toc a:hover { text-decoration: underline; }

/* ผู้เขียน */
.ap-author { display: grid; grid-template-columns: 88px 1fr; gap: 24px; align-items: center; margin-top: 48px; }
.ap-author-avatar { box-sizing: border-box; width: 88px; height: 88px; border-radius: 50%; border: 2px solid var(--accent-color); padding: 3px; object-fit: cover; background: var(--tp-surface); }
.ap-author-name { margin: 0 0 4px; font-size: 20px; font-weight: 700; color: var(--primary-color); }
.ap-author-bio { margin: 0 0 10px; font-size: 14px; line-height: 1.6; color: var(--text-color); }
.ap-author-links { list-style: none; display: flex; gap: 14px; margin: 0; padding: 0; }
.ap-author-links a { color: var(--text-color); font-size: 18px; display: inline-flex; }
.ap-author-links a:hover { color: var(--accent-color); }

/* ก่อนหน้า / ถัดไป — 2 ช่อง เส้นแบ่งกลาง */
.ap-pn { display: grid; grid-template-columns: 1fr 1fr; margin-top: 48px; border-top: 1px solid var(--divider-color); border-bottom: 1px solid var(--divider-color); }
.ap-pn-item { display: flex; flex-direction: column; gap: 10px; padding: 32px 24px 32px 0; color: inherit; }
.ap-pn-prev { text-align: right; align-items: flex-end; border-right: 1px solid var(--divider-color); }
.ap-pn-next { padding: 32px 0 32px 24px; }
.ap-pn-label { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; letter-spacing: .5px; color: var(--text-color); }
.ap-pn-label .ic { color: var(--accent-color); transition: transform .2s; }
.ap-pn-prev:hover .ap-pn-label .ic { transform: translateX(-4px); }
.ap-pn-next:hover .ap-pn-label .ic { transform: translateX(4px); }
.ap-pn-title { font-size: 17px; font-weight: 700; line-height: 1.5; color: var(--primary-color); }
.ap-pn-item:hover .ap-pn-title { color: var(--accent-color); }

/* อ่านเพิ่มเติม — กริด 2 คอลัมน์ ชื่อ+วันที่ซ้าย รูปขวา */
.ap-more { margin-top: 64px; }
.ap-more-title { margin: 0 0 32px; text-align: center; font-family: "Google Sans", Inter, sans-serif; font-size: 24px; font-weight: 700; color: var(--primary-color); }
.ap-more-title .hl-word { background: linear-gradient(90deg, var(--accent-secondary-color), var(--accent-color)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ap-more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px 50px; }
.ap-more-item { display: grid; grid-template-columns: 1fr 160px; gap: 20px; align-items: start; color: inherit; }
.ap-more-text { display: flex; flex-direction: column; gap: 10px; }
.ap-more-name { font-size: 17px; font-weight: 700; line-height: 1.5; color: var(--primary-color); }
.ap-more-item:hover .ap-more-name { color: var(--accent-color); }
.ap-more-date { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-color); }
.ap-more-thumb { width: 160px; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 10px; }
.ap-more-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ap-more-all { margin-top: 40px; text-align: center; }
.ap-btn-all { display: inline-flex; align-items: center; min-height: 52px; padding: 0 28px; border-radius: 999px; color: var(--tp-on-brand); font-weight: 600; background: linear-gradient(90deg, var(--accent-secondary-color), var(--accent-color)); }
.ap-btn-all:hover { color: var(--tp-on-brand); filter: brightness(1.08); }

/* sidebar: บทความล่าสุด — รูปย่อ 16:9 + เลขวงกลมมุมซ้ายบน */
.ap-side { padding-top: 110px; }
.ap-side-inner { position: sticky; top: 120px; display: flex; flex-direction: column; gap: 40px; }
.ap-widget-title { display: flex; align-items: center; gap: 12px; margin: 0 0 24px; font-size: 15px; font-weight: 600; color: var(--primary-color); }
.ap-widget-title::after { content: ''; flex: 1; height: 1px; background: var(--divider-color); }
.ap-rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 22px; }
.ap-rank-item { display: grid; grid-template-columns: 112px 1fr; gap: 16px; align-items: start; color: inherit; }
.ap-rank-thumb { position: relative; width: 112px; aspect-ratio: 16 / 9; }
.ap-rank-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.ap-rank-no { position: absolute; top: -10px; left: -10px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-color); color: var(--tp-on-brand); font-size: 14px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; border: 2px solid var(--tp-surface); }
.ap-rank-title { font-size: 15px; font-weight: 600; line-height: 1.5; color: var(--primary-color); }
.ap-rank-item:hover .ap-rank-title, .ap-rank-item.is-current .ap-rank-title { color: var(--accent-color); }
.ap-rank-now { display: block; margin-top: 4px; font-size: 13px; font-weight: 400; color: var(--text-color); }

/* วงแหวน % การอ่าน — มุมขวาบนใต้ navbar */
.ap-progress { position: fixed; top: 110px; right: 32px; z-index: 50; width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.9); box-shadow: 0 4px 16px rgba(0,0,0,.08); backdrop-filter: blur(8px); opacity: 0; transform: translateY(-8px); pointer-events: none; transition: opacity .25s, transform .25s; }
.ap-progress.on { opacity: 1; transform: none; }
.ap-progress svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ap-progress circle { fill: none; }
.ap-progress-track { stroke: rgba(0,0,0,.08); stroke-width: 3; }
.ap-progress-bar { stroke: var(--accent-color); stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset .15s linear; }
.ap-progress span { position: relative; font-size: 14px; font-weight: 600; color: var(--primary-color); }
@media (prefers-reduced-motion: reduce) { .ap-share-btn, .ap-progress, .ap-progress-bar, .ap-pn-label .ic { transition: none; } }

@media (max-width: 1119px) { .ap-grid { grid-template-columns: minmax(0, 1fr); } .ap-side { display: none; } }  /* แคบกว่า grid เต็ม: ไม่มีที่ให้ sidebar */

/* ≤ 991: คอลัมน์เดียว · แชร์เป็นแถวใต้ปก · sidebar ท้ายเนื้อหา */
@media (max-width: 991px) {
  .ap-band { padding: 40px 0 90px; }
  .ap-title { font-size: 26px; }
  .ap-grid { grid-template-columns: minmax(0, 1fr); }
  .ap-row { flex-direction: column; }
  .ap-share { position: static; width: auto; flex-direction: row; align-items: center; flex-wrap: wrap; margin-bottom: 32px; }
  .ap-share-title { margin: 0 6px 0 0; }
  .ap-body { max-width: none; }
  .ap-side { padding-top: 20px; }
  .ap-side-inner { position: static; }
  .ap-progress { display: none; }
}
@media (max-width: 767px) {
  .ap .ap-toc { padding: 16px 20px; }
  .ap-pn, .ap-more-grid { grid-template-columns: 1fr; }
  .ap-pn-prev { text-align: left; align-items: flex-start; border-right: 0; border-bottom: 1px solid var(--divider-color); }
  .ap-pn-item, .ap-pn-next { padding: 24px 0; }
  .ap-more-item { grid-template-columns: 1fr 120px; }
  .ap-more-thumb { width: 120px; }
}

/* ไอคอนโลโก้ทึบ (ข้อ 47: ไอคอนเส้นบางอ่านไม่ออก) */
.ap .ic-fill { width: 18px; height: 18px; }
.ap-author-links .ic-fill { width: 17px; height: 17px; }

/* tooltip ตอน hover/focus — ใช้ aria-label · คอลัมน์แชร์ขึ้นทางขวา ที่อื่นขึ้นด้านบน */
.ap :is(.ap-share-btn, .ap-author-links a) { position: relative; }
.ap :is(.ap-share-btn, .ap-author-links a)::after {
  content: none; position: absolute; z-index: 20;   /* สร้างเฉพาะตอน hover/focus — ซ่อนด้วย opacity ยังกินพื้นที่ ทำหน้าล้นบนมือถือ */ white-space: nowrap; pointer-events: none;
  padding: 6px 10px; border-radius: 6px; background: var(--tp-text); color: var(--tp-on-brand);
  font: 500 12px/1.2 var(--tp-font); opacity: 0; transition: opacity .15s, transform .15s;
  left: calc(100% + 10px); top: 50%; transform: translate(-4px, -50%);
}
.ap-author-links a::after { left: 50%; top: auto; bottom: calc(100% + 8px); transform: translate(-50%, 4px); }
.ap :is(.ap-share-btn, .ap-author-links a):is(:hover, :focus-visible)::after { content: attr(aria-label); opacity: 1; transform: translate(0, -50%); }
.ap .ap-author-links a:is(:hover, :focus-visible)::after { transform: translate(-50%, 0); }
.ap .ap-share-btn.ok::after { content: attr(data-tip-done); opacity: 1; transform: translate(0, -50%); }
@media (max-width: 991px) {   /* แชร์เป็นแถวแนวนอน → tooltip ขึ้นด้านบน */
  .ap .ap-share-btn::after { left: 50%; top: auto; bottom: calc(100% + 8px); transform: translate(-50%, 4px); }
  .ap .ap-share-btn:is(:hover, :focus-visible, .ok)::after { transform: translate(-50%, 0); }
}
@media (prefers-reduced-motion: reduce) { .ap :is(.ap-share-btn, .ap-author-links a)::after { transition: none; } }

/* หัวข้อใน sidebar ไม่เกิน 3 บรรทัด (หัวข้อไทยยาว · 2 บรรทัดตัดกลางประโยค) — "กำลังอ่านเรื่องนี้" อยู่นอกส่วนที่ตัด */
.ap-rank-t { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* รูปในบทความกว้างเต็มคอลัมน์เท่ากันทุกรูป (เดิม Webflow "align-center" แคบ 406 ชิดซ้าย) · รูปแนวตั้งสูงไม่เกิน 620 แสดงทั้งรูปบนพื้นเทา */
.ap .ap-content figure { width: 100% !important; max-width: 100% !important; margin-left: 0 !important; margin-right: 0 !important; }
.ap .ap-content figure > div { width: 100% !important; max-width: 100% !important; }
.ap .ap-content figure img { display: block; width: 100%; max-height: 620px; object-fit: contain; background: var(--tp-surface-2); border-radius: 12px; }

/* แกลเลอรี: รูปหลายรูปติดกันใน markdown (blog-publish.py md_images · ตรงกับพรีวิวหลังบ้าน) — 2/3 คอลัมน์ ครอปสี่เหลี่ยมจัตุรัส */
.ap .ap-content .md-gallery { display: grid; gap: 8px; margin: 40px 0; }
.ap .ap-content .md-gallery--2 { grid-template-columns: repeat(2, 1fr); }
.ap .ap-content .md-gallery :is(img, video) { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 12px; }
/* คอลลาจ 3 รูป: รูปแรกใหญ่ซ้าย 2 แถว + 2 รูปเล็กซ้อนขวา */
.ap .ap-content .md-gallery--3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 4 / 3; }
.ap .ap-content .md-gallery--3 :is(img, video) { aspect-ratio: auto; height: 100%; }
.ap .ap-content .md-gallery--3 :is(img, video):first-child { grid-row: span 2; }
/* แถบฟิล์ม 4 เฟรม (เฟรมจากคลิปเล่าต่อกัน) · มือถือ 2×2 */
.ap .ap-content .md-gallery--4 { grid-template-columns: repeat(4, 1fr); }
.ap .ap-content .md-gallery--4 :is(img, video) { aspect-ratio: 9 / 16; }
@media (max-width: 640px) { .ap .ap-content .md-gallery--4 { grid-template-columns: repeat(2, 1fr); } }
/* รูปเดี่ยวแนวตั้งไม่ให้สูงเกินจอ */
/* รูปเดี่ยว: ไม่เกิน 520px สูง · รูปแนวตั้งหดกว้างตามสัดส่วน วางกลาง ไม่เต็มคอลัมน์ */
.ap .ap-content .md-figure > div { text-align: center; }
.ap .ap-content .md-video video { display: block; width: auto; max-width: 100%; max-height: min(640px, 80vh); margin: 0 auto; border-radius: 12px; background: #000; }
.ap .ap-content .md-figure img { width: auto; max-width: 100%; max-height: min(520px, 70vh); margin: 0 auto; border-radius: 12px; }

@media (hover: none) { .ap :is(.ap-share-btn, .ap-author-links a):not(.ok)::after { content: none !important; } }  /* จอสัมผัสไม่มี hover */

/* พื้นเบลอหลังรูป (ตั้ง --ap-bg จาก article.js) */
.ap .ap-blurbox { position: relative; overflow: hidden; border-radius: 12px; isolation: isolate; }
.ap .ap-blurbox::before { content: ""; position: absolute; inset: -48px; z-index: -1; background: var(--ap-bg) center / cover no-repeat; filter: blur(32px) saturate(1.2); transform: scale(1.1); }
.ap .ap-content .ap-blurbox img { background: transparent; border-radius: 0; }
/* ปกบทความ: แสดงรูปเต็มไม่ตัด · ที่เหลือเป็นรูปเดียวกันเบลอ */
.ap-cover { position: relative; isolation: isolate; }
.ap-cover::before { content: ""; position: absolute; inset: -48px; z-index: -1; background: var(--ap-bg) center / cover no-repeat; filter: blur(32px) saturate(1.2); }
.ap-cover > img { object-fit: contain; }
/* ไอคอนโซเชียลผู้เขียน: กล่องเท่ากัน 24×24 จัดกึ่งกลาง → แนวตรงกันทุกตัว */
.ap-author-links { align-items: center; }
.ap-author-links a { width: 24px; height: 24px; display: inline-flex !important; align-items: center; justify-content: center; }
.ap-author-links a svg, .ap-author-links .ic-fill { width: 18px !important; height: 18px !important; display: block; }
.ap-author-bio { font-size: 15px; line-height: 1.6; }
.ap .ap-author-links a::after { line-height: 1.4; white-space: nowrap; z-index: 30; }  /* ลิงก์ตั้ง line-height:0 เพื่อจัดไอคอน → tooltip ต้องคืนค่า ไม่งั้นกล่องแบนทับไอคอน */
.ap .ap-author-links a::after { left: 50%; top: auto; bottom: calc(100% + 8px); transform: translate(-50%, 4px); }  /* specificity เท่ากฎฐาน → tooltip ขึ้นด้านบนจริง (เดิม top:50% ชนกับ bottom → กล่องแบน) */

/* ทางลัด/สารบัญ → หัวข้อไม่จมใต้เมนูด้านบน */
.ap-content .ap-toc-list a { color: inherit; text-decoration: underline; text-decoration-color: var(--tp-border, #ccc); text-underline-offset: 4px; }
.ap-content .ap-toc-list a:hover { color: var(--accent-color, #E2572B); text-decoration-color: currentColor; }

/* บับเบิลคำพูด: > “…” ใน markdown — คั่นจังหวะไม่ให้อ่านเป็นพืด · สองบับเบิลติดกัน = บทสนทนา (อันที่สองชิดขวา) */
/* .ap-say = บับเบิลแบบเดียวกับ blockquote ทุกตัว (กฎด้านบน) */
/* ตาราง markdown (| a | b |) */
.ap .ap-content .md-table { margin: 32px 0; overflow-x: auto; }
.ap .ap-content .md-table table { width: 100%; border-collapse: collapse; font-size: 17px; }
.ap .ap-content .md-table th, .ap .ap-content .md-table td { padding: 12px 14px; border-bottom: 1px solid #E8E4DC; text-align: left; }
.ap .ap-content .md-table th { font-weight: 700; background: #FFF1E6; }
.ap .ap-content .md-table td:not(:first-child), .ap .ap-content .md-table th:not(:first-child) { text-align: center; font-weight: 700; }

/* เครดิตภาพใต้แกลเลอรี: ย่อหน้าที่มีแต่ *ตัวเอียง* ต่อจาก .md-gallery */
.ap .ap-content .md-gallery + p:has(> em:only-child) { margin-top: 8px; font-size: 13px; line-height: 1.5; color: #8a8a8a; }
.ap .ap-content .md-gallery + p:has(> em:only-child) a { color: inherit; }
.ap .ap-content .md-gallery:has(+ p > em:only-child) { margin-bottom: 0; }
.ap .ap-content .md-gallery + p:has(> em:only-child) em { font-size: 13px; line-height: 1.5; color: #8a8a8a; }
