/* ==========================================================================
   VideoWeb v2 - YouTube-like Design
   On top of Bootstrap 5.3.3 + Roboto
   ========================================================================== */

:root {
    --yt-bg: #f9f9f9;
    --yt-text: #0f0f0f;
    --yt-text-primary: #0f0f0f;
    --yt-text-secondary: #545454;
    --yt-border: #e5e5e5;
    --yt-hover: #f2f2f2;
    --yt-radius: 12px;
    --yt-radius-sm: 8px;
    /* Theme: overridden per-site via inline <style> in layout.php */
    --yt-bg-secondary: #f0f0f0;
    --vw-navbar-bg: #121212;
    --vw-navbar-text: #ffffff;
    --vw-accent: #1c62b9;
}

/* btn-outline-secondary contrast fix: Bootstrap's #6c757d fails 4.5:1 on #f9f9f9 */
.btn-outline-secondary {
    --bs-btn-color: #5a6268;
    --bs-btn-border-color: #5a6268;
    --bs-btn-hover-bg: #5a6268;
    --bs-btn-hover-border-color: #5a6268;
}

/* Links inside secondary-bg small text blocks — darken for WCAG AA contrast (4.5:1+) */
.home-intro .small a,
.watch-editorial .small a,
.blog-intro .small a,
.category-intro .small a {
    color: #0a58ca;
    --bs-link-color-rgb: 10, 88, 202;
}

body {
    background-color: var(--yt-bg);
    color: var(--yt-text);
    font-family: "Segoe UI", Arial, sans-serif;
}

/* --------------------------------------------------------------------------
   Navbar
   -------------------------------------------------------------------------- */

.vw-navbar {
    padding: 0;
    box-shadow: 0 1px 0 var(--yt-border);
}

.vw-nav-top {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem .75rem;
    padding: .5rem 0;
}

.navbar-brand {
    font-size: 1.2rem;
    letter-spacing: -0.03em;
    margin-right: 0;
    flex-shrink: 0;
}


/* Search bar - always visible */
.vw-search {
    flex: 1;
    max-width: 540px;
    display: flex;
    margin: 0 auto;
}

.vw-search-input {
    flex: 1;
    background: var(--vw-navbar-bg);
    border: 1px solid rgba(255,255,255,.18);
    border-right: none;
    border-radius: 20px 0 0 20px;
    padding: .5rem 1rem;
    font-size: .9375rem;
    color: var(--vw-navbar-text);
    outline: none;
    min-width: 0;
}

.vw-search-input::placeholder {
    color: #767676;
}

.vw-search-input:focus {
    border-color: var(--vw-accent);
    background: rgba(255,255,255,.06);
}

.vw-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.18);
    border-left: none;
    border-radius: 0 20px 20px 0;
    padding: 0 1rem;
    color: var(--vw-navbar-text);
    cursor: pointer;
    transition: background .15s ease;
}

.vw-search-btn:hover {
    background: rgba(255,255,255,.2);
}

@media (max-width: 767.98px) {
    .vw-search {
        max-width: none;
        order: 10;
        flex-basis: 100%;
        margin: .25rem 0 0;
    }
}

.vw-catbar {
    background: rgba(0,0,0,.15);
    border-top: 1px solid rgba(255,255,255,.08);
}

/* Desktop: wrap + auto-shrink | Mobile: single scrollable row */
.vw-catbar-scroll {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
    padding: .6rem 0;
}

/* --- Normal size (default, few categories) --- */
.vw-catchip {
    display: inline-block;
    white-space: nowrap;
    font-size: .8125rem;
    font-weight: 500;
    padding: .375rem .75rem;
    border-radius: 8px;
    text-decoration: none;
    color: #f1f1f1;
    background: rgba(255,255,255,.1);
    border: none;
    transition: background-color .15s, color .15s, transform .15s;
}

/* --- Compact size (medium count) --- */
.vw-catbar-compact .vw-catchip {
    font-size: .75rem;
    padding: .3rem .6rem;
}
.vw-catbar-compact {
    gap: .375rem;
}

/* --- Mini size (many categories) --- */
.vw-catbar-mini .vw-catchip {
    font-size: .6875rem;
    padding: .25rem .5rem;
    border-radius: 6px;
}
.vw-catbar-mini {
    gap: .3rem;
}

.vw-catchip:hover {
    background: rgba(255,255,255,.2);
    color: #fff;
    transform: translateY(-1px);
}

.vw-catchip.active {
    background: #f1f1f1;
    color: #0f0f0f;
    font-weight: 600;
}

/* Mobile: horizontal scroll, no wrap */
@media (max-width: 767.98px) {
    .vw-catbar-scroll {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .vw-catbar-scroll::-webkit-scrollbar {
        display: none;
    }
    .vw-catchip {
        flex-shrink: 0;
    }
}


.vw-region-switch {
    flex-shrink: 0;
}

.vw-region-select {
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.92);
    padding: .3rem 1.6rem .3rem .65rem;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.2;
    max-width: 180px;
}

.vw-region-select:hover,
.vw-region-select:focus {
    border-color: rgba(255,255,255,.28);
    background: rgba(255,255,255,.14);
    color: #fff;
    outline: none;
    box-shadow: none;
}

.vw-region-select option {
    color: #111;
}

/* --------------------------------------------------------------------------
   YouTube Video Card (yt-card)
   -------------------------------------------------------------------------- */

.yt-card {
    margin-bottom: .25rem;
}

.yt-card-thumb {
    display: block;
    position: relative;
    border-radius: var(--yt-radius);
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: #e4e4e4;
}

.yt-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.yt-card-thumb:hover img {
    opacity: .85;
}

.yt-duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0,0,0,.8);
    color: #fff;
    font-size: .75rem;
    font-weight: 500;
    padding: 1px 4px;
    border-radius: 4px;
    line-height: 1.3;
    letter-spacing: .03em;
}

.yt-card-info {
    padding: 8px 2px 4px;
}

.yt-card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: .875rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--yt-text);
    text-decoration: none;
    margin-bottom: 2px;
}

.yt-card-title:hover {
    color: var(--yt-text);
}

.yt-card-channel {
    font-size: .75rem;
    color: var(--yt-text-secondary);
    line-height: 1.4;
}

.yt-card-channel:hover {
    color: var(--yt-text);
}

.yt-card-meta {
    font-size: .75rem;
    color: var(--yt-text-secondary);
    line-height: 1.4;
}

/* --------------------------------------------------------------------------
   Section Titles
   -------------------------------------------------------------------------- */

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--yt-text);
}

/* --------------------------------------------------------------------------
   Watch Page
   -------------------------------------------------------------------------- */

.watch-title {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--yt-text);
}

/* Player (YouTube IFrame API) */
.yt-player-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin-top: 1rem;
}

.yt-player-wrap iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--yt-radius);
    display: block;
    border: 0;
}

#ytPlayer {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--yt-radius);
}

.yt-autoplay-fallback {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .62);
    border-radius: var(--yt-radius);
    padding: 1rem;
}

.yt-autoplay-fallback[hidden] {
    display: none !important;
}

.yt-autoplay-fallback-inner {
    text-align: center;
    color: #fff;
}

.yt-autoplay-fallback-text {
    font-size: .9rem;
    color: rgba(255, 255, 255, .88);
}

.yt-autoplay-fallback-btn {
    border: 1px solid rgba(255, 255, 255, .5);
    background: #fff;
    color: #111;
    border-radius: 999px;
    padding: .5rem 1rem;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease;
}

.yt-autoplay-fallback-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
}

/* Auto-next bar */
.auto-next-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    background: rgba(0,0,0,.88);
    color: #fff;
    padding: 8px 14px;
    border-radius: 0 0 var(--yt-radius) var(--yt-radius);
    transition: opacity .18s ease;
}

.auto-next-bar.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#autoNextCount {
    display: inline-block;
    min-width: 1ch;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.auto-next-thumb {
    width: 80px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
}

.ratio.rounded {
    border-radius: var(--yt-radius) !important;
}
.ratio.rounded iframe {
    border-radius: var(--yt-radius);
}

/* Info card (channel + description) */
.watch-info-card {
    background-color: var(--yt-hover);
    cursor: default;
}

.channel-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #606060;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .875rem;
    flex-shrink: 0;
}

.channel-name {
    font-weight: 600;
    font-size: .875rem;
    color: var(--yt-text);
    text-decoration: none;
}

.channel-name:hover {
    color: var(--yt-text);
}

.watch-description {
    overflow: hidden;
}

.watch-description.collapsed {
    max-height: 4.5rem;
}

.watch-description:not(.collapsed) {
    max-height: none;
}

.watch-desc-toggle {
    color: #1f2937;
}

.watch-desc-toggle:hover,
.watch-desc-toggle:focus {
    color: #111827;
}

.white-space-pre-line {
    white-space: pre-line;
}

/* Like badge */
.badge.bg-light {
    font-size: .8rem;
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   Related Videos (Watch sidebar)
   -------------------------------------------------------------------------- */

.related-video-thumb {
    width: 168px;
    height: 94px;
    object-fit: cover;
    border-radius: var(--yt-radius-sm);
    flex-shrink: 0;
}

.related-thumb-wrap {
    flex-shrink: 0;
}

.related-video-item {
    padding: 4px;
    border-radius: var(--yt-radius-sm);
    transition: background-color .15s ease;
}

.related-video-item:hover {
    background-color: var(--yt-hover);
}

.related-video-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
    font-size: .8125rem;
    color: var(--yt-text) !important;
}

.duration-badge {
    font-size: .7rem;
    padding: 1px 4px;
    line-height: 1.2;
    letter-spacing: .03em;
    pointer-events: none;
    z-index: 2;
    border-radius: 4px;
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   Sidebar Categories
   -------------------------------------------------------------------------- */

.sidebar-categories .list-group-item {
    border: none;
    border-radius: var(--yt-radius-sm) !important;
    padding: .45rem .75rem;
    margin-bottom: 1px;
    font-size: .875rem;
    color: var(--yt-text);
    background: transparent;
    transition: background-color .15s ease;
}

.sidebar-categories .list-group-item:hover {
    background-color: var(--yt-hover);
}

.sidebar-categories .list-group-item.active {
    background-color: var(--yt-text);
    color: #fff;
}

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */

.pagination .page-link {
    border-radius: 20px;
    border: none;
    margin: 0 2px;
    padding: .375rem .85rem;
    font-size: .875rem;
    color: var(--yt-text);
    background: transparent;
}

.pagination .page-link:hover {
    background-color: var(--yt-hover);
}

.pagination .page-item.active .page-link {
    background-color: var(--yt-text);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    color: #ccc;
    background: transparent;
}

/* --------------------------------------------------------------------------
   Timed Ad Overlay (Watch page)
   -------------------------------------------------------------------------- */

.vw-timed-ad-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.92);
    z-index: 10;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--yt-radius);
    padding: 1.5rem;
    text-align: center;
}
.vw-timed-ad-overlay.active { display: flex; }

.vw-timed-ad-content {
    max-width: 100%;
    max-height: 70%;
    overflow: auto;
    color: #fff;
}

.vw-timed-ad-countdown {
    color: rgba(255,255,255,.7);
    font-size: .8rem;
    margin-top: .75rem;
}

.vw-timed-ad-skip {
    margin-top: .75rem;
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 4px;
    padding: .35rem 1rem;
    font-size: .8125rem;
    cursor: pointer;
    transition: background .15s ease;
}
.vw-timed-ad-skip:hover {
    background: rgba(255,255,255,.25);
}

/* Watch overlay ad (non-Bootstrap modal) */
body.vw-overlay-open {
    overflow: hidden;
}

.vw-ad-overlay {
    position: fixed;
    inset: 0;
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.vw-ad-overlay[hidden] {
    display: none !important;
}

.vw-ad-overlay-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    margin: 0;
    padding: 0;
    background: rgba(0,0,0,.72);
}

.vw-ad-overlay-dialog {
    position: relative;
    width: min(92vw, 560px);
    max-height: 88vh;
    overflow: auto;
    border-radius: 12px;
    background: #fff;
    color: #111;
    box-shadow: 0 18px 44px rgba(0,0,0,.35);
}

.vw-ad-overlay-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .7rem .9rem;
    border-bottom: 1px solid #ececec;
}

.vw-ad-overlay-title {
    margin: 0;
    font-size: .95rem;
    font-weight: 600;
}

.vw-ad-overlay-close {
    border: 0;
    background: transparent;
    color: #4b5563;
    font-size: 1.25rem;
    line-height: 1;
    padding: .1rem .25rem;
}

.vw-ad-overlay-close:hover {
    color: #111;
}

.vw-ad-overlay-body {
    padding: .9rem;
}

/* --------------------------------------------------------------------------
   Ad Slots
   -------------------------------------------------------------------------- */

.ad-slot { min-height: 50px; overflow: hidden; }
.ad-slot[data-ad-size="728"] { max-width: 728px; margin: 0 auto; }
.ad-slot[data-ad-size="300"] { max-width: 300px; margin: 0 auto; }
.ad-slot[data-ad-size="468"] { max-width: 468px; margin: 0 auto; }

/* Fixed-size AdSense containers to minimize CLS */
.ad-slot-fixed {
    display: flex;
    align-items: center;
    justify-content: center;
    contain: layout paint style;
}

.ad-slot-fixed .adsbygoogle {
    display: inline-block !important;
}

.ad-slot-fixed[data-ad-size="728"] { min-height: 90px; }
.ad-slot-fixed[data-ad-size="300"] { min-height: 250px; }
.ad-slot-fixed[data-ad-size="468"] { min-height: 60px; }

@media (max-width: 767.98px) {
    .ad-slot-fixed[data-ad-size="728"],
    .ad-slot-fixed[data-ad-size="468"] {
        display: none;
    }
}

/* --------------------------------------------------------------------------
   404
   -------------------------------------------------------------------------- */

.display-1 { font-size: 8rem; color: #ddd; }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

footer a {
    text-decoration: none;
    color: var(--yt-text-secondary);
}

footer a:hover {
    color: var(--yt-text) !important;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 991.98px) {
    .related-video-thumb { width: 160px; height: 90px; }
}

@media (max-width: 767.98px) {
    .related-video-thumb { width: 120px; height: 68px; }
    .yt-card-title { font-size: .8125rem; }
    .watch-title { font-size: 1.1rem; }
    .display-1 { font-size: 5rem; }
}

@media (max-width: 575.98px) {
    .related-video-thumb { width: 100px; height: 56px; }
    .yt-card-thumb { border-radius: var(--yt-radius-sm); }
}

/* --------------------------------------------------------------------------
   Utility
   -------------------------------------------------------------------------- */

.min-w-0 { min-width: 0; }

/* --------------------------------------------------------------------------
   Blog
   -------------------------------------------------------------------------- */

.blog-content h2 { margin-top: 2rem; margin-bottom: 1rem; font-size: 1.35rem; }
.blog-content h3 { margin-top: 1.5rem; margin-bottom: .75rem; font-size: 1.15rem; }
.blog-content p { margin-bottom: 1rem; }
.blog-content ul, .blog-content ol { margin-bottom: 1rem; padding-left: 1.5rem; }
.blog-content li { margin-bottom: .35rem; }

/* --------------------------------------------------------------------------
   Blog Hero Banner (category-based)
   -------------------------------------------------------------------------- */

.blog-hero {
    position: relative;
    border-radius: var(--yt-radius);
    overflow: hidden;
    margin-bottom: 1.25rem;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    color: #fff;
}

.blog-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: .07;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.blog-hero-text {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
}

.blog-hero-category {
    display: inline-block;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    background: rgba(255,255,255,.2);
    backdrop-filter: blur(4px);
    padding: .25rem .65rem;
    border-radius: 4px;
    margin-bottom: .5rem;
}

.blog-hero-title {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.35;
    margin: 0;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,.15);
}

.blog-hero-icon {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    font-size: 3rem;
    line-height: 1;
    margin-left: 1.5rem;
    opacity: .35;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,.15));
}

@media (max-width: 767.98px) {
    .blog-hero {
        min-height: 120px;
        padding: 1.25rem 1.25rem;
    }
    .blog-hero-title {
        font-size: 1rem;
    }
    .blog-hero-icon {
        font-size: 2.25rem;
        margin-left: 1rem;
    }
}

/* Blog Index - Category color stripe on cards */
.blog-card-stripe {
    height: 4px;
    border-radius: var(--yt-radius) var(--yt-radius) 0 0;
}

.blog-card-has-stripe {
    border-radius: var(--yt-radius) !important;
    overflow: hidden;
}
