/* YouTube Channel Feed — frontend styles */

.ycf {
    --ycf-gap: 1rem;
    --ycf-radius: 0.75rem;
    --ycf-bg: #ececec;
    --ycf-text: inherit;
    --ycf-meta: #6b6b6b;
    --ycf-accent: #ff0000;
    --ycf-nav-bg: rgba(0, 0, 0, 0.7);
    --ycf-nav-bg-hover: rgba(0, 0, 0, 0.9);
    --ycf-columns: 3;

    position: relative;
    margin: 1.5rem 0;
    color: var(--ycf-text);
    font-family: inherit;
    box-sizing: border-box;
}

.ycf *,
.ycf *::before,
.ycf *::after {
    box-sizing: border-box;
}

/* ---------- Track layouts ---------- */

.ycf__track {
    display: grid;
    grid-template-columns: repeat(var(--ycf-columns), minmax(0, 1fr));
    gap: var(--ycf-gap);
}

.ycf--carousel .ycf__track {
    display: flex;
    grid-template-columns: none;
    gap: var(--ycf-gap);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    padding: 0 0 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.ycf--carousel .ycf__card {
    flex: 0 0 calc((100% - (var(--ycf-columns) - 1) * var(--ycf-gap)) / var(--ycf-columns));
    scroll-snap-align: start;
}

/* ---------- Card ---------- */

.ycf__card {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ycf__thumb {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--ycf-bg);
    border-radius: var(--ycf-radius);
    overflow: hidden;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.ycf__thumb:focus-visible {
    outline: 2px solid var(--ycf-accent);
    outline-offset: 2px;
}

.ycf__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.ycf__thumb:hover .ycf__img,
.ycf__thumb:focus-visible .ycf__img {
    transform: scale(1.04);
}

.ycf__play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 45px;
    opacity: 0.92;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

.ycf__thumb:hover .ycf__play,
.ycf__thumb:focus-visible .ycf__play {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.ycf__play svg {
    width: 100%;
    height: 100%;
    display: block;
}

.ycf__duration {
    position: absolute;
    right: 0.5rem;
    bottom: 0.5rem;
    padding: 0.15rem 0.4rem;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 0.25rem;
    line-height: 1.2;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}

.ycf__title {
    margin: 0.65rem 0 0.2rem;
    font-size: 1rem;
    line-height: 1.35;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.ycf__title a {
    color: inherit;
    text-decoration: none;
}

.ycf__title a:hover {
    color: var(--ycf-accent);
}

.ycf__meta {
    font-size: 0.85rem;
    color: var(--ycf-meta);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: baseline;
}

.ycf__meta span + span::before {
    content: "•";
    margin-right: 0.5rem;
    opacity: 0.7;
}

/* ---------- Inline player swap-in ---------- */

.ycf__thumb--playing {
    cursor: default;
    background: #000;
}

.ycf__player {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* ---------- Carousel nav ---------- */

.ycf__nav {
    position: absolute;
    top: calc((100% - var(--ycf-card-extra, 5rem)) / 2);
    z-index: 2;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 0;
    background: var(--ycf-nav-bg);
    color: #fff;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, opacity 0.2s ease;
    padding: 0;
}

.ycf__nav:hover,
.ycf__nav:focus-visible {
    background: var(--ycf-nav-bg-hover);
}

.ycf__nav svg {
    width: 24px;
    height: 24px;
    display: block;
}

.ycf__nav--prev { left: -8px; }
.ycf__nav--next { right: -8px; }

.ycf--carousel .ycf__nav {
    display: flex;
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
    .ycf:not(.ycf--carousel) {
        --ycf-columns: 3;
    }
}

@media (max-width: 820px) {
    .ycf:not(.ycf--carousel) {
        --ycf-columns: 2;
    }
    .ycf--carousel {
        --ycf-columns: 2.2;
    }
}

@media (max-width: 520px) {
    .ycf:not(.ycf--carousel) {
        --ycf-columns: 1;
    }
    .ycf--carousel {
        --ycf-columns: 1.4;
    }
    .ycf__title {
        font-size: 0.95rem;
    }
}

/* ---------- Dark mode (auto, when site uses prefers-color-scheme) ---------- */

@media (prefers-color-scheme: dark) {
    .ycf {
        --ycf-bg: #2a2a2a;
        --ycf-meta: #a3a3a3;
    }
}
