﻿/* ===========================================================================
   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;

    background-color: var(--gpb-gallery-page);
    color: var(--gpb-gallery-ink);
}

/* ---------------------------------------------------------------- head ---- */

.gpb-gallery .article-image-gallery-header {
    display: flex;
    align-items: baseline;
    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: clamp(1.25rem, 3vw, 1.75rem);
    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;
    }
}
