/* Updates & Stories carousel (Part 3, CC-1276).
   Sizes from the Figma components on the page "Phase 2 — Components":
   - Desktop "Updates & Stories Carousel" (1440 x 632): white, 1px maroon line
     at the top, heading 28/30 Medium 24px from the top and sides, arrows
     21 x 18 with a 12px gap at the right of the heading row, card row 78px
     from the top, cards 683px and 566px wide (alternating) with a 12px gap,
     images 390px high, then 24px, date 20/22 Bold capitals, 24px, title
     28/30 Medium. The row starts with a 12px strip of the previous card and
     the first full card 24px from the left.
   - Mobile "Mobile Updates and Stories" (430 wide): 24px padding at the top
     and bottom, heading 28/30 Medium with 12px side padding, 24px, cards
     302px wide with a 12px gap (first card 12px from the left), images
     302 x 390, then 24px, date 14/16 Medium capitals, 12px, title 20/22
     Medium, then 48px and the arrows at the left.
   Swiper's own stylesheet is not loaded; the few rules it needs are below. */

.stories-carousel {
    --stories-carousel-text: var(--ge-black-01, #542438);
    --stories-carousel-focus: var(--ge-black-01, #542438);
    position: relative;
    display: flex; flex-direction: column;
    padding: 24px 0;
    border-top: 1px solid var(--stories-carousel-text);
    background: #fff;
    color: var(--stories-carousel-text);
}
.stories-carousel h2,
.stories-carousel h3,
.stories-carousel p { color: inherit; }
.stories-carousel a { color: inherit; text-decoration: none; }
.stories-carousel a:focus-visible,
.stories-carousel button:focus-visible { outline: 2px solid var(--stories-carousel-focus); outline-offset: 2px; }

.stories-carousel__title {
    margin: 0; padding: 0 12px;
    font-size: 28px; line-height: 30px; font-weight: 500; letter-spacing: 0;
}

/* Swiper core rules (from swiper-bundle.css, only what this block uses).
   The site stylesheet adds 10px padding to every .swiper and a 24px gap to
   every .swiper-wrapper; !important removes them here, because Swiper sets
   the 12px space between cards itself. The left padding puts the first full
   card 12px (mobile) or 24px (desktop) from the edge; with the loop, the end
   of the previous card shows in that padding, as in Figma. */
.stories-carousel .swiper { position: relative; overflow: hidden; list-style: none; padding: 0 0 0 12px !important; z-index: 1; margin-top: 24px; }
/* Let the phone scroll the page up and down, and give sideways swipes to the
   carousel. Without this, Safari on iPhone treats a sideways swipe as a page
   gesture and cancels it, so only the arrows move the cards. Swiper's own
   stylesheet has this rule, but it does not reach the carousel on every page
   (10 Nov 2026: it worked on Innovation only), so set it here. */
.stories-carousel .swiper { touch-action: pan-y; }
/* The site stylesheet gives every .swiper "margin-left: auto; margin-right:
   auto". In this flex column that stops the box from stretching, so with few
   cards (no loop, for example Innovation with 3 stories) the box grew to the
   width of all the cards: the page scrolled sideways and Swiper hid the
   arrows. Keep the box at the width of the section. */
.stories-carousel .swiper { width: 100%; max-width: 100%; margin-left: 0 !important; margin-right: 0 !important; box-sizing: border-box; }
.stories-carousel .swiper-wrapper {
    position: relative; display: flex; width: 100%; height: 100%; z-index: 1;
    margin: 0; padding: 0; list-style: none; gap: 0 !important;
    transition-property: transform; transition-timing-function: ease; box-sizing: content-box;
}
.stories-carousel .swiper-slide { flex-shrink: 0; position: relative; height: auto; }
/* The 12px space between the cards is a margin set here, not by Swiper
   (spaceBetween is 0 in stories-carousel.js): the site stylesheet removes
   slide margins on the country pages (".ethiopia .swiper-slide
   { margin-right: 0 !important }") and limits slide images to half width
   (".ethiopia .swiper-slide img { max-width: 50% }"). Swiper measures each
   card with its margin, so the spacing is the same on every page. */
.stories-carousel .swiper-initialized .stories-carousel__slide.swiper-slide { margin-right: 12px !important; }
.stories-carousel .stories-carousel__slide.swiper-slide img { max-width: none; }
.stories-carousel .swiper-notification { position: absolute; left: 0; top: 0; pointer-events: none; opacity: 0; z-index: -1000; }
/* Before Swiper starts (and without JavaScript) the row scrolls sideways. */
.stories-carousel .swiper:not(.swiper-initialized) { overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-left: 12px; }
.stories-carousel .swiper:not(.swiper-initialized) .swiper-wrapper { gap: 12px !important; }
.stories-carousel .swiper:not(.swiper-initialized) .swiper-slide { scroll-snap-align: start; }

/* Site CSS adds list bullets to li elements. */
.stories-carousel__slide { list-style: none; width: 302px; }
.stories-carousel__slide::marker { content: none; }

.stories-carousel__link { display: flex; flex-direction: column; height: 100%; }
.stories-carousel__image { height: 390px; overflow: hidden; background: rgba(84, 36, 56, 0.08); }
.stories-carousel__image picture { display: block; width: 100%; height: 100%; }
.stories-carousel__image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stories-carousel__date {
    margin: 24px 0 0;
    font-size: 14px; line-height: 16px; font-weight: 500; text-transform: uppercase;
}
.stories-carousel__card-title {
    position: relative; margin: 12px 0 0;
    font-size: 20px; line-height: 22px; font-weight: 500; letter-spacing: 0;
}

/* Card hover, the same as the stories page cards (Figma "Stories Card 5"):
   a 14 x 12 arrow slides in before the title and the title moves right by
   26px. Keyboard focus shows the same state; touch screens do not. */
.stories-carousel__card-title-text { display: block; transition: padding-left 0.3s ease-out; }
.stories-carousel__card-arrow {
    position: absolute; left: 0; top: 5px; width: 14px; height: 12px;
    opacity: 0; transform: translateX(-12px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}
@media (hover: hover) {
    .stories-carousel__link:hover .stories-carousel__card-title-text { padding-left: 26px; }
    .stories-carousel__link:hover .stories-carousel__card-arrow { opacity: 1; transform: none; }
}
.stories-carousel__link:focus-visible .stories-carousel__card-title-text { padding-left: 26px; }
.stories-carousel__link:focus-visible .stories-carousel__card-arrow { opacity: 1; transform: none; }

/* Arrows: under the cards at the left on mobile. The buttons are 21 x 18 as
   in Figma; the ::after area makes them easier to tap. */
.stories-carousel__arrows { order: 1; display: flex; gap: 12px; margin-top: 48px; padding: 0 12px; }
.stories-carousel__arrow {
    position: relative; display: block; width: 21px; height: 18px; padding: 0; margin: 0;
    border: 0; background: none; color: inherit; cursor: pointer;
}
.stories-carousel__arrow::after { content: ''; position: absolute; inset: -13px -6px; }
.stories-carousel__arrow svg { display: block; width: 21px; height: 18px; }
.stories-carousel__arrow.swiper-button-disabled { opacity: 0.3; cursor: default; }
/* Swiper adds this class when all the cards fit, so the arrows are not needed. */
.stories-carousel__arrow.swiper-button-lock,
.stories-carousel .swiper:not(.swiper-initialized) ~ .stories-carousel__arrows { display: none; }

@media (min-width: 1024px) {
    .stories-carousel { padding: 24px 0 34px; }
    .stories-carousel__title { padding: 0 24px; }
    .stories-carousel__slide--wide { width: 683px; }
    .stories-carousel__slide--narrow { width: 566px; }
    .stories-carousel__date { font-size: 20px; line-height: 22px; font-weight: 700; }
    .stories-carousel__card-title { margin-top: 24px; font-size: 28px; line-height: 30px; }
    .stories-carousel__card-arrow { top: 9px; }
    .stories-carousel .swiper { padding-left: 24px !important; }
    .stories-carousel .swiper:not(.swiper-initialized) { scroll-padding-left: 24px; }
    /* The arrows sit at the right end of the heading row. */
    .stories-carousel__arrows { position: absolute; top: 30px; right: 24px; margin: 0; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .stories-carousel * { transition: none !important; }
}
