/* SK Playlist Embed - Frontend Styles */

.skplem-wrapper {
    margin: 20px 0;
}

.skplem-grid,
.skplem-cards-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.skplem-grid > .skplem-card,
.skplem-cards-grid > .skplem-card {
    box-sizing: border-box;
    width: 100%;
}

.skplem-cols-2 > .skplem-card {
    width: calc(50% - 10px);
}

.skplem-cols-3 > .skplem-card {
    width: calc(33.333% - 13.333px);
}

.skplem-cols-4 > .skplem-card {
    width: calc(25% - 15px);
}

.skplem-cols-5 > .skplem-card {
    width: calc(20% - 16px);
}

.skplem-cols-6 > .skplem-card {
    width: calc(16.666% - 16.666px);
}

.skplem-card {
    cursor: pointer;
    border-radius: 8px;
}

.skplem-card:focus-visible,
.skplem-track-btn:focus-visible,
.skplem-page-btn:focus-visible,
.skplem-page-num:focus-visible,
.skplem-modal__close:focus-visible {
    outline: 3px solid #2271b1;
    outline-offset: 2px;
}

.skplem-card__thumbnail {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #f0f0f0;
    overflow: hidden;
    border-radius: 6px;
}

.skplem-card__thumbnail img {
    width: 100%;
    max-width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* List Layout */
.skplem-layout-list .skplem-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.skplem-layout-list .skplem-card {
    display: flex;
    gap: 16px;
    flex-direction: row;
    width: 100%;
}

.skplem-layout-list .skplem-card__thumbnail {
    flex: 0 0 280px;
}

.skplem-layout-list .skplem-card__body {
    flex: 1;
    min-width: 0;
}

/* Cards Layout */
.skplem-layout-cards .skplem-cards-grid > .skplem-card {
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.skplem-layout-cards .skplem-cards-grid > .skplem-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.09);
}

.skplem-layout-cards .skplem-card__thumbnail {
    border-radius: 0;
}

.skplem-layout-cards .skplem-card__body {
    padding: 12px 14px 14px;
}

/* Shorts Layout (9:16 or 4:5 Portrait Thumbnails + Playlist Card Style) */
.skplem-layout-shorts .skplem-card__thumbnail {
    aspect-ratio: 9 / 16;
    border-radius: 10px;
    background: #111;
}

.skplem-layout-shorts.skplem-shorts-aspect-4-5 .skplem-card__thumbnail {
    aspect-ratio: 4 / 5;
}

.skplem-shorts-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(220, 38, 38, 0.92);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.03em;
    padding: 3px 8px;
    border-radius: 999px;
    pointer-events: none;
}

.skplem-track-shell {
    position: relative;
}

.skplem-shorts-track {
    --skplem-track-cols: var(--skplem-cols, 5);
    display: flex;
    flex-wrap: nowrap;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    touch-action: pan-y;
    padding-bottom: 8px;
    scrollbar-width: thin;
}

@media (prefers-reduced-motion: no-preference) {
    .skplem-shorts-track {
        scroll-behavior: smooth;
    }
}

.skplem-shorts-track > .skplem-card {
    flex: 0 0 calc((100% - (var(--skplem-track-cols) - 1) * 16px) / var(--skplem-track-cols));
    width: auto;
    min-width: 0;
    scroll-snap-align: start;
}

.skplem-track-controls {
    position: absolute;
    top: 38%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 6px;
    pointer-events: none;
    z-index: 2;
}

.skplem-track-btn {
    pointer-events: auto;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.14);
    background: rgba(255, 255, 255, 0.94);
    color: #111;
    font-size: 22px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    touch-action: manipulation;
    transition: background-color 0.15s ease, opacity 0.15s ease;
}

.skplem-track-btn:hover:not(:disabled) {
    background: #fff;
}

.skplem-track-btn:disabled {
    opacity: 0;
    pointer-events: none;
}

.skplem-card__body {
    padding-top: 4px;
}

.skplem-card__count {
    font-size: 12px;
    color: #777;
    margin-right: 6px;
    font-weight: 600;
}

.skplem-card__title {
    margin: 6px 0 4px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: #1a1a2e;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.skplem-card__description {
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
    color: #666;
}

/* Native Modal Lightbox */
.skplem-modal {
    border: none;
    padding: 20px;
    margin: auto;
    background: transparent;
    max-width: 100vw;
    max-height: 100dvh;
    overflow: visible;
    box-sizing: border-box;
}

.skplem-modal[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.skplem-modal:modal {
    overscroll-behavior: contain;
}

.skplem-modal::backdrop {
    background: rgba(0, 0, 0, 0.85);
    overflow: hidden;
    overscroll-behavior: contain;
}

.skplem-modal__content {
    position: relative;
    width: min(640px, 90vw);
    max-width: 100%;
}

.skplem-modal--vertical .skplem-modal__content {
    width: min(380px, 88vw, calc(82dvh * 9 / 16));
}

.skplem-modal__close-form {
    margin: 0;
}

.skplem-modal__close {
    position: absolute;
    top: -44px;
    right: 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.35);
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    min-width: 38px;
    min-height: 38px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.skplem-modal__close:hover {
    background: rgba(220, 38, 38, 0.9);
    border-color: rgba(255, 255, 255, 0.85);
}

.skplem-modal__video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.skplem-modal--vertical .skplem-modal__video-wrapper {
    aspect-ratio: 9 / 16;
    border-radius: 12px;
}

.skplem-modal__video-wrapper iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* Pagination */
.skplem-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e2e4e7;
}

.skplem-page-btn,
.skplem-page-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #fff;
    color: #344054;
    font-size: 14px;
    cursor: pointer;
    touch-action: manipulation;
}

.skplem-page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.skplem-page-num.active {
    background: #1a73e8;
    border-color: #1a73e8;
    color: #fff;
    font-weight: 600;
}

/* Responsive Breakpoints (strictly largest to smallest) */
@media (max-width: 1199px) {
    .skplem-cols-5 > .skplem-card,
    .skplem-cols-6 > .skplem-card {
        width: calc(25% - 15px);
    }

    .skplem-shorts-track.skplem-cols-5,
    .skplem-shorts-track.skplem-cols-6 {
        --skplem-track-cols: 4;
    }
}

@media (max-width: 1100px) {
    .skplem-cols-4 > .skplem-card,
    .skplem-cols-5 > .skplem-card,
    .skplem-cols-6 > .skplem-card {
        width: calc(33.333% - 13.333px);
    }

    .skplem-shorts-track.skplem-cols-4,
    .skplem-shorts-track.skplem-cols-5,
    .skplem-shorts-track.skplem-cols-6 {
        --skplem-track-cols: 3;
    }
}

@media (max-width: 991px) {
    .skplem-cols-3 > .skplem-card,
    .skplem-cols-4 > .skplem-card,
    .skplem-cols-5 > .skplem-card,
    .skplem-cols-6 > .skplem-card {
        width: calc(50% - 10px);
    }

    .skplem-shorts-track.skplem-cols-3,
    .skplem-shorts-track.skplem-cols-4,
    .skplem-shorts-track.skplem-cols-5,
    .skplem-shorts-track.skplem-cols-6 {
        --skplem-track-cols: 3;
    }
}

@media (max-width: 767px) {
    .skplem-cols-2 > .skplem-card,
    .skplem-cols-3 > .skplem-card,
    .skplem-cols-4 > .skplem-card,
    .skplem-cols-5 > .skplem-card,
    .skplem-cols-6 > .skplem-card {
        width: 100%;
    }

    /* Keep wrapped Shorts 2-up on phones so 9:16 cards stay compact */
    .skplem-layout-shorts .skplem-grid.skplem-cols-2 > .skplem-card,
    .skplem-layout-shorts .skplem-grid.skplem-cols-3 > .skplem-card,
    .skplem-layout-shorts .skplem-grid.skplem-cols-4 > .skplem-card,
    .skplem-layout-shorts .skplem-grid.skplem-cols-5 > .skplem-card,
    .skplem-layout-shorts .skplem-grid.skplem-cols-6 > .skplem-card {
        width: calc(50% - 10px);
    }

    .skplem-shorts-track.skplem-cols-2,
    .skplem-shorts-track.skplem-cols-3,
    .skplem-shorts-track.skplem-cols-4,
    .skplem-shorts-track.skplem-cols-5,
    .skplem-shorts-track.skplem-cols-6 {
        --skplem-track-cols: 2.15;
    }

    .skplem-layout-list .skplem-card {
        flex-direction: column;
    }

    .skplem-layout-list .skplem-card__thumbnail {
        flex: none;
        width: 100%;
    }

    .skplem-modal {
        padding: 12px;
    }

    .skplem-modal__close {
        top: -40px;
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
        font-size: 18px;
    }
}
