/* ==========================================================================
   Component: datpro_news
   The News index card language. Phase 01 had no news component (the Homepage
   section was removed together with the legacy CMS posts), so /tin-tuc/ owns
   this file and every later listing — search results, a category page, a
   "related articles" strip — should reuse it rather than invent a second card.

     .dp-news-filter      pill row that filters a listing by data-product
     .dp-news-card__icon  small product-coloured badge inside .dp-news-card__meta
     .dp-news-grid        3-up desktop · 2-up tablet · 1-up mobile
     .dp-news-card        thumbnail + category + date + title (+ optional excerpt)
     .dp-news-empty       spacing wrapper for the shared .dp-empty-state

   Drop 6–12 .dp-news-card items into .dp-news-grid and nothing else has to
   change: the grid is uniform, every card stretches to the row height, and the
   media box is a fixed 16:9 crop so mixed source images stay aligned.

   NAMING — the Homepage owns `.dp-product-card` (product-ecosystem.css). This
   file only ever writes `.dp-news-card…`, so the two never collide.
   ========================================================================== */

/* --------------------------------------------------------------------------
   .dp-news-filter — the pill row inside the hero that lets a visitor narrow
   the listing by product line instead of scanning a wall of look-alike
   cards. Pure client-side show/hide (see the page's own <script>); "Tất cả"
   is always item[0] and starts active.
   -------------------------------------------------------------------------- */

.dp-news-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.625rem;
  margin-top: clamp(1.25rem, 2.2vw, 1.75rem);
}

.dp-news-filter__btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1.125rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--dp-border-strong);
  background: #fff;
  color: var(--dp-text-body);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease),
    background var(--dur) var(--ease);
}

.dp-news-filter__btn:hover {
  border-color: var(--dp-blue-200);
  color: var(--dp-blue);
}

.dp-news-filter__btn.is-active {
  background: var(--dp-blue);
  border-color: var(--dp-blue);
  color: #fff;
}

/* --------------------------------------------------------------------------
   .dp-news-grid
   <div class="dp-news-grid">
     <article class="dp-news-card"> … </article>
   </div>
   -------------------------------------------------------------------------- */

.dp-news-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.5rem, 2.6vw, 2.25rem);
}

@media (min-width: 640px) {
  .dp-news-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .dp-news-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* --------------------------------------------------------------------------
   .dp-news-card
   <article class="dp-news-card">
     <div class="dp-news-card__media">
       <img …>
       <span class="dp-news-card__flag">…</span>          <!-- optional -->
     </div>
     <div class="dp-news-card__body">
       <div class="dp-news-card__meta">
         <span class="dp-news-card__category">…</span>
         <time class="dp-news-card__date" data-news-date="2026-09-11"
               datetime="2026-09-11">11/09/2026</time>
       </div>
       <h3 class="dp-news-card__title"><a href="…">…</a></h3>
       <p class="dp-news-card__excerpt">…</p>             <!-- optional -->
       <div class="dp-news-card__foot">
         <span class="dp-news-card__more">… <svg><use href="#icon-arrow-right"></use></svg></span>
       </div>
     </div>
   </article>

   The title link is stretched over the whole card, so the card is one target
   with one accessible name. Keep .dp-news-card__more a <span>: a second anchor
   underneath the overlay would be unreachable.

   `data-news-date` is picked up by assets/js/ui.js and reformatted for the
   active locale; author the element with the ISO date in `datetime` and a
   readable Vietnamese fallback as its text.
   -------------------------------------------------------------------------- */

.dp-news-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--dp-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.dp-news-card:hover {
  border-color: var(--dp-border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.dp-news-card:focus-within {
  border-color: var(--dp-blue-200);
}

/* ---------- Media --------------------------------------------------------- */

.dp-news-card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--dp-surface-2);
  border-bottom: 1px solid var(--dp-border);
  overflow: hidden;
}

.dp-news-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 480ms var(--ease);
}

.dp-news-card:hover .dp-news-card__media img {
  transform: scale(1.03);
}

/* Corner flag — "sample", "announcement", whatever the listing needs to say
   about one entry without changing the card shape. */
.dp-news-card__flag {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  max-width: calc(100% - var(--sp-6));
  padding: 0.25rem 0.625rem;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--dp-border);
  color: var(--dp-text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Body ---------------------------------------------------------- */

.dp-news-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  padding: clamp(1.125rem, 1.8vw, 1.5rem);
}

.dp-news-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.625rem;
  margin-bottom: var(--sp-3);
}

.dp-news-card__category {
  color: var(--dp-blue);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-eyebrow);
  line-height: 1.4;
  text-transform: uppercase;
}

/* ---------- Product badge — visual variety per product line --------------
   A small gradient icon chip sits before the category text and tints it to
   match; same palette (--dp-product-*, tokens.css) and gradient treatment as
   .dp-product-card__icon on the Homepage (product-ecosystem.css), so a
   listing full of different products reads as varied at a glance instead of
   every card looking identical. Add a data-product value here as each new
   product line gets its own articles. */

.dp-news-card__icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  color: #fff;
}

.dp-news-card__icon svg {
  width: 13px;
  height: 13px;
}

.dp-news-card__icon[data-product="enterprise"] {
  background: linear-gradient(155deg, #3d92e8 8%, var(--dp-product-enterprise) 92%);
}
.dp-news-card__icon[data-product="care"] {
  background: linear-gradient(155deg, #17b268 8%, var(--dp-product-care) 92%);
}
.dp-news-card__icon[data-product="language"] {
  background: linear-gradient(155deg, #fba733 8%, var(--dp-product-language) 92%);
}
.dp-news-card__icon[data-product="car"] {
  background: linear-gradient(155deg, #ec4b3b 8%, var(--dp-product-car) 92%);
}
.dp-news-card__icon[data-product="kids"] {
  background: linear-gradient(155deg, #b28ae6 8%, var(--dp-product-kids) 92%);
}
.dp-news-card__icon[data-product="life"] {
  background: linear-gradient(155deg, #e8c97a 8%, var(--dp-product-life) 92%);
}

.dp-news-card__icon[data-product="enterprise"] + .dp-news-card__category { color: var(--dp-product-enterprise); }
.dp-news-card__icon[data-product="care"] + .dp-news-card__category { color: var(--dp-product-care); }
.dp-news-card__icon[data-product="language"] + .dp-news-card__category { color: var(--dp-product-language); }
.dp-news-card__icon[data-product="car"] + .dp-news-card__category { color: var(--dp-product-car); }
.dp-news-card__icon[data-product="kids"] + .dp-news-card__category { color: var(--dp-product-kids); }
.dp-news-card__icon[data-product="life"] + .dp-news-card__category { color: var(--dp-product-life); }

.dp-news-card__sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--dp-border-strong);
}

.dp-news-card__date {
  color: var(--dp-text-subtle);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.dp-news-card__title {
  font-size: var(--fs-h4);
  line-height: 1.42;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
}

.dp-news-card__title a {
  color: var(--dp-text);
  transition: color var(--dur) var(--ease);
}

/* Stretched link — the whole card is the target. */
.dp-news-card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--r-lg);
}

.dp-news-card:hover .dp-news-card__title a {
  color: var(--dp-blue);
}

.dp-news-card__excerpt {
  margin-top: var(--sp-2);
  color: var(--dp-text-muted);
  font-size: var(--fs-sm);
  line-height: 1.65;
  overflow-wrap: break-word;
  text-wrap: pretty;
}

.dp-news-card__foot {
  margin-top: auto;
  padding-top: clamp(1rem, 1.8vw, 1.25rem);
}

/* Visual echo of .dp-link-arrow — deliberately not an anchor, see above. */
.dp-news-card__more {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  color: var(--dp-blue);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: 1.4;
}

.dp-news-card__more svg {
  flex: none;
  width: 1em;
  height: 1em;
  transition: transform var(--dur) var(--ease);
}

.dp-news-card:hover .dp-news-card__more svg {
  transform: translateX(3px);
}

/* --------------------------------------------------------------------------
   .dp-news-empty — the honest "nothing else yet" cell.

   It is a grid ITEM, not a block underneath the grid: with a single real card
   the row would otherwise be two-thirds empty white space, which reads as a
   broken listing rather than a young one. Here it fills the remaining columns
   and matches the card height, so the row looks deliberate.

   ▸ DELETE the whole .dp-news-empty element from the markup once the grid
     holds real articles. Nothing else needs changing.
   -------------------------------------------------------------------------- */

.dp-news-empty {
  min-width: 0;
  grid-column: 1 / -1;
}

@media (min-width: 640px) {
  .dp-news-empty {
    /* 2-up: sits beside the card */
    grid-column: span 1;
  }
}

@media (min-width: 1024px) {
  .dp-news-empty {
    /* 3-up: fills the two remaining columns */
    grid-column: span 2;
  }
}

.dp-news-empty .dp-empty-state {
  height: 100%;
  align-content: center;
}
