/* ═══════════════════════════════════════════════════════════════
   detail.css — หน้ารายละเอียด (ข่าว · กิจกรรม · เนื้อหา) ใช้ร่วมกับ site.css (โหลดต่อท้าย)
   Header Banner + breadcrumb → บทความ + แถบข้าง
   ═══════════════════════════════════════════════════════════════ */

/* ── Header Banner ──────────────────────────────────────── */
.dt-hero { background: var(--navy); }
.dt-banner { display: block; position: relative; overflow: hidden; background: var(--navy); line-height: 0; }
.dt-banner img { display: block; width: 100%; height: auto; max-height: 340px; object-fit: cover; object-position: center; }
a.dt-banner:hover { text-decoration: none; }
.dt-fallback { min-height: 150px; display: grid; place-items: center; padding: 28px 24px; line-height: 1.3; text-align: center;
  background: radial-gradient(1200px 260px at 15% 0%, rgba(47, 111, 224, .55), transparent 60%), linear-gradient(135deg, var(--navy), var(--blue)); }
.dt-fallback span { color: #fff; font: 700 clamp(1.2rem, 3vw, 1.9rem)/1.3 var(--font-head); text-shadow: 0 2px 10px rgba(0, 0, 0, .25); }

/* ── Breadcrumb ─────────────────────────────────────────── */
.dt-crumb { background: #fff; border-bottom: 1px solid var(--line); }
.dt-crumb ol { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; list-style: none; margin: 0; padding: 11px 0; font-size: .86rem; color: var(--muted); }
.dt-crumb li { display: inline-flex; align-items: center; min-width: 0; }
.dt-crumb li + li::before { content: "›"; margin: 0 9px; color: #9aa7bf; }
.dt-crumb a { color: var(--blue); }
.dt-crumb [aria-current] span { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: min(60vw, 560px); display: inline-block; }

/* ── โครงหน้า ───────────────────────────────────────────── */
.dt-wrap { padding-block: 26px 40px; }
.dt-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.dt-article { padding: clamp(18px, 3vw, 34px); }
.dt-side { position: sticky; top: 92px; display: grid; gap: 20px; }
.dt-side .card { padding: 18px 20px; }
.dt-side .sec-title { font-size: 1.2rem; margin-bottom: 8px; }
.dt-latest .item { padding: 12px 0; align-items: flex-start; }
.dt-latest .item .th { width: 76px; aspect-ratio: 4 / 3; }
.dt-latest .item a.tt { font-size: .9rem; -webkit-line-clamp: 3; }
.dt-none { margin: 4px 0 0; color: var(--muted); }

/* ── หัวบทความ ───────────────────────────────────────────── */
.dt-head { margin-bottom: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.dt-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; min-height: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--sky); color: var(--blue); font-size: .8rem; font-weight: 600; padding: 3px 12px; border-radius: 99px; }
.chip-pin { background: #fff4d6; color: #8a6406; }
.dt-chips .badge-new { margin-left: 0; font-size: .74rem; padding: 2px 9px; }
.dt-head h1 { margin: 0 0 12px; font-size: clamp(1.45rem, 3.2vw, 2.05rem); line-height: 1.35; font-weight: 700; color: var(--navy); overflow-wrap: anywhere; }
.dt-meta { display: flex; flex-wrap: wrap; gap: 6px 22px; list-style: none; margin: 0; padding: 0; color: var(--muted); font-size: .9rem; }
.dt-meta li { display: inline-flex; align-items: center; gap: 7px; }
.dt-meta .ic { color: var(--blue-2); }

/* ── ภาพปก / เนื้อหา ─────────────────────────────────────── */
.dt-cover { margin: 0 0 22px; text-align: center; background: var(--sky); border-radius: 12px; overflow: hidden; }
.dt-cover a { display: block; cursor: zoom-in; }
.dt-cover img { display: block; margin-inline: auto; max-width: 100%; max-height: 780px; width: auto; height: auto; object-fit: contain; }
.dt-body { font-size: 1.04rem; line-height: 1.85; color: var(--ink); overflow-wrap: anywhere; }
.dt-body > :first-child { margin-top: 0; }
.dt-body p { margin: 0 0 1em; }
.dt-body h2, .dt-body h3, .dt-body h4 { color: var(--navy); line-height: 1.4; margin: 1.5em 0 .5em; }
.dt-body h2 { font-size: 1.4rem; } .dt-body h3 { font-size: 1.2rem; } .dt-body h4 { font-size: 1.05rem; }
.dt-body img { max-width: 100%; height: auto; border-radius: 8px; }
.dt-body ul, .dt-body ol { padding-left: 1.5em; margin: 0 0 1em; }
.dt-body li { margin-bottom: .25em; }
.dt-body a { text-decoration: underline; text-underline-offset: 2px; }
.dt-body blockquote { margin: 1em 0; padding: 10px 18px; border-left: 4px solid var(--blue-2); background: var(--sky); border-radius: 0 10px 10px 0; color: #34415c; }
.dt-body table { width: 100%; border-collapse: collapse; margin: 0 0 1em; display: block; overflow-x: auto; }
.dt-body th, .dt-body td { border: 1px solid var(--line); padding: 8px 12px; vertical-align: top; }
.dt-body th { background: var(--sky); color: var(--navy); text-align: left; }
.dt-body hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }

/* ── ส่วนย่อย: วิดีโอ / ภาพ / ไฟล์ ───────────────────────── */
.dt-sec { margin-top: 30px; }
.dt-sec h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 1.2rem; color: var(--navy); }
.dt-sec h2 .ic { color: var(--blue); }
.dt-sec h2 small { font: 400 .82rem var(--font); color: var(--muted); margin-left: 4px; }
.dt-sec .video { max-width: 760px; }
.dt-gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.dt-gallery li { margin: 0; min-width: 0; }
.dt-gallery a { display: block; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--sky); cursor: zoom-in; }
.dt-gallery img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s; }
.dt-gallery a:hover img { transform: scale(1.06); }
.dt-gallery span { display: block; font-size: .8rem; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.dt-files { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.dt-files a { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--navy); transition: border-color .2s, box-shadow .2s; }
.dt-files a:hover { text-decoration: none; border-color: var(--blue-2); box-shadow: var(--shadow); }
.dt-files .dtag { flex: none; min-width: 54px; text-align: center; font: 700 .72rem/1 var(--font); letter-spacing: .04em; color: #fff; padding: 8px 6px; border-radius: 8px; background: #64748b; }
.dt-files .dtag-pdf { background: #d3262f; }
.dt-files .dtag-link { background: var(--blue); }
.dt-files .fn { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-files .go { display: inline-flex; align-items: center; gap: 5px; color: var(--blue); font-size: .88rem; font-weight: 600; white-space: nowrap; }

/* ── แชร์ / ก่อนหน้า-ถัดไป ──────────────────────────────── */
.dt-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); }
.dt-share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dt-share > span { color: var(--muted); font-size: .9rem; margin-right: 4px; }
.sh { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); background: #fff; color: var(--navy); font: 500 .85rem var(--font); cursor: pointer; }
.sh:hover { background: var(--sky); text-decoration: none; }
.sh-fb { background: #1877f2; border-color: #1877f2; color: #fff; }
.sh-fb:hover { background: #0f63d1; color: #fff; }
.sh.is-done { background: #e6f6ec; border-color: #9ad5b1; color: #176b3a; }
.btn-ghost { background: transparent; color: var(--blue); border: 1px solid var(--blue); padding: 8px 20px; }
.btn-ghost:hover { background: var(--blue); color: #fff; }
.dt-pn { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 22px; }
.dt-pn a { display: grid; gap: 3px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; color: var(--navy); background: var(--bg); min-width: 0; }
.dt-pn a:hover { text-decoration: none; border-color: var(--blue-2); background: #fff; }
.dt-pn small { color: var(--muted); font-size: .78rem; display: inline-flex; align-items: center; gap: 4px; }
.dt-pn span { font-weight: 600; font-size: .93rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dt-pn .n { text-align: right; } .dt-pn .n small { justify-content: flex-end; }

/* ── ไม่พบข้อมูล ─────────────────────────────────────────── */
.dt-missing { max-width: 560px; margin: 24px auto; text-align: center; padding: 40px 24px; display: grid; gap: 8px; justify-items: center; }
.dt-missing .ic { color: var(--blue-2); opacity: .5; }
.dt-missing h1 { margin: 6px 0 0; font-size: 1.5rem; color: var(--navy); }
.dt-missing p { margin: 0 0 12px; color: var(--muted); }

/* ── Lightbox ───────────────────────────────────────────── */
.lb { position: fixed; inset: 0; z-index: 200; display: none; background: rgba(8, 16, 36, .92); align-items: center; justify-content: center; padding: 56px 64px 64px; }
.lb.is-open { display: flex; }
.lb figure { margin: 0; max-width: 100%; max-height: 100%; display: grid; gap: 10px; justify-items: center; }
.lb img { max-width: 100%; max-height: calc(100vh - 150px); object-fit: contain; border-radius: 6px; background: #000; }
.lb figcaption { color: #dfe8fa; font-size: .92rem; text-align: center; min-height: 1.4em; }
.lb button { position: absolute; width: 46px; height: 46px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5); background: rgba(18, 48, 107, .6); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }
.lb button:hover { background: var(--blue); }
.lb .lb-x { top: 14px; right: 14px; } .lb .lb-p { left: 12px; top: 50%; translate: 0 -50%; } .lb .lb-n { right: 12px; top: 50%; translate: 0 -50%; }
.lb .lb-c { position: absolute; top: 20px; left: 20px; color: #cbd6ee; font-size: .85rem; }
.lb.single .lb-p, .lb.single .lb-n, .lb.single .lb-c { display: none; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1060px) {
  .dt-grid { grid-template-columns: 1fr; }
  .dt-side { position: static; }
}
@media (max-width: 680px) {
  .dt-banner img { max-height: 180px; }
  .dt-fallback { min-height: 110px; }
  .dt-wrap { padding-block: 16px 28px; }
  .dt-body { font-size: 1rem; line-height: 1.8; }
  .dt-pn { grid-template-columns: 1fr; }
  .dt-pn .n { text-align: left; } .dt-pn .n small { justify-content: flex-start; }
  .dt-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dt-files a { flex-wrap: wrap; } .dt-files .go { margin-left: auto; }
  .lb { padding: 56px 8px 70px; } .lb .lb-p { left: 6px; top: auto; bottom: 12px; translate: 0 0; } .lb .lb-n { right: 6px; top: auto; bottom: 12px; translate: 0 0; }
}

/* ── พิมพ์ ──────────────────────────────────────────────── */
@media print {
  .topbar, .site-head, .dt-crumb, .dt-side, .dt-share, .btn-ghost, .dt-pn, .site-foot, .fab, .totop, .dt-sec .video, .lb { display: none !important; }
  body { background: #fff; }
  .dt-banner img { max-height: 120px; }
  .dt-grid { display: block; } .card { box-shadow: none; border: 0; padding: 0; }
  .dt-files a::after { content: " (" attr(href) ")"; font-size: .75rem; color: #555; }
}
@media (prefers-reduced-motion: reduce) { .dt-gallery img { transition: none; } }

/* ── ตัวอ่านเอกสารแนบ (PDF / MS Office) ───────────────────── */
.dt-doc-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 12px; }
.dt-doc-bar h2 { margin: 0; }
.dt-doc-act { display: flex; flex-wrap: wrap; gap: 8px; }
.dt-doc .dtag { display: inline-block; min-width: 0; font: 700 .72rem/1 var(--font); letter-spacing: .04em; color: #fff; padding: 5px 9px; border-radius: 6px; background: #64748b; vertical-align: middle; }
.dt-doc .dtag-pdf { background: #d3262f; } .dt-doc .dtag-office { background: #1d6fb8; } .dt-doc .dtag-link { background: #64748b; }
.dt-viewer { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #525659; box-shadow: var(--shadow); }
.dt-viewer iframe { display: block; width: 100%; height: 780px; border: 0; background: #fff; }
.dt-viewer-office { background: #fff; }
.dt-viewer-office iframe { height: 640px; }
.dt-viewer-note { margin: 8px 2px 0; font-size: .8rem; color: var(--muted); }
@media (max-width: 680px) {
  .dt-viewer-pdf, .dt-viewer-pdf + .dt-viewer-note { display: none; }   /* เบราว์เซอร์มือถือฝัง PDF ไม่ได้ → ใช้ปุ่มเปิด/ดาวน์โหลด */
  .dt-viewer-office iframe { height: 480px; }
}
@media print { .dt-doc .dt-viewer, .dt-viewer-note { display: none !important; } }

/* ── หน้าเอกสาร (document_show) ───────────────────────────── */
.dt-head.has-cover { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.dt-bookcover { display: block; border-radius: 8px; overflow: hidden; box-shadow: 0 8px 22px rgba(18, 48, 107, .22); background: var(--sky); cursor: zoom-in; transform: rotate(-1deg); transition: transform .25s; }
.dt-bookcover:hover { transform: rotate(0) scale(1.02); }
.dt-bookcover img { display: block; width: 100%; height: auto; }
.chip-year { background: var(--navy); color: #fff; }
.dt-meta .dtag { display: inline-block; font: 700 .7rem/1 var(--font); letter-spacing: .04em; color: #fff; padding: 4px 8px; border-radius: 6px; background: #64748b; margin-right: 4px; }
.dt-meta .dtag-pdf { background: #d3262f; } .dt-meta .dtag-office { background: #1d6fb8; }
.dt-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.dt-cta .btn { padding: 11px 26px; font-size: .95rem; }
.dt-cta .btn-ghost { padding: 10px 22px; }
.dt-latest .item .th.th-cover { width: 56px; aspect-ratio: 3 / 4; background: var(--sky); border-radius: 6px; }
.dt-latest .item .th.ft { width: 56px; aspect-ratio: 1; }
@media (max-width: 680px) {
  .dt-head.has-cover { grid-template-columns: 1fr; justify-items: center; text-align: left; }
  .dt-bookcover { width: min(220px, 70%); }
  .dt-head.has-cover .dt-headtx { width: 100%; }
  .dt-cta .btn { flex: 1 1 100%; justify-content: center; }
}
@media print { .dt-cta { display: none; } .dt-bookcover { box-shadow: none; transform: none; } }

/* เมื่อหน้ามีปุ่มดาวน์โหลดด้านบนแล้ว ไม่ต้องซ้ำที่แถบตัวอ่าน; มือถือซ่อนส่วน PDF ทั้งก้อน */
.has-cta .dt-doc-act { display: none; }
.has-cta .dt-doc-bar { margin-bottom: 10px; }
@media (max-width: 680px) { .has-cta .dt-doc.is-pdf { display: none; } }
