/**
 * PD Social Video Embed - Frontend stílusok v2.1.0
 *
 * Újdonságok:
 *  - Layered, smoothabb árnyékok (3 réteg blur)
 *  - Custom play gomb színek CSS változókkal
 *  - HD thumbnail crispebb megjelenítés
 *  - Finomabb hover állapotok
 *
 * @package PD_Social_Video_Embed
 * @author  Papp Ádám – PixelDesigns
 */

/* ==========================================================================
   Wrapper alapok
   ========================================================================== */
.pd-sve-wrap {
    /* Default értékek (felülírva az inline CSS által ha van beállítás) */
    --pd-sve-accent: #0066ff;
    --pd-sve-radius: 16px;
    --pd-sve-play-bg: #ffffff;
    --pd-sve-play-fg: #0a0a0a;

    --pd-sve-bg: #0a0a0a;
    --pd-sve-bg-soft: #1a1a1a;
    --pd-sve-text: #fafafa;
    --pd-sve-text-muted: rgba(255, 255, 255, 0.7);
    --pd-sve-border: rgba(255, 255, 255, 0.08);

    /* Layered shadow rendszer - smoothabb, mélyebb mint korábban */
    --pd-sve-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 2px 4px -1px rgba(0, 0, 0, 0.06),
        0 8px 16px -4px rgba(0, 0, 0, 0.08),
        0 24px 48px -12px rgba(0, 0, 0, 0.12);

    --pd-sve-shadow-hover:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 4px 8px -2px rgba(0, 0, 0, 0.08),
        0 16px 32px -8px rgba(0, 0, 0, 0.14),
        0 40px 80px -20px rgba(0, 0, 0, 0.22);

    /* Platform színek */
    --pd-sve-tiktok: #fe2c55;
    --pd-sve-tiktok-cyan: #25f4ee;
    --pd-sve-youtube: #ff0033;

    --pd-sve-gap: 20px;
    --pd-sve-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --pd-sve-ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

    box-sizing: border-box;
    width: 100%;
    margin: 0 auto;
    font-family: inherit;
}

.pd-sve-wrap *,
.pd-sve-wrap *::before,
.pd-sve-wrap *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   Kártya
   ========================================================================== */
.pd-sve-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--pd-sve-bg);
    border-radius: var(--pd-sve-radius);
    overflow: hidden;
    transition:
        transform 0.5s var(--pd-sve-ease),
        box-shadow 0.5s var(--pd-sve-ease);
    box-shadow: var(--pd-sve-shadow);
    isolation: isolate;
}

.pd-sve-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--pd-sve-shadow-hover);
}

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

.pd-sve-card__player:focus-visible {
    outline: 3px solid var(--pd-sve-accent);
    outline-offset: 3px;
}

/* Thumbnail - HD verzió crisp rendering */
.pd-sve-card__thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition:
        transform 0.7s var(--pd-sve-ease),
        filter 0.5s ease;
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
    image-rendering: -webkit-optimize-contrast; /* Crisp HD megjelenés */
}

.pd-sve-card__player:hover .pd-sve-card__thumb {
    transform: scale(1.05);
    filter: brightness(0.92);
}

.pd-sve-card__thumb--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.3);
}

.pd-sve-card__thumb--placeholder.pd-sve-card__thumb--tiktok {
    background: linear-gradient(135deg, var(--pd-sve-tiktok-cyan) 0%, #000 50%, var(--pd-sve-tiktok) 100%);
}

.pd-sve-card__thumb--placeholder.pd-sve-card__thumb--youtube {
    background: linear-gradient(135deg, #1a1a1a 0%, var(--pd-sve-youtube) 100%);
}

/* Overlay */
.pd-sve-card__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0) 55%,
        rgba(0, 0, 0, 0.4) 100%
    );
    transition: background 0.4s var(--pd-sve-ease);
    pointer-events: none;
}

.pd-sve-card__player:hover .pd-sve-card__overlay {
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.15) 0%,
        rgba(0, 0, 0, 0.15) 50%,
        rgba(0, 0, 0, 0.55) 100%
    );
}

/* Play gomb - testreszabható színek */
.pd-sve-card__play {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: var(--pd-sve-play-bg);
    color: var(--pd-sve-play-fg);
    border-radius: 50%;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.15),
        0 12px 32px rgba(0, 0, 0, 0.25),
        inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    transition:
        transform 0.4s var(--pd-sve-ease-bounce),
        background 0.3s ease,
        color 0.3s ease,
        box-shadow 0.4s var(--pd-sve-ease);
    transform: translateZ(0);
}

.pd-sve-card__play-icon-default {
    margin-left: 3px; /* optikai központosítás háromszögnél */
}

.pd-sve-card__play-icon-custom {
    width: 28px;
    height: 28px;
    object-fit: contain;
    margin-left: 2px;
    pointer-events: none;
}

.pd-sve-card__player:hover .pd-sve-card__play {
    transform: scale(1.1);
    background: var(--pd-sve-accent);
    color: #fff;
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.2),
        0 16px 40px rgba(0, 0, 0, 0.3),
        inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.pd-sve-card__player:active .pd-sve-card__play {
    transform: scale(0.96);
}

/* Platform badge */
.pd-sve-card__platform-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.pd-sve-card__platform-badge--tiktok {
    background: rgba(0, 0, 0, 0.75);
}

.pd-sve-card__platform-badge--youtube {
    background: var(--pd-sve-youtube);
}

/* Loading állapot */
.pd-sve-card.is-loading .pd-sve-card__play {
    animation: pd-sve-pulse 1.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pd-sve-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.92); }
}

/* Aktív állapot */
.pd-sve-card.is-active .pd-sve-card__player {
    cursor: default;
}

.pd-sve-card.is-active .pd-sve-card__overlay,
.pd-sve-card.is-active .pd-sve-card__thumb,
.pd-sve-card.is-active .pd-sve-card__platform-badge {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.pd-sve-card__iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
    z-index: 2;
}

/* Meta lábléc */
.pd-sve-card__meta {
    padding: 14px 16px;
    background: var(--pd-sve-bg);
    color: var(--pd-sve-text);
    border-top: 1px solid var(--pd-sve-border);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.pd-sve-card__author {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--pd-sve-text);
}

.pd-sve-card__caption {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--pd-sve-text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   Single mód
   ========================================================================== */
.pd-sve-wrap--single .pd-sve-card--vertical {
    max-width: 380px;
    margin: 0 auto;
}

.pd-sve-wrap--single .pd-sve-card--horizontal {
    max-width: 720px;
    margin: 0 auto;
}

.pd-sve-wrap--single .pd-sve-card--square {
    max-width: 480px;
    margin: 0 auto;
}

.pd-sve-wrap--single .pd-sve-card--custom {
    max-width: 600px;
    margin: 0 auto;
}

/* ==========================================================================
   Grid mód
   ========================================================================== */
.pd-sve-wrap--grid {
    display: grid;
    grid-template-columns: repeat(var(--pd-sve-cols, 3), minmax(0, 1fr));
    gap: var(--pd-sve-gap);
    align-items: start;
}

@media (max-width: 1024px) {
    .pd-sve-wrap--grid {
        grid-template-columns: repeat(min(3, var(--pd-sve-cols, 3)), minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .pd-sve-wrap--grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: calc(var(--pd-sve-gap, 20px) * 0.75);
    }
}

@media (max-width: 480px) {
    .pd-sve-wrap--grid {
        grid-template-columns: 1fr;
        gap: var(--pd-sve-gap, 20px);
    }
}

/* ==========================================================================
   Carousel
   ========================================================================== */
.pd-sve-wrap--carousel {
    position: relative;
    padding: 0 48px;
}

.pd-sve-carousel__track {
    display: flex;
    gap: var(--pd-sve-gap, 20px);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    padding: 4px 4px 16px;
    align-items: flex-start;
}

.pd-sve-carousel__track::-webkit-scrollbar {
    display: none;
}

.pd-sve-wrap--carousel .pd-sve-card {
    flex: 0 0 auto;
    scroll-snap-align: start;
}

.pd-sve-wrap--carousel .pd-sve-card--vertical {
    width: 280px;
}

.pd-sve-wrap--carousel .pd-sve-card--horizontal {
    width: 480px;
}

.pd-sve-wrap--carousel .pd-sve-card--square,
.pd-sve-wrap--carousel .pd-sve-card--custom {
    width: 360px;
}

@media (max-width: 768px) {
    .pd-sve-wrap--carousel { padding: 0 40px; }
    .pd-sve-wrap--carousel .pd-sve-card--vertical { width: 240px; }
    .pd-sve-wrap--carousel .pd-sve-card--horizontal { width: 400px; }
    .pd-sve-wrap--carousel .pd-sve-card--square,
    .pd-sve-wrap--carousel .pd-sve-card--custom { width: 320px; }
}

@media (max-width: 480px) {
    .pd-sve-wrap--carousel { padding: 0; }
    .pd-sve-wrap--carousel .pd-sve-card--vertical { width: 220px; }
    .pd-sve-wrap--carousel .pd-sve-card--horizontal { width: 320px; }
    .pd-sve-wrap--carousel .pd-sve-card--square,
    .pd-sve-wrap--carousel .pd-sve-card--custom { width: 280px; }
    .pd-sve-carousel__nav { display: none; }
}

.pd-sve-carousel__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a1a;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    cursor: pointer;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.08),
        0 8px 24px rgba(0, 0, 0, 0.12);
    transition: all 0.3s var(--pd-sve-ease);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.pd-sve-carousel__nav:hover:not(:disabled) {
    background: var(--pd-sve-accent);
    color: #fff;
    transform: translateY(-50%) scale(1.1);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.12),
        0 12px 32px rgba(0, 0, 0, 0.2);
}

.pd-sve-carousel__nav:focus-visible {
    outline: 3px solid var(--pd-sve-accent);
    outline-offset: 2px;
}

.pd-sve-carousel__nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: translateY(-50%) scale(0.95);
}

.pd-sve-carousel__nav--prev { left: 0; }
.pd-sve-carousel__nav--next { right: 0; }

/* ==========================================================================
   List
   ========================================================================== */
.pd-sve-wrap--list {
    display: flex;
    flex-direction: column;
    gap: var(--pd-sve-gap, 24px);
}

.pd-sve-wrap--list .pd-sve-card--vertical {
    max-width: 380px;
}

/* ==========================================================================
   Hibaüzenet
   ========================================================================== */
.pd-sve-error {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    padding: 14px 16px;
    border: 1px dashed #d4a72c;
    border-left: 4px solid #d4a72c;
    border-radius: 8px;
    color: #6c5500;
    font-size: 14px;
    background: #fef9e6;
    line-height: 1.5;
}

/* ==========================================================================
   Sötét mód
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    .pd-sve-wrap {
        --pd-sve-shadow:
            0 0 0 1px rgba(0, 0, 0, 0.2),
            0 2px 4px -1px rgba(0, 0, 0, 0.2),
            0 8px 16px -4px rgba(0, 0, 0, 0.3),
            0 24px 48px -12px rgba(0, 0, 0, 0.4);
        --pd-sve-shadow-hover:
            0 0 0 1px rgba(0, 0, 0, 0.3),
            0 4px 8px -2px rgba(0, 0, 0, 0.3),
            0 16px 32px -8px rgba(0, 0, 0, 0.45),
            0 40px 80px -20px rgba(0, 0, 0, 0.6);
    }

    .pd-sve-carousel__nav {
        background: rgba(40, 40, 40, 0.95);
        color: #fff;
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* ==========================================================================
   Csökkentett animáció (a11y)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .pd-sve-wrap *,
    .pd-sve-wrap *::before,
    .pd-sve-wrap *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
    .pd-sve-card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ccc;
    }

    .pd-sve-card__overlay,
    .pd-sve-card__play,
    .pd-sve-carousel__nav {
        display: none !important;
    }
}
