/* ================================================================
   YT Channel Grid — Public Stylesheet v1.1
   Zero SVG. All icons use CSS shapes or Unicode characters.
   Dark & Light themes | Grid | Slider | Lightbox | Mobile-first
   ================================================================ */

/* ── CSS Variables ──────────────────────────────────────────────── */
.ytcg-theme-dark {
    --ytcg-bg:         #0f0f0f;
    --ytcg-card-bg:    #1a1a1a;
    --ytcg-card-hover: #242424;
    --ytcg-border:     #2a2a2a;
    --ytcg-text:       #f1f1f1;
    --ytcg-text-muted: #aaaaaa;
    --ytcg-accent:     #ff0000;
    --ytcg-shadow:     0 6px 28px rgba(0,0,0,0.65);
    --ytcg-arrow-bg:   rgba(255,255,255,0.12);
    --ytcg-arrow-hover:rgba(255,255,255,0.22);
    --ytcg-dot-idle:   rgba(255,255,255,0.28);
    --ytcg-dot-active: #ff0000;
    --ytcg-overlay:    rgba(0,0,0,0.90);
    --ytcg-play-bg:    rgba(0,0,0,0.70);
    --ytcg-play-hover: #ff0000;
}

.ytcg-theme-light {
    --ytcg-bg:         #f4f4f4;
    --ytcg-card-bg:    #ffffff;
    --ytcg-card-hover: #f9f9f9;
    --ytcg-border:     #e0e0e0;
    --ytcg-text:       #111111;
    --ytcg-text-muted: #666666;
    --ytcg-accent:     #cc0000;
    --ytcg-shadow:     0 6px 24px rgba(0,0,0,0.13);
    --ytcg-arrow-bg:   rgba(0,0,0,0.09);
    --ytcg-arrow-hover:rgba(0,0,0,0.18);
    --ytcg-dot-idle:   rgba(0,0,0,0.22);
    --ytcg-dot-active: #cc0000;
    --ytcg-overlay:    rgba(0,0,0,0.85);
    --ytcg-play-bg:    rgba(0,0,0,0.62);
    --ytcg-play-hover: #cc0000;
}

/* ── Wrapper ────────────────────────────────────────────────────── */
.ytcg-wrap {
    background:  var(--ytcg-bg);
    border-radius: 10px;
    padding:     22px;
    box-sizing:  border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.ytcg-heading {
    color:       var(--ytcg-text);
    font-size:   clamp(1.1rem, 3vw, 1.5rem);
    font-weight: 700;
    margin:      0 0 18px;
}

/* ── Grid ───────────────────────────────────────────────────────── */
.ytcg-grid {
    display: grid;
    gap:     16px;
}
.ytcg-cols-2 { grid-template-columns: repeat(2, 1fr); }
.ytcg-cols-3 { grid-template-columns: repeat(3, 1fr); }
.ytcg-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .ytcg-cols-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 680px) {
    .ytcg-cols-3,
    .ytcg-cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .ytcg-cols-2,
    .ytcg-cols-3,
    .ytcg-cols-4 { grid-template-columns: 1fr; }
    .ytcg-wrap   { padding: 14px; }
}

/* ── Card ───────────────────────────────────────────────────────── */
.ytcg-card {
    background:    var(--ytcg-card-bg);
    border:        1px solid var(--ytcg-border);
    border-radius: 8px;
    overflow:      hidden;
    cursor:        pointer;
    transition:    transform 0.2s ease, box-shadow 0.2s ease;
    outline:       none;
}
.ytcg-card:hover,
.ytcg-card:focus {
    transform:  translateY(-3px);
    box-shadow: var(--ytcg-shadow);
    outline:    2px solid var(--ytcg-accent);
}

/* ── Thumbnail ──────────────────────────────────────────────────── */
.ytcg-thumb-wrap {
    position:     relative;
    aspect-ratio: 16 / 9;
    overflow:     hidden;
    background:   #000;
}
.ytcg-thumb {
    width:      100%;
    height:     100%;
    object-fit: cover;
    display:    block;
    transition: transform 0.3s ease, opacity 0.3s;
}
.ytcg-card:hover .ytcg-thumb {
    transform: scale(1.05);
    opacity:   0.75;
}

/* ── Play button — pure CSS circle + triangle ───────────────────── */
.ytcg-play-btn {
    position:   absolute;
    top:        50%;
    left:       50%;
    transform:  translate(-50%, -50%) scale(0.8);
    opacity:    0;
    transition: opacity 0.22s ease, transform 0.22s ease;
    pointer-events: none;
}
.ytcg-card:hover .ytcg-play-btn {
    opacity:   1;
    transform: translate(-50%, -50%) scale(1);
}

/* Circle background */
.ytcg-play-circle {
    width:         58px;
    height:        58px;
    border-radius: 50%;
    background:    var(--ytcg-play-bg);
    display:       flex;
    align-items:   center;
    justify-content: center;
    transition:    background 0.2s;
    /* Subtle border ring */
    box-shadow:    0 0 0 3px rgba(255,255,255,0.25);
}
.ytcg-card:hover .ytcg-play-circle {
    background: var(--ytcg-play-hover);
}

/* Triangle — CSS border trick, zero SVG */
.ytcg-play-triangle {
    width:        0;
    height:       0;
    border-style: solid;
    /* pointing right */
    border-width: 10px 0 10px 18px;
    border-color: transparent transparent transparent #ffffff;
    margin-left:  4px; /* optical center */
}

/* ── Date badge ─────────────────────────────────────────────────── */
.ytcg-date {
    position:      absolute;
    bottom:        7px;
    right:         7px;
    background:    rgba(0,0,0,0.75);
    color:         #fff;
    font-size:     11px;
    font-weight:   600;
    padding:       2px 7px;
    border-radius: 3px;
    line-height:   1.6;
}

/* ── Title ──────────────────────────────────────────────────────── */
.ytcg-title {
    color:              var(--ytcg-text);
    font-size:          13px;
    font-weight:        600;
    line-height:        1.45;
    margin:             9px 11px 11px;
    display:            -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow:           hidden;
}

/* ================================================================
   SLIDER
   ================================================================ */
.ytcg-slider-wrapper {
    position: relative;
    padding:  0 48px; /* space for arrows */
}

@media (max-width: 520px) {
    .ytcg-slider-wrapper { padding: 0 36px; }
}

.ytcg-slider-track-wrap {
    overflow:      hidden;
    border-radius: 8px;
}

.ytcg-slider-track {
    display:    flex;
    gap:        16px;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    will-change: transform;
}
.ytcg-slider-track.is-dragging {
    transition: none;
    cursor:     grabbing;
}

/* Slides */
.ytcg-slider-track .ytcg-slide {
    flex:          0 0 calc(33.333% - 11px);
    min-width:     0;
    border-radius: 8px;
}
@media (max-width: 900px) {
    .ytcg-slider-track .ytcg-slide { flex-basis: calc(50% - 8px); }
}
@media (max-width: 560px) {
    .ytcg-slider-track .ytcg-slide { flex-basis: calc(82vw); }
}

/* ── Arrow buttons — CSS chevron, no SVG ────────────────────────── */
.ytcg-arrow {
    position:        absolute;
    top:             50%;
    transform:       translateY(-60%); /* above dots */
    z-index:         10;
    width:           36px;
    height:          36px;
    border-radius:   50%;
    border:          none;
    background:      var(--ytcg-arrow-bg);
    color:           var(--ytcg-text);
    cursor:          pointer;
    display:         flex;
    align-items:     center;
    justify-content: center;
    transition:      background 0.2s, opacity 0.2s;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.ytcg-arrow:hover       { background: var(--ytcg-arrow-hover); }
.ytcg-arrow[disabled]   { opacity: 0.3; cursor: default; }
.ytcg-arrow:focus       { outline: 2px solid var(--ytcg-accent); }

.ytcg-arrow-prev { left:  4px; }
.ytcg-arrow-next { right: 4px; }

/* CSS chevron: a rotated square with two borders */
.ytcg-chevron {
    display:      block;
    width:        10px;
    height:       10px;
    border-style: solid;
    border-color: var(--ytcg-text);
    border-width: 2px 2px 0 0;
}
.ytcg-chevron-left  { transform: rotate(-135deg); margin-left:  3px; }
.ytcg-chevron-right { transform: rotate(45deg);   margin-right: 3px; }

/* ── Dots ───────────────────────────────────────────────────────── */
.ytcg-dots {
    display:         flex;
    justify-content: center;
    gap:             7px;
    margin-top:      14px;
}
.ytcg-dot {
    width:         8px;
    height:        8px;
    border-radius: 50%;
    background:    var(--ytcg-dot-idle);
    border:        none;
    padding:       0;
    cursor:        pointer;
    transition:    background 0.2s, transform 0.2s;
}
.ytcg-dot.is-active {
    background: var(--ytcg-dot-active);
    transform:  scale(1.45);
}
.ytcg-dot:focus { outline: 2px solid var(--ytcg-accent); }

/* ================================================================
   LIGHTBOX
   ================================================================ */
.ytcg-lightbox {
    position: fixed;
    inset:    0;
    z-index:  99999;
    display:  flex;
    align-items:     center;
    justify-content: center;
}
.ytcg-lightbox[hidden] { display: none; }

.ytcg-lightbox-overlay {
    position:   absolute;
    inset:      0;
    background: var(--ytcg-overlay);
    cursor:     pointer;
    animation:  ytcgFadeIn 0.22s ease;
}

.ytcg-lightbox-inner {
    position:   relative;
    z-index:    1;
    width:      90vw;
    max-width:  940px;
    animation:  ytcgSlideUp 0.28s ease;
}

/* 16:9 video container */
.ytcg-lightbox-video {
    position:      relative;
    padding-top:   56.25%;
    border-radius: 8px;
    overflow:      hidden;
    background:    #000;
    box-shadow:    0 20px 80px rgba(0,0,0,0.85);
}
.ytcg-lightbox-video iframe {
    position: absolute;
    inset:    0;
    width:    100%;
    height:   100%;
    border:   none;
}

.ytcg-lightbox-title {
    color:       #fff;
    text-align:  center;
    margin:      14px 0 0;
    font-size:   14px;
    font-weight: 600;
    line-height: 1.4;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

/* ── Close button — Unicode × no SVG ───────────────────────────── */
.ytcg-lightbox-close {
    position:        absolute;
    top:             -14px;
    right:           -14px;
    width:           34px;
    height:          34px;
    border-radius:   50%;
    border:          2px solid rgba(255,255,255,0.35);
    background:      rgba(20,20,20,0.85);
    color:           #fff;
    cursor:          pointer;
    display:         flex;
    align-items:     center;
    justify-content: center;
    z-index:         2;
    transition:      background 0.18s, border-color 0.18s;
    padding:         0;
    line-height:     1;
}
.ytcg-lightbox-close:hover {
    background:   rgba(204,0,0,0.9);
    border-color: #cc0000;
}
.ytcg-lightbox-close:focus { outline: 2px solid var(--ytcg-accent, #ff0000); }

/* The × character */
.ytcg-close-icon {
    font-size:   22px;
    font-weight: 300;
    line-height: 1;
    margin-top:  -1px;
    font-family: Arial, sans-serif;
}

/* ── Animations ─────────────────────────────────────────────────── */
@keyframes ytcgFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes ytcgSlideUp {
    from { opacity: 0; transform: translateY(18px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── Reduced motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ytcg-card,
    .ytcg-thumb,
    .ytcg-play-btn,
    .ytcg-play-circle,
    .ytcg-slider-track,
    .ytcg-lightbox-overlay,
    .ytcg-lightbox-inner {
        transition: none !important;
        animation:  none !important;
    }
}

/* ================================================================
   SHORTS MODE — Portrait 9:16 thumbnails
   ================================================================ */

/* Portrait aspect ratio for Shorts thumbnails */
.ytcg-thumb-portrait {
    aspect-ratio: 9 / 16 !important;
}

/* Shorts cards are naturally narrower — bump default columns */
.ytcg-shorts-mode .ytcg-cols-3 { grid-template-columns: repeat(3, 1fr); }
.ytcg-shorts-mode .ytcg-cols-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 600px) {
    .ytcg-shorts-mode .ytcg-cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 400px) {
    .ytcg-shorts-mode .ytcg-cols-2,
    .ytcg-shorts-mode .ytcg-cols-3 { grid-template-columns: 1fr; }
}

/* Shorts slider cards are narrower */
.ytcg-shorts-mode .ytcg-slider-track .ytcg-slide {
    flex-basis: calc(25% - 12px);
}
@media (max-width: 900px) {
    .ytcg-shorts-mode .ytcg-slider-track .ytcg-slide { flex-basis: calc(33.333% - 11px); }
}
@media (max-width: 600px) {
    .ytcg-shorts-mode .ytcg-slider-track .ytcg-slide { flex-basis: calc(55vw); }
}

/* ── Type badges ──────────────────────────────────────────────── */
.ytcg-type-badge {
    position:      absolute;
    top:           7px;
    left:          7px;
    font-size:     10px;
    font-weight:   700;
    padding:       2px 7px;
    border-radius: 3px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height:   1.6;
}

.ytcg-badge-short {
    background: #ff0000;
    color:      #ffffff;
}

.ytcg-badge-video {
    background: rgba(0, 0, 0, 0.65);
    color:      #ffffff;
}
