/* ── YouTube Grid Plugin ── */

/* Grid layout */
.ytg-wrapper {
    position: relative;
    margin: 2em 0;
}

.ytg-grid {
    display: grid;
    grid-template-columns: repeat(var(--ytg-cols, 3), 1fr);
    gap: 1.25rem;
}

@media (max-width: 900px) {
    .ytg-grid {
        grid-template-columns: repeat(
            min(var(--ytg-cols, 3), 2),
            1fr
        );
    }
}

@media (max-width: 540px) {
    .ytg-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Card ── */
.ytg-card {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
    outline: none;
}

.ytg-card:hover,
.ytg-card:focus {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
}

/* Thumbnail */
.ytg-thumb-wrap {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: #111;
}

.ytg-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s ease;
}

.ytg-card:hover .ytg-thumb {
    transform: scale(1.05);
}

/* Play button overlay */
.ytg-play-btn {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s ease;
}

.ytg-card:hover .ytg-play-btn,
.ytg-card:focus .ytg-play-btn {
    opacity: 1;
}

.ytg-play-btn svg {
    width: 68px;
    height: 48px;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,.5));
}

/* Duration badge */
.ytg-duration {
    position: absolute;
    bottom: 6px;
    right: 8px;
    background: rgba(0,0,0,.75);
    color: #fff;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

/* Card body */
.ytg-card-body {
    padding: .65rem .85rem .8rem;
}

.ytg-card-title {
    margin: 0;
    font-size: .92rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #1a1a1a;
}

/* ── Load More ── */
.ytg-load-more-wrap {
    text-align: center;
    margin-top: 1.75rem;
}

.ytg-load-more-btn {
    display: inline-block;
    padding: .65rem 2.2rem;
    background: #ff0000;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s ease, transform .15s ease;
}

.ytg-load-more-btn:hover {
    background: #cc0000;
    transform: translateY(-1px);
}

.ytg-load-more-btn:disabled {
    background: #aaa;
    cursor: not-allowed;
    transform: none;
}

/* ── Loading spinner ── */
.ytg-loading {
    display: none;
    justify-content: center;
    padding: 1.5rem 0;
}

.ytg-loading.active {
    display: flex;
}

.ytg-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #ddd;
    border-top-color: #ff0000;
    border-radius: 50%;
    animation: ytg-spin .7s linear infinite;
}

@keyframes ytg-spin {
    to { transform: rotate(360deg); }
}

/* ── Lightbox ── */
.ytg-lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.8);
    z-index: 9998;
    animation: ytg-fade-in .2s ease;
}

.ytg-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ytg-lightbox.open,
.ytg-lightbox-overlay.open {
    display: flex;
}

@keyframes ytg-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.ytg-lightbox-inner {
    background: #111;
    border-radius: 12px;
    overflow: hidden;
    width: 100%;
    max-width: 900px;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
    animation: ytg-slide-up .25s ease;
    position: relative;
}

@keyframes ytg-slide-up {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.ytg-lightbox-close {
    position: absolute;
    top: 10px;
    right: 14px;
    z-index: 10;
    background: rgba(0,0,0,.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ytg-lightbox-close:hover {
    background: rgba(255,0,0,.8);
}

.ytg-lightbox-iframe-wrap {
    position: relative;
    padding-top: 56.25%; /* 16:9 */
    background: #000;
}

.ytg-lightbox-iframe-wrap iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.ytg-lightbox-info {
    padding: .9rem 1.1rem 1.1rem;
    color: #f0f0f0;
}

.ytg-lightbox-title {
    margin: 0 0 .4rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
}

.ytg-lightbox-desc {
    margin: 0;
    font-size: .85rem;
    color: #aaa;
    line-height: 1.5;
}

/* ── Error ── */
.ytg-error {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: .75rem 1rem;
    border-radius: 4px;
    font-size: .9rem;
}
