/*!
 * Albourse — article pages (news/<slug>.html, generated by scripts/publish-news.mjs)
 * Section-tinted hero (.page-hero) · Markazi headline · byline + share · cover photo · .prose body ·
 * source box · tags · share bar · «الأحدث» rail · related news.  Tokens only (both themes).
 */

/* ---------- layout ---------- */
/* one measure for every block of the main column (body text, source box, tags, share bar, note), so their
   edges line up whatever their font size: 46rem = the 70ch the 17.5px body text had */
.story { --container: 1140px; --story-measure: 46rem; padding-bottom: 0; }
.story .page-hero { --accent: inherit; --accent-ink: inherit; --accent-soft: inherit; padding-bottom: clamp(26px, 3vw, 40px); }
.story__grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: clamp(28px, 4vw, 56px); align-items: start;
  padding-top: clamp(26px, 3vw, 40px);
}
.story__main { min-width: 0; }
.story__aside { position: sticky; top: calc(var(--header-h) + 20px); min-width: 0; }

/* ---------- hero: crumbs, kicker, headline, dek, meta ---------- */
.story-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: var(--sp-5); }
.story-kicker .cat { min-height: 30px; padding: 3px 12px; font-size: 13px; }
.story-kicker .cat:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.story-flag { min-height: 30px; padding: 3px 11px 3px 12px; gap: 5px; border-radius: var(--radius-pill); font-size: 13px; letter-spacing: 0; }
.story-flag .icon { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.story-kicker__own { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.story-kicker__own .dot { width: 6px; height: 6px; box-shadow: none; background: var(--text-3); }
.story-title {
  margin-top: var(--sp-4); max-width: 23em; overflow-wrap: break-word;
  font-family: var(--font-serif); font-weight: 700; font-size: clamp(31px, 1.8vw + 19px, 52px); line-height: 1.42; color: var(--text);
}
.story-dek { margin-top: var(--sp-4); max-width: 62ch; overflow-wrap: break-word; font-size: clamp(17px, .35vw + 15px, 19.5px); line-height: 1.85; color: var(--text-2); }
.story-meta {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px;
  margin-top: var(--sp-6); padding-top: var(--sp-5); border-top: 1px solid var(--border);
}
.story-byline { display: flex; align-items: center; gap: 12px; min-width: 0; }
.story-avatar {
  flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; overflow: hidden;
  background: var(--accent-soft, var(--surface-3)); color: var(--accent-ink, var(--text)); font-family: var(--font-head); font-size: 19px; font-weight: 800; line-height: 1;
}
.story-avatar--brand { background: none; border-radius: 28.125%; box-shadow: 0 8px 20px -10px rgba(23, 195, 176, .45); } /* the «الب» tile (rx 18 of 64) */
.story-avatar--brand svg { width: 46px; height: 46px; }
.story-byline__text { min-width: 0; }
.story-byline__name { font-size: 15.5px; font-weight: 700; line-height: 1.45; color: var(--text); }
.story-when { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 13.5px; line-height: 1.6; color: var(--text-3); }
.story-when time { color: var(--text-2); }
.story-when__sep { opacity: .7; }
.story-meta__end { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.story-read { min-height: 32px; padding-inline: 12px; }

/* ---------- share buttons ---------- */
.story-share__btns, .story-share--compact { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.share-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-family: var(--font-body); font-size: 14px; font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease);
}
.share-btn:hover { background: var(--surface-3); border-color: var(--text-3); }
.share-btn:active { transform: scale(.97); }
.share-btn .icon, .share-ico { width: 18px; height: 18px; flex: none; }
.share-ico--line { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.share-btn.is-done { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 45%, transparent); }
.share-btn--native { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.share-btn--native:hover { background: var(--brand); border-color: transparent; opacity: .92; }
.story-share--compact .share-btn { width: 40px; min-height: 40px; height: 40px; padding: 0; background: var(--surface); }
.story-share--compact .share-btn--native { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
/* the native share sheet is the primary action on phones only */
@media (hover: hover) and (pointer: fine) {
  .story-share--compact .share-btn--native { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
  .story-share--compact .share-btn--native:hover { background: var(--surface-3); opacity: 1; }
}
.story-share--compact .share-btn .icon, .story-share--compact .share-ico { width: 17px; height: 17px; }
.story-share--compact .share-btn.is-done { width: auto; padding: 0 12px; font-size: 13px; }

/* ---------- cover photo ---------- */
.story-cover { margin: 0 0 var(--sp-8); }
.story-cover__frame {
  position: relative; isolation: isolate; overflow: hidden; border-radius: var(--radius-xl);
  background: var(--img-fallback); box-shadow: var(--shadow); max-height: min(78vh, 720px); margin-inline: auto;
}
.story-cover__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.story-cover--contain .story-cover__img { object-fit: contain; }
/* portrait / unknown-ratio photos: the same picture, blurred, fills the frame behind the whole photo */
.story-cover__bg { position: absolute; inset: -6%; width: 112%; height: 112%; max-width: none; object-fit: cover; filter: blur(30px) saturate(1.15); opacity: .6; z-index: -1; }
.story-cover__caption { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; font-size: var(--fs-sm); line-height: 1.75; color: var(--text-3); overflow-wrap: break-word; }
.story-cover__caption .icon { width: 16px; height: 16px; margin-top: 3px; }

/* ---------- body ---------- */
/* break-word: a long token (a wallet address, a tx hash, a long #hashtag) wraps instead of widening the page */
.story-body { max-width: var(--story-measure); overflow-wrap: break-word; }
.story-body > :first-child { margin-top: 0; }
.story-body a:not([class]) { overflow-wrap: anywhere; }
.story-body .story-figure { margin: 1.9em 0; }
.story-figure img { width: 100%; height: auto; border-radius: var(--radius-lg); background: var(--img-fallback); box-shadow: var(--shadow-sm); }
.story-figure--portrait img { width: auto; max-width: 100%; max-height: min(78vh, 720px); margin-inline: auto; }
.story-figure figcaption { margin-top: 10px; font-size: var(--fs-sm); line-height: 1.75; color: var(--text-3); }
.story-figure--portrait figcaption { text-align: center; }
.story-body .story-table { margin: 1.6em 0; font-size: 15px; }
.story-body .story-table .table { font-size: 14.5px; }
.story-code { margin: 1.6em 0; padding: 16px 18px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); overflow-x: auto; font-size: 14px; line-height: 1.7; text-align: left; }
.story-body hr { margin: 2.2em 0; }
.story-body blockquote p + p { margin-top: .6em; }
.story-body del { color: var(--text-3); }

/* ---------- after the body: source, tags, share, note ---------- */
.story-source {
  position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 14px;
  max-width: var(--story-measure); margin-top: var(--sp-8); padding: 14px 18px 14px 16px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast), background-color var(--t-fast);
}
.story-source:hover { border-color: var(--border-strong); background: var(--surface-2); }
.story-source__icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--accent-soft, var(--surface-3)); color: var(--accent-ink, var(--text-2)); }
.story-source__label { font-size: 12.5px; font-weight: 600; line-height: 1.5; color: var(--text-3); }
.story-source__link { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 16px; font-weight: 700; line-height: 1.5; color: var(--text); text-decoration: none; }
.story-source__link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.story-source__link:focus-visible { outline: none; }
.story-source__link:focus-visible::after { outline: 2px solid var(--focus); outline-offset: 3px; }
.story-source__host { font-size: 13px; font-weight: 500; color: var(--text-3); }
.story-source__go { color: var(--text-3); transition: transform var(--t-med) var(--ease-spring); }
.story-source:hover .story-source__go { transform: translateX(-4px); color: var(--text); }
.story-tags { display: flex; flex-wrap: wrap; gap: 8px; max-width: var(--story-measure); margin: var(--sp-6) 0 0; padding: 0; list-style: none; }
.story-tags .tag { min-height: 28px; padding: 2px 11px; border-radius: var(--radius-pill); font-size: 13px; }
.story-share--end {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 20px;
  max-width: var(--story-measure); margin-top: var(--sp-8); padding: 18px 20px; border-radius: var(--radius-lg);
  background: var(--accent-soft, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--accent, var(--text-3)) 22%, transparent);
}
.story-share__title { font-family: var(--font-head); font-size: 18px; font-weight: 700; line-height: 1.4; }
.story-share--end .share-btn { background: var(--surface); }
.story-share--end .share-btn:hover { background: var(--surface-2); }
.story-share--end .share-btn--native { background: var(--brand); }
.story-note { display: flex; align-items: flex-start; gap: 8px; max-width: var(--story-measure); margin-top: var(--sp-5); font-size: 13px; line-height: 1.75; color: var(--text-3); }
.story-note .icon { width: 16px; height: 16px; margin-top: 3px; color: var(--warn); }

/* ---------- «الأحدث» rail + related ---------- */
.story-latest .latest { padding: 18px 20px 8px; }
.story-latest .latest__title { font-size: 18px; }
.story-latest .latest__link { font-size: 16.5px; }
.story-related { grid-column: 1 / -1; min-width: 0; margin-top: clamp(28px, 4vw, 48px); }
.story-related .section-head { margin-bottom: var(--sp-6); }
.story-related .section-head__title { font-size: var(--fs-2xl); }
[data-story-list][data-layout="grid"]:empty { min-height: 380px; }
[data-story-list][data-layout="latest"]:empty { min-height: 520px; }

/* ---------- responsive ---------- */
@media (max-width: 1099px) {
  .story__grid { grid-template-columns: minmax(0, 1fr); }
  .story__aside { position: static; order: 3; }
  .story-related { order: 2; }
  .story-latest .latest__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
  .story-latest .latest__item:nth-last-child(2) { border-bottom: 0; }
}
@media (max-width: 699px) {
  .story .page-hero { padding-top: 18px; }
  .story-kicker { margin-top: var(--sp-4); }
  .story-title { font-size: clamp(27px, 6.6vw + 2px, 34px); line-height: 1.45; }
  .story-dek { font-size: 16.5px; line-height: 1.8; }
  .story-meta { margin-top: var(--sp-5); padding-top: var(--sp-4); gap: 14px; }
  .story-meta__end { width: 100%; justify-content: space-between; }
  .story-when__sep { display: none; }
  .story-when__upd { flex-basis: 100%; }
  .story-avatar, .story-avatar--brand svg { width: 42px; height: 42px; }
  .story__grid { padding-top: 0; gap: var(--sp-10); }
  .story-cover { margin-inline: calc(var(--gutter) * -1); margin-bottom: var(--sp-6); }
  .story-cover__frame { border-radius: 0; box-shadow: none; max-height: 78vh; }
  .story-cover__caption { padding-inline: var(--gutter); }
  .story-figure img { border-radius: var(--radius); }
  .story-share--end { padding: 16px; }
  .story-share--end .story-share__btns { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .story-share--end .share-btn { padding: 0 10px; }
  .story-share--end .share-btn--native:not([hidden]) { grid-column: 1 / -1; }
  .story-latest .latest__list { display: flex; }
  .story-latest .latest__item:nth-last-child(2) { border-bottom: 1px solid var(--border); }
  .story-related .news-grid .ncard { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 10px; align-items: start; }
  .story-related .news-grid .ncard__media { border-radius: 11px; aspect-ratio: 1 / 1; }
  .story-related .news-grid .ncard__body { padding: 0; gap: 6px; }
  .story-related .news-grid .ncard__title { font-size: 17px; -webkit-line-clamp: 3; }
  .story-related .news-grid .ncard__summary { display: none; }
  .story-related .news-grid .nfb__glyph { width: 30px; height: 30px; top: 6px; inset-inline-start: 6px; border-radius: 9px; }
  .story-related .news-grid .nfb__glyph .icon { width: 16px; height: 16px; }
}
/* phones / touch: every tap target ≥ 44px (DESIGN.md) — the compact share buttons grow, the section chip keeps its
   look and gets a 44px hit area */
@media (max-width: 699px), (pointer: coarse) {
  .story-share--compact .share-btn { width: 44px; height: 44px; min-height: 44px; }
  .story-kicker .cat { position: relative; }
  .story-kicker .cat::after { content: ""; position: absolute; inset: -7px -4px; }
}
@media print {
  .story-share, .story__aside, .story-related, .story-note, .story-meta__end { display: none !important; }
  .story__grid { grid-template-columns: minmax(0, 1fr); }
  .story-cover__frame { max-height: 360px; }
}
