/* =========================================================
   POST FORMATS — Video / Gallery / Audio on the article page,
   plus card badges. Uses the brand tokens from styles.css.
   ========================================================= */

/* ---------- Shared round play / pause button ---------- */
.apf-btn {
  display: grid; place-items: center; padding: 0;
  border-radius: 50%; border: 2px solid rgba(255, 255, 255, .9); cursor: pointer;
  background: var(--color-red); color: var(--color-white);
  box-shadow: 0 6px 18px -4px rgba(0, 0, 0, .55);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), bottom .25s var(--ease);
}
.apf-btn svg { width: 44%; height: 44%; }
.apf-btn .apf-i-play { margin-left: 8%; }
.apf-btn .apf-i-pause { display: none; }
.is-playing .apf-btn .apf-i-play { display: none; }
.is-playing .apf-btn .apf-i-pause { display: block; }
.apf-btn:hover { transform: scale(1.08); background: var(--color-red-dark); }
.apf-btn:focus-visible { outline: 3px solid var(--color-accent-soft); outline-offset: 3px; }

/* ---------- Video ---------- */
.apf-video {
  position: relative; margin: 0 auto; width: 100%; max-width: 960px; aspect-ratio: 16 / 9;
  background: #000; border-radius: var(--radius-md); overflow: hidden;
}
.apf-video:not(.is-started):not(.is-loaded) { cursor: pointer; }
.apf-video__media, .apf-video iframe, .apf-video__poster { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; margin: 0; }
.apf-video__media { object-fit: contain; background: #000; }
.apf-video:not(.is-started) .apf-video__media { object-fit: cover; }
.apf-video__poster { object-fit: cover; }
.apf-video--youtube::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(41, 52, 75, .5)); pointer-events: none; }
.apf-video--youtube.is-loaded::after, .apf-video--youtube.is-loaded .apf-video__poster { display: none; }
.apf-video__btn {
  position: absolute; z-index: 3;
  right: clamp(10px, 2vw, 18px); bottom: clamp(10px, 2vw, 18px);
  width: clamp(40px, 5vw, 50px); height: clamp(40px, 5vw, 50px);
}
.apf-video.is-playing .apf-video__btn { background: rgba(41, 52, 75, .78); }
.apf-video.is-playing .apf-video__btn:hover { background: var(--color-red); }
/* Once the player's own control bar is showing, sit just above it. */
.apf-video.is-started .apf-video__btn, .apf-video.is-loaded .apf-video__btn { bottom: clamp(52px, 7vw, 62px); }

/* ---------- Gallery slideshow ---------- */
.apf-gallery { margin: 0; }
.apf-gallery__stage { position: relative; border-radius: var(--radius-md); overflow: hidden; background: var(--color-header-bg); }
.apf-gallery__track {
  display: flex; margin: 0; padding: 0; list-style: none;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; overscroll-behavior-x: contain;
  scrollbar-width: none; aspect-ratio: 21 / 9; outline: 0;
}
.apf-gallery__track::-webkit-scrollbar { display: none; }
.apf-gallery__track:focus-visible { box-shadow: inset 0 0 0 3px var(--color-accent-soft); }
.apf-gallery__slide { position: relative; flex: 0 0 100%; margin: 0; scroll-snap-align: center; scroll-snap-stop: always; }
.apf-gallery__slide img { display: block; width: 100%; height: 100%; object-fit: cover; }
.apf-gallery__cap { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 2.5rem 1.25rem 1rem; color: var(--color-white); font-size: .9rem; background: linear-gradient(transparent, rgba(41, 52, 75, .85)); }
.apf-gallery__nav {
  position: absolute; top: 50%; z-index: 2; transform: translateY(-50%);
  width: clamp(40px, 5vw, 48px); height: clamp(40px, 5vw, 48px); padding: 0;
  display: grid; place-items: center; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .94); color: var(--color-header-bg);
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .5); transition: background var(--dur) var(--ease), color var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.apf-gallery__nav--prev { left: clamp(10px, 2vw, 18px); }
.apf-gallery__nav--next { right: clamp(10px, 2vw, 18px); }
.apf-gallery__nav:hover, .apf-gallery__nav:focus-visible { background: var(--color-red); color: var(--color-white); }
.apf-gallery__nav[disabled] { opacity: 0; pointer-events: none; }
.apf-gallery__count {
  position: absolute; right: clamp(10px, 2vw, 18px); top: clamp(10px, 2vw, 18px); z-index: 2;
  padding: .3rem .7rem; border-radius: 999px; background: rgba(41, 52, 75, .78); color: var(--color-white);
  font: 500 .75rem var(--font-mono); letter-spacing: .06em;
}
.apf-gallery__thumbs { display: flex; gap: .5rem; margin: .75rem 0 0; padding: 0 0 .25rem; list-style: none; overflow-x: auto; scrollbar-width: thin; }
.apf-gallery__thumb { display: block; width: 84px; height: 60px; padding: 0; border: 2px solid transparent; border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; background: none; opacity: .6; transition: opacity var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.apf-gallery__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.apf-gallery__thumb:hover { opacity: 1; }
.apf-gallery__thumb.is-active { opacity: 1; border-color: var(--color-accent-soft); }

/* ---------- Audio: waveform player blended into the featured image ---------- */
.apf-audio { margin: 0; }
.apf-audio__art { position: relative; aspect-ratio: 21 / 9; overflow: hidden; border-radius: var(--radius-md); background: var(--color-header-bg); cursor: pointer; isolation: isolate; }
.apf-audio__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 8s ease; }
.apf-audio.is-playing .apf-audio__img { transform: scale(1.03); }
.apf-audio__ph { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255, 182, 6, .55); background: radial-gradient(900px 500px at 80% -10%, rgba(255, 255, 255, .08), transparent 60%), var(--color-header-bg); }
.apf-audio__fade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 66%; z-index: 1; pointer-events: none;
  background: linear-gradient(to top, rgba(1, 22, 26, .94) 0%, rgba(1, 22, 26, .8) 30%, rgba(1, 22, 26, .35) 65%, rgba(1, 22, 26, 0) 100%);
  transition: height .5s ease;
}
.apf-audio.is-playing .apf-audio__fade { height: 74%; }
.apf-audio__player {
  --wf-played: var(--color-accent-soft); --wf-rest: rgba(255, 255, 255, .32); --wf-hover: rgba(255, 255, 255, .6);
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; cursor: default;
  display: grid; grid-template-columns: auto minmax(120px, 1fr) minmax(0, 2.4fr) auto auto; align-items: center; gap: clamp(.75rem, 2vw, 1.5rem);
  padding: 0 clamp(1rem, 3vw, 2rem) clamp(1rem, 2.6vw, 1.75rem); color: var(--color-white);
}
.apf-audio__player audio { display: none; }
.apf-audio__play {
  width: 56px; height: 56px; border: 0;
  background: rgba(255, 255, 255, .16); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28);
}
.apf-audio__play svg { width: 24px; height: 24px; }
.apf-audio__play:hover, .apf-audio__play:focus-visible, .apf-audio.is-playing .apf-audio__play { background: var(--color-red); box-shadow: none; }
.apf-audio__meta { min-width: 0; line-height: 1.3; }
.apf-audio__meta strong { display: block; font: 700 clamp(1rem, 1.6vw, 1.2rem)/1.3 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apf-audio__meta span { display: block; margin-top: .15rem; font-size: .88rem; color: rgba(255, 255, 255, .68); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apf-audio__meta strong, .apf-audio__meta span, .apf-audio__dur, .apf-audio__now { text-shadow: 0 1px 8px rgba(0, 0, 0, .55); }
.apf-audio__wf { position: relative; height: 64px; cursor: pointer; touch-action: none; outline: 0; }
.apf-audio__wf:focus-visible { box-shadow: 0 0 0 2px var(--color-accent-soft); border-radius: var(--radius-sm); }
.apf-audio__wf canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.apf-audio__head { position: absolute; left: 0; top: -8px; bottom: -8px; width: 2px; margin-left: -1px; background: var(--color-white); pointer-events: none; will-change: transform; }
.apf-audio__now { position: absolute; left: 8px; top: -8px; font: 500 .75rem/1 var(--font-mono); white-space: nowrap; }
.apf-audio__hover { position: absolute; left: 0; bottom: -12px; font: 500 .68rem/1 var(--font-mono); color: rgba(255, 255, 255, .72); pointer-events: none; white-space: nowrap; }
.apf-audio__dur { font: 500 .95rem var(--font-mono); }
.apf-audio__tools { display: flex; gap: .25rem; }
.apf-audio__mute, .apf-audio__dl { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: none; color: rgba(255, 255, 255, .78); cursor: pointer; }
.apf-audio__mute:hover, .apf-audio__dl:hover { background: rgba(255, 255, 255, .14); color: var(--color-white); }
.apf-audio__mute .apf-i-muted { display: none; }
.apf-audio.is-muted .apf-audio__mute .apf-i-muted { display: inline; }
.apf-audio.is-muted .apf-audio__mute .apf-i-vol { display: none; }

/* Streaming link: the service's player replaces the featured image */
.apf-audio__stream { border-radius: var(--radius-md); overflow: hidden; max-width: 960px; margin-inline: auto; }
.apf-audio__stream iframe { display: block; width: 100%; max-width: 100%; border: 0; }
.apf-audio__link { margin: 0; padding: 1.25rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); font-weight: 700; }

@media (max-width: 760px) {
  .apf-gallery__track { aspect-ratio: 4 / 3; }
  .apf-audio__art { aspect-ratio: 1 / 1; }
  .apf-audio__fade { height: 72%; }
  .apf-audio__player { grid-template-columns: auto 1fr auto; grid-template-areas: "play meta tools" "wf wf dur"; row-gap: 1.1rem; }
  .apf-audio__play { grid-area: play; width: 48px; height: 48px; }
  .apf-audio__meta { grid-area: meta; }
  .apf-audio__tools { grid-area: tools; }
  .apf-audio__wf { grid-area: wf; height: 52px; }
  .apf-audio__dur { grid-area: dur; font-size: .82rem; }
}

/* ---------- Card badges (news grids, archives, search, related) ---------- */
.apf-card-icon {
  position: absolute; top: .85rem; right: .85rem; z-index: 2; width: 38px; height: 38px;
  display: grid; place-items: center; border-radius: 50%; pointer-events: none;
  background: rgba(41, 52, 75, .6); color: var(--color-white); border: 2px solid rgba(255, 255, 255, .85);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.apf-card-icon svg { width: 16px; height: 16px; margin-left: 2px; }
.apf-card-icon--audio svg { margin-left: 0; }
.news-card:hover .apf-card-icon { transform: scale(1.06); background: var(--color-red); border-color: var(--color-red); }
.apf-card-count {
  position: absolute; right: .85rem; bottom: .85rem; display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .6rem; border-radius: var(--radius-sm); background: rgba(41, 52, 75, .82); color: var(--color-white);
  font-size: .72rem; font-weight: 700;
}
.news-card__media > img:not([class]) { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

@media (prefers-reduced-motion: reduce) {
  .apf-gallery__track { scroll-behavior: auto; }
  .apf-audio__img { transition: none; }
}

/* News index (index.php) grid — the .news-card-grid class had no styles, so
   the fallback News page showed one full-width card per row. Mirrors
   .search-results__grid. */
.news-card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
@media (max-width: 960px) { .news-card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .news-card-grid { grid-template-columns: 1fr; } }
