@property --lab-promo-height {
    syntax: "<length>";
    inherits: true;
    initial-value: 3.5rem;
}

:root {
    --lab-promo-height: 3.5rem;

    /* The ticker plus the roll-up knot hanging below it. Panels are inset by this
       rather than by the ticker's own height, so the knot never lands on a topbar
       or a page heading. It tracks `--lab-promo-height`, so rolling the ticker up
       collapses the reserved space too. */
    --lab-promo-reserve: calc(var(--lab-promo-height) + 2.25rem);
}

html.lab-promo-up {
    --lab-promo-height: 0px;
}

html.fi {
    transition: --lab-promo-height 340ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.lab-promo {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: var(--lab-promo-height);
    overflow: hidden;
    padding: 0 1.15rem 0 1.4rem;
    background: #1c1b4b;
    color: #fff;
    font-family: Outfit, Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 1.125rem;
    line-height: 1.2;
    box-shadow: 0 1px 0 rgb(255 255 255 / 8%);
}

.lab-promo-pull {
    position: fixed;
    top: var(--lab-promo-height);
    left: 50%;
    z-index: 81;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 2.75rem;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
    transform: translateX(-50%);
    cursor: pointer;
}

.lab-promo-cord {
    width: 2px;
    height: 7px;
    background: #1c1b4b;
}

.lab-promo-knot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border: 2px solid #fff;
    border-radius: 999px;
    background: #1c1b4b;
    box-shadow: 0 4px 12px rgb(28 27 75 / 28%);
    transition: background 160ms ease, transform 160ms ease;
}

.lab-promo-knot svg {
    display: block;
}

html.lab-promo-up .lab-promo-knot svg {
    transform: scaleY(-1);
}

html.lab-promo-up .lab-promo-stage,
html.lab-promo-up .lab-promo-more {
    visibility: hidden;
}

.lab-promo-pull:hover .lab-promo-knot,
.lab-promo-pull:focus-visible .lab-promo-knot {
    background: #35389d;
    transform: scale(1.06);
}

.lab-promo-pull:focus-visible {
    outline: none;
}

.lab-promo-pull:focus-visible .lab-promo-knot {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1c1b4b;
}

.lab-promo-stage {
    position: relative;
    flex: 1 1 auto;
    height: 100%;
    min-width: 0;
    overflow: hidden;
    color: #fff;
    text-decoration: none;
}

.lab-promo-ad {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    overflow: hidden;
    font-weight: 650;
    letter-spacing: 0.01em;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0;
    animation: lab-promo-flash 12s linear infinite;
    animation-delay: calc(var(--i) * 4s);
}

.lab-promo-stage:hover .lab-promo-ad,
.lab-promo-stage:focus-visible .lab-promo-ad {
    text-decoration: underline;
}

.lab-promo-more {
    flex: 0 0 auto;
    padding: 0.5rem 1rem;
    border: 1px solid rgb(255 255 255 / 45%);
    border-radius: 999px;
    color: #fff;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-decoration: none;
    white-space: nowrap;
}

.lab-promo-more:hover,
.lab-promo-more:focus-visible {
    background: #fff;
    color: #1c1b4b;
}

@keyframes lab-promo-flash {
    0%,
    30% {
        opacity: 1;
    }

    33%,
    100% {
        opacity: 0;
    }
}

html.fi body.fi-body {
    padding-top: var(--lab-promo-reserve);
}

/* Spiggle keeps its own inset and clears only the ticker. The knot sits on the
   shell, so the blue background does not show as a second bar. The topbar is
   in normal flow; the sticky offset would shove it down and leave a gap. */
html.fi[data-spiggle-nav] body.fi-body.fi-body-has-navigation {
    padding-top: calc(0.75rem + var(--lab-promo-height)) !important;
}

html.fi[data-spiggle-nav='solid'] body.fi-body.fi-body-has-navigation,
html.fi[data-spiggle-nav='canvas'] body.fi-body.fi-body-has-navigation {
    padding-top: var(--lab-promo-height) !important;
}

html.fi[data-spiggle-nav='solid'] .fi-sidebar.fi-main-sidebar,
html.fi[data-spiggle-nav='canvas'] .fi-sidebar.fi-main-sidebar {
    height: calc(100dvh - var(--lab-promo-height)) !important;
    max-height: calc(100dvh - var(--lab-promo-height)) !important;
}

html.fi[data-spiggle-nav] .fi-topbar-ctn {
    top: auto !important;
}

/* Material's own promo is the green bar. Reserve only the lab ticker, or a
   dark strip appears above that bar and above the sidebar. */
html.fi[data-smt-density] body.fi-body {
    padding-top: var(--lab-promo-height) !important;
}

html.fi[data-smt-density] .fi-topbar-ctn {
    top: var(--lab-promo-height) !important;
}

html.fi[data-smt-density] body.fi-body.fi-body-has-navigation .fi-sidebar.fi-main-sidebar {
    top: var(--lab-promo-height) !important;
    height: calc(100dvh - var(--lab-promo-height)) !important;
    max-height: calc(100dvh - var(--lab-promo-height)) !important;
}

/* The knot would cover Material's promo line. Drop it onto the toolbar instead. */
html.fi[data-smt-density] .lab-promo-pull {
    top: calc(var(--lab-promo-height) + var(--smt-promo, 36px));
}

html.fi .fi-topbar-ctn {
    top: var(--lab-promo-reserve) !important;
}

html.fi body.fi-body:has(.smt-promo) .fi-sidebar.fi-main-sidebar {
    top: var(--lab-promo-height) !important;
    height: calc(100dvh - var(--lab-promo-height)) !important;
    max-height: calc(100dvh - var(--lab-promo-height)) !important;
}

/* Fascia's desktop rail is fixed 80px down, level with the header. Drop it by the promo. */
@media (min-width: 1024px) {
    html[data-fascia-layout="compact"] body.fi-body .fi-sidebar.fi-main-sidebar,
    html[data-fascia-layout="compact"] body.fi-body .fi-sidebar.fi-main-sidebar.fi-sidebar-open {
        top: calc(80px + var(--lab-promo-reserve)) !important;
    }
}

html[data-fascia-layout="large"] body.fi-body .fi-sidebar.fi-main-sidebar {
    top: var(--lab-promo-reserve) !important;
    height: calc(100dvh - var(--lab-promo-reserve)) !important;
}

@media (max-width: 1023px) {
    html[data-fascia-layout] body.fi-body .fi-sidebar.fi-main-sidebar {
        top: var(--lab-promo-reserve) !important;
        height: calc(100dvh - var(--lab-promo-reserve)) !important;
    }
}

html[data-fascia-layout] #fascia-secondary-portal {
    top: calc(var(--topbar-height, 5rem) + var(--lab-promo-reserve));
    height: calc(100dvh - var(--topbar-height, 5rem) - var(--lab-promo-reserve));
}

.lab-shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17.5rem, 1fr));
    gap: 1.5rem;
}

.lab-shop-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e7e5e4;
    border-radius: 1rem;
    background: #fff;
    color: #1c1917;
    text-decoration: none;
    box-shadow: 0 1px 2px rgb(28 25 23 / 6%);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.lab-shop-card:hover,
.lab-shop-card:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgb(28 25 23 / 12%);
}

.lab-shop-card.is-current {
    border-color: #35389d;
    box-shadow: 0 0 0 2px #35389d;
}

.lab-shop-media {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #f4f1ea;
}

.lab-shop-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lab-shop-ribbon {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: #35389d;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.lab-shop-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.9rem 1rem 1rem;
}

.lab-shop-title-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.lab-shop-name {
    color: #1c1917;
    font-size: 1.02rem;
    font-weight: 700;
}

.lab-shop-price {
    color: #57534e;
    font-size: 0.92rem;
    white-space: nowrap;
}

.lab-shop-blurb {
    display: -webkit-box;
    overflow: hidden;
    min-height: 2.7em;
    color: #57534e;
    font-size: 0.88rem;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.lab-shop-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.35rem;
}

.lab-shop-chip {
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: #eceafe;
    color: #35389d;
    font-size: 0.72rem;
    font-weight: 700;
}

.lab-shop-buy {
    margin-left: auto;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    background: #35389d;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
}

@media (max-width: 640px) {
    .lab-promo {
        gap: 0.6rem;
        padding-right: 0.7rem;
        padding-left: 0.8rem;
        font-size: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html.fi {
        transition: none;
    }

    .lab-promo-ad {
        position: relative;
        animation: none;
        opacity: 0;
    }

    .lab-promo-ad:first-child {
        opacity: 1;
    }

    .lab-shop-card {
        transition: none;
    }
}

.fi-lab-demo-login {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.45;
    color: #1e293b;
}
