/* ══════════════════════════════════════════════════════════════════
   CLOUD VIDEO ENGINE v1 — styles
   Matches the visual vocabulary of .vte-* (dark stage, brand accents,
   rounded 14px cards, soft elevation). All selectors are cve-* to avoid
   any collision with existing vte-* classes.
   ══════════════════════════════════════════════════════════════════ */

/* ── Preview card (shown inside vte-player-stage for cloud imports) ── */
.cve-preview {
    --cve-brand: #6B7280;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 260px;
    background: linear-gradient(155deg, #0c0d10 0%, #15171c 100%);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: #fff;
    isolation: isolate;
}

.cve-preview-accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, var(--cve-brand) 30%, var(--cve-brand) 70%, transparent 100%);
    z-index: 2;
    opacity: 0.9;
}

.cve-preview-poster {
    position: relative;
    flex: 1;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 50%, rgba(255,255,255,0.04) 0%, transparent 70%), #0c0d10;
    overflow: hidden;
}

.cve-preview-poster-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    filter: saturate(0.95);
    transition: opacity 0.35s;
}

.cve-preview-poster-icon {
    position: relative;
    font-size: 3.4rem;
    opacity: 0.28;
    z-index: 1;
    text-shadow: 0 4px 18px rgba(0,0,0,0.5);
    transition: opacity 0.25s, transform 0.25s;
}

.cve-preview:hover .cve-preview-poster-icon {
    opacity: 0.5;
    transform: scale(1.04);
}

/* When the real poster image loads, dim the backup icon so the
   image becomes the dominant visual. */
.cve-preview-poster--loaded .cve-preview-poster-icon {
    opacity: 0;
}

.cve-preview-poster--loaded .cve-preview-poster-img {
    opacity: 0.92;
    animation: cve-poster-in 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cve-poster-in {
    from {
        opacity: 0;
        filter: blur(6px) saturate(0.8);
    }

    to {
        opacity: 0.92;
        filter: blur(0) saturate(0.95);
    }
}

/* Thumbnail loading spinner — shown while getPoster() resolves. */
.cve-preview-thumb-loading {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    background: rgba(0,0,0,0.55);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    animation: cve-fade-in 0.2s 0.3s forwards;
}

@keyframes cve-fade-in {
    to {
        opacity: 1;
    }
}

.cve-spinner-sm {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: rgba(255,255,255,0.85);
    border-radius: 50%;
    animation: cve-spin 0.8s linear infinite;
}

/* Pre-click warning banner — shown on the preview card when the
   resolver already knows the URL won't embed. Surfacing this at
   paste time stops users from clicking Preview, waiting 10 s, and
   getting a confusing fallback screen. */
.cve-preview-warning {
    position: absolute;
    bottom: 14px;
    left: 14px;
    right: 14px;
    z-index: 4;
    background: rgba(251, 191, 36, 0.18);
    border: 1px solid rgba(251, 191, 36, 0.45);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fbbf24;
    line-height: 1.35;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

    .cve-preview-warning .bi {
        flex-shrink: 0;
        font-size: 0.95rem;
    }

.cve-preview-play--muted {
    background: rgba(107, 114, 128, 0.7) !important;
    box-shadow: 0 6px 18px rgba(0,0,0,0.35), 0 0 0 5px rgba(255,255,255,0.03) !important;
}

    .cve-preview-play--muted:hover {
        background: rgba(107, 114, 128, 0.85) !important;
    }

.cve-preview-play {
    position: relative;
    z-index: 2;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 0;
    background: var(--cve-brand);
    color: #fff;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0,0,0,0.45), 0 0 0 6px rgba(255,255,255,0.04), 0 0 0 12px rgba(255,255,255,0.02);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}

    .cve-preview-play:hover {
        transform: scale(1.08);
        box-shadow: 0 14px 40px rgba(0,0,0,0.55), 0 0 0 8px rgba(255,255,255,0.06), 0 0 0 16px rgba(255,255,255,0.03);
    }

    .cve-preview-play:focus-visible {
        outline: 2px solid #fff;
        outline-offset: 4px;
    }

    .cve-preview-play .bi {
        line-height: 1;
        margin-left: 3px;
    }

.cve-preview-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 6px;
    font-size: 0.72rem;
}

.cve-preview-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    white-space: nowrap;
}

.cve-preview-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.7);
}

.cve-preview-actions {
    display: flex;
    gap: 8px;
    padding: 6px 16px 14px;
}

.cve-preview-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    border: 0;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.14s, filter 0.14s, background 0.18s;
    color: #fff;
    white-space: nowrap;
}

    .cve-preview-btn:hover {
        transform: translateY(-1px);
        filter: brightness(1.08);
    }

    .cve-preview-btn:focus-visible {
        outline: 2px solid rgba(255,255,255,0.5);
        outline-offset: 2px;
    }

.cve-preview-btn--primary {
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}

.cve-preview-btn--ghost {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.85);
}

    .cve-preview-btn--ghost:hover {
        background: rgba(239, 68, 68, 0.18);
        border-color: rgba(239, 68, 68, 0.4);
        color: #fca5a5;
    }

/* ── Modal shell ─────────────────────────────────────────────────── */
.cve-modal {
    position: fixed;
    inset: 0;
    z-index: 10050;
    background: rgba(6, 7, 11, 0.78);
    backdrop-filter: blur(6px) saturate(1.1);
    -webkit-backdrop-filter: blur(6px) saturate(1.1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3vh 3vw;
    opacity: 0;
    transition: opacity 0.22s ease;
}

.cve-modal--in {
    opacity: 1;
}

.cve-modal-shell {
    position: relative;
    width: min(1040px, 100%);
    max-height: 94vh;
    background: #0c0d10;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    transform: scale(0.96) translateY(10px);
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.cve-modal--in .cve-modal-shell {
    transform: scale(1) translateY(0);
}

.cve-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.cve-modal-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
}

    .cve-modal-title .bi {
        font-size: 1.1rem;
    }

.cve-modal-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 0;
    background: rgba(255,255,255,0.06);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.16s, transform 0.14s;
}

    .cve-modal-close:hover {
        background: rgba(239, 68, 68, 0.85);
        transform: rotate(90deg);
    }

    .cve-modal-close:focus-visible {
        outline: 2px solid rgba(255,255,255,0.6);
        outline-offset: 2px;
    }

.cve-modal-body {
    flex: 1;
    min-height: 0;
    display: flex;
    background: #000;
    overflow: hidden;
}

.cve-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    aspect-ratio: 16 / 9;
    max-height: 76vh;
    background: #000;
}

.cve-modal-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: linear-gradient(0deg, rgba(255,255,255,0.03) 0%, transparent 100%);
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 0.7rem;
    color: rgba(255,255,255,0.55);
    flex-shrink: 0;
    min-height: 38px;
}

.cve-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    .cve-status::before {
        content: '';
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: #10b981;
        box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
        animation: cve-pulse 1.8s ease-in-out infinite;
    }

@keyframes cve-pulse {
    0%, 100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

.cve-warn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 14px;
    background: rgba(251, 191, 36, 0.12);
    color: #fbbf24;
    font-size: 0.66rem;
    font-weight: 600;
    margin-right: 8px;
}

/* ── Player wrap (container for <video> or <iframe> in stage) ───── */
.cve-player-wrap {
    position: absolute;
    inset: 0;
    background: #000;
    overflow: hidden;
}

.cve-video,
.cve-iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: #000;
}

.cve-video {
    object-fit: contain;
}

/* ── Loader (brand-tinted spinner + text, overlaid on the player) ─ */
.cve-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(0,0,0,0.55);
    pointer-events: none;
    z-index: 2;
}

.cve-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(255,255,255,0.12);
    border-top-color: rgba(255,255,255,0.8);
    border-radius: 50%;
    animation: cve-spin 0.9s linear infinite;
}

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

.cve-loader-text {
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

/* ── Graceful fallback (L4) ─────────────────────────────────────── */
.cve-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 40px 24px;
    background: radial-gradient(ellipse at 50% 30%, rgba(255,255,255,0.04) 0%, transparent 60%), #0c0d10;
    color: #fff;
    text-align: center;
}

.cve-fallback-icon {
    font-size: 3rem;
    filter: drop-shadow(0 6px 18px rgba(0,0,0,0.5));
}

.cve-fallback-title {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.cve-fallback-body {
    font-size: 0.78rem;
    line-height: 1.55;
    color: rgba(255,255,255,0.68);
    max-width: 440px;
}

.cve-fallback-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 6px;
}

.cve-fallback-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: 22px;
    font-size: 0.74rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    border: 0;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0,0,0,0.35);
    transition: transform 0.14s, filter 0.14s;
}

    .cve-fallback-btn:hover {
        transform: translateY(-1px);
        filter: brightness(1.1);
    }

    .cve-fallback-btn:focus-visible {
        outline: 2px solid rgba(255,255,255,0.6);
        outline-offset: 2px;
    }

.cve-fallback-close {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 22px;
    font-size: 0.74rem;
    font-weight: 700;
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.85);
    border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
    transition: background 0.14s, transform 0.14s;
}

    .cve-fallback-close:hover {
        background: rgba(255,255,255,0.1);
        transform: translateY(-1px);
    }

/* ── Small-screen tuning ─────────────────────────────────────────── */
@media (max-width: 680px) {
    .cve-modal {
        padding: 0;
    }

    .cve-modal-shell {
        border-radius: 0;
        max-height: 100vh;
        width: 100%;
    }

    .cve-stage {
        aspect-ratio: auto;
        height: calc(100vh - 100px);
        max-height: none;
    }

    .cve-preview-play {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .cve-fallback-title {
        font-size: 0.9rem;
    }

    .cve-fallback-body {
        font-size: 0.72rem;
    }
}

/* ── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .cve-modal,
    .cve-modal-shell,
    .cve-preview-play,
    .cve-preview-btn,
    .cve-modal-close,
    .cve-spinner,
    .cve-status::before {
        transition: none !important;
        animation: none !important;
    }

    .cve-modal-shell {
        transform: none !important;
    }
}
