/* =========================================================================
   story-shared.css — SINGLE SOURCE OF TRUTH for news story rendering.
   Used by:
     - Admin Editor  (admin.html -> .news-story-canvas)
     - Final Preview (admin.html -> .news-story-canvas[data-news-story-readonly])
     - Published Story (news-story.html -> .story-shell)
   The story CSS below must NOT be mirrored or copied into any other file.
   ========================================================================= */

/* Layout ------------------------------------------------------------------ */
.story-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-areas: "main sidebar";
  gap: clamp(28px, 4vw, 48px);
  align-items: start;
  max-width: 1120px;
  margin-inline: auto;
}

.story-main-col {
  grid-area: main;
  min-width: 0;
}

.story-sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

/* Head -------------------------------------------------------------------- */
.story-head.story-head-feature {
  display: block;
  padding: 4px 0 26px;
}

.story-head-copy {
  min-width: 0;
  max-width: 680px;
  direction: ltr;
  text-align: left;
}

html[dir="rtl"] .story-head-copy,
.story-head-copy[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

.story-head-copy[dir="ltr"] {
  direction: ltr;
  text-align: left;
}

.story-back-top {
  margin: 0 0 16px;
}

.story-back-top a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0;
  border-radius: 0;
  color: #071126;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.story-back-top a::before {
  content: "\2190";
  display: inline-block;
  margin-inline-end: 9px;
  font-size: 16.3px;
  line-height: 1;
  vertical-align: -1px;
}

html[dir="rtl"] .story-back-top a::before,
.story-back-top a[dir="rtl"]::before {
  content: "\2192";
}

.story-kicker {
  display: none;
}

.story-title {
  max-width: 680px;
  margin: 0;
  color: #071126;
  font-size: clamp(21.1px, 2.6vw, 26px);
  line-height: 1.35;
  letter-spacing: -.02em;
  font-weight: 800;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

html[dir="rtl"] .story-title,
.story-title[dir="rtl"] {
  font-size: clamp(20.3px, 2.5vw, 24.4px);
  line-height: 1.42;
  letter-spacing: 0;
}

.story-summary {
  max-width: 680px;
  margin: 14px 0 0;
  color: #3a4c66;
  font-size: 13.8px;
  line-height: 1.8;
  font-weight: 500;
  overflow-wrap: anywhere;
}

html[dir="rtl"] .story-summary,
.story-summary[dir="rtl"] {
  line-height: 1.85;
}

.story-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  color: #3a4c66;
  font-size: 12.2px;
  margin-top: 18px;
}

.story-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #3a4c66;
  font-weight: 600;
}

.story-meta-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #071126;
  font-size: 14.6px;
  line-height: 1;
}

.story-meta-separator {
  width: 1px;
  height: 26px;
  background: rgba(15, 23, 42, .28);
  display: inline-block;
}

/* Hero media -------------------------------------------------------------- */
.story-media {
  position: relative;
  margin: 0 auto 26px;
  max-width: 680px;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(11, 31, 58, .08);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(7, 17, 38, .16);
  overflow: hidden;
  background: #e8edf3;
}

.story-media::after {
  display: none;
}

.story-media img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  object-fit: cover;
  border-radius: 0;
}

.story-media-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  color: #657287;
  text-align: center;
  background: #eef2f7;
}

/* Body -------------------------------------------------------------------- */
.story-body {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 6px 0 34px;
  display: grid;
  gap: 18px;
  font-size: var(--story-reading-size, 13px);
  line-height: 1.8;
  color: #10213a;
  transition: font-size .18s ease;
}

/* A floated media item cannot wrap following text while it is a direct grid
   item. Switch only stories that explicitly request square wrapping to normal
   block flow; stories without floating media keep the existing grid rhythm. */
.story-body:has(> figure.acw-media[data-media-layout="floating"][data-media-wrap="square"]:not([data-media-side="center"])) {
  display: flow-root;
}

.story-body:has(> figure.acw-media[data-media-layout="floating"][data-media-wrap="square"]:not([data-media-side="center"]))
  > :not(:first-child):not(figure.acw-media) {
  margin-top: 18px;
}

.story-body:has(> figure.acw-media[data-media-layout="floating"][data-media-wrap="square"]:not([data-media-side="center"]))
  > h2:not(:first-child) {
  margin-top: 26px;
}

.story-body:has(> figure.acw-media[data-media-layout="floating"][data-media-wrap="square"]:not([data-media-side="center"]))
  > :is(h3, h4):not(:first-child) {
  margin-top: 22px;
}

.story-body p,
.story-body h2,
.story-body h3,
.story-body h4,
.story-body blockquote,
.story-body ul,
.story-body ol {
  margin: 0;
  min-width: 0;
}

.story-body h2 {
  margin-top: 8px;
  font-size: 1.55em;
  line-height: 1.4;
  font-weight: 900;
  color: #10213a;
}

.story-body h3,
.story-body h4 {
  margin-top: 4px;
  font-size: 1.28em;
  line-height: 1.45;
  font-weight: 850;
  color: #10213a;
}

.story-body ul,
.story-body ol {
  display: grid;
  gap: 8px;
  padding-inline-start: 1.45em;
}

.story-body li {
  padding-inline-start: 2px;
}

.story-body blockquote {
  padding: 14px 18px;
  border-inline-start: 4px solid var(--gold, #d4a64a);
  border-radius: 16px;
  background: #fff8e9;
  color: #304156;
}

.story-body a {
  color: #0b4f8f;
  text-decoration: underline;
  text-underline-offset: 4px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.story-body strong,
.story-body b {
  font-weight: 900;
  color: #0b1f3a;
}

.story-body em,
.story-body i {
  font-style: italic;
}

.story-body > * {
  max-width: 100%;
  min-width: 0;
}

.story-body .acw-text-xs { font-size: .8em; }
.story-body .acw-text-s { font-size: .92em; }
.story-body .acw-text-m { font-size: 1em; }
.story-body .acw-text-l { font-size: 1.1em; }
.story-body .acw-text-xl { font-size: 1.22em; }
.story-body .acw-text-2xl { font-size: 1.38em; }
.story-body .acw-text-accent { color: #1f5c9c; }
.story-body .acw-text-muted { color: #657287; }
.story-body .acw-text-strong { color: #182033; }
.story-body .acw-highlight-warm { background: #fff2c9; }
.story-body .acw-highlight-cool { background: #dff0ff; }
.story-body .acw-align-start { text-align: start; }
.story-body .acw-align-center { text-align: center; }
.story-body .acw-align-end { text-align: end; }
.story-body .acw-align-justify { text-align: justify; }

.story-body .acw-block-lead-intro {
  font-size: 1.16em;
  line-height: 2;
  color: #1e2d4b;
}

.story-body .acw-block-highlight-box,
.story-body .acw-block-alert-note,
.story-body .acw-block-fact-card {
  padding: 14px 16px;
  border-radius: 18px;
}

.story-body .acw-block-highlight-box {
  background: #f8fbff;
  border: 1px solid #dbe6f5;
}

.story-body .acw-block-alert-note {
  background: #fff8ec;
  border: 1px solid #f0d598;
}

.story-body .acw-block-quote-feature {
  padding: 16px 18px;
  border-inline-start: 4px solid var(--gold, #d4a64a);
  background: #fffaf0;
  border-radius: 18px;
}

.story-body .acw-block-fact-card {
  background: #f3f6fb;
  border: 1px solid #dbe3ef;
}

.story-body::after {
  content: "";
  display: block;
  clear: both;
}

.story-body figure.acw-media {
  display: grid;
  gap: 10px;
  margin: 8px 0;
  max-width: min(100%, var(--acw-media-width, 760px));
  min-width: 0;
  overflow: visible;
  clear: both;
}

.story-body .acw-media-size-25 { max-width: min(100%, var(--acw-media-width, min(25%, 220px))); }
.story-body .acw-media-size-50 { max-width: min(100%, var(--acw-media-width, min(50%, 420px))); }
.story-body .acw-media-size-75 { max-width: min(100%, var(--acw-media-width, min(75%, 620px))); }
.story-body .acw-media-size-100,
.story-body .acw-media-align-full { max-width: min(100%, var(--acw-media-width, 100%)); }
.story-body .acw-media-align-start { margin-inline-end: auto; }
.story-body .acw-media-align-center { margin-inline: auto; }
.story-body .acw-media-align-end { margin-inline-start: auto; }

.story-body .acw-media img,
.story-body .acw-media video,
.story-body .acw-media audio,
.story-body .acw-media iframe {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 0;
}

.story-body .acw-media img,
.story-body .acw-media video,
.story-body .acw-media iframe {
  border-radius: 18px;
}

.story-body .acw-media-inline img {
  border-radius: 14px;
}

.story-body .acw-media-card,
.story-body .acw-media-feature,
.story-body .acw-player-card {
  padding: 12px;
  border-radius: 20px;
  background: #f8fbff;
  border: 1px solid #dfe8f3;
  box-shadow: 0 10px 24px rgba(16, 33, 58, .06);
}

.story-body .acw-media-feature {
  padding: 14px;
  box-shadow: 0 16px 30px rgba(29, 43, 72, .08);
}

.story-body .acw-media figcaption {
  color: #66758c;
  font-size: 11.4px;
  line-height: 1.8;
}

/* Social embed cards (pasted links) --------------------------------------- */
.story-body .acw-media-social { max-width: 100%; }
.story-body .acw-media-social .acw-social-embed-body { display: grid; gap: 14px; padding: 14px; border-radius: 18px; border: 1px solid #dfe8f3; background: #f8fbff; }
.story-body .acw-media-social .acw-social-embed-media { display: block; border-radius: 14px; overflow: hidden; background: #eef3fa; }
.story-body .acw-media-social .acw-social-thumb { display: block; width: 100%; max-height: 420px; object-fit: cover; border-radius: 0; }
.story-body .acw-media-social .acw-social-embed-media-empty { display: grid; place-items: center; min-height: 120px; }
.story-body .acw-media-social .acw-social-media-fallback { color: #637286; font-size: 11.4px; font-weight: 700; letter-spacing: .3px; }
.story-body .acw-media-social .acw-social-embed-content { display: grid; gap: 8px; justify-items: center; text-align: center; }
.story-body .acw-media-social .acw-social-embed-link { color: #1e4fd6; font-weight: 700; font-size: 13px; line-height: 1.7; text-decoration: none; word-break: break-word; }
.story-body .acw-media-social .acw-social-embed-link:hover { text-decoration: underline; }
.story-body .acw-media-social .acw-social-author { color: #24344d; font-size: 11.4px; font-weight: 600; }
.story-body .acw-media-social .acw-social-editorial { color: #3c4c66; font-size: 12.2px; line-height: 1.9; }
.story-body .acw-media-social .acw-social-credit { color: #637286; font-size: 10.6px; }
.story-body .acw-media-social .acw-social-stats { display: inline-flex; gap: 16px; justify-content: center; color: #637286; font-size: 10.6px; }
.story-body .acw-media-social .acw-social-stat { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.story-body .acw-media-social .acw-social-stat svg { width: 15px; height: 15px; flex: 0 0 auto; }
.story-body .acw-media-social .acw-social-share { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 18px; border: 1px solid #cdd9ea; border-radius: 999px; background: #fff; color: #1e2d4b; font-size: 10.6px; font-weight: 600; text-decoration: none; cursor: pointer; }
.story-body .acw-media-social .acw-social-share:hover { background: #f3f7ff; }
.story-body .acw-media-social .acw-social-share svg { width: 15px; height: 15px; flex: 0 0 auto; }

/* Related stories --------------------------------------------------------- */
.story-related {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 16px;
  border-top: 1px solid var(--line, rgba(11, 31, 58, .12));
  background: #fbfaf7;
  border-radius: 16px;
  display: grid;
  gap: 18px;
}

.story-related[hidden] {
  display: none !important;
}

.story-related-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.story-related-head h2 {
  margin: 0;
  font-size: 14.6px;
  line-height: 1.25;
}

.story-related-head span {
  color: var(--muted, #667488);
  font-size: 11.4px;
  font-weight: 700;
}

.story-related-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.story-related-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line, rgba(11, 31, 58, .12));
  border-radius: 12px;
  background: #fff;
  text-decoration: none;
  color: inherit;
}

.story-related-card img {
  width: 96px;
  height: 100%;
  min-height: 72px;
  object-fit: cover;
  display: block;
}

.story-related-card-thumb-empty {
  width: 96px;
  min-height: 72px;
  background: #e8edf3;
  display: block;
}

.story-related-card strong {
  padding: 10px 12px;
  font-size: 11.4px;
  line-height: 1.55;
  align-self: center;
}

.story-back-top a:focus-visible,
.story-related-card:focus-visible {
  outline: 3px solid rgba(212, 166, 74, .58);
  outline-offset: 3px;
}

/* Responsive -------------------------------------------------------------- */
@media (max-width: 1100px) {
  .story-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "main" "sidebar";
    gap: 26px;
  }

  .story-sidebar {
    order: 2;
  }

  .story-title,
  html[dir="rtl"] .story-title,
  .story-title[dir="rtl"] {
    font-size: clamp(19.5px, 5vw, 24.4px);
    line-height: 1.4;
  }

  .story-summary {
    font-size: 13px;
  }
}

@media (max-width: 900px) {
  .story-title,
  html[dir="rtl"] .story-title,
  .story-title[dir="rtl"] {
    font-size: clamp(17.9px, 6vw, 22.8px);
    line-height: 1.42;
  }

  .story-summary {
    font-size: 13px;
  }

  .story-media {
    margin: 0 auto 22px;
    border-radius: 14px;
  }

  .story-body {
    padding: 4px 0 28px;
  }
}

@media (max-width: 768px) {
  .story-body:has(> figure.acw-media[data-media-layout="floating"][data-media-wrap="square"]:not([data-media-side="center"])) {
    display: grid;
  }

  .story-body:has(> figure.acw-media[data-media-layout="floating"][data-media-wrap="square"]:not([data-media-side="center"]))
    > :not(:first-child):not(figure.acw-media) {
    margin-top: 0;
  }

  .story-body:has(> figure.acw-media[data-media-layout="floating"][data-media-wrap="square"]:not([data-media-side="center"]))
    > h2:not(:first-child) {
    margin-top: 8px;
  }

  .story-body:has(> figure.acw-media[data-media-layout="floating"][data-media-wrap="square"]:not([data-media-side="center"]))
    > :is(h3, h4):not(:first-child) {
    margin-top: 4px;
  }

  .story-body figure.acw-media {
    float: none !important;
    margin-inline: 0 !important;
    max-width: 100% !important;
    transform: none !important;
  }
}

@media (max-width: 620px) {
  .story-head.story-head-feature,
  html[dir="rtl"] .story-head.story-head-feature {
    padding-inline: 10px;
  }

  .story-title,
  html[dir="rtl"] .story-title,
  .story-title[dir="rtl"] {
    font-size: clamp(17.1px, 7vw, 20.3px);
  }

  .story-summary {
    margin-top: 12px;
    font-size: 13px;
  }

  .story-meta {
    margin-top: 16px;
    gap: 12px;
    font-size: 11.4px;
  }

  .story-media {
    margin: 0 auto 18px;
    border-radius: 12px;
  }

  .story-related {
    padding: 14px;
  }

  .story-related-card strong {
    font-size: 11.4px;
  }

  .story-body {
    padding-inline: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-body {
    transition: none;
  }
}
