/*
 * Media listing and story pages. Builds on pages.css (.pg tokens). Scoped under .md.
 */

/* ---------- Toolbar: category tabs + search ---------- */
.md-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 30px; }
.md-tabs { display: inline-flex; flex-wrap: wrap; gap: 6px; padding: 6px; background: var(--pg-soft); border: 1px solid var(--pg-line); border-radius: 14px; }
.md-tabs a {
  display: inline-flex; align-items: center; gap: .55rem; min-height: 42px; padding: 0 16px; border-radius: 10px;
  color: var(--pg-muted); font-family: var(--pg-head); font-weight: 700; font-size: 14px; transition: background-color .15s ease, color .15s ease;
}
.md-tabs a:hover { color: var(--pg-ink); background: #fff; }
.md-tabs a[aria-current] { background: var(--pg-navy); color: #fff; box-shadow: 0 4px 12px rgba(13, 43, 92, .2); }
.md-tabs a span { min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px; display: inline-grid; place-items: center; font-size: 12px; background: rgba(13, 43, 92, .08); }
.md-tabs a[aria-current] span { background: rgba(255, 255, 255, .2); }
.md-search { position: relative; flex: 0 1 340px; }
.md-search i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--pg-muted); pointer-events: none; }
.md-search input {
  width: 100%; height: 50px; padding: 0 16px 0 42px; border: 1px solid #c9d3e1; border-radius: 12px; font: inherit; font-size: 15px; color: var(--pg-ink); background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.md-search input:focus { border-color: var(--pg-blue); box-shadow: 0 0 0 3px rgba(31, 95, 191, .15); outline: none; }
.md-results { font-size: 14px; color: var(--pg-muted); margin: -14px 0 22px; min-height: 1.4em; }

/* ---------- Badges & meta ---------- */
.md-badge { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .75rem; border-radius: 999px; font-size: 12.5px; font-weight: 700; letter-spacing: .02em; }
.md-badge--news { background: #e8effc; color: #1a4fa0; }
.md-badge--press_release { background: #fde4e5; color: #a3161c; }
.md-badge--on-image { position: absolute; left: 16px; top: 16px; z-index: 1; box-shadow: 0 4px 12px rgba(0, 0, 0, .15); }
.md-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 13.5px; color: var(--pg-muted); }
.md-meta span { display: inline-flex; align-items: center; gap: .45rem; }
.md-meta i { color: var(--pg-green); }

/* ---------- Featured story ---------- */
.md-featured { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); background: #fff; border: 1px solid var(--pg-line); border-radius: 24px; overflow: hidden; box-shadow: var(--pg-shadow); margin-bottom: 30px; }
.md-featured__img { position: relative; display: block; min-height: 360px; background: var(--pg-soft); overflow: hidden; }
.md-featured__img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; transition: transform .7s ease; }
.md-featured:hover .md-featured__img img { transform: scale(1.04); }
.md-featured__body { padding: 40px; display: flex; flex-direction: column; justify-content: center; gap: 16px; }
.md-featured__label { font-family: var(--pg-head); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--pg-red); }
.md-featured h2 { font-size: clamp(1.4rem, 2.6vw, 2rem); font-weight: 800; line-height: 1.25; }
.md-featured h2 a { color: var(--pg-ink); }
.md-featured h2 a:hover { color: var(--pg-blue); }
.md-featured p { color: var(--pg-text); font-size: 16px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Story cards ---------- */
.md-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.md-card { position: relative; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--pg-line); border-radius: 18px; overflow: hidden; transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease; }
.md-card:hover { box-shadow: var(--pg-shadow); transform: translateY(-4px); border-color: #c9d5e8; }
.md-card__img { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--pg-soft); }
.md-card__img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s ease; }
.md-card:hover .md-card__img img { transform: scale(1.05); }
.md-date { position: absolute; right: 14px; bottom: 14px; z-index: 1; width: 54px; padding: 6px 0; border-radius: 12px; background: #fff; text-align: center; box-shadow: 0 6px 16px rgba(0, 0, 0, .18); line-height: 1.1; }
.md-date b { display: block; font-family: var(--pg-head); font-size: 1.25rem; color: var(--pg-navy); }
.md-date span { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--pg-red); letter-spacing: .05em; }
.md-card__body { padding: 22px 22px 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.md-card h3 { font-size: 1.12rem; font-weight: 700; line-height: 1.35; }
.md-card h3 a { color: var(--pg-ink); }
.md-card h3 a::after { content: ""; position: absolute; inset: 0; } /* whole card is clickable */
.md-card:hover h3 a { color: var(--pg-blue); }
.md-card p { font-size: 15px; color: var(--pg-text); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.md-card__foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--pg-line); display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13.5px; color: var(--pg-muted); }
.md-card__foot .pg-link { font-size: 14px; }

.md-empty { text-align: center; padding: 56px 24px; border: 1px dashed #c9d3e1; border-radius: 20px; background: #fff; }
.md-empty i { font-size: 34px; color: var(--pg-muted); margin-bottom: 14px; display: block; }
.md-empty h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: 6px; }
.md-empty p { color: var(--pg-muted); }
.md [hidden] { display: none !important; }

/* ---------- Story page ---------- */
.md-progress { position: fixed; left: 0; top: 0; z-index: 1400; height: 4px; width: 100%; background: transparent; pointer-events: none; }
.md-progress span { display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, #1f5fbf, #2fbf5a 85%, #d9232b); }

.md-hero { position: relative; overflow: hidden; color: #fff; padding: 60px 0 120px; background: var(--pg-navy); }
.md-hero__bg { position: absolute; inset: -20px; background-size: cover; background-position: center; filter: blur(14px) saturate(1.1); transform: scale(1.08); opacity: .45; }
.md-hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10, 31, 69, .7) 0%, rgba(13, 43, 92, .95) 100%); }
.md-hero .pg-wrap { position: relative; z-index: 1; }
.md-hero h1 { color: #fff; font-family: var(--pg-head); font-size: clamp(1.8rem, 4.4vw, 3rem); font-weight: 800; line-height: 1.15; letter-spacing: -.01em; max-width: 900px; margin: 16px 0 18px; }
.md-hero .md-meta { color: #c6d3ea; font-size: 14.5px; }
.md-hero .md-meta i { color: #8fe3a8; }
.md-crumb-title { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.md-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 36px; align-items: start; margin-top: -84px; position: relative; z-index: 2; }
.md-article { background: #fff; border: 1px solid var(--pg-line); border-radius: 24px; box-shadow: var(--pg-shadow); overflow: hidden; }
.md-article__cover { background: var(--pg-soft); }
.md-article__cover img { display: block; width: 100%; height: auto; max-height: 560px; object-fit: cover; }
.md-article__body { padding: 40px 44px 44px; }

/* Article typography (story HTML from the editor, already sanitised) */
.md-prose { font-size: 17.5px; line-height: 1.85; color: #2c3852; overflow-wrap: break-word; }
.md-prose > * + * { margin-top: 1.1em; }
.md-prose :is(h2, h3, h4) { font-family: var(--pg-head); color: var(--pg-ink); line-height: 1.3; margin-top: 1.6em; }
.md-prose h2 { font-size: 1.55rem; } .md-prose h3 { font-size: 1.3rem; } .md-prose h4 { font-size: 1.12rem; }
.md-prose p { margin: 0; }
.md-prose :is(ul, ol) { padding-left: 1.4em; margin: 0; }
.md-prose li { list-style: revert; margin-top: .4em; }
.md-prose li::marker { color: var(--pg-green); }
.md-prose a { color: var(--pg-blue); text-decoration: underline; text-underline-offset: 3px; }
.md-prose strong { color: var(--pg-ink); }
.md-prose img { max-width: 100%; height: auto; border-radius: 14px; }
.md-prose blockquote { margin: 1.4em 0; padding: 18px 22px; border-left: 4px solid var(--pg-green); background: var(--pg-soft-green); border-radius: 0 14px 14px 0; font-size: 1.05em; color: var(--pg-ink); }
.md-prose table { width: 100%; border-collapse: collapse; font-size: 15px; display: block; overflow-x: auto; }
.md-prose :is(th, td) { border: 1px solid var(--pg-line); padding: 10px 12px; text-align: left; }
.md-prose th { background: var(--pg-soft); }

/* Gallery */
.md-gallery { margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--pg-line); }
.md-gallery h2 { font-size: 1.3rem; font-weight: 800; display: flex; align-items: center; gap: .6rem; margin-bottom: 18px; }
.md-gallery h2 i { color: var(--pg-green); }
.md-gallery h2 small { font-family: "Ubuntu", sans-serif; font-weight: 500; font-size: 14px; color: var(--pg-muted); }
/* 6-column grid, 3 photos per row; the last row always fills the width */
.md-gallery__grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.md-gallery__item { grid-column: span 2; position: relative; aspect-ratio: 4 / 3; border: 0; padding: 0; border-radius: 12px; overflow: hidden; cursor: zoom-in; background: var(--pg-soft); }
.md-gallery__item:last-child:nth-child(3n+1) { grid-column: span 6; aspect-ratio: 16 / 9; }
.md-gallery__item:nth-last-child(2):nth-child(3n+1), .md-gallery__item:last-child:nth-child(3n+2) { grid-column: span 3; }
.md-gallery__item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s ease; }
.md-gallery__item::after { content: "\f00e"; font-family: "Font Awesome 5 Free"; font-weight: 900; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 22px; background: rgba(13, 43, 92, .45); opacity: 0; transition: opacity .2s ease; }
.md-gallery__item:hover img { transform: scale(1.06); }
.md-gallery__item:hover::after, .md-gallery__item:focus-visible::after { opacity: 1; }

/* Share */
.md-share { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.md-share__label { font-family: var(--pg-head); font-weight: 700; color: var(--pg-ink); font-size: 14.5px; margin-right: 4px; }
.md-share a, .md-share button {
  width: 42px; height: 42px; border-radius: 50%; display: inline-grid; place-items: center; border: 1px solid var(--pg-line); background: #fff; color: var(--pg-navy);
  font-size: 16px; cursor: pointer; transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .15s ease;
}
.md-share a:hover, .md-share button:hover { transform: translateY(-2px); color: #fff; border-color: transparent; }
.md-share .is-whatsapp:hover { background: #1fa855; }
.md-share .is-facebook:hover { background: #1877f2; }
.md-share .is-x:hover { background: #111; }
.md-share .is-linkedin:hover { background: #0a66c2; }
.md-share .is-email:hover, .md-share .is-copy:hover, .md-share .is-native:hover { background: var(--pg-navy); }
.md-share .is-copy.is-copied { background: var(--pg-green); color: #fff; border-color: transparent; }
.md-share .is-native { display: none; }
.md-share.has-native .is-native { display: inline-grid; }
.md-aside .md-share__label { display: none; }
.md-article__share { margin-top: 36px; padding: 20px 22px; border-radius: 16px; background: var(--pg-soft); }

/* Previous / next */
.md-pager { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 24px; }
.md-pager a { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 14px; align-items: center; padding: 14px; background: #fff; border: 1px solid var(--pg-line); border-radius: 16px; color: var(--pg-ink); transition: border-color .2s ease, box-shadow .2s ease; }
.md-pager a:hover { border-color: #b9d0f3; box-shadow: var(--pg-shadow); }
.md-pager a.is-next { grid-template-columns: minmax(0, 1fr) 76px; text-align: right; }
.md-pager a.is-next img { order: 2; }
.md-pager img { width: 76px; height: 60px; object-fit: cover; border-radius: 10px; }
.md-pager small { display: flex; align-items: center; gap: .4rem; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--pg-green); }
.md-pager a.is-next small { justify-content: flex-end; }
.md-pager strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-family: var(--pg-head); font-size: 15px; line-height: 1.35; margin-top: 3px; }

/* Sidebar */
.md-aside { position: sticky; top: 100px; display: grid; gap: 18px; }
.md-aside__card { background: #fff; border: 1px solid var(--pg-line); border-radius: 20px; padding: 22px; box-shadow: var(--pg-shadow); }
.md-aside__card h2 { font-size: 1.05rem; font-weight: 800; display: flex; align-items: center; gap: .55rem; margin-bottom: 14px; }
.md-aside__card h2 i { color: var(--pg-green); }
.md-recent li + li { border-top: 1px solid var(--pg-line); }
.md-recent a { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; align-items: center; padding: 12px 0; color: var(--pg-ink); }
.md-recent img { width: 72px; height: 56px; border-radius: 10px; object-fit: cover; }
.md-recent strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14.5px; line-height: 1.35; font-weight: 700; }
.md-recent a:hover strong { color: var(--pg-blue); }
.md-recent span { display: block; font-size: 12.5px; color: var(--pg-muted); margin-top: 3px; }
.md-cats a { display: flex; justify-content: space-between; align-items: center; padding: 11px 12px; border-radius: 10px; color: var(--pg-text); font-size: 15px; }
.md-cats a:hover { background: var(--pg-soft); color: var(--pg-ink); }
.md-cats a i { width: 18px; margin-right: 8px; color: var(--pg-blue); }
.md-cats a b { font-size: 12.5px; padding: 2px 10px; border-radius: 999px; background: var(--pg-soft); color: var(--pg-navy); }

/* Lightbox */
.md-lightbox { border: 0; padding: 0; margin: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; background: rgba(6, 15, 33, .96); color: #fff; }
.md-lightbox:not([open]) { display: none !important; }
.md-lightbox[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.md-lightbox::backdrop { background: rgba(6, 15, 33, .96); }
.md-lightbox__bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; }
.md-lightbox__count { font-family: var(--pg-head); font-weight: 700; font-size: 15px; color: #c6d3ea; }
.md-lightbox__stage { position: relative; display: grid; place-items: center; padding: 0 76px; min-height: 0; }
.md-lightbox__stage img { max-width: 100%; max-height: calc(100vh - 170px); object-fit: contain; border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); user-select: none; }
.md-lb-btn { width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .08); color: #fff; font-size: 18px; cursor: pointer; transition: background-color .15s ease; }
.md-lb-btn:hover { background: rgba(255, 255, 255, .2); }
.md-lb-prev, .md-lb-next { position: absolute; top: 50%; transform: translateY(-50%); }
.md-lb-prev { left: 16px; } .md-lb-next { right: 16px; }
.md-lightbox__thumbs { display: flex; gap: 8px; justify-content: center; padding: 14px 20px 20px; overflow-x: auto; }
.md-lightbox__thumbs button { flex: 0 0 auto; width: 64px; height: 48px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; opacity: .55; cursor: pointer; background: none; transition: opacity .15s ease, border-color .15s ease; }
.md-lightbox__thumbs button[aria-current] { opacity: 1; border-color: #8fe3a8; }
.md-lightbox__thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }

@media (prefers-reduced-motion: reduce) {
  .md-card, .md-card *, .md-featured *, .md-gallery__item * { transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .md-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md-featured { grid-template-columns: minmax(0, 1fr); }
  .md-featured__img { min-height: 0; aspect-ratio: 16 / 9; }
  .md-layout { grid-template-columns: minmax(0, 1fr); }
  .md-aside { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md-aside__card--share { display: none; } /* the share bar inside the article covers it */
}
@media (max-width: 680px) {
  .md-toolbar { flex-direction: column; align-items: stretch; }
  .md-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .md-tabs a { justify-content: center; padding: 0 8px; font-size: 13px; gap: .35rem; }
  .md-tabs a i { display: none; }
  .md-search { flex: 1 1 auto; }
  .md-grid { grid-template-columns: minmax(0, 1fr); }
  .md-featured__body { padding: 24px 20px; }
  .md-hero { padding: 40px 0 100px; }
  .md-crumb-title { max-width: 140px; }
  .md-article { border-radius: 18px; }
  .md-article__body { padding: 24px 20px 28px; }
  .md-prose { font-size: 16.5px; }
  .md-gallery__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md-gallery__item, .md-gallery__item:nth-last-child(2):nth-child(3n+1), .md-gallery__item:last-child:nth-child(3n+2) { grid-column: span 1; }
  .md-gallery__item:last-child:nth-child(odd) { grid-column: span 2; aspect-ratio: 16 / 9; }
  .md-pager { grid-template-columns: minmax(0, 1fr); }
  .md-aside { grid-template-columns: minmax(0, 1fr); }
  .md-lightbox__stage { padding: 0 8px; }
  .md-lightbox__stage img { max-height: calc(100vh - 230px); }
  .md-lb-prev, .md-lb-next { top: auto; bottom: 8px; transform: none; }
  .md-lb-prev { left: calc(50% - 56px); } .md-lb-next { right: calc(50% - 56px); }
  .md-lightbox__stage { padding-bottom: 68px; }
}
@media print {
  .md-progress, .md-aside, .md-article__share, .md-pager, .md-gallery { display: none !important; }
  .md-layout { display: block; margin: 0; }
  .md-hero { background: none; color: #000; padding: 0; }
  .md-hero::before, .md-hero__bg { display: none; }
  .md-hero h1 { color: #000; }
}
