/* Hover video tiles: one-line title; font scales with tile width and name length (--title-chars from JS). */

.card-hover-preview-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.28s ease;
    pointer-events: none;
}

.card--hover-preview:hover .card-hover-preview-video,
.card--hover-preview:focus-within .card-hover-preview-video {
    opacity: 1;
}

.card--hover-preview::after {
    inset: auto 0 0 0 !important;
    top: auto !important;
    width: 100%;
    min-width: 0;
    height: auto !important;
    max-height: min(16%, 1.4rem);
    z-index: 1;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-wrap: nowrap !important;
    align-content: center;
    padding: 2px 5px 3px;
    box-sizing: border-box;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden !important;
    font-size: clamp(0.1rem, calc(62cqw / (4 + var(--title-chars, 12))), 0.5rem);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: 0.005em;
    text-align: center;
    background: transparent !important;
    color: #fff;
    text-shadow:
        0 0 3px rgba(0, 0, 0, 1),
        0 0 10px rgba(0, 0, 0, 0.85),
        0 1px 2px rgba(0, 0, 0, 0.95);
}

@container (max-width: 108px) {
    .card--hover-preview::after {
        font-size: clamp(0.09rem, calc(46cqw / (4 + var(--title-chars, 12))), 0.3rem);
        max-height: min(20%, 1.15rem);
        padding: 1px 2px 2px;
    }
}

@container (min-width: 109px) and (max-width: 132px) {
    .card--hover-preview::after {
        font-size: clamp(0.09rem, calc(50cqw / (4 + var(--title-chars, 12))), 0.34rem);
        max-height: min(18%, 1.2rem);
        padding: 1px 3px 2px;
    }
}

@container (min-width: 133px) and (max-width: 168px) {
    .card--hover-preview::after {
        font-size: clamp(0.1rem, calc(54cqw / (4 + var(--title-chars, 12))), 0.38rem);
        max-height: min(17%, 1.28rem);
        padding: 2px 4px 2px;
    }
}

@container (min-width: 169px) and (max-width: 220px) {
    .card--hover-preview::after {
        font-size: clamp(0.1rem, calc(56cqw / (4 + var(--title-chars, 12))), 0.44rem);
        max-height: min(16%, 1.32rem);
        padding: 2px 5px 3px;
    }
}

@container (min-width: 221px) and (max-width: 300px) {
    .card--hover-preview::after {
        font-size: clamp(0.1rem, calc(58cqw / (4 + var(--title-chars, 12))), 0.48rem);
        max-height: min(15%, 1.38rem);
        padding: 2px 7px 3px;
    }
}

@container (min-width: 301px) {
    .card--hover-preview::after {
        font-size: clamp(0.11rem, calc(62cqw / (4 + var(--title-chars, 12))), 0.52rem);
        max-height: min(14%, 1.45rem);
        padding: 3px 10px 4px;
    }
}

body.light .card--hover-preview::after {
    color: #111;
    background: transparent !important;
    text-shadow:
        0 0 3px rgba(255, 255, 255, 1),
        0 0 10px rgba(255, 255, 255, 0.9),
        0 1px 2px rgba(255, 255, 255, 0.95);
}

@media (prefers-reduced-motion: reduce) {
    .card-hover-preview-video {
        display: none !important;
    }

    .card--hover-preview:hover .card-hover-preview-video,
    .card--hover-preview:focus-within .card-hover-preview-video {
        opacity: 0;
    }

    .card--hover-preview::after {
        inset: auto 0 0 0 !important;
        top: auto !important;
        height: auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-wrap: nowrap !important;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden !important;
        background: transparent !important;
        font-weight: 700;
        line-height: 1.12;
        letter-spacing: 0.01em;
        text-align: center;
        color: #fff;
        text-shadow:
            0 0 3px rgba(0, 0, 0, 1),
            0 0 10px rgba(0, 0, 0, 0.85),
            0 1px 2px rgba(0, 0, 0, 0.95);
    }

    body.light .card--hover-preview::after {
        color: #111;
        background: transparent !important;
        text-shadow:
            0 0 3px rgba(255, 255, 255, 1),
            0 0 10px rgba(255, 255, 255, 0.9),
            0 1px 2px rgba(255, 255, 255, 0.95);
    }
}
