/* ==========================================================================
   Cross Kashmir — Article page
   Requires tokens, base, typography, layout, components (and header/footer
   for the page shell). Everything is scoped under .article-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.

   Breakpoints used: 640, 768 (same system as the rest of the site).

   Anatomy (every part is filled from a content field via data-field):

     <main class="article-page">
       <article class="article container">
         <header class="article-header">   category, title, excerpt, author, dates, readingTime
         <figure class="article-cover">    coverImage, coverImageAlt, coverCaption
         <div class="article-body prose">  body
         <footer class="article-footer">   tags, sharing
       </article>
       <section class="related">           relatedStories
     </main>

   Widths: the text column reuses --container-narrow (42rem = 672px, inside the
   650-760px reading target). The cover is wider than the text: the text width
   plus 2 x --space-12 (= 768px). No new raw maximum widths.
   ========================================================================== */

.article-page {
  --article-wide: calc(var(--container-narrow) + 2 * var(--space-12));   /* 48rem = 768px */
}

/* ---- Hidden parts and page states (Session 8) -------------------------------------
   (Session 8; the loader script is gone since Session 14, the parts are generated.)
   Template parts may be shown and hidden with the `hidden` attribute.
   Several of those parts set their own `display` (e.g. .article-meta > div), which
   would override the browser default, so hidden is made binding on this page. */
.article-page [hidden] {
  display: none !important;
}

/* Loading / not found / could not load: one centred reading-width block. */
.article-page .article-state {
  max-inline-size: var(--container-narrow);
  padding-block: var(--space-8);
}

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

@media (min-width: 768px) {
  .article-page .article-state {
    padding-block: var(--space-12);
  }
}

/* ---- Page rhythm ------------------------------------------------------------ */
/* The <article> is itself a .container, so it aligns with the header, the
   footer and every other page. Its children are centred at the reading width. */
.article-page .article {
  padding-block: var(--space-6) var(--space-8);
}

.article-page .article > * {
  max-inline-size: var(--container-narrow);
  margin-inline: auto;
}

.article-page .article > .article-cover {
  max-inline-size: var(--article-wide);
}

.article-page .article > * + * {
  margin-block-start: var(--space-6);
}

@media (min-width: 768px) {
  .article-page .article {
    padding-block: var(--space-8) var(--space-12);
  }

  .article-page .article > * + * {
    margin-block-start: var(--space-8);
  }
}

/* ---- Placeholder image and sample marker -------------------------------------
   Same look as the homepage placeholders (home.css scopes them under .home, so
   they are repeated here, scoped to this page). Decorative: aria-hidden. */
.article-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);
}

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

.article-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);
}

/* ---- Article header ----------------------------------------------------------- */
.article-page .article-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
}

.article-page .article-header > * {
  max-inline-size: 100%;
}

.article-page .article-header__tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* Nastaliq ascenders rise above the line box: keep air between the label and
   the headline (same reason as .hero__title / .card__title on the homepage). */
.article-page .article-header__title {
  margin-block-start: var(--space-2);
}

/* Author / dates / reading time: label over value, wraps as a block, no
   separator characters that could end up at the start of a wrapped line. */
.article-page .article-meta {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  margin-block-start: var(--space-2);
  padding-block: var(--space-3);
  border-block: var(--border);
}

.article-page .article-meta > div {
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
}

.article-page .article-meta dt {
  font-size: var(--fs-caption);
  line-height: var(--lh-ui);
  color: var(--color-text-muted);
}

.article-page .article-meta dd {
  margin: 0;
  font-size: var(--fs-meta);
  font-weight: var(--fw-medium);
  line-height: var(--lh-ui);
}

/* ---- Cover ---------------------------------------------------------------------- */
.article-page .article-cover__media {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* When a real photo replaces the placeholder (see the comment in the HTML) */
.article-page .article-cover__media img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}

.article-page .article-cover figcaption {
  margin-block-start: var(--space-2);
}

/* ---- Article body -----------------------------------------------------------------
   Rhythm, lists and blockquote base styles come from .prose (typography.css).
   Only what the article adds on top is here. */
.article-page .article-body {
  min-inline-size: 0;
}

.article-page .article-body > h2 {
  margin-block-start: var(--space-12);
}

.article-page .article-body > h2 + *,
.article-page .article-body > h3 + * {
  margin-block-start: var(--space-3);
}

.article-page .article-body blockquote {
  margin-block: var(--space-8);
  padding-block: var(--space-1);
  font-weight: var(--fw-medium);
}

/* Nastaliq has no italic design, so a browser would only slant it artificially.
   In the Urdu edition, <em> is shown with weight and colour instead. */
.article-page .article-body:lang(ur) em {
  font-style: normal;
  font-weight: var(--fw-medium);
  color: var(--color-primary);
}

/* ---- Article footer: tags + sharing --------------------------------------------- */
.article-page .article-footer {
  display: grid;
  gap: var(--space-6);
  padding-block-start: var(--space-6);
  border-block-start: var(--border);
}

.article-page .article-footer > * {
  margin: 0;                                   /* the grid gap sets the rhythm here */
}

.article-page .article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Tags are links to the search page. 44px tap target, and a hover/focus state so they read as clickable. */
.article-page .article-tags .tag--link {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
  padding-block: var(--space-1) 0;
}

.article-page .article-tags .tag--link:hover {
  background-color: var(--color-primary);
  color: var(--color-on-primary);
  text-decoration: underline;
}

.article-page .article-share__title {
  margin-block-end: var(--space-3);
  font-size: var(--fs-sub);
}

/* Share row: the platform links are always there; the two buttons that need JavaScript (device share sheet,
   copy link) carry [hidden] until js/share.js shows them, so nothing here is ever a control that does nothing. */
.article-page .article-share__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.article-page .article-share__list > [hidden] {
  display: none;
}

.article-page .article-share__status {
  min-block-size: 1.5em;               /* reserves the line so the "copied" message does not move the page */
  margin-block-start: var(--space-2);
}

/* ---- Related stories ----------------------------------------------------------------
   A full-width band under the article (same surface treatment as the homepage
   People band). Cards are the ordinary .card component; they are not links
   because no story pages exist yet. When they do, add .card--link and put an
   <a> inside .card__title (see components.css). */
.article-page .related {
  padding-block: var(--space-8);
  background-color: var(--color-surface);
  border-block: var(--border);
}

.article-page .related__title {
  position: relative;
  margin-block-end: var(--space-4);
  padding-block-end: var(--space-2);
  border-block-end: var(--border);
  font-size: var(--fs-section);
  line-height: var(--lh-heading);
}

.article-page .related__title::after {         /* gold tab, as in the homepage section headings */
  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 */
}

.article-page .related__grid {
  display: grid;
  gap: var(--space-4);
}

/* Phones: rows with a thumbnail (same pattern as the homepage "compact" card) */
.article-page .related .card {
  flex-direction: row;
}

.article-page .related .card__media {
  flex: 0 0 6.5rem;
  aspect-ratio: auto;
  min-block-size: 6.5rem;
}

.article-page .related .ph span {
  display: none;                               /* too small for a label */
}

.article-page .related .card__body {
  min-inline-size: 0;
  padding: var(--space-3);
}

.article-page .related .card__title {
  margin-block-start: var(--space-1);          /* Nastaliq ascenders, as on the homepage */
}

@media (min-width: 640px) {
  .article-page .related .card__media {
    flex-basis: clamp(6.5rem, 34%, 11rem);
  }
}

@media (min-width: 768px) {
  .article-page .related {
    padding-block: var(--space-12);
  }

  .article-page .related__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-6);
  }

  .article-page .related .card {
    flex-direction: column;
  }

  .article-page .related .card__media {
    flex: none;
    aspect-ratio: 16 / 9;
    min-block-size: 0;
  }

  .article-page .related .ph span {
    display: inline;
  }

  .article-page .related .card__body {
    padding: var(--space-4);
  }
}
