@layer components {
    /* the fixed bar; it places the ticker but leaves its insides to the ticker */
    @scope (.header) to (.ticker > *) {
        :scope {
            --header-pad-x: 40px;
            --header-pad-bottom: 16px;
            position: fixed;
            inset-block: 0 auto;
            inset-inline: 0 var(--page-push);
            z-index: 10;
            /* its own layer in a view transition, so cards sliding under it stay under it */
            view-transition-name: header;
            height: var(--bar-height);
            padding-inline: var(--header-pad-x);
            padding-block: 0 var(--header-pad-bottom);
            display: flex;
            align-items: flex-end;
            justify-content: center;
            background: var(--bg);
            border-block-end: var(--border);
            box-shadow: var(--shadow);
            transition: inset-inline-end var(--t-base) var(--ease);

            @container page (width < 1400px) {
                --header-pad-x: max(var(--edge), (100cqi - var(--content)) / 2);
                justify-content: flex-start;
            }

            @media (width < 768px) {
                --header-pad-bottom: 0px;
                align-items: center;
            }
        }

        .ticker {
            position: absolute;
            inset-inline-start: var(--header-pad-x);
            inset-block-end: var(--header-pad-bottom);
            height: var(--ticker-height);

            @container page (width < 1400px) {
                inset-inline: auto var(--header-pad-x);
            }

            @media (width < 768px) {
                position: static;
                flex: 1;
                min-width: 0;
            }
        }

        .header-name {
            position: absolute;
            inset-inline-end: var(--header-pad-x);
            inset-block-end: var(--header-pad-bottom);
            height: var(--ticker-height);
            display: flex;
            align-items: center;
            color: var(--muted);

            @container page (width < 1400px) {
                display: none;
            }
        }

        /* as tall as the ticker, so the two share a centre line */
        .header-logo {
            height: var(--ticker-height);
            display: flex;
            align-items: center;

            @media (width < 768px) {
                display: none;
            }
        }

        .header-logo-img {
            display: block;
            height: 28px;
        }
    }

    /* rotating slides: today's footprint, the next event, and on phones the logo */
    @scope (.ticker) {
        :scope {
            --ticker-dot: 5px;
            --ticker-gap: 8px;
            display: flex;
            align-items: center;
            gap: var(--ticker-gap);

            @container page (width < 1400px) {
                flex-direction: row-reverse;
            }
        }

        .ticker-dots {
            display: grid;
            gap: var(--ticker-dot);
        }

        .ticker-dot {
            width: var(--ticker-dot);
            height: var(--ticker-dot);
            border-radius: 50%;
            background: var(--muted);
            transition: background var(--t-base);

            &.is-active {
                background: var(--fg);
            }
        }

        .ticker-slides {
            height: var(--ticker-height);
            overflow: hidden;

            @media (width < 768px) {
                flex: 1;
                min-width: 0;
            }
        }

        .ticker-track {
            transition: translate var(--t-base) ease;
        }

        .ticker-slide {
            height: var(--ticker-height);
            display: grid;
            grid-template-columns: auto auto;
            align-content: center;
            align-items: baseline;
            justify-content: start;
            gap: 2px var(--ticker-gap);
            font-size: var(--text-md);
            white-space: nowrap;
            text-decoration: none;

            /* tablet: the ticker sits at the right gutter, so its text hugs the right edge */
            @container page (768px <= width < 1400px) {
                grid-template-columns: auto;
                justify-content: end;
                justify-items: end;
            }

            @media (width < 768px) {
                grid-template-columns: minmax(0, auto);
                font-size: var(--text-sm);
            }
        }

        .ticker-label {
            grid-column: 1 / -1;
        }

        .ticker-text {
            @media (width < 768px) {
                overflow: hidden;
                text-overflow: ellipsis;
                /* room for descenders inside the clipped box */
                padding-block: 0.25em;
                margin-block: -0.25em;
            }
        }

        .ticker-updated {
            @container page (width < 1400px) {
                display: none;
            }
        }

        .ticker-line {
            display: flex;
            align-items: center;
            gap: var(--ticker-gap);
            min-width: 0;
        }

        .ticker-info {
            width: 14px;
            height: 14px;
            opacity: 0.6;
            transition: opacity var(--t-fast) ease;
        }

        .ticker-slide--footprint:is(:hover, :focus-visible) .ticker-info {
            opacity: 1;
        }

        /* the logo slide and its dot only exist on phones, where the header logo is hidden */
        .ticker-slide--logo {
            display: flex;
            align-items: center;
            justify-content: center;
            /* shift by the dot and gap so the logo centres on the screen */
            padding-inline-start: calc(var(--ticker-dot) + var(--ticker-gap));
        }

        .ticker-logo {
            display: block;
            height: 23.4px;
        }

        .ticker-slide--logo,
        .ticker-dot--logo {
            @media (width >= 768px) {
                display: none;
            }
        }
    }
}
