:root {
  --news-line: #00000014;
  --news-chip-border: #E5E5E5;
  --news-grey: #6F6F6F;
}

/* ===== News archive (archive-news.php) ===== */
.page-news .news-breadcrumb,
.page-news .news-breadcrumb a {
  color: var(--grey);
}
.page-news .news-breadcrumb a:hover {
  color: var(--primary);
}
#pageNews .pt-sec-news {
  padding-top: 2.5rem;
}
#pageNews .news-subtitle {
  max-width: 800px;
}
.page-news .news-tag {
  display: inline-block;
  padding: .25rem .5rem;
  border-radius: .25rem;
  color: var(--white);
  font-size: .875rem;
  white-space: nowrap;
}
.page-news .news-date {
  color: var(--black-variant);
  white-space: nowrap;
}

/* ----- Highlight slide ----- */

#secNewsHighlight .newsSwiper {
  border-radius: 12px;
  background-color: var(--white);
  box-shadow: 0 4px 16px #00000014;
}
.news-clover {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  width: 48px;
  height: 48px;
  pointer-events: none;
}
.news-slide {
  display: flex;
  flex-direction: column;
  height: auto;
  color: var(--black);
  background-image: url(../images/bg-press.webp);
  background-repeat: repeat;
  &:hover {
    color: var(--black);
  }
}
.news-slide-img {
  padding: .75rem .75rem 0;
}
.news-slide-img img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: .5rem;
}
.news-slide-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem 1rem 2.5rem;
}
.news-slide-title {
  transition: color var(--trans-2);
}
.news-slide:hover .news-slide-title {
  color: var(--primary);
}
#secNewsHighlight .swiper-pagination {
  bottom: 1rem;
}
#secNewsHighlight .swiper-pagination-bullet {
  width: 24px;
  height: 4px;
  margin: 0 2px;
  border-radius: 2px;
  background-color: var(--news-grey);
  opacity: .5;
  transition: background-color var(--trans-2);
}
#secNewsHighlight .swiper-pagination-bullet-active {
  background-color: var(--primary);
  opacity: 1;
  
}

/* ----- Search + Category ----- */
.news-filter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}
.news-search {
  position: relative;
  width: 100%;
}
.news-search input {
  height: 48px;
  padding-right: 3rem;
  border-color: var(--news-chip-border) !important;
  border-radius: 8px;
  font-size: .875rem;
  &:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 .2rem var(--btn-white-hov);
  }
  &::-webkit-search-cancel-button {
    display: none;
  }
}
.news-search button {
  position: absolute;
  top: 50%;
  right: .5rem;
  transform: translateY(-50%);
  display: flex;
  padding: .25rem;
  border: none;
  background: none;
  color: var(--black-variant);
}
/* mobile : chip เลื่อนแนวนอนได้ */
.news-cats {
  display: flex;
  gap: .5rem;
  width: calc(100% + 1rem);
  margin-right: -1rem;
  padding: 2px 1rem 2px 2px;
  overflow-x: auto;
  scrollbar-width: none;
  &::-webkit-scrollbar {
    display: none;
  }
}
.news-cat-btn {
  flex-shrink: 0;
  padding: .5rem .75rem;
  border: 1px solid var(--news-chip-border);
  border-radius: .5rem;
  font-weight: 500;;
  background-color: var(--white);
  color: var(--black-variant);
  white-space: nowrap;
  transition: border-color var(--trans-2), background-color var(--trans-2);
  &:hover {
    background-color: var(--btn-white-hov);
  }
  &.active {
    border-color: var(--pink);
    color: var(--black);
  }
}

/* ----- List ----- */
.news-grid {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 1rem;
  transition: opacity var(--trans-2);
  &.is-loading {
    opacity: .4;
    pointer-events: none;
  }
}
.news-card {
  padding: 1rem 0;
  border-bottom: 1px solid var(--news-line);
}
.news-card-link {
  display: flex;
  gap: 1rem;
  color: var(--black);
  &:hover {
    color: var(--black);
  }
}
.news-card-img {
  flex-shrink: 0;
  width: 80px;
}
.news-card-img img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: .5rem;
  transition: opacity var(--trans-2);
}
.news-card-title {
  font-size: 1rem;
  line-height: 1.5rem;
  transition: color var(--trans-2);
}
.news-card-link:hover .news-card-title {
  color: var(--primary);
}
.news-card-link:hover .news-card-img img {
  opacity: .85;
}
.news-loader {
  display: flex;
  justify-content: center;
  padding: 2.5rem 0;
  color: var(--grey);
}
.news-loader svg {
  animation: news-spin 1s steps(8) infinite;
}
@keyframes news-spin {
  to {
    transform: rotate(360deg);
  }
}


@media (min-width: 768px) {
  .news-clover {
    top: -24px;
    left: -22px;
    width: 120px;
    height: 120px;
  }
  .news-slide-img {
    padding: .75rem .75rem 0;
  }
  .news-slide-body {
    padding: 1.5rem 3rem 3rem;
  }
  .news-search {
    max-width: 560px;
  }
  .news-cats {
    flex-wrap: wrap;
    justify-content: center;
    width: auto;
    margin-right: 0;
    padding: 2px;
    overflow: visible;
  }
  .news-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .news-card {
    padding: 1.5rem;
  }
  .news-card:nth-child(2n + 1) {
    border-right: 1px solid var(--news-line);
  }
  .news-card-link {
    flex-direction: column;
    gap: 1.25rem;
  }
  .news-card-img {
    width: 100%;
  }
  .news-card-img img {
    aspect-ratio: 16 / 9;
  }
  .news-card-title {
    font-size: 1.125rem;
  }
}

@media (min-width: 992px) {
  .news-slide {
    flex-direction: row;
  }
  .news-slide-img {
    width: 50%;
    padding: .75rem 0 .75rem .75rem;
  }
  .news-slide-img img {
    height: 100%;
    aspect-ratio: 412 / 280;
  }
  .news-slide-body {
    width: 50%;
    padding: 2rem 2rem 3rem;
  }
  /* bullets อยู่ใต้ข้อความฝั่งขวา */
  #secNewsHighlight .swiper-pagination {
    left: 50%;
    width: 50%;
  }
  .news-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .news-card:nth-child(2n + 1) {
    border-right: none;
  }
  .news-card:not(:nth-child(3n)) {
    border-right: 1px solid var(--news-line);
  }
}

@media (min-width: 1200px) {
  .news-filter {
    flex-direction: row;
    justify-content: space-between;
  }
  .news-cats {
    justify-content: flex-end;
  }
}

/* ===== News detail (single-news.php / template-parts/content-news.php) ===== */
.news-breadcrumb-current {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 220px;
}
.news-detail-head {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "title title"
    "share meta";
  align-items: center;
  gap: 1rem;
}
.news-detail-title {
  grid-area: title;
  font-size: 1.75rem;
  line-height: 1.25;
}
.news-share {
  grid-area: share;
}
.news-detail-meta {
  grid-area: meta;
  justify-self: end;
}
.news-share-btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .375rem 1rem;
  border: 1px solid var(--news-chip-border);
  border-radius: 999px;
  background-color: transparent;
  color: var(--black);
  font-size: .875rem;
  transition: background-color var(--trans-2);
  &:hover, &[aria-expanded="true"] {
    background-color: var(--btn-white-hov);
  }
}
.news-share-menu {
  min-width: 176px;
  padding: 0;
  overflow: hidden;
  border: none;
  border-radius: 8px;
  box-shadow: 0 4px 16px #00000024;
}
.news-share-menu li:not(:last-child) {
  border-bottom: 1px solid var(--news-line);
}
.news-share-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .875rem 1.25rem;
  color: var(--black);
  & svg {
    flex-shrink: 0;
    color: var(--primary);
  }
  &:hover, &:focus {
    background-color: var(--lighpink);
  }
}
.news-detail-content {
  padding-top: 1.5rem;
  color: var(--black-variant);
  font-size: .875rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}
.news-detail-content .news-detail-cover {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 1.5rem;
  border-radius: .5rem;
}
.news-detail-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}
.news-detail-content p {
  margin-bottom: 1.25rem;
}
.news-detail-content :is(h2, h3, h4, h5, h6) {
  margin: 1.5rem 0 1rem;
  color: var(--black-variant);
  font-size: 1.25rem;
  font-weight: 500;
}
.news-detail-content a:not(.btn-primary-cust) {
  color: var(--primary);
  text-decoration: underline;
}
.news-detail-content .gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}
.news-file {
  padding: 1.25rem;
  border-radius: 8px;
  background-color: var(--white);
  color: var(--black);
}
.recent-item {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  color: var(--black);
  &:not(:last-child) {
    border-bottom: 1px solid var(--news-line);
  }
}
.recent-item-img {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
}
.recent-item-title {
  font-size:1.125rem;
  color: var(--black-variant);
  line-height: 1.5;
  transition: color var(--trans-2);
}
.recent-item:hover .recent-item-title,
.recent-card:hover .recent-item-title {
  color: var(--primary);
}
.recent-mascot {
  width: 182px;
  height: auto;
}
.recent-slider {
  padding-top: 2.5rem;
}
.recent-card {
  display: block;
  height: auto;
  padding: 0 1rem;
  color: var(--black);
  &:not(:last-child) {
    border-right: 1px solid var(--news-line);
  }
}
.recent-card-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
}

@media (min-width: 576px) {
  .news-detail-head {
    grid-template-areas:
      "title share"
      "meta meta";
    align-items: start;
  }
  .news-detail-meta {
    justify-self: start;
  }
  .news-breadcrumb-current {
    max-width: 320px;
  }
}

@media (min-width: 768px) {
  .news-detail-content {
    font-size: 1rem;
  }
}

@media (min-width: 1200px) {
  .news-detail-title {
    font-size: 2rem;
  }
  /* sidebar ติดใต้ header (header เป็น sticky-xl-top สูงเท่า --height-menu-tablet) */
  .recent-aside {
    position: sticky;
    top: calc(var(--height-menu-tablet) + 1.5rem);
    z-index: 1;
  }
}
