/* Recent-events photo carousel (inc/event-carousel.php).

   A filmstrip rather than a one-photo-at-a-time slider: every photo keeps
   its own shape at a fixed row height, so nothing is ever cropped (these
   are photos of people; object-fit: cover would cut off heads). Each card's
   width comes from --event-carousel-ar, the photo's width/height ratio,
   which the PHP writes on the <li>. The row heights and card cap below are
   mirrored in washdc_cursillo_event_carousel_metrics() for the `sizes`
   attribute -- change both together. */

.event-carousel {
    --event-carousel-row: 320px;
    --event-carousel-card-max: 480px;
    --event-carousel-gap: 16px;
    /* Room inside the scroller for card shadows; the negative margin on the
       track cancels it so the first photo lines up with the heading. */
    --event-carousel-inset: 6px;
}

.event-carousel-track {
    display: flex;
    gap: var(--event-carousel-gap);
    list-style: none;
    margin: 0 calc(-1 * var(--event-carousel-inset));
    padding: var(--event-carousel-inset) var(--event-carousel-inset) 16px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--event-carousel-inset);
    scrollbar-width: thin;
    /* Once recoloured, the thumb is ours to keep at 3:1 (WCAG 1.4.11); it
       is the main "scroll me" cue when JavaScript is off. #5b7a95 is 4:1 or
       better anywhere on the page background, blue corner glow included. */
    scrollbar-color: #5b7a95 transparent;
    border-radius: 12px;
}

/* The strip itself is the keyboard stop (arrow keys scroll it), so it needs
   an unmistakable ring. The global :focus-visible rule would also square
   the corners to 2px. */
.event-carousel-track:focus-visible {
    outline: 3px solid var(--secondary-color);
    outline-offset: 2px;
    border-radius: 12px;
}

@media (prefers-reduced-motion: no-preference) {
    .event-carousel-track {
        scroll-behavior: smooth;
    }
}

.event-carousel-slide {
    display: flex;
    flex: 0 0 auto;
    /* Row height x aspect ratio, but never wider than the card cap (so a
       panorama cannot take over the strip) and never so wide that the next
       photo stops peeking in -- the peek is what says "scroll me". */
    width: min(calc(var(--event-carousel-row) * var(--event-carousel-ar, 1)), var(--event-carousel-card-max), 85%);
    scroll-snap-align: start;
}

.event-carousel-figure {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    background: #ffffff;
    border-top: 4px solid var(--rainbow-blue);
    border-radius: 10px;
    overflow: hidden;
    /* Outline drawn with a shadow, not a border, so it adds no width and
       the photo keeps exactly the width its ratio calls for. */
    box-shadow:
        0 0 0 1px #d9e2ea,
        0 6px 14px rgba(14, 30, 37, 0.1);
}

/* Same rainbow rotation as the homepage feature cards. */
.event-carousel-slide:nth-child(6n+1) .event-carousel-figure {
    border-top-color: var(--rainbow-red);
}

.event-carousel-slide:nth-child(6n+2) .event-carousel-figure {
    border-top-color: var(--rainbow-orange);
}

.event-carousel-slide:nth-child(6n+3) .event-carousel-figure {
    border-top-color: var(--rainbow-gold);
}

.event-carousel-slide:nth-child(6n+4) .event-carousel-figure {
    border-top-color: var(--rainbow-green);
}

.event-carousel-slide:nth-child(6n+5) .event-carousel-figure {
    border-top-color: var(--rainbow-blue);
}

.event-carousel-slide:nth-child(6n+6) .event-carousel-figure {
    border-top-color: var(--rainbow-purple);
}

/* The photo's own shape, never taller than the row. Ordinary photos fill
   the row height exactly; a card narrowed by the width cap (a landscape
   photo on a phone, a panorama) comes out shorter, and its photo then sits
   flush under the coloured edge instead of floating between grey bars. */
.event-carousel-media {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    aspect-ratio: var(--event-carousel-ar, 1);
    max-height: var(--event-carousel-row);
    background: var(--light-bg);
}

.event-carousel-img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 100%;
    /* Belt and braces: if a width/height pair were ever wrong, letterbox
       rather than crop or stretch. */
    object-fit: contain;
}

.event-carousel-caption {
    padding: 10px 12px 12px;
    color: var(--text-color);
    font-size: 0.88rem;
    line-height: 1.4;
}

/* Clamped on an inner span: clamping the padded figcaption itself lets a
   sliver of the third line show through the bottom padding. The full text
   is still in the DOM, and the source page has every caption in full. */
.event-carousel-caption span {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
}

/* Prev/next only appear once the script has run (it adds .is-enhanced);
   without it the strip scrolls natively and dead buttons would mislead.
   :not([hidden]) lets the script hide them when every photo already fits. */
.event-carousel-controls {
    display: none;
}

/* Left-aligned so the buttons never share the bottom-right column with the
   site's fixed back-to-top button, which would otherwise sit on top of Next
   and catch taps meant for it. */
.event-carousel.is-enhanced .event-carousel-controls:not([hidden]) {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    margin-top: 6px;
}

.event-carousel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #ffffff;
    background: linear-gradient(135deg, #10283d 0%, #214f75 100%);
    box-shadow: 0 4px 10px rgba(14, 30, 37, 0.18);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.event-carousel-btn:hover:not([aria-disabled="true"]) {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(14, 30, 37, 0.24);
}

.event-carousel-btn:focus-visible {
    outline: 3px solid var(--secondary-color);
    outline-offset: 3px;
    border-radius: 50%;
}

/* aria-disabled, not :disabled: the button stays focusable at the ends of
   the strip (see event-carousel.js), so it keeps its focus ring. */
.event-carousel-btn[aria-disabled="true"] {
    color: #5b6b7a;
    background: #dde4ea;
    box-shadow: none;
    cursor: not-allowed;
}

.event-carousel-btn svg {
    display: block;
    width: 20px;
    height: 20px;
}

/* Homepage section: heading on the left, "See all event photos" on the
   right, wrapping underneath on narrow screens. */
.event-carousel-section .event-carousel-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px 24px;
}

.event-carousel-more {
    color: var(--secondary-color);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.event-carousel-more:hover {
    color: var(--accent-color);
    text-decoration-thickness: 2px;
}

@media (max-width: 768px) {
    .event-carousel {
        --event-carousel-row: 240px;
        --event-carousel-gap: 12px;
    }
}
