/**
 * YouTube Shorts Carousel - Frontend Styles
 */

.ytsc-wrap {
    --ytsc-visible: 4;
    --ytsc-rows: 1;
    --ytsc-gap: 14px;
    --ytsc-radius: 14px;
    --ytsc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --ytsc-font-size: 14px;
    --ytsc-title-color: #0f0f0f;
    --ytsc-card-bg: #ffffff;
    --ytsc-card-border: #e5e5e5;
    --ytsc-btn-color: #000000;
    --ytsc-btn-bg: #ffffff;
    --ytsc-arrow-size: 40px;

    width: 100%;
    position: relative;
    font-family: var(--ytsc-font);
}

/* =========================
   NAVIGATION CONTAINER
   ========================= */
.ytsc-nav {
    display: flex;
    gap: 8px;
    z-index: 10;
}

/* Arrow Positions */
.ytsc-arrows-top-right .ytsc-nav { justify-content: flex-end; margin-bottom: 12px; }
.ytsc-arrows-top-left .ytsc-nav { justify-content: flex-start; margin-bottom: 12px; }
.ytsc-arrows-top-center .ytsc-nav { justify-content: center; margin-bottom: 12px; }
.ytsc-arrows-bottom-right .ytsc-nav { justify-content: flex-end; margin-top: 12px; order: 2; }
.ytsc-arrows-bottom-left .ytsc-nav { justify-content: flex-start; margin-top: 12px; order: 2; }
.ytsc-arrows-bottom-center .ytsc-nav { justify-content: center; margin-top: 12px; order: 2; }

/* Bottom arrows - reorder elements */
.ytsc-arrows-bottom-right,
.ytsc-arrows-bottom-left,
.ytsc-arrows-bottom-center {
    display: flex;
    flex-direction: column;
}

/* Side arrows */
.ytsc-arrows-sides,
.ytsc-arrows-sides-outside {
    position: relative;
}

.ytsc-arrows-sides .ytsc-nav,
.ytsc-arrows-sides-outside .ytsc-nav {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    justify-content: space-between;
    pointer-events: none;
    margin: 0;
    padding: 0 8px;
}

.ytsc-arrows-sides-outside .ytsc-nav {
    left: -50px;
    right: -50px;
    padding: 0;
}

.ytsc-arrows-sides .ytsc-btn,
.ytsc-arrows-sides-outside .ytsc-btn {
    pointer-events: auto;
}

/* Hidden arrows */
.ytsc-no-arrows .ytsc-nav { display: none; }

/* =========================
   ARROW BUTTONS
   ========================= */
.ytsc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--ytsc-arrow-size);
    height: var(--ytsc-arrow-size);
    padding: 0;
    border: 1px solid var(--ytsc-btn-color, #000);
    background: var(--ytsc-btn-bg, #fff);
    color: var(--ytsc-btn-color, #000);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ytsc-btn svg {
    width: 50%;
    height: 50%;
}

.ytsc-btn:hover:not(:disabled) {
    opacity: 0.8;
    border-color: var(--ytsc-btn-color);
}

.ytsc-btn:focus {
    outline: 2px solid var(--ytsc-btn-color);
    outline-offset: 2px;
}

.ytsc-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Arrow Styles */
.ytsc-style-circle .ytsc-btn {
    border-radius: 50%;
    border-color: var(--ytsc-btn-color);
}
.ytsc-style-circle-outline .ytsc-btn {
    border-radius: 50%;
    background: transparent !important;
    border: 2px solid var(--ytsc-btn-color);
}
.ytsc-style-square .ytsc-btn {
    border-radius: 4px;
    border-color: var(--ytsc-btn-color);
}
.ytsc-style-square-outline .ytsc-btn {
    border-radius: 4px;
    background: transparent !important;
    border: 2px solid var(--ytsc-btn-color);
}
.ytsc-style-minimal .ytsc-btn {
    background: transparent !important;
    border: none;
}
.ytsc-style-minimal .ytsc-btn:hover:not(:disabled) {
    background: rgba(0,0,0,0.05) !important;
}
.ytsc-style-pill .ytsc-btn {
    border-radius: 20px;
    width: auto;
    padding: 0 16px;
    border-color: var(--ytsc-btn-color);
}

/* =========================
   TRACK / GRID
   ========================= */
.ytsc-track {
    display: grid;
    grid-template-rows: repeat(var(--ytsc-rows), auto);
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - (var(--ytsc-visible) - 1) * var(--ytsc-gap)) / var(--ytsc-visible));
    gap: var(--ytsc-gap);
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding: 8px 0 12px;
    margin: -8px 0 -12px;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.ytsc-track::-webkit-scrollbar { display: none; }

/* =========================
   CARDS
   ========================= */
.ytsc-card {
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--ytsc-card-border);
    border-radius: var(--ytsc-radius);
    overflow: hidden;
    background: var(--ytsc-card-bg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ytsc-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

.ytsc-card:focus {
    outline: 2px solid var(--ytsc-btn-color);
    outline-offset: 2px;
}

/* Thumbnail */
.ytsc-thumb {
    position: relative;
    aspect-ratio: 9 / 16;
    background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
    overflow: hidden;
}

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

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

/* Play button */
.ytsc-play {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    transition: all 0.2s ease;
}

.ytsc-play svg {
    width: 20px;
    height: 20px;
    margin-left: 2px;
}

.ytsc-card:hover .ytsc-play {
    background: rgba(255, 0, 0, 0.9);
    transform: scale(1.1);
}

/* Shorts badge */
.ytsc-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(255, 0, 0, 0.9);
    color: #fff;
}

.ytsc-badge svg {
    width: 14px;
    height: 14px;
}

/* Title */
.ytsc-title {
    padding: 10px 12px 12px;
    font-size: var(--ytsc-font-size);
    font-weight: 500;
    line-height: 1.35;
    color: var(--ytsc-title-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Error */
.ytsc-error {
    padding: 24px;
    text-align: center;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
}

.ytsc-error p { margin: 0 0 8px; }
.ytsc-error p:last-child { margin-bottom: 0; }
.ytsc-error a { color: #dc2626; font-weight: 500; }

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 1200px) {
    .ytsc-arrows-sides-outside .ytsc-nav { left: 0; right: 0; padding: 0 8px; }
}

@media (max-width: 900px) {
    .ytsc-wrap { --ytsc-visible: var(--ytsc-visible-tablet, 3); }
}

@media (max-width: 600px) {
    .ytsc-wrap {
        --ytsc-visible: var(--ytsc-visible-mobile, 1);
        --ytsc-arrow-size: 36px;
    }

    .ytsc-title {
        font-size: 13px;
        padding: 8px 10px;
    }

    .ytsc-play {
        width: 36px;
        height: 36px;
    }

    .ytsc-play svg {
        width: 16px;
        height: 16px;
    }

    .ytsc-badge {
        width: 24px;
        height: 24px;
    }

    .ytsc-badge svg {
        width: 12px;
        height: 12px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ytsc-card,
    .ytsc-thumb img,
    .ytsc-play,
    .ytsc-btn {
        transition: none;
    }

    .ytsc-card:hover { transform: none; }
    .ytsc-card:hover .ytsc-thumb img { transform: none; }
    .ytsc-card:hover .ytsc-play { transform: none; }
    .ytsc-track { scroll-behavior: auto; }
}

/* Print */
@media print {
    .ytsc-nav { display: none; }
    .ytsc-track {
        display: flex;
        flex-wrap: wrap;
        overflow: visible;
    }
    .ytsc-card {
        width: 150px;
        break-inside: avoid;
    }
}
