/* =========================================================
   nitiphong.com : รูปแบบกลางของทุกหน้า (โทนน้ำเงิน–เทา)
   ใช้คู่กับโครงหน้า masthead / plate / foot
   ========================================================= */
:root {
  --ink: #10233F;        /* น้ำเงินเข้ม: แถบหัว หัวข้อ */
  --blue: #2350A8;       /* น้ำเงินหลัก: ลิงก์ ปุ่ม */
  --blue-soft: #E7EDF7;  /* น้ำเงินอ่อน: พื้นปุ่ม */
  --steel: #5B6B80;      /* เทาอมฟ้า: ข้อความรอง */
  --line: #DCE2EA;       /* เทาอ่อน: เส้นคั่น */
  --line-soft: #EBEFF4;  /* เส้นคั่นรายการ */
  --paper: #F3F5F8;      /* พื้นหลังหน้า */
  --text: #1F2D3D;
  --serif: "Noto Serif Thai", "Taviraj", Georgia, serif;
  --sans: "IBM Plex Sans Thai Looped", "Sarabun", "TH SarabunPSK", Tahoma, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 400 1.0625rem/1.75 var(--sans);
}
img { max-width: 100%; height: auto; }
a { color: var(--blue); }
a:focus-visible, button:focus-visible, select:focus-visible {
  outline: 3px solid #8DB0EC; outline-offset: 2px;
}
.wrap { max-width: 64rem; margin: 0 auto; padding: 0 1.25rem; }
.nw { white-space: nowrap; }

/* ---------- แถบบนและส่วนหัว ---------- */
.masthead { background: var(--ink); color: #fff; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 3.5rem; gap: 1rem;
}
.brand { color: #fff; text-decoration: none; font-weight: 600; }
.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .85rem; border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 999px; color: #fff; text-decoration: none; font-size: .95rem;
}
.pill:hover { background: rgba(255, 255, 255, .12); }
.pill svg { width: 1.05em; height: 1.05em; }
.hero { padding-top: 1.75rem; padding-bottom: 6.25rem; }
.crumbs {
  display: flex; flex-wrap: wrap; gap: .35rem 1.25rem; margin: 0 0 .9rem;
  font-size: .95rem;
}
.crumbs a { color: #B7C5D9; text-decoration: none; }
.crumbs a::before { content: "\2039\00a0"; }
.crumbs a:hover { color: #fff; text-decoration: underline; }
.hero h1 {
  margin: 0; max-width: 26em; font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.65rem, 5.6vw, 2.75rem); line-height: 1.35;
}

/* ---------- กล่องเนื้อหา ---------- */
.plate {
  position: relative; margin-top: -4.25rem; padding: 1.4rem 1.2rem 1.6rem;
  background: #fff; border-radius: 14px;
  box-shadow: 0 1px 2px rgba(16, 35, 63, .06), 0 18px 40px -18px rgba(16, 35, 63, .35);
  overflow-wrap: anywhere;
}
.content > :first-child { margin-top: 0; }
.content p { margin: .5rem 0; }
.content ul, .content ol { margin: .5rem 0; padding-left: 1.4rem; }
.content li { margin: .2rem 0; }
.content hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
.content strong, .content b { font-weight: 600; color: var(--ink); }
.content a { text-decoration: none; }
.content a:hover { text-decoration: underline; }
.content img { border-radius: 4px; vertical-align: middle; }

/* หัวข้อย่อย (เดิมเป็นแถบสีในตาราง) */
.content h2.bar {
  margin: 1.75rem 0 .5rem; padding-bottom: .4rem; border-bottom: 2px solid var(--ink);
  font: 600 1.2rem/1.5 var(--serif); color: var(--ink);
}
.content h2.bar a { color: inherit; }

/* ช่องตารางเก่าที่แปลงเป็นบล็อก: แต่ละช่อง = หนึ่งบรรทัดรายการ */
.content .c { padding: .4rem 0; }
.content .c + .c { border-top: 1px solid var(--line-soft); }
.content .c > .c:first-child { padding-top: 0; }
.content .c > .c:last-child { padding-bottom: 0; }
.content .lead {
  margin: 0 0 1rem; padding: .6rem .9rem; border-left: 3px solid #6F95D8;
  background: var(--paper); border-radius: 0 8px 8px 0; color: var(--ink);
}

/* ป้ายชนิดไฟล์ */
.ft {
  display: inline-block; min-width: 2.6em; margin-right: .45rem; padding: 0 .4rem;
  border-radius: 4px; font-size: .72rem; font-weight: 600; line-height: 1.7;
  text-align: center; vertical-align: .12em; letter-spacing: .02em;
}
a .ft + .ft, .ft + .ft { margin-left: -.15rem; }
.ft-pdf { background: #FBE9EA; color: #A3212A; }
.ft-ppt { background: #FCEDE3; color: #A4461B; }
.ft-xls { background: #E3F2E8; color: #1D6B37; }
.ft-doc { background: var(--blue-soft); color: var(--blue); }
.ft-zip, .ft-spss, .ft-mail { background: #ECEFF3; color: #3E4C5E; }
.new {
  display: inline-block; margin-left: .35rem; padding: 0 .45rem; border-radius: 4px;
  background: #C62D3A; color: #fff; font-size: .72rem; font-weight: 600;
  line-height: 1.6; vertical-align: .15em;
}
.dot {
  display: inline-block; width: .5rem; height: .5rem; margin-left: .35rem;
  border-radius: 50%; background: #C62D3A; vertical-align: .1em;
}
.hl { color: #A3212A; font-style: normal; }

/* ตารางข้อมูลจริง: เลื่อนแนวนอนได้บนมือถือ */
.table-wrap { margin: .75rem 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data td, table.data th {
  padding: .45rem .6rem; border: 1px solid var(--line); vertical-align: top; text-align: left;
}
table.data tr:first-child td, table.data th { background: var(--paper); font-weight: 600; }

/* แกลเลอรีภาพ */
.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: .6rem; margin: .75rem 0;
}
.gallery figure { margin: 0; }
.gallery a, .gallery .ph {
  display: block; aspect-ratio: 7 / 5; overflow: hidden; border-radius: 8px; background: #DCE3EC;
}
.gallery img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.gallery a:hover { box-shadow: 0 0 0 3px var(--blue); }
.gallery figcaption { margin-top: .3rem; color: var(--steel); font-size: .88rem; line-height: 1.5; }

/* ฟอร์มเมนูเลือกหน้า */
.content select {
  max-width: 100%; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text); font: inherit;
}

/* ---------- ส่วนท้าย ---------- */
.foot {
  margin-top: 3.5rem; padding: 1.5rem 0 2rem; border-top: 1px solid var(--line);
  color: var(--steel); font-size: .92rem;
}
.foot .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
}
.foot p { margin: 0; }

/* ---------- หน้าต่างดูภาพขยาย ---------- */
.lb {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 3.75rem .75rem; background: rgba(9, 20, 37, .94);
}
.lb[hidden] { display: none; }
.lb figure { margin: 0; text-align: center; }
.lb img { width: auto; max-height: 78vh; max-height: 78dvh; margin: 0 auto; border-radius: 6px; }
.lb figcaption { margin-top: .75rem; color: #C6D2E2; font-size: .95rem; }
.lb button {
  position: absolute; display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .14); color: #fff; cursor: pointer;
}
.lb button:hover { background: rgba(255, 255, 255, .26); }
.lb button svg { width: 1.4rem; height: 1.4rem; }
.lb button[hidden] { display: none; }
.lb-close { top: .75rem; right: .75rem; }
.lb-prev, .lb-next { top: 50%; margin-top: -1.375rem; }
.lb-prev { left: .5rem; }
.lb-next { right: .5rem; }
body.lb-open { overflow: hidden; }

/* ---------- จอกว้าง (แท็บเล็ตและคอมพิวเตอร์) ---------- */
@media (min-width: 720px) {
  .hero { padding-top: 2.5rem; padding-bottom: 6.75rem; }
  .plate { padding: 2rem 2.25rem 2.25rem; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .75rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* =========================================================
   หน้าคลังผลงาน (article.php, academic_services*.php)
   ========================================================= */
.hero .sub { margin: .45rem 0 0; color: #B7C5D9; }
.archive-nav { margin: 0 0 1.75rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.nav-title { margin: 0 0 .6rem; color: var(--steel); font-size: .95rem; font-weight: 600; }
.period-links { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0; padding: 0; list-style: none; }
.period-links a {
  display: inline-flex; align-items: center; min-height: 2.5rem; padding: .3rem .85rem;
  border-radius: 8px; background: var(--blue-soft); color: var(--ink);
  font-size: .92rem; font-weight: 600; text-decoration: none;
}
.period-links a:hover { background: var(--blue); color: #fff; }
.content-section, .year-section { scroll-margin-top: 1rem; }
.content-section { margin-bottom: 2.25rem; }
.year-section { margin-bottom: 1.75rem; }
.section-title {
  margin: 2rem 0 1rem; padding-bottom: .4rem; border-bottom: 2px solid var(--ink);
  font: 600 1.35rem/1.5 var(--serif); color: var(--ink);
}
.archive > main > :first-child .section-title,
.archive section:first-of-type > .section-title:first-child { margin-top: .25rem; }
.section-heading {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: .5rem 1rem; margin: 2rem 0 1rem; border-bottom: 2px solid var(--ink);
}
.section-heading .section-title { margin: 0; border: 0; }
.year-nav { margin: 0 0 1.25rem; }
.year-heading {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: .25rem 1rem; margin-bottom: .35rem;
}
.year-heading h3 { margin: 0; font: 600 1.12rem/1.5 var(--serif); color: var(--blue); }
.year-count { margin: 0; color: var(--steel); font-size: .9rem; }
.service-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.service-item, .publication-item {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem;
  padding: 1rem 0; border-bottom: 1px solid var(--line);
}
.service-copy, .publication-copy { min-width: 0; }
.service-description, .publication-citation { margin: 0; line-height: 1.8; }
.service-date { display: block; margin-top: .2rem; color: var(--steel); font-size: .9rem; }
.new-badge {
  display: inline-block; margin-bottom: .35rem; padding: 0 .5rem; border-radius: 4px;
  background: #C62D3A; color: #fff; font-size: .75rem; font-weight: 600; line-height: 1.7;
}
.review-badge { background: #ECEFF3; color: #3E4C5E; }
.document-link {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  align-self: start; justify-self: start; padding: .4rem .95rem; border-radius: 8px;
  background: var(--blue-soft); color: var(--blue); font-size: .92rem; font-weight: 600;
  line-height: 1.6; text-decoration: none; white-space: nowrap;
}
.document-link:hover { background: var(--blue); color: #fff; }
.document-unavailable { color: var(--steel); font-size: .9rem; }
.publication-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.publication-meta {
  min-width: 0; padding: .7rem .85rem; border-radius: 10px; background: var(--paper);
  font-size: .92rem;
}
.metadata-label { margin: 0 0 .2rem; color: var(--steel); font-size: .8rem; }
.metadata-source { color: var(--ink); line-height: 1.7; }
.metadata-source + .metadata-source { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.metadata-source .document-link { display: flex; margin-top: .4rem; }
.report-item .publication-meta {
  display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; background: transparent;
}
.report-item .metadata-label { margin: 0; }
.resource-grid { display: grid; gap: .9rem; }
.resource-card { min-width: 0; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 12px; }
.resource-link {
  display: inline-flex; align-items: center; margin: .2rem .15rem; padding: .2rem .65rem;
  border-radius: 8px; background: var(--blue-soft); color: var(--blue);
  font-size: .9rem; font-weight: 600; text-decoration: none; line-height: 1.6;
}
.resource-link:hover { background: var(--blue); color: #fff; }
.to-top { color: var(--blue); text-decoration: none; font-weight: 600; }
.to-top:hover { text-decoration: underline; }
@media (min-width: 720px) {
  .service-item { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1.5rem; }
  .publication-item { grid-template-columns: minmax(0, 1fr) 13rem; align-items: start; gap: 1.5rem; }
  .report-item { grid-template-columns: minmax(0, 1fr); }
  .resource-grid { grid-template-columns: 1fr 1fr; }
  .resource-card:first-child { grid-column: 1 / -1; }
}
.section-title + .service-list, .section-heading + .service-list,
.section-title + ul.service-list { border-top: 0; }
.content a strong, .content a b, .content a em { color: inherit; }

/* ---------- หน้าอัลบั้มภาพ (family/fam.php, family/fam2.php) ---------- */
.album { padding-bottom: 3rem; }
.content .photo { margin: 0; }
.content .photo img { display: block; width: 100%; max-width: 40rem; margin: 0 auto; border-radius: 8px; }
.more-link {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: .4rem 1rem; margin: 1.25rem 0 0 !important;
}
.more-link span { color: var(--steel); font-size: .9rem; }
.content .btn-more {
  display: inline-flex; align-items: center; padding: .45rem 1.1rem; border-radius: 8px;
  background: var(--ink); color: #fff; font-weight: 600; text-decoration: none;
}
.content .btn-more:hover { background: var(--blue); text-decoration: none; }

/* ---------- รายการไฟล์ และตารางไฟล์ข้อมูล (files/index.php) ---------- */
.content .note { color: var(--steel); font-size: .92rem; }
.content h3.sub { margin: 1.1rem 0 .2rem; font: 600 1rem/1.5 var(--sans); color: var(--steel); }
.files { list-style: none; margin: .5rem 0 0 !important; padding: 0 !important; }
.files li { margin: 0 !important; padding: .5rem 0; border-top: 1px solid var(--line-soft); line-height: 1.6; }
.files li:first-child { border-top: 0; }
table.datafiles th { white-space: nowrap; }
table.datafiles td a { display: inline-block; padding: .1rem 0; }
table.data tr.grp th { background: var(--blue-soft); color: var(--ink); }
table.data tr.sub td:first-child { padding-left: 1.4rem; }
@media (min-width: 720px) {
  .files.two { columns: 2; column-gap: 2.5rem; }
  .files.two li { break-inside: avoid; }
}

/* ---------- หน้าครูบาอาจารย์ (kunkru/kunkru.php) ---------- */
.poem { max-width: 38rem; margin: 0 auto; font-family: var(--serif); color: var(--ink); line-height: 1.95; }
.poem p { margin: 0 0 .35rem; }
.poem p span { display: block; }
.poem p span + span { padding-left: 1.75em; }
.poem .credit { margin-top: .6rem; text-align: right; font-family: var(--sans); color: var(--steel); font-size: .92rem; }
.content .note.center { text-align: center; margin-top: 1rem; }
/* ภาพบุคคล: แสดงเต็มภาพ ไม่ครอป เห็นหน้าและศีรษะครบ */
.gallery.people { grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); }
.gallery.people .ph { aspect-ratio: 4 / 3; background: var(--paper); }
.gallery.people img { object-fit: contain; object-position: center; }
.gallery.people figcaption { color: var(--ink); font-weight: 600; text-align: center; }
@media (min-width: 600px) {
  .poem p span { display: inline-block; width: 50%; vertical-align: top; }
  .poem p span + span { padding-left: 1rem; }
}
/* ตารางไม่ตัดคำกลางคำ (เลื่อนแนวนอนแทน) */
.plate table { overflow-wrap: normal; }
@media (max-width: 599px) {
  table.datafiles, table.datafiles tbody, table.datafiles tr,
  table.datafiles td, table.datafiles th { display: block; width: auto; }
  table.datafiles tr:first-child { display: none; }
  table.datafiles tr { padding: .55rem 0; border-top: 1px solid var(--line); }
  table.datafiles td, table.datafiles th { padding: .1rem 0; border: 0; background: none; }
  table.datafiles td:first-child { font-weight: 600; color: var(--ink); }
  table.data tr.grp th { padding: .35rem .6rem; background: var(--blue-soft); border-radius: 6px; }
  table.data tr.sub td:first-child { padding-left: 0; }
  table.datafiles td a { margin-right: 1rem; }
}
@media (min-width: 720px) {
  .gallery.people { grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: 1rem; }
}
@media (min-width: 600px) {
  .poem p { display: flex; gap: 1.5rem; }
  .poem p span, .poem p span + span { display: block; flex: 1; width: auto; padding-left: 0; }
}
.poem p.credit { display: block; }

/* ---------- สลับภาษา ไทย / English / 中文 ---------- */
html[data-lang="en"] [data-l="th"], html[data-lang="zh"] [data-l="th"],
html:not([data-lang="en"]) [data-l="en"], html:not([data-lang="zh"]) [data-l="zh"] { display: none !important; }
/* ภาษาจีน: ใช้ฟอนต์จีนของเครื่องผู้อ่านสำหรับอักษรจีน */
html[data-lang="zh"] {
  --serif: "Noto Serif Thai", "Noto Serif SC", "Noto Serif CJK SC", "Songti SC", "Microsoft YaHei", "PingFang SC", Georgia, serif;
  --sans: "IBM Plex Sans Thai Looped", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", "Sarabun", Tahoma, sans-serif;
}
html[data-lang="zh"] h2 .nw { white-space: normal; }
@media (max-width: 420px) {
  .lang button { padding: .15rem .5rem; }
  h1 .nw, h2 .nw { white-space: normal; }
}
@media (max-width: 360px) {
  .topbar { gap: .5rem; padding-left: 1rem; padding-right: 1rem; }
  .brand { font-size: .95rem; }
  .top-actions { gap: .35rem; }
  .lang button { padding: .15rem .4rem; font-size: .84rem; }
}
.top-actions { display: flex; align-items: center; gap: .5rem; }
.lang {
  display: inline-flex; flex: none; padding: 2px;
  border: 1px solid rgba(255, 255, 255, .3); border-radius: 999px;
}
.lang button {
  padding: .15rem .65rem; border: 0; border-radius: 999px; background: transparent;
  color: #fff; font: inherit; font-size: .88rem; line-height: 1.5; cursor: pointer;
}
.lang button:hover { background: rgba(255, 255, 255, .12); }
.lang button[aria-pressed="true"] { background: #fff; color: var(--ink); font-weight: 600; }
@media (max-width: 420px) {
  .top-actions > a .lbl {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .top-actions > a { padding: .35rem .6rem; }
}

