/* YouTube videos block, following the GSTHR design system (tokens/*.css).
   Each value falls back to the design-system default until the tokens are loaded globally.
   The block only holds the videos; the section heading is composed from separate blocks. */
.yt-vids {
    --yt-heading: var(--text-heading, #222);
    --yt-body: var(--text-body, #222);
    --yt-secondary: var(--text-secondary, #626262);
    --yt-muted: var(--text-muted, #828282);
    --yt-link-hover: var(--text-link-hover, #a92727);
    --yt-brand: var(--text-brand, #c53030);
    --yt-action: var(--action-primary, #c53030);
    --yt-card: var(--surface-card, #fff);
    --yt-border: var(--border-default, #dededa);
    --yt-border-strong: var(--border-strong, #c9c9c4);
    --yt-shadow: var(--shadow-card, 0 1px 2px rgba(34, 34, 34, 0.04));
    --yt-focus: var(--focus-ring, 0 0 0 2px #f7f7f5, 0 0 0 4px #c53030);
    --yt-ease: var(--ease-out, cubic-bezier(0.22, 0.61, 0.36, 1));
    --yt-duration: var(--duration-base, 200ms);
    container: yt-vids / inline-size;
    color: var(--yt-body);
}

/* Dark band variant (Advanced settings → theme). */
.yt-vids[data-bs-theme="dark"],
[data-bs-theme="dark"] .yt-vids {
    --yt-heading: var(--text-on-dark, #f5f4f1);
    --yt-body: var(--text-on-dark, #f5f4f1);
    --yt-secondary: var(--text-on-dark-secondary, #b8b6b0);
    --yt-muted: var(--text-on-dark-secondary, #b8b6b0);
    --yt-link-hover: #fff;
    --yt-card: var(--surface-dark-raised, #2b2b2b);
    --yt-border: var(--border-on-dark, rgba(255, 255, 255, 0.16));
    --yt-border-strong: rgba(255, 255, 255, 0.32);
}

.yt-vids > link {
    display: none;
}

.yt-vids__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
}

/* Featured video: a card with the player on top and its caption below. */
.yt-vids__feature {
    margin: 0;
    overflow: hidden;
    background: var(--yt-card);
    border: 1px solid var(--yt-border);
    border-radius: 12px;
    box-shadow: var(--yt-shadow);
}

.yt-vids__player {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #222;
}

.yt-vids__player iframe,
.yt-vids__facade {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.yt-vids__facade {
    display: block;
}

.yt-vids__facade:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 3px var(--yt-action);
}

.yt-vids__thumb,
.yt-vids__row-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Play control: neutral until hovered, then the primary action colour. */
.yt-vids__play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 64px;
    height: 64px;
    background: rgba(34, 34, 34, 0.78);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: background-color var(--yt-duration) var(--yt-ease);
}

.yt-vids__play::before {
    position: absolute;
    top: 50%;
    left: 54%;
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
    border-left: 17px solid #fff;
    content: "";
    transform: translate(-50%, -50%);
}

.yt-vids__facade:hover .yt-vids__play,
.yt-vids__facade:focus-visible .yt-vids__play,
.yt-vids__row:hover .yt-vids__play,
.yt-vids__row:focus-visible .yt-vids__play {
    background: var(--yt-action);
}

.yt-vids__play--sm {
    width: 30px;
    height: 30px;
}

.yt-vids__play--sm::before {
    border-top-width: 5px;
    border-bottom-width: 5px;
    border-left-width: 8px;
}

.yt-vids__caption {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 20px 18px;
}

.yt-vids__meta {
    color: var(--yt-muted);
    font-size: 12.5px;
}

.yt-vids__title {
    color: var(--yt-heading);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.yt-vids__desc {
    color: var(--yt-secondary);
    font-size: 14px;
    line-height: 1.5;
}

/* Playlist: rows separated by 1px dividers rather than more cards. */
.yt-vids__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.yt-vids__list li + li {
    border-top: 1px solid var(--yt-border);
}

.yt-vids__row {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 12px 2px;
    color: var(--yt-body);
    text-decoration: none;
}

.yt-vids__row:hover {
    color: var(--yt-body);
    text-decoration: none;
}

.yt-vids__row:focus-visible {
    outline: none;
    border-radius: 8px;
    box-shadow: var(--yt-focus);
}

.yt-vids__row-thumb {
    position: relative;
    flex: 0 0 128px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: #222;
    border: 1px solid var(--yt-border);
    border-radius: 8px;
}

.yt-vids__row-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.yt-vids__row-title {
    display: -webkit-box;
    overflow: hidden;
    color: var(--yt-heading);
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.yt-vids__row-desc {
    display: -webkit-box;
    overflow: hidden;
    color: var(--yt-secondary);
    font-size: 13px;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.yt-vids__row-meta {
    color: var(--yt-muted);
    font-size: 12.5px;
}

/* The playing video swaps its channel line for a "Now playing" label. */
.yt-vids__row-now,
.yt-vids__row[aria-current="true"] .yt-vids__row-source {
    display: none;
}

.yt-vids__row[aria-current="true"] .yt-vids__row-now {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--yt-brand);
    font-weight: 600;
}

.yt-vids__row-now::before {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    content: "";
}

.yt-vids__row:hover .yt-vids__row-title {
    color: var(--yt-link-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}


.yt-vids__more {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    padding-top: 12px;
    color: var(--yt-brand);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.yt-vids__more:hover {
    color: var(--yt-link-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.yt-vids__more i {
    transition: transform var(--yt-duration) var(--yt-ease);
}

.yt-vids__more:hover i {
    transform: translateX(3px);
}

.yt-vids__more:focus-visible {
    outline: none;
    border-radius: 4px;
    box-shadow: var(--yt-focus);
}

.yt-vids__playlist {
    display: flex;
    flex-direction: column;
}

/* Wide blocks with a single video: the caption moves beside the player, so the
   video does not take the full width. */
@container yt-vids (min-width: 820px) {
    .yt-vids:not(.yt-vids--playlist) .yt-vids__feature {
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
        gap: 40px;
        align-items: center;
        overflow: visible;
        background: transparent;
        border: 0;
        box-shadow: none;
    }

    .yt-vids:not(.yt-vids--playlist) .yt-vids__player {
        overflow: hidden;
        border: 1px solid var(--yt-border);
        border-radius: 12px;
        box-shadow: var(--yt-shadow);
    }

    .yt-vids:not(.yt-vids--playlist) .yt-vids__caption {
        gap: 10px;
        padding: 0;
    }

    .yt-vids:not(.yt-vids--playlist) .yt-vids__meta {
        font-size: 13px;
    }

    .yt-vids:not(.yt-vids--playlist) .yt-vids__title {
        font-size: 22px;
    }

    .yt-vids:not(.yt-vids--playlist) .yt-vids__desc {
        font-size: 15px;
        line-height: 1.6;
    }
}

/* Wide blocks: the playlist sits beside the player and scrolls within its height. */
@container yt-vids (min-width: 820px) {
    .yt-vids--playlist .yt-vids__layout {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
        gap: 32px;
    }

    /* Size containment stops the playlist from adding height, so the column matches
       the player; the list then takes the height it needs, keeps the link right below
       it, and scrolls when it would overflow. */
    .yt-vids--playlist .yt-vids__playlist {
        contain: size;
    }

    .yt-vids--playlist .yt-vids__list {
        flex: 0 1 auto;
        min-height: 0;
        overflow-y: auto;
    }

    .yt-vids__list li:first-child .yt-vids__row {
        padding-top: 0;
    }

    /* Two or three videos leave the column mostly empty, so their rows grow. */
    .yt-vids--few .yt-vids__row {
        gap: 18px;
        padding: 20px 2px;
    }

    .yt-vids--few .yt-vids__row-thumb {
        flex-basis: clamp(128px, 45%, 210px);
    }

    .yt-vids--few .yt-vids__row-body {
        gap: 6px;
    }

    .yt-vids--few .yt-vids__row-title {
        font-size: 16.5px;
        -webkit-line-clamp: 3;
    }

    .yt-vids--few .yt-vids__row-desc {
        font-size: 14px;
        -webkit-line-clamp: 3;
    }

    .yt-vids--few .yt-vids__more {
        padding-top: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .yt-vids__play,
    .yt-vids__more i {
        transition: none;
    }

    .yt-vids__more:hover i {
        transform: none;
    }
}
