/*
 * Trip cards: the Trip Listings section (WEB-INF/ptypes/pilgrimages.xhtml, WEB-INF/tripCard.xhtml), issue 154.
 * The photo IS the card and the text sits on a scrim over it; the section's next departure is one large card
 * above a grid of the rest. Chosen by the owner from the prototype of 2026-11-16 ("Immersive" with the "Hero").
 *
 * Colors are the theme's variables, with ONE deliberate exception: text over a photo is white on a black scrim in
 * every palette, because the photo, not the palette, is its background (theme-branding.md, "an overlay on a
 * photo"). Both literals are declared once, here, and everything else mixes from them.
 *
 * The properties are declared on BOTH roots that use them: the listing, and a trip page's hero, whose picture
 * shares .tripCardImg. A var() with no value makes the whole transition invalid, and the hero then never fades.
 */
.tripCards, .tripTop {
    --tc-ink: #fff;
    --tc-shade: #000;
    --tc-ease: cubic-bezier(0.23, 1, 0.32, 1);
}
/* Capped and centered like a band (site.css .band-inner): a full-width page gives a section the whole window, and
   a featured card twice as wide as its widest stored picture is a stretched one. The cap is on the block that
   holds the heading, the cards and the empty state together, so they share an edge. */
.tripCardsSection, .tripHero, .tripFacts {
    max-width: 1200px;
    margin-inline: auto;
}
.tripCards {
    container-type: inline-size;
    margin: 0 0 18px;
}

.tripCardGrid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr);
}
/* Two across, like three, only when each card can still be mostly picture (about 320px wide): the text block does
   not shrink with the card, and on a narrower one a long title's scrim covers the whole photo.
   BOTH breakpoints, the 16px gap and the 1200px cap above are restated as window widths in the pictures' sizes
   attributes, which trip's TripPictureCommands answers (wideSizes, gridSizes): move one and move those too
   (TripCardsPwIT and OrgSubdomainPwIT compare the two, in both layouts). */
@container (min-width: 660px) {
    .tripCardGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Three across only when each card can still be mostly picture: below that the text block eats the photo. */
@container (min-width: 980px) {
    .tripCardGrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

a.tripCard, a.tripCard:link, a.tripCard:visited, a.tripCard:hover {
    color: var(--tc-ink);
    text-decoration: none;
}
.tripCard {
    position: relative;
    display: block;
    overflow: hidden;
    isolation: isolate;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10), 0 1px 3px rgba(0, 0, 0, 0.14);
    -webkit-tap-highlight-color: transparent;
    /* The release: slower than the press below, so a press that is dragged off settles instead of snapping. */
    transition: transform 160ms var(--tc-ease);
}
.tripCard:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}
.tripCard:active {
    transform: scale(0.98);
    transition: transform 100ms var(--tc-ease);
}
/* The large card moves three times as many pixels at the same factor, so it gets a smaller one. */
.tripCardFeature:active {
    transform: scale(0.985);
}

/* The picture: one 3:2 shape in the grid, over the picture's own average color until it arrives. */
.tripCardMedia {
    position: relative;
    display: block;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    background-color: var(--surface-100);
}
.tripCardImg {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 220ms var(--tc-ease);
}
/* site.css gives every content image that carries width and height attributes "height: auto", so it scales with
   its width. A card's picture must FILL its box instead (the large card's box is not 3:2), and only a heavier
   selector than that rule's can say so; without it the picture sat at the top over a band of placeholder color. */
.tripCardMedia > img.tripCardImg[width][height] {
    height: 100%;
}
/* Set by tripCards.js only on a picture that has not arrived yet; without the script every picture just shows. */
.tripCardImg.tripCardImg-loading {
    opacity: 0;
}
@media (hover: hover) and (pointer: fine) {
    .tripCardImg {
        transition: opacity 220ms var(--tc-ease), transform 240ms var(--tc-ease);
    }
    .tripCard:hover .tripCardImg {
        transform: scale(1.04);
    }
    .tripCardFeature:hover .tripCardImg {
        transform: scale(1.02);
    }
}

/* No picture and none from the organization: its accent under a dark wash, with a compass. The wash is the scrim's
   own shade, so the white text holds on the pale palettes too. */
.tripCardGenerated {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 18%;
    background:
        radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--tc-ink) 10%, transparent) 1px, transparent 0)
            0 0 / 14px 14px,
        linear-gradient(140deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 45%, var(--tc-shade)));
}
.tripCardGenerated .pi {
    font-size: 2.4rem;
    color: color-mix(in srgb, var(--tc-ink) 85%, transparent);
}

/* The text and its scrim are ONE block: the scrim grows with the text, and reaches two-thirds black within its top
   30px, above the first line (the padding is 40px), so white holds at least 7:1 over any photo. */
.tripCardText {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: block;
    padding: 40px 16px 14px;
    background: linear-gradient(to top,
            color-mix(in srgb, var(--tc-shade) 84%, transparent) 0,
            color-mix(in srgb, var(--tc-shade) 66%, transparent) calc(100% - 30px),
            transparent 100%);
}
.tripCardTitle {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0 0 4px;
    font-size: 1.2rem;
    line-height: 1.25;
    font-weight: 700;
    color: var(--tc-ink);
    text-wrap: balance;
}
.tripCardMeta, .tripCardSub {
    display: block;
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.4;
}
.tripCardMeta {
    font-weight: 600;
}

/* The registration state, top right, on its own solid ground so it reads over any photo. */
.tripCardTop {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
    display: flex;
    gap: 6px;
}
.tripChip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.tripChip .pi {
    font-size: 0.75rem;
}
/* Register is the palette's OWN accent pair, the one every accent button on the site uses: its text color is
   chosen per palette to hold on the accent. The accent as text on a tint of itself read as low as 1.7:1. */
.tripChip-register {
    color: var(--primary-color-text);
    background: var(--primary-color);
}
.tripChip-registered {
    color: var(--status-success);
    background: var(--status-success-bg);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--status-success) 35%, var(--status-success-bg));
}
.tripChip-full {
    color: var(--status-warning);
    background: var(--status-warning-bg);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--status-warning) 35%, var(--status-warning-bg));
}
.tripChip-closed, .tripChip-pending {
    color: var(--text-color);
    background: var(--surface-50);
    box-shadow: inset 0 0 0 1px var(--surface-border);
}

/* The section's next departure: the same card, large. A phone gets a taller shape, so the text block (five lines
   there) still leaves the top half as picture; a wide container gets a wide crop of the same picture. */
.tripCardFeature {
    margin-bottom: 16px;
}
.tripCardFeature .tripCardMedia {
    aspect-ratio: 4 / 5;
}
.tripCardFeature .tripCardTop {
    top: 14px;
    right: 14px;
}
.tripCardFeature .tripCardText {
    padding: 44px 18px 18px;
}
.tripCardFeature .tripCardTitle {
    font-size: 1.45rem;
    margin-bottom: 6px;
}
.tripCardFeature .tripCardMeta {
    font-size: 0.95rem;
}
.tripCardEyebrow {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 6px;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
@container (min-width: 440px) {
    .tripCardFeature .tripCardMedia { aspect-ratio: 3 / 2; }
}
@container (min-width: 680px) {
    .tripCardFeature .tripCardMedia { aspect-ratio: 2 / 1; }
    .tripCardFeature .tripCardText { padding: 72px 28px 24px; }
    .tripCardFeature .tripCardTitle { font-size: 1.9rem; }
}

/* A featured trip with NO picture is a banner, not a hero: a large generated cover is a large blank. */
.tripCardFeature.tripCardNoPhoto .tripCardMedia {
    aspect-ratio: 3 / 2;
}
@container (min-width: 680px) {
    .tripCardFeature.tripCardNoPhoto .tripCardMedia { aspect-ratio: 7 / 2; }
    .tripCardFeature.tripCardNoPhoto .tripCardGenerated { justify-content: flex-end; padding: 0 6% 0 0; }
}

/* A section with nothing to list says so, instead of ending at its heading. */
.tripCardsEmpty {
    margin: 0 0 18px;
    padding: 28px 16px;
    text-align: center;
    border: 1px dashed var(--surface-border);
    border-radius: 12px;
}
.tripCardsEmpty .pi {
    font-size: 2rem;
    color: var(--primary-color);
}
.tripCardsEmpty p {
    margin: 6px 0 0;
}

/* Nothing moves by itself, and nothing moves at all for a visitor who asked for less motion. A picture still
   fades in for them: opacity is not movement, and without it the picture pops in over its placeholder. */
@media (prefers-reduced-motion: reduce) {
    .tripCard, .tripCard:active {
        transition: none;
    }
    .tripCardImg {
        transition: opacity 220ms var(--tc-ease);
    }
    .tripCard:active, .tripCard:hover .tripCardImg {
        transform: none;
    }
}

/*
 * The top of a trip's own page (WEB-INF/tripPictureHero.xhtml): the cover as a hero, a manual gallery when the
 * trip has more pictures, and a line of facts. The hero reuses the card's picture class and loads tripCards.js,
 * so it fades in the same.
 */
.tripHero {
    margin-bottom: 14px;
    border-radius: 12px;
    overflow: hidden;
    /* The gallery picture's shape (width over height) and tallest size, ONCE: the picture rule and the gallery's
       reserved height both read them, so a trip's own stylesheet that changes the gallery changes these
       (trip-page-starter.css says so) and the reserve follows. */
    --trip-gallery-ratio: 1.5;
    --trip-gallery-max: 70vh;
}
.tripHeroMedia {
    display: block;
    aspect-ratio: 3 / 2;
    overflow: hidden;
}
@media (min-width: 720px) {
    .tripHeroMedia { aspect-ratio: 2 / 1; }
}
/* Capped by the window's height too, as the album gallery is (albums.css): a 1200px-wide slide is 800px tall, and
   on a laptop the caption and thumbnails would sit below the fold. It crops (object-fit), never letterboxes. */
.tripGalleryImg {
    display: block;
    width: 100%;
    height: auto;
    max-height: var(--trip-gallery-max);
    aspect-ratio: var(--trip-gallery-ratio);
    object-fit: cover;
}
/* The gallery holds its built height from the first paint. PrimeFaces rebuilds it when its script runs, and for
   that moment the whole gallery was 28px tall, so the facts and Register Now below jumped up and back down (on a
   slow connection for half a second; measured 2026-11-16). Built, it is the picture (the .tripHero properties
   above) over the thumbnail strip, whose 76px is PrimeFaces' own at every width. The gallery is its own size
   container, so the reserve follows ITS width, also when a trip's stylesheet narrows it. TripCardsPwIT holds this
   to the gallery's own built height, so a reserve too short or too tall fails. */
.tripGallery {
    container-type: inline-size;
}
.tripGallery > .ui-galleria-content {
    /* The ratio in its own parentheses: a property is substituted as written, so "16 / 9" would otherwise divide
       twice (by 16, then by 9). */
    min-height: calc(min(100cqw / (var(--trip-gallery-ratio)), var(--trip-gallery-max)) + 76px);
}
/* A thumbnail fits its slot: PrimeFaces gives each of the five a fifth of the strip (a third on a phone), and a
   fixed 72px picture in a narrower slot makes the slot scroll inside itself. With three on a phone no window gives
   a slot under about 74px today, so this is a guard for a layout change (TripCardsPwIT checks the tightest
   windows), not something a visitor sees. */
.tripGallery .ui-galleria-thumbnail-item {
    min-width: 0;
}
.tripGalleryThumb {
    display: block;
    width: 100%;
    max-width: 72px;
    height: auto;
    aspect-ratio: 3 / 2;
    object-fit: cover;
}
/* A picture with no description shows no caption bar. visibility, never display: the captions are a row of
   full-width slots PrimeFaces slides in step with the pictures, and removing one shifts the rest (albums.css). */
.tripGallery .ui-galleria-caption-item:empty {
    visibility: hidden;
}
/* The slide between pictures. PrimeFaces writes its own (500ms, the built-in ease) INLINE on three strips (the
   pictures, their captions and the thumbnails), which only !important can override. A visitor who asked for less
   motion gets the next picture in place. */
.tripGallery .ui-galleria-items,
.tripGallery .ui-galleria-caption-items,
.tripGallery .ui-galleria-thumbnail-items {
    transition: transform 350ms cubic-bezier(0.32, 0.72, 0, 1) !important;
}
@media (prefers-reduced-motion: reduce) {
    .tripGallery .ui-galleria-items,
    .tripGallery .ui-galleria-caption-items {
        transition: none !important;
    }
    /* Not none: the thumbnail widget tidies up in its transitionend handler, which "none" never fires. */
    .tripGallery .ui-galleria-thumbnail-items {
        transition: transform 1ms !important;
    }
}
.tripFactNote {
    font-size: 0.875rem;
}
/* Capped and centered with the hero above it (the one cap rule at the top), so the two share an edge. */
.tripFacts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 22px;
    align-items: baseline;
    margin-bottom: 18px;
}
.tripFact .pi {
    color: var(--primary-color);
    margin-right: 4px;
}
a.tripFact.flyerLink {
    font-weight: 700;
}
