/* =========================
   Story Single - Premium Stable Layout (Best & Robust)
   - Strong responsive behavior
   - Prevents overflow from long text/URLs
   - Safe handling for WYSIWYG content (images/tables/iframes)
   - No dependencies, performance-friendly
   ========================= */

.story-single {
  --max: 1120px;
  --content: 780px;
  --radius: 16px;

  --line: rgba(17, 24, 39, 0.10);
  --muted: rgba(17, 24, 39, 0.70);
  --text: rgba(17, 24, 39, 0.92);
  --bg-soft: rgba(17, 24, 39, 0.03);

  color: var(--text);
}

/* Prevent any children from causing horizontal scroll */
.story-single,
.story-single * {
  box-sizing: border-box;
}

.story-single .story {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px 18px 60px;
}

/* Safe overflow handling for long strings */
.story-single .story,
.story-meta-card__value,
.story-richtext {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Section heads */
.story-section__head {
  max-width: var(--max);
  margin: 0 auto 14px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.story-section__title {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.2px;
}

/* =========================
   HERO
   ========================= */
.story-hero {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 22px;
  align-items: start;
  margin-bottom: 26px;
  min-width: 0; /* prevents grid overflow */
}

.story-hero--text-only {
  grid-template-columns: minmax(0, 780px);
  justify-content: center;
}

.story-hero__media {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  min-width: 0;
}

.story-hero__img {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.story-hero__content {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.story-hero__title {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.3px;
}

/* Meta card */
.story-meta-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.story-meta-card__row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.story-meta-card__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 8px 0 2px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.story-meta-card__item {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.story-meta-card__label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.2px;
}

.story-meta-card__value {
  font-size: 14px;
  line-height: 1.45;
  min-width: 0;
}

/* =========================
   BODY / RICHTEXT
   ========================= */
.story-body {
  margin: 6px 0 26px;
}

.story-body__inner {
  max-width: var(--content);
  margin: 0 auto;
  min-width: 0;
}

.story-richtext {
  font-size: 16px;
  line-height: 1.85;
  color: var(--text);
}

/* richtext spacing */
.story-richtext > *:first-child { margin-top: 0; }
.story-richtext > *:last-child { margin-bottom: 0; }

.story-richtext p { margin: 0 0 14px; }
.story-richtext h2,
.story-richtext h3 {
  margin: 22px 0 10px;
  line-height: 1.35;
  letter-spacing: -0.2px;
}
.story-richtext h2 { font-size: 20px; }
.story-richtext h3 { font-size: 17px; }

.story-richtext ul,
.story-richtext ol {
  margin: 10px 0 16px 18px;
  padding: 0;
}

.story-richtext li { margin: 6px 0; }

.story-richtext blockquote {
  margin: 16px 0;
  padding: 10px 14px;
  border-left: 3px solid rgba(17, 24, 39, 0.18);
  background: rgba(17, 24, 39, 0.03);
  border-radius: 10px;
}

.story-richtext a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Make WYSIWYG media stable */
.story-richtext img,
.story-richtext video,
.story-richtext iframe,
.story-richtext embed,
.story-richtext object {
  max-width: 100%;
  height: auto;
}

.story-richtext figure {
  max-width: 100%;
  margin: 16px 0;
}

.story-richtext table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.story-richtext td,
.story-richtext th {
  border: 1px solid var(--line);
  padding: 8px 10px;
}

/* =========================
   PHOTOS
   ========================= */
.story-gallery {
  margin: 10px 0 30px;
}

.story-gallery__grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, 1fr);
  min-width: 0;
}

.story-photo {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  min-width: 0;
}

.story-photo__img {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--bg-soft);
}

.story-photo__cap {
  padding: 10px 12px 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  border-top: 1px solid var(--line);
}

/* =========================
   VIDEOS
   ========================= */
.story-videos {
  margin: 10px 0 10px;
}

.story-videos__list {
  max-width: var(--content);
  margin: 0 auto;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.story-video {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  min-width: 0;
}

.story-video__label {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

/* oEmbed wrapper becomes responsive */
.story-video__embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
}

.story-video__embed iframe,
.story-video__embed video,
.story-video__embed embed,
.story-video__embed object {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* MP4 player */
.story-video__player video {
  width: 100%;
  height: auto;
  display: block;
  background: var(--bg-soft);
}

/* fallback link */
.story-video__link {
  display: block;
  padding: 14px 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 980px) {
  .story-hero {
    grid-template-columns: 1fr;
  }
  .story-hero__title {
    font-size: 26px;
  }
  .story-gallery__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .story-single .story {
    padding: 22px 14px 52px;
  }
  .story-hero__title {
    font-size: 22px;
  }
  .story-meta-card__row {
    grid-template-columns: 1fr;
  }
  .story-meta-card__grid {
    grid-template-columns: 1fr;
  }
  .story-gallery__grid {
    grid-template-columns: 1fr;
  }
}
