/**
 * Wuteve Global Academy — the media centre.
 *
 * News, resources, reports, gallery, events and career insights all share this one
 * set of components: a section switcher, a grid of cards, and an article. Only the
 * gallery changes anything, and it only changes the shape of the picture.
 *
 * Every colour is a token from `wga-shell.css` — `--ink`, `--muted`, `--line`,
 * `--surface`, `--brand` — which is what makes these pages work in both themes
 * without a second stylesheet or a `body.dark-mode` rule for each component.
 */

:root {
  /**
   * The text colour for anything filled with `--brand`.
   *
   * It cannot be a constant. `--brand` is a deep blue in light mode and a light
   * one in dark mode, so white-on-brand reads at 6.2:1 in one theme and 2.5:1 in
   * the other — the same declaration, correct half the time. This flips with the
   * theme, so both filled components state it once and neither has to know.
   */
  --media-on-brand: #ffffff;
}

body.dark-mode {
  --media-on-brand: #0f172a;
}

/* ---------------- Section switcher ---------------- */

/**
 * Horizontally scrollable rather than wrapping: six labels wrap to three lines on a
 * phone, which pushes the content below the fold on the one screen that can least
 * afford it.
 */
.media-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 0 18px;
  scrollbar-width: none;
}

.media-tabs::-webkit-scrollbar {
  display: none;
}

.media-tab {
  flex: 0 0 auto;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.media-tab:hover,
.media-tab:focus-visible {
  border-color: var(--brand);
  color: var(--brand);
}

.media-tab.is-current {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--media-on-brand);
}

/* ---------------- Search ---------------- */

.media-search {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0 0 20px;
}

.media-search label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.media-search .wga-input {
  flex: 1;
  min-width: 0;
}

/* ---------------- The grid ---------------- */

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 20px;
  align-items: stretch;
}

.media-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

a.media-card:hover,
a.media-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: var(--shadow);
}

.media-card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--surface-3);
  overflow: hidden;
}

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

/** A gallery is pictures, so its cards are square and the caption sits under them. */
.media-grid--gallery .media-card-media {
  aspect-ratio: 1 / 1;
}

/** No picture: the initials of the section stand in rather than a broken image. */
.media-card-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--brand);
  background: var(--brand-soft);
}

.media-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px 20px;
  flex: 1;
}

.media-card-tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

.media-card-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}

.media-card-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);

  /* Three lines is what a card can hold without the grid going ragged. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------------- Events ---------------- */

.media-when {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--ink);
}

.media-when[data-past='true'] {
  color: var(--muted);
}

.media-group-title {
  margin: 30px 0 14px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

.media-group-title:first-child {
  margin-top: 0;
}

/* ---------------- States ---------------- */

.media-empty,
.media-error {
  padding: 40px 24px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
}

.media-error {
  border-style: solid;
  border-color: var(--accent);
  color: var(--ink);
}

.media-more {
  display: flex;
  justify-content: center;
  padding: 28px 0 8px;
}

/* ---------------- The article ---------------- */

.media-article {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px;
}

.media-article-head {
  padding: 8px 0 18px;
}

.media-article-tag {
  display: inline-block;
  margin-bottom: 10px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

.media-article-title {
  margin: 0 0 12px;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  line-height: 1.2;
  color: var(--ink);
}

.media-article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.88rem;
  color: var(--muted);
}

.media-article-cover {
  width: 100%;
  max-height: 460px;
  object-fit: cover;
  border-radius: 14px;
  margin: 8px 0 26px;
  display: block;
  background: var(--surface-3);
}

.media-article-body {
  font-size: 1.03rem;
  line-height: 1.75;
  color: var(--ink);
}

.media-article-body p {
  margin: 0 0 1.1em;
}

.media-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 30px 0 10px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.media-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border: 1px solid var(--brand);
  border-radius: 10px;
  background: var(--brand);
  color: var(--media-on-brand);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
}

.media-btn:hover,
.media-btn:focus-visible {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.media-btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.media-btn--ghost:hover,
.media-btn--ghost:focus-visible {
  background: var(--surface-3);
  border-color: var(--brand);
  color: var(--ink);
}

.media-back {
  display: inline-block;
  margin: 26px 0 40px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
}

.media-back:hover,
.media-back:focus-visible {
  text-decoration: underline;
}

@media (max-width: 620px) {
  .media-article {
    padding: 0 16px;
  }

  .media-grid {
    grid-template-columns: 1fr;
  }

  .media-search {
    flex-wrap: wrap;
  }
}
