/* ── Hero ── */
.horse-hero {
    position: relative;
    height: 70vh;
    width: 100%;
    padding: 0;
    display: grid;
    /* gallery fills rows 1+2, identity sits in row 2 over the top */
    grid-template-rows: 1fr auto;
    grid-template-columns: 3fr 2fr;
    overflow: hidden;
    background: #111;
}

/* ── Gallery images container ── */
.horse-hero-images {
    /* spans all columns, all rows — is the background layer */
    grid-column: 1 / -1;
    grid-row: 1 / -1;
    display: grid;
    grid-template-columns: 3fr 2fr;
    grid-template-rows: 1fr;
    min-height: 0;
}

/* ── Primary pane ── */
.horse-gallery-primary {
    position: relative;
    overflow: hidden;
    background: #111;
    min-height: 0;
    min-width: 0;
    touch-action: pan-y;
    /* let horizontal swipes reach the JS */
}

/* Soft vignette so photo edges melt into the frame instead of ending hard */
.horse-gallery-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    z-index: 1;
}

/* Two stacked layers crossfade between photos */
.gallery-layer {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 450ms ease;
}

.gallery-layer.is-active {
    opacity: 1;
}

/* Blurred copy of the photo fills any letterbox space */
.gallery-backdrop {
    position: absolute;
    inset: -60px;
    /* oversize so the blur never shows a hard edge */
    background-size: cover;
    background-position: center;
    filter: blur(32px) brightness(0.45) saturate(1.2);
}

.gallery-img {
    position: relative;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    /* follows the visible photo, not the box, when contained */
    filter: drop-shadow(0 12px 32px rgba(0, 0, 0, 0.5));
}

/* Photo shape close to the pane's: just fill it */
.gallery-layer.is-cover .gallery-img {
    object-fit: cover;
    filter: none;
}

.gallery-layer.is-cover .gallery-backdrop {
    display: none;
}

/* ── Prev / next ── */
.gallery-nav {
    position: absolute;
    top: 50%;
    translate: 0 -50%;
    z-index: 3;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(17, 17, 17, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: white;
    cursor: pointer;
    transition: opacity 200ms ease, background 200ms ease, border-color 200ms ease;
}

.gallery-nav--prev {
    left: 16px;
}

.gallery-nav--next {
    right: 16px;
}

.gallery-nav svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.gallery-nav:hover {
    background: rgba(17, 17, 17, 0.75);
    border-color: var(--gold);
}

.gallery-nav:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* Mouse users: arrows appear on hover. Touch devices: always visible. */
@media (hover: hover) {
    .gallery-nav {
        opacity: 0;
    }

    .horse-gallery-primary:hover .gallery-nav,
    .gallery-nav:focus-visible {
        opacity: 1;
    }
}

.gallery-counter {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 3;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(17, 17, 17, 0.55);
    color: white;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
}

/* ── Thumb strip ── */
.horse-gallery-strip {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: max-content;
    align-content: start;
    gap: 6px;
    padding: 6px;
    overflow-y: auto;
    background: #0d0d0d;
    min-height: 0;
    min-width: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* 2–4 photos: thumbs stretch to fill the column, no dead space */
.horse-gallery-strip.is-fill {
    grid-auto-rows: 1fr;
    align-content: stretch;
}

.horse-gallery-strip.cols-1 {
    grid-template-columns: 1fr;
}

.horse-gallery-thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    min-height: 0;
    overflow: hidden;
    border: 0;
    padding: 0;
    border-radius: 6px;
    background: #1a1a1a;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 180ms ease;
}

.is-fill .horse-gallery-thumb {
    aspect-ratio: auto;
}

/* Odd count in a 2-col strip: last thumb spans both columns, no empty cell */
.horse-gallery-strip:not(.is-fill) .horse-gallery-thumb:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    aspect-ratio: 8 / 3;
}

.horse-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 300ms ease;
}

.horse-gallery-thumb:hover {
    opacity: 0.85;
}

.horse-gallery-thumb:hover img {
    transform: scale(1.04);
}

.horse-gallery-thumb.is-active {
    opacity: 1;
}

.horse-gallery-thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    pointer-events: none;
    transition: box-shadow 180ms ease;
}

.horse-gallery-thumb.is-active::after {
    box-shadow: inset 0 0 0 2px var(--gold);
}

.horse-gallery-thumb:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

    .gallery-layer,
    .horse-gallery-thumb img {
        transition: none;
    }
}

/* Single-image: collapse the strip column */
.horse-hero-images.has-one .horse-gallery-strip {
    display: none;
}

.horse-hero-images.has-one {
    grid-template-columns: 1fr;
}

.horse-hero.has-one-image {
    grid-template-columns: 1fr;
}

/* Overlay — placed in the hero grid, over the primary pane only */
.horse-hero-overlay {
    grid-column: 1;
    grid-row: 1 / -1;
    background: linear-gradient(to bottom,
            rgba(0, 0, 0, 0.1) 0%,
            rgba(0, 0, 0, 0.6) 100%);
    z-index: 1;
    pointer-events: none;
}

/* Identity text — sits in the bottom row, primary column */
.horse-hero-identity {
    grid-column: 1;
    grid-row: 2;
    position: relative;
    z-index: 2;
    padding: 48px var(--page-padding, 40px) 40px;
    color: white;
    align-self: end;
}

.horse-name {
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin: 0 0 8px;
    color: white;
}

.horse-meta {
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.75;
    margin: 0 0 12px;
}

.horse-hero-identity .horse-tagline {
    font-style: italic;
    font-size: 1.15rem;
    color: var(--gold);
    margin: 0;
}

/* ── Bio ── */
.horse-body {
    padding-block: 64px;
}

.horse-bio {
    max-width: 720px;
    margin-inline: auto;
    font-size: 1.05rem;
    line-height: 1.75;
}

.horse-bio p {
    margin: 0 0 1.25em;
}

.horse-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 40px;
    flex-wrap: wrap;
}

/* ── Foals ── */
.horse-foals {
    background: var(--blue);
    color: white;
    padding-block: 64px;
    text-align: center;
}

.horse-foals .section-kicker {
    color: var(--gold);
}

.horse-foals h2 {
    color: white;
    margin-bottom: 40px;
}

.foal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
}

.foal-card {
    margin: 0;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.foal-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
}

.foal-card figcaption {
    padding: 16px;
    display: grid;
    gap: 4px;
}

.foal-title {
    color: var(--gold);
    font-family: Georgia, serif;
    font-size: 1.1rem;
    display: block;
}

.foal-tagline {
    font-size: 0.9rem;
    opacity: 0.75;
    font-style: italic;
}

/* ── Responsive ── */
@media (max-width: 768px) {

    /* Collapse hero to single column; strip becomes horizontal scrolling row */
    .horse-hero {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto auto;
        min-height: unset;
    }

    .horse-hero-images {
        grid-column: 1;
        grid-row: 1 / 3;
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
    }

    .horse-gallery-strip,
    .horse-gallery-strip.is-fill {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        height: 76px;
        scrollbar-width: none;
    }

    .horse-gallery-strip::-webkit-scrollbar {
        display: none;
    }

    .horse-gallery-thumb,
    .is-fill .horse-gallery-thumb {
        flex: 0 0 auto;
        height: 100%;
        aspect-ratio: 4 / 3;
    }

    .gallery-nav {
        width: 40px;
        height: 40px;
    }

    .gallery-nav--prev {
        left: 10px;
    }

    .gallery-nav--next {
        right: 10px;
    }

    .horse-hero-overlay {
        grid-column: 1;
        grid-row: 1;
    }

    .horse-hero-identity {
        grid-column: 1;
        grid-row: 3;
        background: #111;
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .horse-hero-images.has-one {
        grid-template-rows: 1fr;
    }

    .horse-hero-images.has-one~.horse-hero-identity {
        grid-row: 2;
    }
}