/* KartBrain sponsored placements — clearly marked ads */

.kb-ad {
    box-sizing: border-box;
    font-family: inherit;
    --kb-ad-bg: #111111;
}

.kb-ad-label {
    margin: 0 0 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #fbbf24;
}

.kb-ad a {
    color: inherit;
}

.kb-ad-cta {
    display: inline-block;
    margin-top: 6px;
    font-weight: 700;
    color: #fbbf24;
}

.kb-ad-fine {
    margin: 8px 0 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.65);
}

.kb-ad-fine a {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: underline;
}

.kb-ad-text-links {
    margin: 8px 0 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

.kb-ad-text-links a {
    color: #93c5fd;
    text-decoration: underline;
    font-weight: 600;
}

/* Header chip */
.kb-ad-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 10px;
    padding: 3px 8px 3px 3px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #fff !important;
    text-decoration: none !important;
    flex: 0 0 auto;
    max-width: 9.5rem;
}

.kb-ad-header:hover {
    background: rgba(0, 0, 0, 0.28);
}

.kb-ad-header img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: block;
    background: #111;
}

.kb-ad-header-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.05;
    min-width: 0;
}

.kb-ad-header .kb-ad-label {
    margin: 0;
    font-size: 0.58rem;
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: 0.06em;
}

.kb-ad-brand {
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 5.5rem;
}

/* Homepage / library banner */
.kb-ad-banner {
    margin: 16px auto;
    padding: 12px;
    max-width: 960px;
    width: calc(100% - 24px);
    background: var(--kb-ad-bg, #111);
    color: #f3f4f6;
    border: 2px dashed #f59e0b;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.kb-ad-banner-link {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    text-decoration: none !important;
    color: inherit !important;
}

.kb-ad-banner-img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    background: #1f2937;
}

.kb-ad-banner-copy {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kb-ad-banner-copy strong {
    font-size: 1.15rem;
    line-height: 1.25;
}

.kb-ad-banner-copy > span:first-of-type {
    font-size: 0.95rem;
    color: #d1d5db;
    line-height: 1.4;
}

/* Forum sidebar */
.forum-side {
    flex: 0 0 240px;
    width: 240px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.forum-side .forum-aside {
    position: static;
    top: auto;
    max-height: none;
    overflow: visible;
    width: 100%;
    flex: 0 0 auto;
    transform: none !important;
}

.kb-ad-sidebar {
    width: 100%;
    padding: 12px;
    background: var(--kb-ad-bg, #111);
    color: #f3f4f6;
    border: 2px dashed #f59e0b;
    border-radius: 10px;
    box-sizing: border-box;
}

.kb-ad-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none !important;
    color: #f3f4f6 !important;
}

.kb-ad-shot {
    width: 100%;
    height: auto;
    max-height: 110px;
    object-fit: cover;
    object-position: center top;
    border-radius: 8px;
    display: block;
    background: #1f2937;
}

.kb-ad-logo {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    display: block;
}

.kb-ad-headline {
    font-size: 0.95rem;
    line-height: 1.25;
}

.kb-ad-body {
    font-size: 0.82rem;
    color: #d1d5db;
    line-height: 1.35;
}

/* Watch-page CTA under the player */
.kb-ad-video-cta {
    margin: 14px 0;
    padding: 12px;
    background: var(--kb-ad-bg, #111);
    color: #f3f4f6;
    border: 2px dashed #f59e0b;
    border-radius: 10px;
}

.kb-ad-cta-shot-link {
    flex: 1 1 160px;
    min-width: 120px;
    max-width: 240px;
    display: block;
    line-height: 0;
}

.kb-ad-cta-shot {
    width: 100%;
    height: auto;
    max-height: 72px;
    object-fit: cover;
    object-position: center top;
    border-radius: 8px;
    display: block;
}

.kb-ad-video-cta-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.kb-ad-icon-link {
    flex: 0 0 auto;
    display: block;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #fdba74;
    line-height: 0;
}

.kb-ad-icon-link img {
    width: 40px;
    height: 40px;
    display: block;
}

.kb-ad-video-cta-copy {
    flex: 1 1 220px;
    min-width: 0;
}

.kb-ad-video-cta-copy strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 2px;
}

.kb-ad-video-cta-copy p {
    margin: 0;
    font-size: 0.88rem;
    color: #d1d5db;
    line-height: 1.35;
}

.kb-ad-btn {
    flex: 0 0 auto;
    display: inline-block;
    padding: 8px 14px;
    border-radius: 8px;
    background: #c41230;
    color: #fff !important;
    font-weight: 700;
    text-decoration: none !important;
    font-size: 0.9rem;
}

.kb-ad-btn:hover {
    background: #9f0f27;
}

/* Mid-play overlay: bottom 20% of the player, 8s animated popup */
.kb-ad-midroll {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    height: 20%;
    min-height: 88px;
    max-height: 160px;
    padding: 6px 36px 8px 10px;
    background: var(--kb-ad-bg, #111);
    border-top: 2px solid #f59e0b;
    color: #fff;
    box-sizing: border-box;
    transform: translateY(110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.45s ease, opacity 0.35s ease;
}

.kb-ad-midroll[hidden] {
    display: none !important;
}

.kb-ad-midroll.is-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.kb-ad-midroll.is-hiding {
    transform: translateY(110%);
    opacity: 0;
    pointer-events: none;
}

.kb-ad-midroll-close {
    position: absolute;
    top: 4px;
    right: 6px;
    z-index: 2;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.kb-ad-midroll-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.kb-ad-midroll .kb-ad-label {
    margin: 0 0 4px;
    font-size: 0.62rem;
}

.kb-ad-midroll-link {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    height: calc(100% - 1rem);
    text-decoration: none !important;
    color: #fff !important;
}

.kb-ad-midroll-img {
    width: 100%;
    height: 100%;
    max-height: 120px;
    object-fit: cover;
    object-position: center top;
    border-radius: 6px;
    display: block;
    background: #1f2937;
}

.kb-ad-midroll-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.kb-ad-midroll-copy strong {
    font-size: clamp(0.85rem, 2.2vw, 1.05rem);
    line-height: 1.2;
}

.kb-ad-midroll-copy em {
    font-style: normal;
    font-size: clamp(0.72rem, 1.6vw, 0.85rem);
    color: #d1d5db;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 800px) {
    .kb-ad-midroll {
        min-height: 78px;
        padding-right: 34px;
    }

    .kb-ad-midroll-link {
        grid-template-columns: 1fr;
    }

    .kb-ad-midroll-img {
        display: none;
    }

    .kb-ad-midroll-copy em {
        -webkit-line-clamp: 1;
    }
}

/* End-of-video banner: large, bottom-centered over the player */
.kb-ad-video-end {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    z-index: 7;
    width: min(720px, calc(100% - 24px));
    padding: 10px 12px 12px;
    background: var(--kb-ad-bg, #111);
    border: 2px solid #f59e0b;
    border-radius: 12px;
    color: #fff;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.kb-ad-video-end[hidden] {
    display: none !important;
}

.kb-ad-video-end .kb-ad-label {
    color: #fbbf24;
    margin: 0 0 8px;
    text-align: center;
}

.kb-ad-end-btn {
    display: grid;
    grid-template-columns: 72px minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    text-decoration: none !important;
    color: #fff !important;
}

.kb-ad-end-logo {
    width: 72px;
    height: 72px;
    border-radius: 14px;
    flex: 0 0 auto;
    display: block;
    background: #111;
}

.kb-ad-end-shot {
    width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: cover;
    object-position: center top;
    border-radius: 8px;
    display: block;
    background: #1f2937;
}

.kb-ad-end-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.kb-ad-end-btn strong {
    display: block;
    font-size: 1.15rem;
    line-height: 1.25;
}

.kb-ad-end-btn em {
    display: block;
    font-style: normal;
    font-size: 0.9rem;
    color: #d1d5db;
    line-height: 1.35;
}

.kb-ad-end-cta {
    display: inline-block;
    margin-top: 4px;
    font-weight: 700;
    font-size: 0.95rem;
    color: #fbbf24;
}

@media (max-width: 800px) {
    .kb-ad-video-end {
        bottom: 8px;
        width: calc(100% - 16px);
        padding: 8px 10px 10px;
    }

    .kb-ad-end-btn {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    .kb-ad-end-logo {
        width: 56px;
        height: 56px;
        border-radius: 12px;
        flex: 0 0 auto;
    }

    .kb-ad-end-shot {
        display: none;
    }

    .kb-ad-end-copy {
        flex: 1 1 auto;
    }

    .kb-ad-end-btn strong {
        font-size: 1rem;
    }

    .kb-ad-end-btn em {
        font-size: 0.82rem;
    }
}

/* Small text-style chip (after description / comments) */
.kb-ad-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px 0;
    padding: 8px 10px;
    background: var(--kb-ad-bg, #111);
    color: #f3f4f6;
    border: 1px dashed #f59e0b;
    border-radius: 8px;
}

.kb-ad-inline .kb-ad-label {
    margin: 0;
}

.kb-ad-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #93c5fd !important;
    text-decoration: underline;
}

.kb-ad-chip img {
    width: 22px;
    height: 22px;
    border-radius: 4px;
}

@media (max-width: 800px) {
    .kb-ad-banner-link {
        grid-template-columns: 1fr;
    }

    .kb-ad-header-text .kb-ad-brand {
        max-width: 4.2rem;
    }

    .kb-ad-video-cta-row {
        align-items: flex-start;
    }

    .forum-side {
        flex: 1 1 auto;
        width: 100%;
        position: static;
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 768px) {
    .forum-side {
        flex: 1 1 auto;
        width: 100%;
        position: static;
        max-height: none;
    }
}

@media (min-width: 1300px) {
    .forum-side {
        transform: translateX(calc((var(--container-max) - 100vw) / 2 - 8px));
    }
}

@media (max-width: 520px) {
    .kb-ad-header span.kb-ad-brand {
        display: none;
    }

    .kb-ad-header {
        padding: 2px;
        margin-right: 6px;
    }
}
