/* ==========================================================================
   Cross Kashmir — Listing pages
   The Latest page now; category pages will reuse it. Requires tokens, base,
   typography, layout, components (and header/footer for the page shell).
   Everything is scoped under .listing-page so nothing here can leak into other
   pages. Shared by the English and Urdu editions: direction comes from
   dir="ltr" / dir="rtl" and logical properties only.

   Anatomy (cards are generated at build time from templates/partials/card-listing.html;
   the wording lives in templates/strings/<lang>.json):

     <main class="listing-page" data-article-base="/articles/">
       <div class="container">
         <header class="listing-head">     h1 + short introduction
         [data-state=loading|load|empty]    one block at a time, never the list
         <ol class="listing__list">         one <li> per story
           <li class="listing__item">
             <article class="card card--link"> media, tags, h2 title, excerpt, meta

   Mobile first. Phones get a single-column feed: each story is a full-width
   card with its image on top, because narrow text columns are the weakest
   point of long Urdu lines and a side thumbnail would squeeze them. Columns
   are only added once the text still has room: 2 from 768px, 3 from 1280px
   (at 1024px three columns would leave less text width than a phone has).
   Breakpoints used: 768, 1280.

   A story is a link only when its article page exists (see tools/build.py and
   README.md). Linked cards use the existing .card--link pattern: ONE anchor,
   inside the headline, stretched over the card. There is no second link on
   the image or the meta, so assistive technology announces each story once.
   ========================================================================== */

/* hidden is made binding here: several parts below set their own display. */
.listing-page [hidden] {
  display: none !important;
}

/* ---- Page head: title + introduction over a hairline with a gold tab -------------
   Same motif as the homepage section headings (.section-head in home.css). */
.listing-page .listing-head {
  position: relative;
  margin-block-end: var(--space-6);
  padding-block: var(--space-6) var(--space-4);
  border-block-end: var(--border);
}

.listing-page .listing-head::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  inset-block-end: calc(-1 * var(--border-width));
  inline-size: var(--space-12);
  block-size: 3px;
  background-color: var(--color-accent);       /* decorative only */
}

.listing-page .listing-head__intro {
  margin-block-start: var(--space-2);
  max-inline-size: var(--container-narrow);
}

@media (min-width: 768px) {
  .listing-page .listing-head {
    margin-block-end: var(--space-8);
    padding-block: var(--space-8) var(--space-6);
  }
}

/* ---- Loading / error / empty: one reading-width block ------------------------------ */
.listing-page .listing-state {
  max-inline-size: var(--container-narrow);
  padding-block: var(--space-4) var(--space-12);
}

.listing-page .listing-state > * + * {
  margin-block-start: var(--space-4);
}

.listing-page .listing-state__title {
  font-size: var(--fs-section);
}

/* ---- The list ------------------------------------------------------------------------ */
.listing-page .listing__list {
  display: grid;
  gap: var(--space-4);
  padding-block-end: var(--space-12);
}

.listing-page .listing__item {
  display: flex;                               /* cards in one row share the tallest height */
  min-inline-size: 0;
}

.listing-page .listing__item > .card {
  flex: 1 1 auto;
}

@media (min-width: 768px) {
  .listing-page .listing__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-6);
  }
}

@media (min-width: 1280px) {
  .listing-page .listing__list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---- Placeholder image and sample marker ---------------------------------------------
   Same look as on the homepage and article page (those scope them under .home /
   .article-page, so they are repeated here, scoped to this page). Decorative:
   the placeholder is aria-hidden. */
.listing-page .ph {
  display: grid;
  place-items: center;
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--fs-caption);
  line-height: var(--lh-ui);
}

.listing-page .ph--alt {
  background-color: var(--color-border);
}

.listing-page .sample-badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3) 0;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  font-size: var(--fs-meta);
  line-height: var(--lh-ui);
}

/* ---- Card parts ------------------------------------------------------------------------- */
.listing-page .listing-card__tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* Nastaliq ascenders rise above the line box: keep air between the tags and the
   headline (same reason as .card__title on the homepage). */
.listing-page .card__title {
  margin-block-start: var(--space-1);
  font-size: var(--fs-section);
}

/* Author, date and reading time: wrap as separate items. The shared .meta
   adds a "·" before each item, which would land at the start of a wrapped
   line, so separation here is spacing only (as in the article header). */
.listing-page .card__meta {
  column-gap: var(--space-4);
}

.listing-page .meta > * + *::before {
  content: none;
}

/* ---- Search page ----------------------------------------------------------------------
   Same page shell as a listing (.listing-page). The results are built by js/search.js. */
.search-page .search {
  max-inline-size: var(--container-narrow);
  padding-block-end: var(--space-12);
}

.search-page .search-form__row {
  display: flex;
  gap: var(--space-3);
}

.search-page .search-form__input {
  flex: 1 1 auto;
  min-inline-size: 0;                  /* lets the field shrink next to the button on a 360px phone */
}

.search-page .search-form__row .btn {
  padding-inline: var(--space-4);
}

.search-page .search__status {
  min-block-size: 1.5em;
  margin-block: var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--fs-meta);
  line-height: var(--lh-ui);
}

.search-page .search__results {
  display: grid;
  gap: var(--space-4);
}

.search-page .search-result {
  padding-block-end: var(--space-4);
  border-block-end: var(--border);
}

.search-page .search-result__heading {
  font-size: var(--fs-section);
  line-height: var(--lh-heading);
}

.search-page .search-result__meta {
  margin-block-start: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--fs-meta);
}

.search-page .search-result__excerpt {
  margin-block-start: var(--space-2);
}

/* ---- Author pages (Session 18) ---------------------------------------------------------
   /authors lists everyone with a published story (the same cards as a listing, without an image);
   /authors/<id> shows one author above their stories. Same page shell as a listing (.listing-page);
   logical properties only, so the Urdu edition mirrors without extra rules. */
.listing-page .author-head__back {
  margin-block-end: var(--space-3);
  font-size: var(--fs-meta);
  line-height: var(--lh-ui);
}

.listing-page .author-head__back a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-block-size: var(--tap-target);              /* touch target, though the link is small text */
}

.listing-page .author-head__role {
  margin-block-start: var(--space-2);
  color: var(--color-text-muted);
}

.listing-page .author-head__bio {
  max-inline-size: var(--container-narrow);       /* reading width */
  margin-block-start: var(--space-3);
}

.listing-page .author-head__count {
  margin-block-start: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--fs-meta);
  line-height: var(--lh-ui);
}

.listing-page .authors-invite {
  max-inline-size: var(--container-narrow);
  padding-block-end: var(--space-12);
}
