/* ==========================================================================
   Components — the shared vocabulary. Every section reuses these; only
   --accent changes between them.
   ========================================================================== */

/* --- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
  border: 1px solid transparent; border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand-500); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--brand-600); }
:root[data-theme="dark"] .btn--primary { color: var(--text-on-accent); }
.btn--accent { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn--accent { color: var(--text-on-accent); }
.btn--outline { border-color: var(--border-strong); background: transparent; }
.btn--outline:hover { background: var(--surface-alt); border-color: var(--text-faint); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--surface-alt); }
.btn--sm { padding: var(--s-2) var(--s-3); font-size: var(--fs-xs); }
.btn--block { width: 100%; }

/* Icon-only control */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex: none;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-alt); color: var(--text); }
.icon-btn[aria-pressed="true"] { color: var(--accent); }
.icon-btn[aria-pressed="true"] svg { fill: currentColor; }

/* --- Pills & badges ----------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 3px var(--s-2);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); line-height: 1.5;
  border-radius: var(--r-full); white-space: nowrap;
}
.pill--section { background: var(--accent-soft); color: var(--accent); }
.pill--verified { background: var(--ok-soft); color: var(--ok); }
.pill--muted { background: var(--bg-sunken); color: var(--text-muted); }

/* Deadline countdown. Urgency shifts the colour, not the shape. Spec 6.1 */
.countdown {
  display: inline-flex; align-items: center; gap: var(--s-1);
  font-size: var(--fs-xs); font-weight: var(--fw-semi);
  padding: 3px var(--s-2); border-radius: var(--r-sm);
  background: var(--bg-sunken); color: var(--text-muted);
}
.countdown--soon   { background: var(--warn-soft);   color: var(--warn); }
.countdown--urgent { background: var(--danger-soft); color: var(--danger); }
.countdown--closed { background: var(--bg-sunken); color: var(--text-faint); text-decoration: line-through; }

/* --- Card ---------------------------------------------------------------
   One card pattern, reused by all five sections. Visual-first: media,
   then title, then a one-line summary, then facts. Exactly ONE primary
   action visible (bookmark); everything else lives in the overflow menu.
   Spec 6, "Visual & UX principles".                                       */
.card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.card:focus-within { border-color: var(--accent); }

/* Templated card image, generated from post fields — no scraped artwork
   for scholarships / local jobs / visas / news. Spec 2.1 */
.card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 140% at 15% 10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    var(--accent-soft);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.card__media-icon { width: 46px; height: 46px; color: var(--accent); opacity: .85; }
.card__flag {
  position: absolute; z-index: 3;
  inset-block-start: 6px; inset-inline-start: 6px;
  display: block;
  line-height: 0;
}
.card__flag img {
  display: block;
  width: 52px; height: 39px;
  /* The global `img { max-width: 100% }` would resolve against this chip, which
     is itself sized by the image — a circular constraint that collapses both to
     nothing inside an absolutely positioned box. */
  max-width: none;
  object-fit: cover; border-radius: 3px;
  /* No chip behind the flag any more, so it needs its own edge: several
     national flags are largely white and would otherwise dissolve into a pale
     photograph. A hairline plus a soft shadow, not a white border. */
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, .18),
    0 1px 4px rgba(0, 0, 0, .35);
}
@media (max-width: 560px) {
  .card__flag img { width: 44px; height: 33px; }
}
.card__media-tag {
  position: absolute; inset-block-end: var(--s-3); inset-inline-start: var(--s-3);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 0; box-shadow: var(--shadow-sm);
  font-weight: var(--fw-semi);
}

/* Photographic media. The image sits under a soft wash of the section accent,
   so five sections of stock photography still read as one system. */
.card__media--photo { background: var(--bg-sunken); }
.card__media > img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  transition: transform var(--dur-slow) var(--ease);
}
.card:hover .card__media > img { transform: scale(1.04); }
.card__media--photo::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to top, color-mix(in srgb, var(--accent) 42%, transparent), transparent 58%),
    linear-gradient(to bottom, color-mix(in srgb, var(--accent) 14%, transparent), transparent 40%);
  mix-blend-mode: multiply;
}
:root[data-theme="dark"] .card__media--photo::after { mix-blend-mode: normal; opacity: .72; }
.card__media--photo .card__flag,
.card__media--photo .card__media-tag { z-index: 2; }

/* Overseas Jobs: the original newspaper advertisement, shown inside the post.
   The card itself uses the destination photo — a grey scan is unreadable at
   card size, and the badge tells the reader the original is there. Spec 2.1 */
.card__media--scan {
  background: repeating-linear-gradient(
    180deg, var(--bg-sunken) 0 3px, var(--surface-alt) 3px 6px);
}
.card__media--scan::after {
  content: "Original newspaper advertisement";
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
  color: var(--text-faint); text-align: center; padding: var(--s-4);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}

.card__body { padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); flex: 1; }
.card__meta { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.card__title { font-size: var(--fs-md); font-weight: var(--fw-semi); line-height: var(--lh-snug); }
.card__title a::after { content: ""; position: absolute; inset: 0; } /* whole-card target */
/* Grade sits beside the title rather than in the facts row — it identifies
   the post as much as the title does, so it reads at the same moment. */
.card__grade {
  display: inline-block; margin-inline-start: var(--s-2);
  font-size: var(--fs-xs); font-weight: var(--fw-semi); color: var(--accent);
  vertical-align: middle;
}

/* Local job particulars — fee, domicile, quota, shown as tags rather than
   hidden behind a click. Not every listing carries all three, or any of
   them, so this never pads with placeholders; it prints only what exists. */
.card__particulars {
  list-style: none; padding: 0; margin: var(--s-2) 0 0;
  display: flex; flex-wrap: wrap; gap: var(--s-2);
}
.card__particulars li {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px var(--s-2); border-radius: var(--r-full);
  background: var(--bg-subtle); color: var(--text-muted);
  font-size: var(--fs-xs); line-height: 1.5;
}
.card__particulars svg { width: 11px; height: 11px; flex: none; opacity: .7; }
.card { position: relative; }
.card__summary {
  font-size: var(--fs-sm); color: var(--text-muted); line-height: var(--lh-snug);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Comparison strip — the same fields, in the same order, on every card in the
   section, so a grid can be read down a column rather than card by card. */
.card__compare {
  display: grid; grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s-1) var(--s-3);
  margin: 0; padding: var(--s-3) 0;
  border-block: 1px solid var(--border);
  font-size: var(--fs-xs);
}
.card__compare dt { color: var(--text-faint); }
.card__compare dd {
  margin: 0; color: var(--text); font-weight: var(--fw-medium);
  line-height: 1.45;
  /* Wraps rather than truncating. "Bachelors · Masters · PhD" clipped to
     "Bachelors · Mast…" hides one of the four facts the strip exists to show,
     and cards in a grid row stretch to equal height anyway, so the extra line
     costs nothing in alignment. Two lines is the ceiling. */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__facts {
  list-style: none; padding: 0; margin-top: auto;
  display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4);
  font-size: var(--fs-xs); color: var(--text-muted);
}
.card__facts li { display: inline-flex; align-items: center; gap: var(--s-1); }
.card__facts svg { width: 13px; height: 13px; flex: none; opacity: .7; }
.card__footer {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}
.card__actions { display: flex; align-items: center; gap: var(--s-1); position: relative; z-index: 1; }

/* --- Card grid ---------------------------------------------------------- */
.card-grid {
  display: grid; gap: var(--s-4);
  grid-template-columns: 1fr;
}
@media (min-width: 560px) { .card-grid { grid-template-columns: repeat(2, 1fr); gap: var(--s-5); } }
@media (min-width: 1000px) { .card-grid--3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .card-grid--4 { grid-template-columns: repeat(4, 1fr); } }

/* --- Compact list row (trending sidebar, similar posts) ------------------ */
.row-item {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) 0; border-bottom: 1px solid var(--border);
  position: relative;
}
.row-item:last-child { border-bottom: 0; }
.row-item__rank {
  flex: none; width: 22px; height: 22px; display: grid; place-items: center;
  border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent);
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
}
.row-item__text { min-width: 0; }
.row-item__title {
  font-size: var(--fs-sm); font-weight: var(--fw-medium); line-height: var(--lh-snug);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.row-item__title a::after { content: ""; position: absolute; inset: 0; }
.row-item__sub { font-size: var(--fs-xs); color: var(--text-faint); margin-top: 2px; }
.row-item:hover .row-item__title { color: var(--accent); }

/* --- Breadcrumbs. Spec 6.3 ---------------------------------------------- */
.breadcrumbs {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  padding-block: var(--s-3);
  font-size: var(--fs-xs); color: var(--text-faint);
}
.breadcrumbs a:hover { color: var(--text); text-decoration: underline; }
.breadcrumbs svg { width: 12px; height: 12px; opacity: .5; }
.breadcrumbs [aria-current] { color: var(--text-muted); }

/* --- Panel -------------------------------------------------------------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s-5);
}
.panel__head {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--fs-sm); font-weight: var(--fw-semi);
  margin-bottom: var(--s-2);
}
.panel__head svg { width: 16px; height: 16px; color: var(--accent); }

/* --- Skeleton loading (never a blank screen or a spinner). Spec 6 ------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--surface-alt) 37%, var(--bg-sunken) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skeleton--line { height: 10px; margin-bottom: var(--s-2); }
.skeleton--title { height: 14px; width: 80%; }
.skeleton--media { aspect-ratio: 16/9; border-radius: 0; }

/* --- Overflow menu ------------------------------------------------------ */
.menu { position: relative; }
.menu__list {
  position: absolute; inset-inline-end: 0; inset-block-start: calc(100% + 6px);
  min-width: 184px; padding: var(--s-1);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  list-style: none; z-index: 30;
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.menu[data-open="true"] .menu__list { opacity: 1; transform: none; pointer-events: auto; }
.menu__list button {
  display: flex; align-items: center; gap: var(--s-2); width: 100%;
  padding: var(--s-2) var(--s-3); border: 0; background: transparent;
  font-size: var(--fs-sm); text-align: start; border-radius: var(--r-sm); cursor: pointer;
}
.menu__list button:hover { background: var(--surface-alt); }
.menu__list svg { width: 15px; height: 15px; color: var(--text-muted); flex: none; }

/* The media tag sits opposite the flag so the two never collide. */
.card__media-tag {
  inset-block-end: auto;
  inset-block-start: var(--s-3);
  inset-inline-start: auto;
  inset-inline-end: var(--s-3);
}


/* --- Pagination ----------------------------------------------------------
   Defined once here rather than twice in section.css and news.css, which
   carried identical copies that only differed by which pages loaded them.

   The flex has to sit on `.nav-links`, not on `.pagination`. WordPress
   renders the block as <nav class="pagination"><h2><div class="nav-links">
   ...links...</div></nav>, so a flex row on the nav lays out the heading
   and one div, and the links inside stay in normal block flow. Combined
   with `display: grid` on each link, which is block-level, every page
   number took a full line and the numbers ran down the page. */
.pagination { margin-top: var(--s-10); }
.pagination .nav-links {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: center;
  gap: var(--s-1);
}
.pagination a, .pagination span.page-numbers {
  min-width: 36px; height: 36px; padding-inline: var(--s-2);
  display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: var(--fs-sm); color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination [aria-current="page"] {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: var(--fw-semi);
}
:root[data-theme="dark"] .pagination [aria-current="page"] { color: var(--text-on-accent); }
/* The ellipsis is not a destination, so it gets no box. */
.pagination .dots, .pagination .is-gap { border: 0; background: transparent; min-width: auto; }
/* Prev and Next are words, not digits, and need room for them. */
.pagination .prev, .pagination .next { padding-inline: var(--s-3); }
