﻿/* ===========================================================================
   GenPageBuilder — ImageGallery

   A photographic plate, not a carousel widget: frames seated in a mount with a
   visible gutter, caption set below like a plate label.

   THEMING CONTRACT
   Every value a site might want to change is a custom property, declared here
   on `.image-gallery-container.gpb-gallery` (specificity 0,2,0).

   This stylesheet is registered during body render, so it loads AFTER the
   per-site file from Resources/Styles/. Source order will not save an override.
   Per-site files must therefore set the tokens on
       .gen-article-section .image-gallery-container.gpb-gallery      (0,3,0)
   which wins on specificity regardless of order. Do not use !important.

   The `gpb-gallery` marker class also keeps these rules off GenArticle's older
   fork of the same markup, which uses the same bare class names.
   =========================================================================== */

.image-gallery-container.gpb-gallery {
    /* --- color ------------------------------------------------------------ */
    --gpb-gallery-mount: #e4e2df;       /* ground the frames sit in           */
    --gpb-gallery-page: #ffffff;        /* caption shelf, meets the page      */
    --gpb-gallery-ink: #1f1d1b;         /* title and caption                  */
    --gpb-gallery-ink-quiet: #6a6560;   /* the count                          */
    --gpb-gallery-accent: #710a2c;      /* active/focused frame. one job only */
    --gpb-gallery-viewer: #141312;      /* lightbox ground — dark every site  */
    --gpb-gallery-viewer-ink: #f2f0ee;

    /* --- structure -------------------------------------------------------- */
    --gpb-gallery-cols: 4;              /* frames across; JS reads this too   */
    --gpb-gallery-frame: 3px;           /* half the gutter between frames     */
    --gpb-gallery-radius: 3px;          /* on the mount only; frames stay square */
    --gpb-gallery-heading-font: inherit;
    --gpb-gallery-heading-color: var(--gpb-gallery-ink);
    --gpb-gallery-heading-size: clamp(1.25rem, 3vw, 1.75rem);
    --gpb-gallery-heading-transform: none;
    --gpb-gallery-heading-spacing: normal;
    --gpb-gallery-heading-weight: normal;

    background-color: var(--gpb-gallery-page);
    color: var(--gpb-gallery-ink);
}

/* ---------------------------------------------------------------- head ---- */

/* Centred, not baseline: the arrow buttons have no text, so a baseline row dropped the
   title below them. */
.gpb-gallery .article-image-gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 0 .5rem;
    background: none;
    color: inherit;
}

.gpb-gallery .article-image-gallery-header > span {
    font-family: var(--gpb-gallery-heading-font);
    font-size: var(--gpb-gallery-heading-size);
    color: var(--gpb-gallery-heading-color);
    text-transform: var(--gpb-gallery-heading-transform);
    letter-spacing: var(--gpb-gallery-heading-spacing);
    font-weight: var(--gpb-gallery-heading-weight);
    line-height: 1.2;
}

.gpb-gallery .gal-controls {
    display: flex;
    flex: 0 0 auto;
    gap: .25rem;
    float: none;
}

/* Drawn chevrons. The markup carries no glyph, so nothing is announced and
   nothing has to be hidden from assistive tech. */
.gpb-gallery .directional-control {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background-color: var(--gpb-gallery-mount);
    color: var(--gpb-gallery-ink);
    cursor: pointer;
    position: relative;
}

.gpb-gallery .directional-control::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: .5rem;
    height: .5rem;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
}

.gpb-gallery .directional-control.left::before {
    transform: translate(-40%, -50%) rotate(45deg);
}

.gpb-gallery .directional-control.right::before {
    transform: translate(-60%, -50%) rotate(-135deg);
}

.gpb-gallery .directional-control:hover:not([disabled]) {
    background-color: var(--gpb-gallery-accent);
    color: #fff;
}

.gpb-gallery .directional-control[disabled] {
    opacity: .35;
    cursor: default;
}

/* ---------------------------------------------------------- the mount ---- */

.gpb-gallery .article-image-gallery {
    width: 100%;
    background-color: var(--gpb-gallery-mount);
    border-radius: var(--gpb-gallery-radius);
    white-space: nowrap;
    overflow: hidden;
}

.gpb-gallery .gal-item-container {
    position: relative;
    left: 0;
    font-size: 0;
    transition: left .35s ease;
}

/* A frame. 3:2 — the still-photography ratio; 16:9 is video's and letterboxes
   stills against the mount. The border IS the gutter, so there are no rules
   and no per-item borders anywhere in this design.
   padding-top resolves against the CONTAINER's width, so the border has to be
   subtracted back out or the ratio drifts by its own thickness. */
.gpb-gallery .gal-item {
    box-sizing: border-box;
    display: inline-block;
    position: relative;
    width: calc(100% / var(--gpb-gallery-cols));
    padding: 0 0 calc((100% / var(--gpb-gallery-cols)) * 2 / 3 - var(--gpb-gallery-frame) * 2);
    border: var(--gpb-gallery-frame) solid var(--gpb-gallery-mount);
    background: none;
    cursor: pointer;
    vertical-align: top;
}

/* `cover` in the strip, `contain` in the viewer: browsing crops, looking does not. */
.gpb-gallery .gal-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gpb-gallery .gal-item:hover img {
    opacity: .82;
}

.gpb-gallery .gal-item:focus {
    outline: none;
}

.gpb-gallery .gal-item:focus-visible {
    outline: 3px solid var(--gpb-gallery-accent);
    outline-offset: -3px;
}

.gpb-gallery .gal-no-items {
    padding: 2rem;
    font-size: 1rem;
    color: var(--gpb-gallery-ink-quiet);
    white-space: normal;
}

/* ---------------------------------------------------------------- foot ---- */

.gpb-gallery .article-image-gallery-footer {
    padding: .5rem 0 0;
    background: none;
    font-style: normal;
    font-size: .875rem;
    color: var(--gpb-gallery-ink-quiet);
    font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- viewer ---- */

.fsmodal.modal-dialog {
    max-width: 100%;
    margin: 0;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100vh;
    display: flex;
}

.fsmodal .modal-content {
    height: 100vh;
    border-radius: 0;
}

.gallery-modal-content.modal-content {
    background-color: var(--gpb-gallery-viewer, #141312);
    color: var(--gpb-gallery-viewer-ink, #f2f0ee);
}

.gallery-modal-content.modal-content .modal-header,
.gallery-modal-content.modal-content .modal-footer {
    border-color: rgba(255, 255, 255, .14);
}

.image-gallery-container .modal-content .modal-title {
    color: var(--gpb-gallery-viewer-ink, #f2f0ee);
    font-family: var(--gpb-gallery-heading-font, inherit);
}

.gallery-modal-content .close,
.gallery-modal-content .close:hover {
    color: var(--gpb-gallery-viewer-ink, #f2f0ee);
    opacity: 1;
}

.gallery-modal-content .carousel-item {
    height: 100%;
}

.gallery-modal-content .carousel-item img {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    object-fit: contain;
}

.gpb-gallery .gal-modal-body,
.gpb-gallery .gal-carousel,
.gpb-gallery .gal-carousel .carousel-inner {
    height: 100%;
}

.gpb-gallery .gal-modal-footer {
    display: block;
    border: none;
}

.gpb-gallery .gal-caption {
    text-align: left;
    margin: 0 -12px;
    padding: 12px;
    border-bottom: 1px solid var(--gpb-gallery-accent);
    min-height: 3rem;
}

.image-gallery-container .carousel-control-next,
.image-gallery-container .carousel-control-prev {
    background: transparent;
    border: none;
}

/* Bootstrap ships these at opacity .5 with a 20px icon. Against the viewer's
   near-black that is hard to find, and they are the only way to move between
   photos with the mouse. */
.gpb-gallery .gal-carousel .carousel-control-prev,
.gpb-gallery .gal-carousel .carousel-control-next {
    width: 11%;
    opacity: .7;
}

.gpb-gallery .gal-carousel .carousel-control-prev:hover,
.gpb-gallery .gal-carousel .carousel-control-next:hover {
    opacity: 1;
}

.gpb-gallery .gal-carousel .carousel-control-prev-icon,
.gpb-gallery .gal-carousel .carousel-control-next-icon {
    width: 2.25rem;
    height: 2.25rem;
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, .8));
}

.gpb-gallery .gal-carousel .carousel-control-prev:focus-visible,
.gpb-gallery .gal-carousel .carousel-control-next:focus-visible,
.gallery-modal-content .close:focus-visible {
    outline: 3px solid var(--gpb-gallery-accent);
    outline-offset: -3px;
    opacity: 1;
}

.gallery-modal-content .close {
    font-size: 2rem;
    line-height: 1;
}

/* viewer thumbnail rail */
.gal-fs-controls {
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    font-size: 0;
}

.gal-control-scroll-container {
    position: relative;
    transition: left .6s;
}

.gal-fs-controls .gal-thumb {
    display: inline-block;
    box-sizing: border-box;
    width: 160px;
    height: 90px;
    padding: 0;
    margin: 0 2px;
    border: 2px solid transparent;
    background: none;
    cursor: pointer;
}

.gal-fs-controls .gal-thumb:first-child {
    margin-left: 0;
}

.gal-fs-controls .gal-thumb:last-child {
    margin-right: 0;
}

.gal-fs-controls .gal-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gal-fs-controls .gal-thumb.active {
    border-color: var(--gpb-gallery-viewer-ink, #f2f0ee);
}

.gal-fs-controls .gal-thumb:not(.active):hover img {
    opacity: .82;
}

.gal-fs-controls .gal-thumb:focus {
    outline: none;
}

.gal-fs-controls .gal-thumb:focus-visible {
    outline: 3px solid var(--gpb-gallery-accent);
    outline-offset: 1px;
}

/* --------------------------------------------------------- breakpoints ---- */

/* Tablet. The JS reads --gpb-gallery-cols, so this is the only place the
   per-row count is written — no duplicated breakpoints to fall out of sync. */
@media screen and (max-width: 991px) {
    .image-gallery-container.gpb-gallery {
        --gpb-gallery-cols: 3;
    }
}

/* Phone. Two, not one: a single full-width photo stops reading as a set. */
@media screen and (max-width: 576px) {
    .image-gallery-container.gpb-gallery {
        --gpb-gallery-cols: 2;
    }

    .gal-fs-controls .gal-thumb {
        width: 96px;
        height: 54px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gpb-gallery .gal-item-container,
    .gal-control-scroll-container {
        transition: none;
    }
}

/* ===========================================================================
   Grid layout
   Same frames, same 3:2, same mount and gutter - the contact sheet simply wraps
   instead of scrolling sideways. Chosen per gallery from the section toolbar.

   The filmstrip exists because a long set shouldn't push the rest of the page
   down; the grid exists because a short set shouldn't hide two thirds of itself
   behind an arrow. Neither is the better default, which is why it's a choice.
   =========================================================================== */

.gpb-gallery-grid .article-image-gallery {
    /* the strip clips a sliding row; the grid has nothing to clip and must wrap */
    white-space: normal;
    overflow: visible;
    padding: var(--gpb-gallery-frame);
}

.gpb-gallery-grid .gal-item-container {
    display: flex;
    flex-wrap: wrap;
    position: static;
    left: auto;
    transition: none;
}

/* Captions earn their place here: in the grid a frame has room beneath it, and
   36 of the 45 live images have no caption, so the rule only shows when there is
   something to say. */
.gpb-gallery-grid .gal-item {
    padding-bottom: calc((100% / var(--gpb-gallery-cols)) * 2 / 3 - var(--gpb-gallery-frame) * 2);
}

.gpb-gallery-grid .gal-item:focus-visible {
    outline-offset: 0;
    z-index: 1;
}

/* A lone frame on the final row would stretch oddly in a flex container; fixing the
   width keeps every frame the same size regardless of how the last row falls. */
.gpb-gallery-grid .gal-item-container::after {
    content: "";
    flex: 999 1 0;
}

@media screen and (max-width: 991px) {
    .image-gallery-container.gpb-gallery-grid {
        --gpb-gallery-cols: 3;
    }
}

@media screen and (max-width: 576px) {
    .image-gallery-container.gpb-gallery-grid {
        --gpb-gallery-cols: 2;
    }
}

/* =============================================================== banner ====
   02.04.00. One full-width photo at a time, rotating: the stand-in for the HWUSlider
   module on hero panes. Each slide is a .gal-item button, so the base frame rules above
   (inline-block, fixed-ratio padding, mount border) must be undone here, and Bootstrap's
   own .carousel-item display rules restored, because `.gpb-gallery .gal-item` (0,2,0)
   outranks `.carousel-item` (0,1,0) and would otherwise show every slide at once.
   The frame's shape comes from an inline aspect-ratio set from the whitelisted
   BannerAspect (16:9 / 16:5 / 4:3).
   =========================================================================== */

.image-gallery-container.gpb-gallery-banner {
    background: none;
}

.gpb-gallery-banner .gpb-banner-frame {
    width: 100%;
    overflow: hidden;
    background-color: var(--gpb-gallery-mount);
}

.gpb-gallery-banner .gal-item.carousel-item {
    display: none;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
}

.gpb-gallery-banner .gal-item.carousel-item.active,
.gpb-gallery-banner .gal-item.carousel-item-next,
.gpb-gallery-banner .gal-item.carousel-item-prev {
    display: block;
}

.gpb-gallery-banner .gal-item:hover img {
    opacity: 1;
}

.gpb-gallery-banner .gal-item:focus-visible {
    outline-offset: -6px;
    outline-color: #ffffff;
}

.gpb-gallery-banner .gal-no-items {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* Dots and arrows sit on the photo; a soft shadow keeps them legible on pale images.
   Round dots, not Bootstrap's dashes; list-style none because some site skins number every ol li. */
.gpb-gallery-banner .gpb-banner-dots {
    list-style: none;
    padding-left: 0;
    flex-wrap: wrap;    /* long galleries (24 photos on The Bluff House) wrap instead of squeezing */
    row-gap: 8px;
}

.gpb-gallery-banner .gpb-banner-dots li {
    list-style: none;
    flex: 0 0 12px;     /* Bootstrap's flex-shrink squeezed dots into ovals when many */
    width: 12px;
    height: 12px;
    margin: 0 6px;      /* 24px centre to centre */
    border: 0;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, .55);
    opacity: 1;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 0 3px rgba(0, 0, 0, .45);
}

.gpb-gallery-banner .gpb-banner-dots li::marker {
    content: none;
}

.gpb-gallery-banner .gpb-banner-dots li.active {
    background-color: #ffffff;
}

/* Long galleries show "3 / 24" instead of dots: white on 60% black, well over 4.5:1 on any photo. */
.gpb-gallery-banner .gpb-banner-count {
    position: absolute;
    left: 50%;
    bottom: 12px;
    z-index: 15;
    transform: translateX(-50%);
    margin: 0;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .6);
    color: #ffffff;
    font: 600 14px/1.4 Arial, sans-serif;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    pointer-events: none;
}

/* Arrows and Pause: 44px targets on a 60% black disc, so the white icon keeps well over
   3:1 contrast (WCAG 1.4.11) on any photo, even pure white. Full opacity always, since
   Bootstrap fades its controls to .5. Focus: a white ring inside a black one, visible
   on light and dark photos alike (WCAG 2.4.7). */
.gpb-gallery-banner .gpb-banner-arrow,
.gpb-gallery-banner .gpb-banner-pause {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .6);
    opacity: 1;
}

.gpb-gallery-banner .gpb-banner-arrow {
    top: 50%;
    bottom: auto;
    margin: 0 12px;
    transform: translateY(-50%);
}

.gpb-gallery-banner .gpb-banner-arrow span:first-child {
    width: 18px;
    height: 18px;
}

.gpb-gallery-banner .gpb-banner-arrow:hover,
.gpb-gallery-banner .gpb-banner-pause:hover {
    background: rgba(0, 0, 0, .8);
    opacity: 1;
}

.gpb-gallery-banner .gpb-banner-arrow:focus,
.gpb-gallery-banner .gpb-banner-pause:focus {
    outline: 0;
    opacity: 1;
}

.gpb-gallery-banner .gpb-banner-arrow:focus-visible,
.gpb-gallery-banner .gpb-banner-pause:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 0;
    box-shadow: 0 0 0 6px #000000;
}

.gpb-gallery-banner .gpb-banner-pause {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 16;    /* above Bootstrap's indicators (15) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.gpb-gallery-banner .gpb-banner-pause[hidden] {
    display: none;
}

/* Two bars for Pause; a triangle for Play once paused. */
.gpb-gallery-banner .gpb-pause-icon {
    display: block;
    box-sizing: border-box;
    width: 14px;
    height: 16px;
    border-left: 5px solid #ffffff;
    border-right: 5px solid #ffffff;
}

.gpb-gallery-banner .gpb-banner-pause.is-paused .gpb-pause-icon {
    width: 0;
    height: 0;
    margin-left: 4px;
    border-style: solid;
    border-width: 8px 0 8px 14px;
    border-color: transparent transparent transparent #ffffff;
}

/* Video banners: the current video's name under the player, as HWUSlider's title bar did. */
.gpb-gallery-banner .gpb-banner-title {
    margin: 0 0 1em;
    padding: .6em 1em;
    background: var(--gpb-gallery-accent);
    color: #ffffff;
    font-weight: 600;
    line-height: 1.4;
}

.gpb-gallery-banner.gpb-banner-half .gpb-banner-title {
    width: 50%;
    margin: -1em auto 1em;
}

@media screen and (max-width: 1023px) {
    .gpb-gallery-banner.gpb-banner-half .gpb-banner-title {
        width: 100%;
    }
}

/* ================================================================ video ====
   02.05.00. A gallery item with a Vimeo link shows its image as a thumbnail with a play
   badge (filmstrip, grid and banner alike); the player itself only exists in the viewer.
   =========================================================================== */

.gpb-gallery .gal-video::after,
.gpb-gallery .gal-thumb-video::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3.5rem;
    height: 3.5rem;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M9 6.5v11l9-5.5z'/%3E%3C/svg%3E") center / 60% no-repeat,
        rgba(0, 0, 0, .55);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .85);
    pointer-events: none;
    transition: background-color .15s;
}

.gpb-gallery .gal-video:hover::after,
.gpb-gallery .gal-video:focus-visible::after {
    background-color: var(--gpb-gallery-accent);
}

.gpb-gallery .gal-thumb-video {
    position: relative;
}

.gpb-gallery .gal-thumb-video::after {
    width: 1.5rem;
    height: 1.5rem;
    box-shadow: none;
}

.gpb-gallery-banner .gal-video::after {
    width: clamp(3.5rem, 8vw, 5.5rem);
    height: clamp(3.5rem, 8vw, 5.5rem);
}

.gpb-gallery .gpb-viewer-video {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}

.gpb-gallery .gpb-viewer-video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Banner slides are divs holding a full-size button (02.05.00), so a video can play in
   place: its player is appended beside the button and covers it while it plays. */
.gpb-gallery-banner .gpb-banner-hit {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}

.gpb-gallery-banner .gpb-banner-hit:focus {
    outline: none;
}

.gpb-gallery-banner .gpb-banner-hit:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: -6px;
}

.gpb-gallery-banner .gal-video:has(.gpb-banner-hit:hover)::after,
.gpb-gallery-banner .gal-video:has(.gpb-banner-hit:focus-visible)::after {
    background-color: var(--gpb-gallery-accent);
}

.gpb-gallery-banner .gpb-inline-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    z-index: 2;
    background: #000;
}

.gpb-gallery-banner .gal-video.playing::after {
    display: none;
}

/* Banner size "Half": half the content width, centred, as HWUSlider drew its Ribbon and
   Simple sliders (the video pages). Full width again below 1024px, where HWUSlider did
   the same, so it never becomes a postage stamp on a phone. */
.gpb-gallery-banner.gpb-banner-half .gpb-banner {
    width: 50%;
    margin: 1em auto;
}

@media screen and (max-width: 1023px) {
    .gpb-gallery-banner.gpb-banner-half .gpb-banner {
        width: 100%;
    }
}

/* A 16:5 strip is only ~110px tall on a phone, so below 768px it opens up to 16:9, as
   HWUSlider's Large mode did. !important because the shape is an inline style. */
@media screen and (max-width: 767px) {
    .gpb-gallery-banner .gpb-banner-frame.gpb-banner-wide {
        aspect-ratio: 16 / 9 !important;
    }
}
