/*
 * YT Reel Carousel — Frontend Styles
 *
 * Design philosophy:
 *  - Colors & typography inherit from the active WordPress theme (no hardcoded brand colors).
 *  - Only layout, ratios, transitions, and structural chrome are defined here.
 *  - currentColor / inherit used throughout so the theme's palette flows in naturally.
 */

/* ── Reset ───────────────────────────────────────────── */
.ytrc-wrap *,
.ytrc-wrap *::before,
.ytrc-wrap *::after {
    box-sizing: border-box;
}

/* ── Wrapper ──────────────────────────────────────────── */
.ytrc-wrap {
    --ytrc-gap:     14px;
    --ytrc-radius:  12px;
    width: 100%;
    position: relative;
}

/* ── Toggle bar ───────────────────────────────────────── */
.ytrc-toggle-bar {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.ytrc-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 15px;
    border-radius: 6px;
    /* Inherits theme border, bg, color */
    border: 1px solid currentColor;
    background: transparent;
    color: inherit;
    opacity: 0.5;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.18s;
    line-height: 1.4;
}

.ytrc-view-btn svg {
    flex-shrink: 0;
    stroke: currentColor;
}

.ytrc-view-btn--active,
.ytrc-view-btn:hover {
    opacity: 1;
}

/* ── Track ────────────────────────────────────────────── */
.ytrc-track-outer {
    overflow: hidden;
}

.ytrc-track {
    display: flex;
    gap: var(--ytrc-gap);
    align-items: stretch;
    transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

/* Gallery overrides */
.ytrc-view-gallery .ytrc-track-outer {
    overflow: visible;
}
.ytrc-view-gallery .ytrc-track {
    flex-wrap: wrap;
    transform: none !important;
    transition: none;
}
.ytrc-view-gallery.ytrc-cols-3 .ytrc-card {
    flex: 0 0 calc(33.333% - 10px);
}
.ytrc-view-gallery.ytrc-cols-2 .ytrc-card {
    flex: 0 0 calc(50% - 7px);
}

/* ── Card base ────────────────────────────────────────── */
.ytrc-card {
    /* Carousel default: 3 visible at a time */
    flex: 0 0 calc(33.333% - 10px);
    min-width: 0;
    border-radius: var(--ytrc-radius);
    overflow: hidden;
    position: relative;
    transition: transform 0.2s ease;
}

.ytrc-card--thumb {
    cursor: pointer;
}

.ytrc-card--thumb:hover,
.ytrc-card--thumb:focus-visible {
    transform: translateY(-4px);
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

.ytrc-card-inner {
    position: relative;
    width: 100%;
}

/* ── 9:16 aspect ratio container ──────────────────────── */
.ytrc-card--thumb .ytrc-card-inner,
.ytrc-card--embed .ytrc-card-inner {
    padding-top: 177.78%; /* 9 / 16 × 100 */
    height: 0;
    position: relative;
    overflow: hidden;
    border-radius: var(--ytrc-radius);
    /* Very subtle border using the theme's foreground at low opacity */
    box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.2);
}

/* ── Thumbnail image (custom-thumb card) ──────────────── */
.ytrc-thumb-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.ytrc-card--thumb:hover .ytrc-thumb-img {
    transform: scale(1.03);
}

/* ── Gradient overlay ─────────────────────────────────── */
/*
 * We do NOT use brand colors here — the gradient is black-to-transparent
 * so any custom thumbnail looks great regardless of its color palette.
 */
.ytrc-overlay {
    position: absolute;
    inset: 0;
    /* Lower third gradient — pure black fade, no brand color */
    background: linear-gradient(
        to bottom,
        rgba(0,0,0,0)    40%,
        rgba(0,0,0,0.45) 65%,
        rgba(0,0,0,0.75) 100%
    );
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 14px 13px 18px;
    pointer-events: none;
}

/* ── Overlay text lines ───────────────────────────────── */
/*
 * Font: inherits the theme body font.
 * Colors: white only (on dark overlay). No theme color vars — these
 *         must be readable on any thumbnail background.
 */
.ytrc-line {
    display: block;
    color: #fff;
    font-family: inherit;
    line-height: 1.25;
}

.ytrc-line--top {
    font-size: clamp(11px, 2.5cqi, 13px);
    opacity: 0.85;
    margin-bottom: 3px;
    font-weight: 400;
}

.ytrc-line--headline {
    font-size: clamp(15px, 4.5cqi, 22px);
    font-weight: 700;
    /* Yellow accent — matches the reference image's bold headline style */
    color: #f9e04b;
    text-shadow: 0 1px 6px rgba(0,0,0,0.6);
    margin-bottom: 3px;
    word-break: break-word;
}

.ytrc-line--bottom {
    font-size: clamp(11px, 2.5cqi, 13px);
    opacity: 0.8;
    font-weight: 400;
}

/* ── Play ring (custom-thumb card) ───────────────────── */
.ytrc-play-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(40px, 20%, 58px);
    pointer-events: none;
    opacity: 0.9;
    transition: opacity 0.18s, transform 0.18s;
}

.ytrc-play-ring svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.55));
}

.ytrc-card--thumb:hover .ytrc-play-ring {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

/* ── Embedded iframe card ─────────────────────────────── */
/*
 * No custom thumbnail → show actual YouTube iframe.
 * YouTube renders its own thumbnail, channel info, and player controls
 * exactly as seen in card 3 of the reference image.
 */
.ytrc-iframe-ratio {
    position: absolute;
    inset: 0;
}

.ytrc-iframe-ratio iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    border-radius: var(--ytrc-radius);
}

/* ── Carousel navigation ──────────────────────────────── */
.ytrc-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
}

.ytrc-view-gallery .ytrc-nav {
    display: none;
}

.ytrc-arrow {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid currentColor;
    background: transparent;
    color: inherit;
    opacity: 0.55;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.ytrc-arrow:hover {
    opacity: 1;
}

.ytrc-arrow:disabled {
    opacity: 0.2;
    pointer-events: none;
}

.ytrc-arrow svg {
    stroke: currentColor;
}

/* Dot indicators */
.ytrc-dots {
    display: flex;
    gap: 7px;
    align-items: center;
}

.ytrc-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: none;
    padding: 0;
    background: currentColor;
    opacity: 0.25;
    cursor: pointer;
    transition: width 0.22s, border-radius 0.22s, opacity 0.22s;
}

.ytrc-dot.ytrc-dot--active {
    width: 20px;
    border-radius: 4px;
    opacity: 0.9;
}

/* ── Lightbox ──────────────────────────────────────────── */
.ytrc-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ytrc-lightbox.ytrc-lb--open {
    display: flex;
}

.ytrc-lb-bg {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.88);
    cursor: pointer;
}

.ytrc-lb-box {
    position: relative;
    z-index: 1;
    width: min(90vw, 360px);
    border-radius: var(--ytrc-radius);
    overflow: hidden;
    background: #000;
}

.ytrc-lb-ratio {
    position: relative;
    width: 100%;
    padding-top: 177.78%;
}

.ytrc-lb-iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.ytrc-lb-close {
    position: absolute;
    top: -42px;
    right: 0;
    z-index: 2;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.35);
    background: rgba(0,0,0,0.5);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.ytrc-lb-close:hover {
    background: rgba(255,255,255,0.2);
}

.ytrc-lb-close svg {
    stroke: #fff;
}

/* ── Empty state ──────────────────────────────────────── */
.ytrc-empty {
    padding: 2rem;
    text-align: center;
    opacity: 0.6;
    font-style: italic;
}

/* ══ Responsive ════════════════════════════════════════════
   Breakpoints match the JS getCardsPerView() thresholds.
   ═══════════════════════════════════════════════════════ */

/* Tablet: 2 cards per view */
@media ( max-width: 768px ) {

    .ytrc-card {
        flex: 0 0 calc(50% - 7px);
    }

    .ytrc-view-gallery.ytrc-cols-3 .ytrc-card {
        flex: 0 0 calc(50% - 7px);
    }
}

/* Mobile: 1 card + peek at next */
@media ( max-width: 480px ) {

    .ytrc-card {
        flex: 0 0 82%;
    }

    .ytrc-view-gallery.ytrc-cols-3 .ytrc-card,
    .ytrc-view-gallery.ytrc-cols-2 .ytrc-card {
        flex: 0 0 calc(50% - 7px);
    }

    .ytrc-lb-box {
        width: 96vw;
    }
}

/* Very small screens: gallery goes single column */
@media ( max-width: 360px ) {

    .ytrc-view-gallery.ytrc-cols-3 .ytrc-card,
    .ytrc-view-gallery.ytrc-cols-2 .ytrc-card {
        flex: 0 0 100%;
    }
}
