.aligncenter {
  display: block;
  margin-left: auto;
  margin-right: auto;
}
.alignright {
  display: block;
  margin-left: auto;
}
.alignleft {
  display: block;
  margin-right: auto;
}

/* ===== News List Base ===== */
.news-list {
  width: 100%;
  box-sizing: border-box;
}

.news-item {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.news-item:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  text-decoration: none;
  color: inherit;
}

.news-item__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.news-item__title {
  color: #000000;
  font-weight: bold;
  margin: 0 0 6px;
  font-size: 1rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-clamp: 3;
  overflow: hidden;
}

.news-item__excerpt {
  margin: 0 0 6px;
  font-size: 0.9rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-date {
  font-size: 0.8rem;
  display: block;
}

.news-no-results {
  padding: 20px 0;
  text-align: center;
  font-style: italic;
}

/* ===== Horizontal Layout ===== */
/* รูปกับเนื้อหาวางเรียงข้างกัน — ทั้งสอง layout ใช้ HTML ชุดเดียวกัน ต่างกันแค่ CSS นี้ */
.news-list--horizontal {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.news-item--horizontal {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 20px;
  background-color: var(--wp--preset--color--base, #fff);
  border-radius: 12px;
}

.news-item--horizontal .news-item__thumb {
  position: relative;
  flex: 0 0 35%;
  max-height: 300px;
  border-radius: 8px;
  overflow: hidden;
}

.news-item--horizontal .news-item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding-bottom: 10px;
}

.news-item--horizontal .news-item__title {
  color: var(--wp--preset--color--accent-4, #000);
}

.news-item--horizontal .news-item__excerpt,
.news-item--horizontal .news-date {
  color: var(--wp--preset--color--accent-5, #4a5568);
}

@media (max-width: 600px) {
  .news-item--horizontal {
    flex-direction: column;
  }
  .news-item--horizontal .news-item__thumb {
    flex: none;
    width: 100%;
    height: 200px;
  }
}

/* ===== Vertical Grid Layout ===== */
/* การ์ดเรียงเป็นกริด เนื้อหาทับบนรูปด้วยกราเดียนต์ */
.news-list--vertical {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.news-item--vertical {
  position: relative; /* offset parent ของ __body ที่เป็น absolute */
  display: flex;
  flex-direction: column;
  background-color: var(--wp--preset--color--base, #fff);
  border-radius: 12px;
  overflow: hidden;
}

.news-item--vertical .news-item__thumb {
  position: relative;
  width: 100%;
  height: 220px;
  border-radius: 0;
  overflow: hidden;
  flex-shrink: 0;
}

.news-item--vertical .news-item__body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px 14px 14px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, transparent 100%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.news-item--vertical .news-item__title {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.news-item--vertical .news-item__excerpt {
  color: rgba(255, 255, 255, 0.9);
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.news-item--vertical .news-date {
  font-size: 0.85rem;
  color: #ffffff;
}

/* first_horizontal="true" — การ์ด horizontal ที่แทรกอยู่ในกริด vertical กินเต็มแถว */
.news-list--vertical .news-item--horizontal {
  grid-column: 1 / -1;
}

.news-item__arrow-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  background: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.news-item:hover .news-item__arrow-btn {
  background: var(--wp--preset--color--contrast-3, #e0e0e0);
}

@media (max-width: 900px) {
  .news-list--vertical {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .news-list--vertical {
    grid-template-columns: 1fr;
  }
}

/* ===== Document Card ===== */
/* การ์ดของข่าวประเภท document — เป็นแถวเสมอ ไม่ว่า list จะเป็น layout ไหน */
.news-doc {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background-color: var(--wp--preset--color--base, #fff);
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

.news-doc:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  border-color: #d1d5db;
  text-decoration: none;
  color: inherit;
}

/* ในกริด vertical ให้กินเต็มแถว — เอกสารอ่านง่ายกว่าเมื่อเรียงเป็นลิสต์ */
.news-list--vertical .news-doc {
  grid-column: 1 / -1;
}

.news-doc__icon {
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #f1f5f9;
  color: #64748b;
}

.news-doc__ext {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 5px;
  border-radius: 3px;
  background: #1e40af;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.5;
  white-space: nowrap;
}

.news-doc__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.news-doc__title {
  margin: 0;
  font-size: 1rem;
  font-weight: bold;
  line-height: 1.4;
  color: var(--wp--preset--color--contrast, #111);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
}

.news-doc__excerpt {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--wp--preset--color--accent-5, #4a5568);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
}

.news-doc__action {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.news-doc__meta {
  font-size: 0.8rem;
  color: #6b7280;
  white-space: nowrap;
}

.news-doc__btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--wp--preset--color--base-2, #f0f0f0);
  color: #111;
  transition: background 0.15s ease;
}

.news-doc:hover .news-doc__btn {
  background: var(--wp--preset--color--contrast-3, #e0e0e0);
}

@media (max-width: 600px) {
  .news-doc {
    flex-wrap: wrap;
  }

  .news-doc__action {
    width: 100%;
    justify-content: space-between;
  }
}

/* ===== Attached Files (detail page) ===== */
.news-doc-files {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
}

.news-doc-files__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 4px;
  font-size: 1rem;
}

/* ยอดดาวน์โหลดเป็นของ "ข่าว" ไม่ใช่ของไฟล์แต่ละตัว จึงอยู่ที่หัวข้อรวมครั้งเดียว */
.news-doc-files__count {
  font-size: 0.8rem;
  font-weight: 400;
  color: #6b7280;
  white-space: nowrap;
}

.news-doc-files__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
}

.news-doc-files__item:hover {
  background: var(--wp--preset--color--base-2, #f8f8f8);
  text-decoration: none;
  color: inherit;
}

.news-doc-files__ext {
  flex: 0 0 auto;
  min-width: 46px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #1e40af;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.7;
}

.news-doc-files__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.news-doc-files__size {
  flex: 0 0 auto;
  font-size: 0.8rem;
  color: #6b7280;
}

/* ===== Pagination ===== */
.news-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 32px;
}

.news-pagination__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  background-color: var(--wp--preset--color--base-2, #f0f0f0);
  color: inherit;
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid transparent;
  transition: background-color 0.15s ease;
}

.news-pagination__btn:hover {
  background-color: var(--wp--preset--color--contrast-3, #e0e0e0);
  text-decoration: none;
  color: inherit;
}

.news-pagination__btn--active {
  background-color: var(--wp--preset--color--contrast, #111);
  color: var(--wp--preset--color--base, #fff);
  font-weight: 600;
  pointer-events: none;
}

/* ===== News Tag Badges ===== */
.news-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.news-tag-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.8;
  background-color: #f1f5f9;
  color: #4a5568;
}

.news-tag-badge--cat {
  background-color: #fef9e7;
  color: #92400e;
}

.news-tag-badge--tag {
  background-color: #dbeafe;
  color: #1e40af;
}

/* Override badge colors inside vertical overlay (dark gradient background) */
.news-item--vertical .news-item__body .news-tag-badge {
  background-color: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.9);
}

.news-item--vertical .news-item__body .news-tag-badge--cat {
  background-color: rgba(254, 249, 231, 0.2);
  color: #fde68a;
}

.news-item--vertical .news-item__body .news-tag-badge--tag {
  background-color: rgba(219, 234, 254, 0.2);
  color: #93c5fd;
}

/* ===== Category Tabs ===== */
/* ทุกแท็บถูก render มาพร้อมกัน — public.js สลับ [hidden] เอา ไม่มีการเรียก API ตอนคลิก */
.news-tabs {
  display: flex;
  gap: 4px;
  /* กว้างพอดีเนื้อหา จัดกลาง — แท็บน้อยหุ้มพอดี, แท็บเยอะโตได้จนเต็มความกว้าง (เท่า .news-tabs__panels) */
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 24px;
  /* เผื่อกรณีสุดโต่งที่แท็บรวมกันเกินเต็มจอ ให้เลื่อนแทนที่จะล้น */
  overflow-x: auto;
  padding: 6px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  box-shadow: 0 6px 18px rgba(17, 24, 39, 0.08);
}

.news-tabs__tab {
  appearance: none;
  flex: 1 1 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.news-tabs__label {
  display: inline-block;
  /* ย่อลงครึ่งหนึ่งให้ปุ่มเล็กตามแถบ .news-tabs ที่กว้าง 50% */
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  color: #1976d2;
  white-space: nowrap;
  border-radius: 9999px;
  transition:
    color 0.15s ease,
    background-color 0.15s ease,
    box-shadow 0.15s ease;
}
.news-tabs__label:hover {
  color: #003087;
}

.news-tabs__tab:not(.news-tabs__tab--active):hover .news-tabs__label {
  color: #4b5563;
  background-color: #f3f4f6;
}

.news-tabs__tab--active .news-tabs__label {
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, #003087 0%, #2196f3 100%);
  box-shadow: 0 8px 18px rgba(7, 145, 218, 0.32);
  /* background: linear-gradient(180deg, #2563eb 0%, #1e40af 100%); */
  /* box-shadow: 0 4px 12px rgba(30, 64, 175, 0.35); */
}

.news-tabs__panel[hidden] {
  display: none;
}

@media (max-width: 600px) {
  .news-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 26px;
  }

  .news-tabs__tab {
    flex: 0 0 auto;
  }
}

/* ===== Search Form ===== */
.news-search-wrapper {
  width: 100%;
}

.news-search-form {
  /* padding: 16px 20px; */
  /* background-color: var(--wp--preset--color--base-2, #f8f8f8); */
  border-radius: 12px;
  margin-bottom: 28px;
}

.news-search-form__bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.news-search-form__input {
  flex: 1;
  width: auto;
  padding: 10px 14px;
  font-size: 15px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  outline: none;
  box-sizing: border-box;
  background: #fff;
  color: inherit;
}

.news-search-form__input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Advanced filters accordion */
.news-search-advanced {
  margin-top: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.news-search-advanced__toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.news-search-advanced__toggle::-webkit-details-marker {
  display: none;
}

.news-search-advanced__toggle:hover {
  background: #f9fafb;
}

.news-search-advanced[open] .news-search-advanced__chevron {
  transform: rotate(180deg);
}

.news-search-advanced__chevron {
  margin-left: auto;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.news-search-advanced__fields {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid #e5e7eb;
}

.news-search-advanced__row {
  display: flex;
  gap: 12px;
}

.news-search-advanced__group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.news-search-advanced__group--tags {
  flex: 2;
}

.news-search-advanced__label {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
}

.news-search-advanced__label--cat::after,
.news-search-advanced__label--tag::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-left: 5px;
  vertical-align: middle;
}

.news-search-advanced__label--cat::after {
  background: #fef9e7;
  border: 1.5px solid #92400e;
}

.news-search-advanced__label--tag::after {
  background: #dbeafe;
  border: 1.5px solid #1e40af;
}

.news-search-advanced__input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  outline: none;
  box-sizing: border-box;
  color: #111827;
  background: #fff;
}

.news-search-advanced__input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.news-search-advanced__actions {
  display: flex;
  justify-content: flex-end;
}

.news-search-advanced__reset {
  font-size: 13px;
  color: #6b7280;
  text-decoration: underline;
}

.news-search-advanced__reset:hover {
  color: var(--wp--preset--color--contrast, #111);
}

input[type="date"].news-search-advanced__input {
  cursor: pointer;
  /* iOS Safari ยุบความสูง input[type=date] ถ้าไม่บังคับไว้ */
  min-height: 38px;
}

select.news-search-advanced__input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

@media (max-width: 600px) {
  .news-search-form__bar {
    flex-wrap: wrap;
  }

  .news-search-form__bar .news-search-form__input {
    flex-basis: 100%;
  }

  .news-search-form__submit {
    width: 100%;
  }

  .news-search-advanced__row {
    flex-wrap: wrap;
  }

  .news-search-advanced__group,
  .news-search-advanced__group--tags {
    flex-basis: 100%;
  }
}

/* ===== News Detail Page ===== */
.news-detail {
  width: 100%;
  box-sizing: border-box;
}

.news-detail__cats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.news-detail__cats-label {
  font-weight: 600;
  color: #374151;
  margin-right: 4px;
}

.news-detail__cat-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
  border: 1.5px solid #2196f3;
  color: #1976d2;
  background: #fff;
}

.news-detail__cat-badge--active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #003087 0%, #2196f3 100%);
  box-shadow: 0 6px 14px rgba(7, 145, 218, 0.28);
}

.news-detail__title {
  margin: 0 0 14px;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.45;
  color: var(--wp--preset--color--contrast, #111);
}

.news-detail__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
  color: #6b7280;
  font-size: 0.9rem;
}

.news-detail__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---- Share buttons ---- */
.news-detail__share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.news-detail__share-label {
  color: #6b7280;
  font-size: 0.9rem;
}

/* ไอคอนล้วน — วงกลมขนาดเท่ากันทุกปุ่ม (ยังกดง่ายบนมือถือ: 36px ใกล้เคียงเป้าหมายขั้นต่ำ) */
.news-detail__share-btn {
  position: relative; /* ยึด .news-detail__share-text ที่ absolute ไว้ในปุ่ม ไม่ให้ไปดันเลย์เอาต์ที่อื่น */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #fff;
  color: #374151;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 0.15s,
    color 0.15s,
    border-color 0.15s;
}

.news-detail__share-btn svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

/* ข้อความของปุ่มยังอยู่ใน DOM ให้สกรีนรีดเดอร์อ่านและให้ public.js สลับเป็น "คัดลอกแล้ว" ได้ —
   ซ่อนแบบ visually-hidden ไม่ใช่ display:none ที่จะทำให้หายไปจาก accessibility tree ด้วย */
.news-detail__share-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.news-detail__share-btn:hover,
.news-detail__share-btn:focus-visible {
  color: #fff;
}

.news-detail__share-btn--facebook:hover,
.news-detail__share-btn--facebook:focus-visible {
  background: #1877f2;
  border-color: #1877f2;
}

.news-detail__share-btn--line:hover,
.news-detail__share-btn--line:focus-visible {
  background: #06c755;
  border-color: #06c755;
}

.news-detail__share-btn--copy:hover,
.news-detail__share-btn--copy:focus-visible {
  background: #374151;
  border-color: #374151;
}

.news-detail__share-btn--print:hover,
.news-detail__share-btn--print:focus-visible {
  background: #0f766e;
  border-color: #0f766e;
}

/* ปุ่มคัดลอกสลับข้อความเป็น "คัดลอกแล้ว" ชั่วครู่ (public.js) — คงสีเขียวไว้ตลอดช่วงนั้น */
.news-detail__share-btn--copied,
.news-detail__share-btn--copied:hover {
  background: #06c755;
  border-color: #06c755;
  color: #fff;
}

.news-detail__box {
  /* background-color: var(--wp--preset--color--base, #fff);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(17, 24, 39, 0.08);
  padding: 28px 32px; */
  margin-bottom: 40px;
}

.news-detail__box > *:first-child {
  margin-top: 0;
}

.news-detail__box > *:last-child {
  margin-bottom: 0;
}

.news-detail__section {
  margin-bottom: 40px;
}

.news-detail__section-title {
  margin: 0 0 18px;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--wp--preset--color--contrast, #111);
}

/* ---- Gallery ---- */
.news-gallery__viewport {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.news-gallery__viewport::-webkit-scrollbar {
  display: none;
}

.news-gallery__track {
  display: flex;
}

.news-gallery__item {
  flex: 0 0 25%;
  box-sizing: border-box;
  padding: 0 8px;
  scroll-snap-align: start;
}

/* ตัวภาพเป็น <button> เพื่อให้กดดูขนาดใหญ่ได้ทั้งเมาส์และคีย์บอร์ด — ต้องล้างสไตล์ปุ่มของเบราว์เซอร์ทิ้ง */
.news-gallery__zoom {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  border-radius: 12px;
}

.news-gallery__zoom:focus-visible {
  outline: 3px solid #2196f3;
  outline-offset: 3px;
}

.news-gallery__item img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 12px;
}

/* แว่นขยายมุมขวาล่าง — ตัวบอกว่ารูปกดได้ ไม่งั้นไม่มีอะไรต่างจากรูปประกอบเฉย ๆ */
.news-gallery__zoom-icon {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.55);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.news-gallery__zoom:hover .news-gallery__zoom-icon,
.news-gallery__zoom:focus-visible .news-gallery__zoom-icon {
  opacity: 1;
}

/* จอสัมผัสไม่มี hover — ถ้าซ่อนไว้จะไม่มีทางรู้เลยว่ากดได้ */
@media (hover: none) {
  .news-gallery__zoom-icon {
    opacity: 1;
  }
}

/* ---- Lightbox (กดรูปเพื่อดูขนาดใหญ่) ---- */
.news-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 64px;
  background: rgba(0, 0, 0, 0.88);
  cursor: zoom-out;
}

/* กันหน้าเลื่อนอยู่ข้างหลัง overlay ตอนเปิดอยู่ */
body.news-lightbox-open {
  overflow: hidden;
}

.news-lightbox__figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 0;
  max-width: 100%;
  max-height: 100%;
}

.news-lightbox__img {
  max-width: 100%;
  /* 100% ของ figure ลบที่ของ counter ออก ไม่งั้นรูปสูง ๆ จะดันตัวเลขตกจอ */
  max-height: calc(100vh - 130px);
  object-fit: contain;
  border-radius: 10px;
  cursor: default;
}

.news-lightbox__counter {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.75);
}

.news-lightbox__close,
.news-lightbox__nav {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease;
}

.news-lightbox__close:hover,
.news-lightbox__nav:hover,
.news-lightbox__close:focus-visible,
.news-lightbox__nav:focus-visible {
  background: rgba(255, 255, 255, 0.3);
}

.news-lightbox__close {
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
}

.news-lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  font-size: 2rem;
  padding-bottom: 5px; /* glyph ‹ › นั่งสูงกว่ากลางกล่องอยู่แล้ว */
}

.news-lightbox__nav--prev {
  left: 12px;
}

.news-lightbox__nav--next {
  right: 12px;
}

@media (max-width: 600px) {
  .news-lightbox {
    padding: 56px 12px;
  }

  .news-lightbox__nav {
    width: 40px;
    height: 40px;
    font-size: 1.6rem;
  }
}

.news-gallery__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 18px;
}

.news-gallery__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid #d1d5db;
  background: #fff;
  color: #374151;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}

.news-gallery__nav:hover {
  border-color: #2196f3;
  color: #1976d2;
}

.news-gallery__dots {
  display: flex;
  align-items: center;
  gap: 8px;
}

.news-gallery__dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #d1d5db;
  cursor: pointer;
}

.news-gallery__dot--active {
  width: 11px;
  height: 11px;
  background: #2196f3;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.18);
}

@media (max-width: 900px) {
  .news-gallery__item {
    flex-basis: 50%;
  }
}

@media (max-width: 600px) {
  .news-gallery__item {
    flex-basis: 100%;
  }

  .news-detail__box {
    padding: 20px;
  }
}

/* ---- Related news ---- */
.news-related-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.news-related-card {
  display: block;
  text-decoration: none;
  color: inherit;
}

.news-related-card:hover {
  text-decoration: none;
  color: inherit;
}

.news-related-card__thumb {
  position: relative;
  height: 150px;
  border-radius: 12px;
  overflow: hidden;
}

.news-related-card__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.news-related-card__icon {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  color: #111;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.news-related-card__title {
  margin: 10px 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--wp--preset--color--contrast, #111);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
}

.news-related-card .news-date {
  color: #6b7280;
}

@media (max-width: 900px) {
  .news-related-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .news-related-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Tags ---- */
.news-detail__tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 32px;
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
}

.news-detail__tags-label {
  font-weight: 700;
  color: #374151;
  margin-right: 4px;
}

/* ---- Back button ---- */
.news-detail__back-wrap {
  display: flex;
  justify-content: center;
}

.news-detail__back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 30px;
  border-radius: 999px;
  background: linear-gradient(135deg, #003087 0%, #2196f3 100%);
  color: #fff !important;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(7, 145, 218, 0.28);
  transition: filter 0.15s ease;
  font-size: 16px;
}

.news-detail__back:hover {
  color: #fff;
  text-decoration: none;
  filter: brightness(1.08);
}

/* ---- Print (WD-322) ----
   ปุ่ม "พิมพ์" ในแถบแชร์เรียก window.print() เฉย ๆ ตัวที่ทำให้กระดาษออกมาอ่านได้คือบล็อกนี้

   หน้ารายละเอียดถูกวางอยู่ในเพจของธีม จึงมีเฮดเดอร์ เมนู แบนเนอร์ ฟุตเตอร์ และวิดเจ็ตพ่วงมาด้วย
   ทั้งหมด — สั่งพิมพ์ตรง ๆ จะได้กระดาษ 3-4 แผ่นที่มีเนื้อข่าวจริงอยู่แผ่นเดียว ตรงนี้จึงเก็บเฉพาะ
   ส่วนที่เป็นตัวข่าวไว้ แล้วซ่อนของรอบ ๆ ทิ้ง */
@media print {
  /* เลือกด้วยแท็กของธีมแบบกว้าง ๆ เพราะแต่ละเว็บใน 22 เว็บใช้ธีม/คลาสไม่เหมือนกัน —
     ระบุคลาสเจาะจงจะพลาดเว็บที่ตั้งค่าต่างออกไป */
  body:has(.news-detail) header,
  body:has(.news-detail) footer,
  body:has(.news-detail) nav,
  body:has(.news-detail) aside,
  body:has(.news-detail) .wp-block-navigation,
  body:has(.news-detail) .wp-block-template-part,
  #wpadminbar,
  .dwr-breadcrumbs,
  .news-search-wrapper,
  /* วิดเจ็ตช่วยการเข้าถึง (ปุ่ม ก+ / ก-) ของ dwr-accessibility — ลอยอยู่ท้าย body
     จึงไม่โดน selector ของธีมข้างบน และติดไปเป็นกล่องดำ ๆ ริมกระดาษ */
  #dwr-a11y-root {
    display: none !important;
  }

  /* ในตัวข่าวเอง: ปุ่มกดไม่ได้บนกระดาษ และ "ข่าวที่เกี่ยวข้อง" เป็นลิงก์ไปหน้าอื่นล้วน ๆ */
  .news-detail__share,
  .news-detail__back-wrap,
  .news-gallery__controls,
  .news-gallery__zoom-icon,
  .news-lightbox {
    display: none !important;
  }

  .news-detail {
    max-width: none;
    margin: 0;
    padding: 0;
    color: #000;
  }

  .news-detail__box {
    padding: 0;
    border: none;
    box-shadow: none;
  }

  .news-detail__title {
    font-size: 20pt;
  }

  /* แกลเลอรีเป็นแถวเลื่อนแนวนอน — บนกระดาษไม่มีอะไรให้เลื่อน คลี่เป็นกริดแทน
     ไม่งั้นจะพิมพ์ออกมาได้แค่ชุดแรกที่มองเห็นอยู่ */
  .news-gallery__viewport {
    overflow: visible;
  }

  .news-gallery__track {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .news-gallery__item {
    flex-basis: auto;
    padding: 0;
  }

  .news-gallery__item img {
    height: auto;
  }

  /* ลิงก์ไฟล์แนบยังมีความหมายบนกระดาษ ถ้ารู้ว่าปลายทางคืออะไร */
  .news-doc-files__item::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #555;
    word-break: break-all;
  }

  /* อย่าให้หัวข้อค้างอยู่ท้ายหน้าโดยที่เนื้อหาไปอยู่หน้าถัดไป */
  .news-detail__title,
  .news-detail__section-title,
  .news-doc-files__title {
    break-after: avoid;
  }

  .news-gallery__item,
  .news-doc-files__item {
    break-inside: avoid;
  }
}
