/*
 * tif/banner
 *
 * Theme it with custom properties, not by overriding rules:
 *   :root         --tif-banner-size (minimum height)
 *   .tif-banner   --tif-banner-bg, --tif-banner-color, --tif-banner-link (site defaults),
 *                 --tif-banner-gap, --tif-banner-padding-x, --tif-banner-close-size
 *
 * Colours chosen in the Panel are set inline on the banner and win over the
 * site defaults.
 *
 * Read --tif-banner-height to offset other elements (a fixed header, for example).
 * It is the rendered height of the banner, or 0px when there is no banner or a
 * visitor closed it.
 */

:root {
    --tif-banner-size: 3rem;
    --tif-banner-height: 0px;
}

/* Fallback before banner.js measures the real height */
:root:has(.tif-banner:not([hidden])) {
    --tif-banner-height: var(--tif-banner-size);
}

.tif-banner {
    --tif-banner-bg: #1d1d1b;
    --tif-banner-color: #ffffff;
    --tif-banner-link: currentColor;
    --tif-banner-gap: 4rem;
    --tif-banner-padding-x: 1rem;
    --tif-banner-close-size: 3rem;

    position: relative;
    display: flex;
    align-items: center;
    min-height: var(--tif-banner-size);
    overflow: clip;
    background-color: var(--tif-banner-bg);
    color: var(--tif-banner-color);
}

.tif-banner[hidden] {
    display: none;
}

.tif-banner__viewport {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    padding-inline: var(--tif-banner-padding-x);
}

.tif-banner--dismissible:not(.is-scrolling) .tif-banner__viewport {
    padding-inline: var(--tif-banner-close-size);
}

.tif-banner__track {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--tif-banner-gap);
}

.tif-banner__item {
    flex: none;
    max-width: 100%;
    margin: 0;
    color: inherit;
    text-align: center;
}

.tif-banner__item a {
    color: var(--tif-banner-link);
    text-decoration: underline;
}

/* Single line while banner.js measures, and while the ticker runs */
.tif-banner.is-measuring .tif-banner__item,
.tif-banner.is-scrolling .tif-banner__item {
    max-width: none;
    white-space: nowrap;
}

.tif-banner.is-scrolling .tif-banner__viewport {
    padding-inline: 0;
}

.tif-banner.is-scrolling .tif-banner__track {
    justify-content: flex-start;
    width: max-content;
    animation: tif-banner-scroll var(--tif-banner-duration, 20s) linear infinite;
}

.tif-banner.is-scrolling:hover .tif-banner__track,
.tif-banner.is-scrolling:focus-within .tif-banner__track {
    animation-play-state: paused;
}

@keyframes tif-banner-scroll {
    to {
        transform: translateX(calc(-1 * var(--tif-banner-distance, 0px)));
    }
}

.tif-banner__close {
    position: absolute;
    inset-block: 0;
    right: 0;
    z-index: 1;
    display: grid;
    place-items: center;
    width: var(--tif-banner-close-size);
    padding: 0;
    border: 0;
    background-color: var(--tif-banner-bg);
    color: inherit;
    cursor: pointer;
}

.tif-banner__close[hidden] {
    display: none;
}

.tif-banner__close:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -6px;
}

@media (prefers-reduced-motion: reduce) {
    .tif-banner.is-scrolling .tif-banner__track {
        animation: none;
    }
}
