/* BLT Tube — [blt_tube_gallery] front-end styles
 *
 * Self-contained and scoped under .bltt-gallery: this renders inside whatever
 * theme or page builder the site uses, so nothing here touches an element
 * outside the gallery and nothing depends on the admin design system.
 *
 * Theming — set any of these on :root, a wrapper, or .bltt-gallery itself:
 *
 *   --bltt-gallery-gap               space between videos            (20px)
 *   --bltt-gallery-radius            thumbnail / button corner radius (10px)
 *   --bltt-gallery-accent            play button hover, focus ring, "Load more" (#cc181e)
 *   --bltt-gallery-accent-contrast   text/icon colour on the accent  (#fff)
 *
 * Text colour and font are inherited from the theme.
 *
 * Column breakpoints follow the gallery's own width (container queries), not
 * the viewport, so the same shortcode works full-width and in a sidebar:
 * up to 480px wide uses columns_mobile, up to 840px columns_tablet, wider
 * uses columns.
 *
 * Selectors are deliberately a notch more specific than they need to be
 * (.bltt-gallery button.bltt-gallery__thumb) so theme and page-builder button
 * and heading styles don't leak in.
 */

.bltt-gallery {
    container-type: inline-size;
    container-name: bltt-gallery;
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    text-align: start;
}

.bltt-gallery *,
.bltt-gallery *::before,
.bltt-gallery *::after {
    box-sizing: border-box;
}

.bltt-gallery [hidden] {
    display: none !important;
}

.bltt-gallery .bltt-gallery__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------------------------------------------------------------
 * Items: grid by default
 * ------------------------------------------------------------- */

.bltt-gallery .bltt-gallery__items {
    --bltt-cols-now: var(--bltt-cols, 3);
    display: grid;
    grid-template-columns: repeat(var(--bltt-cols-now), minmax(0, 1fr));
    gap: var(--bltt-gallery-gap, 20px);
    margin: 0;
    padding: 0;
}

@container bltt-gallery (max-width: 840px) {
    .bltt-gallery .bltt-gallery__items {
        --bltt-cols-now: var(--bltt-cols-tablet, 2);
    }
}

@container bltt-gallery (max-width: 480px) {
    .bltt-gallery .bltt-gallery__items {
        --bltt-cols-now: var(--bltt-cols-mobile, 1);
    }
}

/* Browsers without container queries fall back to the viewport. */
@supports not (container-type: inline-size) {
    @media (max-width: 1024px) {
        .bltt-gallery .bltt-gallery__items {
            --bltt-cols-now: var(--bltt-cols-tablet, 2);
        }
    }

    @media (max-width: 600px) {
        .bltt-gallery .bltt-gallery__items {
            --bltt-cols-now: var(--bltt-cols-mobile, 1);
        }
    }
}

.bltt-gallery .bltt-gallery__item {
    min-width: 0;
    margin: 0;
    padding: 0;
}

/* ---------------------------------------------------------------
 * Thumbnail facade
 * ------------------------------------------------------------- */

.bltt-gallery .bltt-gallery__media {
    position: relative;
    aspect-ratio: 16 / 9;
    margin: 0;
    border-radius: var(--bltt-gallery-radius, 10px);
    background: #0f0f0f;
}

.bltt-gallery button.bltt-gallery__thumb,
.bltt-gallery a.bltt-gallery__thumb {
    all: unset;
    box-sizing: border-box;
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
    isolation: isolate;
    border-radius: inherit;
    background: #0f0f0f;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    /* Invisible normally; becomes the focus indicator in forced-colors mode. */
    outline: 2px solid transparent;
    outline-offset: 2px;
}

/* Restated for the interactive states so a theme's button:hover can't win. */
.bltt-gallery button.bltt-gallery__thumb:hover,
.bltt-gallery button.bltt-gallery__thumb:focus,
.bltt-gallery button.bltt-gallery__thumb:active,
.bltt-gallery a.bltt-gallery__thumb:hover,
.bltt-gallery a.bltt-gallery__thumb:focus,
.bltt-gallery a.bltt-gallery__thumb:active {
    padding: 0;
    border: 0;
    background: #0f0f0f;
    box-shadow: none;
    outline: 2px solid transparent;
    outline-offset: 2px;
    transform: none;
}

.bltt-gallery .bltt-gallery__thumb .bltt-gallery__img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    object-fit: cover;
}

.bltt-gallery .bltt-gallery__play {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(40px, 18%, 68px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.68);
    color: #fff;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.bltt-gallery .bltt-gallery__play svg {
    display: block;
    width: 52%;
    height: 52%;
    margin: 0;
}

.bltt-gallery .bltt-gallery__thumb:hover .bltt-gallery__play,
.bltt-gallery .bltt-gallery__thumb:focus-visible .bltt-gallery__play {
    background: var(--bltt-gallery-accent, #cc181e);
    color: var(--bltt-gallery-accent-contrast, #fff);
}

/* Focus ring drawn inside the thumbnail, so no scroller, sidebar or builder
   column with overflow:hidden can clip it. Accent band plus a white hairline
   keeps it visible over any thumbnail. */
.bltt-gallery .bltt-gallery__thumb:focus-visible::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    border: 4px solid var(--bltt-gallery-accent, #cc181e);
    border-radius: inherit;
    box-shadow: inset 0 0 0 2px #fff;
    pointer-events: none;
}

.bltt-gallery .bltt-gallery__thumb[aria-current="true"]::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    border: 3px solid var(--bltt-gallery-accent, #cc181e);
    border-radius: inherit;
    pointer-events: none;
}

.bltt-gallery .bltt-gallery__iframe {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: inherit;
    background: #000;
}

/* ---------------------------------------------------------------
 * Text
 * ------------------------------------------------------------- */

.bltt-gallery .bltt-gallery__body {
    min-width: 0;
    padding: 10px 0 0;
}

.bltt-gallery .bltt-gallery__title {
    display: -webkit-box;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-size: 1.05em;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: normal;
    text-transform: none;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.bltt-gallery .bltt-gallery__title::before,
.bltt-gallery .bltt-gallery__title::after {
    content: none;
}

.bltt-gallery .bltt-gallery__date {
    display: block;
    margin: 4px 0 0;
    font-size: 0.875em;
    line-height: 1.4;
    opacity: 0.72;
}

.bltt-gallery .bltt-gallery__desc {
    margin: 6px 0 0;
    padding: 0;
    font-size: 0.925em;
    line-height: 1.5;
    opacity: 0.86;
    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------
 * Header (channel)
 * ------------------------------------------------------------- */

.bltt-gallery .bltt-gallery__header {
    margin: 0 0 16px;
}

.bltt-gallery .bltt-gallery__channel {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    max-width: 100%;
    color: inherit;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
}

.bltt-gallery a.bltt-gallery__channel:hover .bltt-gallery__channel-name,
.bltt-gallery a.bltt-gallery__channel:focus-visible .bltt-gallery__channel-name {
    text-decoration: underline;
}

.bltt-gallery a.bltt-gallery__channel:focus-visible {
    outline: 3px solid var(--bltt-gallery-accent, #cc181e);
    outline-offset: 3px;
    border-radius: 4px;
}

.bltt-gallery .bltt-gallery__channel .bltt-gallery__avatar {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    box-shadow: none;
    object-fit: cover;
}

.bltt-gallery .bltt-gallery__channel-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------
 * List layout
 * ------------------------------------------------------------- */

.bltt-gallery--list .bltt-gallery__items {
    grid-template-columns: minmax(0, 1fr);
}

.bltt-gallery--list .bltt-gallery__item {
    display: grid;
    grid-template-columns: min(38%, 320px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.bltt-gallery--list .bltt-gallery__body {
    padding-top: 0;
}

.bltt-gallery--list .bltt-gallery__title {
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

@container bltt-gallery (max-width: 380px) {
    .bltt-gallery--list .bltt-gallery__item {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .bltt-gallery--list .bltt-gallery__body {
        padding-top: 10px;
    }
}

/* ---------------------------------------------------------------
 * Carousel (and the featured layout's strip)
 * ------------------------------------------------------------- */

.bltt-gallery .bltt-gallery__track {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.bltt-gallery .bltt-gallery__track::-webkit-scrollbar {
    display: none;
}

.bltt-gallery .bltt-gallery__track > .bltt-gallery__item {
    flex: 0 0 calc((100% - (var(--bltt-cols-now) - 1) * var(--bltt-gallery-gap, 20px)) / var(--bltt-cols-now));
    scroll-snap-align: start;
}

.bltt-gallery .bltt-gallery__track--strip > .bltt-gallery__item {
    flex-basis: clamp(132px, 24%, 220px);
}

.bltt-gallery .bltt-gallery__controls {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin: 0 0 12px;
}

.bltt-gallery button.bltt-gallery__nav {
    all: unset;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid currentColor;
    border-radius: 50%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.bltt-gallery button.bltt-gallery__nav svg {
    display: block;
    margin: 0;
}

.bltt-gallery button.bltt-gallery__nav:hover,
.bltt-gallery button.bltt-gallery__nav:focus,
.bltt-gallery button.bltt-gallery__nav:active {
    padding: 0;
    border: 1px solid currentColor;
    background: transparent;
    box-shadow: none;
    color: inherit;
    transform: none;
}

.bltt-gallery button.bltt-gallery__nav:not([aria-disabled="true"]):hover {
    border-color: var(--bltt-gallery-accent, #cc181e);
    background: var(--bltt-gallery-accent, #cc181e);
    color: var(--bltt-gallery-accent-contrast, #fff);
}

.bltt-gallery button.bltt-gallery__nav:focus-visible {
    outline: 3px solid var(--bltt-gallery-accent, #cc181e);
    outline-offset: 2px;
}

.bltt-gallery button.bltt-gallery__nav[aria-disabled="true"] {
    opacity: 0.35;
    cursor: default;
}

/* ---------------------------------------------------------------
 * Featured layout
 * ------------------------------------------------------------- */

.bltt-gallery .bltt-gallery__stage {
    margin: 0 0 var(--bltt-gallery-gap, 20px);
}

.bltt-gallery .bltt-gallery__stage-body {
    padding-top: 14px;
}

.bltt-gallery .bltt-gallery__stage-title {
    display: block;
    font-size: 1.35em;
    line-height: 1.25;
    -webkit-line-clamp: unset;
    line-clamp: unset;
}

/* The thumbnails under the player are navigation, so they sit tighter. */
.bltt-gallery--featured .bltt-gallery__items {
    gap: calc(var(--bltt-gallery-gap, 20px) * 0.6);
}

.bltt-gallery--featured .bltt-gallery__items .bltt-gallery__play {
    width: clamp(30px, 22%, 44px);
}

.bltt-gallery--featured .bltt-gallery__items .bltt-gallery__body {
    padding-top: 6px;
}

.bltt-gallery--featured .bltt-gallery__items .bltt-gallery__title {
    font-size: 0.9em;
}

/* ---------------------------------------------------------------
 * Load more
 * ------------------------------------------------------------- */

.bltt-gallery .bltt-gallery__more {
    display: flex;
    justify-content: center;
    margin: var(--bltt-gallery-gap, 20px) 0 0;
}

.bltt-gallery button.bltt-gallery__more-btn,
.bltt-gallery button.bltt-gallery__more-btn:hover,
.bltt-gallery button.bltt-gallery__more-btn:focus,
.bltt-gallery button.bltt-gallery__more-btn:active {
    all: unset;
    box-sizing: border-box;
    padding: 0.7em 1.6em;
    border-radius: var(--bltt-gallery-radius, 10px);
    background: var(--bltt-gallery-accent, #cc181e);
    color: var(--bltt-gallery-accent-contrast, #fff);
    font-size: 0.95em;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
}

.bltt-gallery button.bltt-gallery__more-btn:hover {
    filter: brightness(0.9);
}

.bltt-gallery button.bltt-gallery__more-btn:focus-visible {
    outline: 3px solid var(--bltt-gallery-accent, #cc181e);
    outline-offset: 3px;
}

/* ---------------------------------------------------------------
 * Lightbox (a native <dialog>, created on first use)
 * ------------------------------------------------------------- */

.bltt-gallery dialog.bltt-gallery__lightbox {
    width: min(92vw, 1100px, calc((100vh - 140px) * 16 / 9));
    max-width: none;
    max-height: none;
    margin: auto;
    padding: 0;
    overflow: visible;
    border: 0;
    background: transparent;
    color: #fff;
}

.bltt-gallery dialog.bltt-gallery__lightbox::backdrop {
    background: rgba(0, 0, 0, 0.86);
}

.bltt-gallery .bltt-gallery__lightbox-bar {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 10px;
}

.bltt-gallery .bltt-gallery__lightbox-frame {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: var(--bltt-gallery-radius, 10px);
    background: #000;
}

.bltt-gallery button.bltt-gallery__lightbox-close,
.bltt-gallery button.bltt-gallery__lightbox-close:hover,
.bltt-gallery button.bltt-gallery__lightbox-close:focus,
.bltt-gallery button.bltt-gallery__lightbox-close:active {
    all: unset;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    cursor: pointer;
}

.bltt-gallery button.bltt-gallery__lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.bltt-gallery button.bltt-gallery__lightbox-close:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

.bltt-gallery button.bltt-gallery__lightbox-close svg {
    display: block;
    margin: 0;
}

/* ---------------------------------------------------------------
 * Admin-only notice
 * ------------------------------------------------------------- */

/*
 * The box is always light, so its text colours are pinned and marked
 * !important: dark-mode themes commonly colour every `p`, `li` and `a` in
 * the content area with more specific selectors, which left this text at
 * ~1.2:1 against the box. #1d2327 and #135e96 are ≥ 6.5:1 on #fcf9e8.
 */
.bltt-gallery .bltt-gallery__notice,
.bltt-gallery .bltt-gallery__notice p,
.bltt-gallery .bltt-gallery__notice ul,
.bltt-gallery .bltt-gallery__notice li,
.bltt-gallery .bltt-gallery__notice em,
.bltt-gallery .bltt-gallery__notice strong {
    color: #1d2327 !important;
    font-size: 14px;
    font-style: normal;
    line-height: 1.5;
}

.bltt-gallery .bltt-gallery__notice {
    margin: 0 0 12px;
    padding: 10px 14px;
    border: 0;
    border-left: 4px solid #dba617;
    border-radius: 4px;
    background: #fcf9e8 !important;
    text-align: left;
}

.bltt-gallery .bltt-gallery__notice p,
.bltt-gallery .bltt-gallery__notice ul {
    margin: 0;
    padding: 0;
}

.bltt-gallery .bltt-gallery__notice ul {
    list-style: disc;
    padding-left: 1.25em;
}

.bltt-gallery .bltt-gallery__notice li {
    margin: 0 0 4px;
}

.bltt-gallery .bltt-gallery__notice li:last-child {
    margin-bottom: 0;
}

.bltt-gallery .bltt-gallery__notice p + p,
.bltt-gallery .bltt-gallery__notice ul + p {
    margin-top: 6px;
}

.bltt-gallery .bltt-gallery__notice em {
    font-style: italic;
}

.bltt-gallery .bltt-gallery__notice a,
.bltt-gallery .bltt-gallery__notice a:visited {
    color: #135e96 !important;
    text-decoration: underline !important;
    background: transparent !important;
}

.bltt-gallery .bltt-gallery__notice a:hover,
.bltt-gallery .bltt-gallery__notice a:focus {
    color: #0a4b78 !important;
}

/* ---------------------------------------------------------------
 * Motion — only for visitors who haven't asked for less of it
 * ------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
    .bltt-gallery .bltt-gallery__thumb .bltt-gallery__img {
        transition: transform 0.35s ease;
    }

    .bltt-gallery .bltt-gallery__thumb:hover .bltt-gallery__img {
        transform: scale(1.04);
    }

    .bltt-gallery .bltt-gallery__play,
    .bltt-gallery button.bltt-gallery__nav {
        transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    }
}
