/*
 * Success stories as vertical reel cards (Instagram-style 9:16), shared by the Arabic and English
 * home pages. The cards sit in one row that scrolls sideways with snap points; js/home-page.js
 * fills #storiesContainer and wires play / previous / next.
 */

:root {
  --reel-red: var(--primary, #a30b00);
  --reel-ink: #16181d;
  --reel-muted: #5b606c;
  --reel-line: rgba(46, 50, 27, 0.18);
  /* 230px wide = 409px tall video, so a whole card (video + text) fits on a laptop screen. */
  --reel-card-width: 230px;
}

/* Header row: title on one side, arrows on the other (arrows hide when everything fits). */
.eh-reels-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.eh-reels-nav { display: flex; gap: 0.5rem; margin-bottom: 2.5rem; }
.eh-reels-nav[hidden] { display: none; }
.eh-reels-nav button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--reel-line);
  background: #fff;
  color: var(--reel-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.eh-reels-nav button:hover { border-color: var(--reel-red); color: var(--reel-red); }
/* Arrow icons point the reading direction on right-to-left pages. */
[dir="rtl"] .eh-reels-nav i { transform: scaleX(-1); }

/* The row: one line of cards, swipe on phones, snap to each card. */
.eh-reels {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 4px;
  padding: 4px 4px 16px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

/* One card. */
.eh-reel {
  flex: 0 0 var(--reel-card-width);
  scroll-snap-align: start;
  background: #fff;
  border: 1px solid var(--reel-line);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(22, 24, 29, 0.06);
}

/* 9:16 frame: video, image or quote. Landscape videos are shown whole with dark bars (contain). */
.eh-reel__frame {
  position: relative;
  aspect-ratio: 9 / 16;
  background: #111;
}
.eh-reel__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111;
}
img.eh-reel__video { object-fit: cover; }

/* Round play button in the middle of the poster; hidden once the reel plays. */
.eh-reel__play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.92);
  color: var(--reel-red);
  font-size: 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}
.eh-reel__play:hover { transform: scale(1.06); }
.eh-reel__play:disabled { opacity: 0.7; }
.eh-reel__play i { margin-inline-start: 4px; } /* the play triangle looks centred this way */
.eh-reel__frame.is-playing .eh-reel__play,
.eh-reel__frame.is-playing .eh-reel__badge { display: none; }

/* Badge on top of the frame. */
.eh-reel__badge {
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  max-width: calc(100% - 24px);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--reel-red);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Text-only stories: a quote filling the frame. */
.eh-reel__quote {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 2rem 1.5rem;
  display: flex;
  align-items: center;
  background: linear-gradient(160deg, var(--reel-red), #6f0700);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.7;
}

/* Under the frame: who, title, short text (cut to 3 lines so cards stay the same height). */
.eh-reel__body { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.eh-reel__who { display: flex; align-items: center; gap: 10px; color: var(--reel-ink); }
.eh-reel__avatar {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(163, 11, 0, 0.1);
  color: var(--reel-red);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.eh-reel__title { font-size: 1rem; font-weight: 800; line-height: 1.5; margin: 4px 0 0; color: var(--reel-ink); }
.eh-reel__text {
  margin: 0;
  color: var(--reel-muted);
  font-size: 0.92rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Phones: a bit narrower so the next card peeks in and invites a swipe. */
@media (max-width: 575.98px) {
  :root { --reel-card-width: 72vw; }
  .eh-reels-nav { display: none; }
}
