/* X-Card v6 — Full-width in post, Custom Video Player */

/* ── Container ── */
.x-card-container {
    width: 100%;
    margin: 8px 0;
    display: block;
    border-radius: 14px;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 2px 8px rgba(0, 0, 0, .04);
    transform: translateZ(0);
    transition: box-shadow 0.25s ease;
}

.x-card-container:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12), 0 4px 16px rgba(0, 0, 0, .06);
}

/* ── Inner ── */
.x-card-inner {
    padding: 12px;
    position: relative;
    color: var(--text-main);
}

/* ── Header ── */

.x-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.x-card-avatar {
    flex-shrink: 0;
    cursor: pointer;
}

.x-card-avatar img {
    height: 32px;
    width: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.x-card-author-info {
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.x-card-names {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.x-card-name-row {
    display: flex;
    align-items: center;
    gap: 3px;
}

.x-card-name {
    font-weight: 600;
    color: var(--text-main);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.x-card-handle {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

a.x-logo {
    flex-shrink: 0;
    height: 26px;
    width: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-main);
    opacity: 0.45;
    text-decoration: none;
    transition: opacity 0.2s, background 0.2s;
}

a.x-logo:hover {
    opacity: 1;
    background: rgba(29, 155, 240, 0.1);
}

a.x-logo svg {
    width: 14px;
    height: 14px;
}

/* ── Content ── */

.x-card-content {
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-main);
    white-space: pre-wrap;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.x-card-content p {
    margin: 0 0 2px;
}

.x-card-content p:last-child {
    margin-bottom: 0;
}

/* ── Photos ── */
.x-card-media {
    margin-top: 8px;
    border-radius: 10px;
    overflow: hidden;
    display: grid;
    gap: 2px;
    cursor: pointer;
}

.x-card-grid-single {
    grid-template-columns: 1fr;
}

.x-card-grid-single .x-card-photo {
    aspect-ratio: 16/9;
    max-height: 270px;
}

.x-card-grid-double {
    grid-template-columns: 1fr 1fr;
}

.x-card-grid-double .x-card-photo {
    aspect-ratio: 1;
    max-height: 220px;
}

.x-card-grid-triple {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.x-card-grid-triple .x-card-photo:first-child {
    grid-row: 1 / 3;
}

.x-card-grid-triple .x-card-photo {
    max-height: 220px;
}

.x-card-grid-quad {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.x-card-grid-quad .x-card-photo {
    aspect-ratio: 4/3;
    max-height: 140px;
}

.x-card-photo {
    overflow: hidden;
    position: relative;
    background: rgba(0, 0, 0, 0.04);
}

.x-card-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.25s ease;
}

.x-card-photo:hover img {
    transform: scale(1.03);
}

/* ═══════════════════════════════════════════════════
   VIDEO PLAYER — Custom UI
   ═══════════════════════════════════════════════════ */

.x-card-video-container {
    margin-top: 8px;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    background: #000;
    cursor: pointer;
    max-height: 320px;
}

.x-card-video-container video {
    width: 100%;
    max-height: 320px;
    display: block;
    object-fit: contain;
}

/* ── Big center play (before first play) ── */
.xv-big-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.xv-big-play svg {
    width: 24px;
    height: 24px;
    fill: #fff;
    margin-left: 3px;
}

/* ── Controls bar — gradient overlay ── */
.xv-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 20px 8px 6px;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.35) 60%, transparent 100%);
    opacity: 0;
    transform: translateY(3px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 4;
    pointer-events: none;
}

.xv-controls.xv-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.x-card-video-container:hover .xv-controls {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ── Buttons ── */
.xv-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    border-radius: 4px;
    transition: background 0.15s;
    flex-shrink: 0;
}

.xv-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.xv-btn svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

/* ── Time ── */
.xv-time {
    color: rgba(255, 255, 255, 0.85);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 62px;
    user-select: none;
    letter-spacing: 0.02em;
}

/* ── Progress bar ── */
.xv-progress {
    flex: 1;
    height: 18px;
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.xv-progress-buffered,
.xv-progress-filled {
    position: absolute;
    top: 50%;
    left: 0;
    height: 4px;
    transform: translateY(-50%);
    border-radius: 2px;
    pointer-events: none;
    transition: height 0.15s ease, width 0.1s linear;
}

.xv-progress-buffered {
    background: rgba(255, 255, 255, 0.2);
    width: 0;
}

.xv-progress-filled {
    background: #1d9bf0;
    width: 0;
    z-index: 1;
}

/* Hover: thicken bar */
.xv-progress:hover .xv-progress-buffered,
.xv-progress:hover .xv-progress-filled {
    height: 6px;
}

/* Range input */
.xv-seek {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 18px;
    background: transparent;
    margin: 0;
    position: relative;
    z-index: 2;
    cursor: pointer;
}

.xv-seek::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    transition: height 0.15s ease;
}

.xv-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #1d9bf0;
    border-radius: 50%;
    border: 2px solid #fff;
    margin-top: -4px;
    box-shadow: 0 0 4px rgba(29, 159, 240, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.xv-progress:hover .xv-seek::-webkit-slider-thumb {
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(29, 159, 240, 0.6), 0 1px 4px rgba(0, 0, 0, 0.5);
}

.xv-progress:hover .xv-seek::-webkit-slider-runnable-track {
    height: 6px;
}

.xv-progress:hover .xv-seek::-webkit-slider-thumb {
    margin-top: -3px;
}

/* Firefox */
.xv-seek::-moz-range-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    border: none;
    transition: height 0.15s ease;
}

.xv-seek::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #1d9bf0;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 4px rgba(29, 159, 240, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s ease;
}

.xv-progress:hover .xv-seek::-moz-range-thumb {
    transform: scale(1.2);
}

/* ── GIF badge ── */
.x-card-gif-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

/* ── Fullscreen mode ── */
.x-card-video-container:fullscreen {
    max-height: none;
    border-radius: 0;
}

.x-card-video-container:fullscreen video {
    max-height: 100vh;
    width: 100%;
    height: 100%;
}

.x-card-video-container:fullscreen .xv-controls {
    padding: 24px 16px 10px;
}

.x-card-video-container:fullscreen .xv-btn svg {
    width: 20px;
    height: 20px;
}

.x-card-video-container:fullscreen .xv-time {
    font-size: 13px;
}

.x-card-video-container:fullscreen .xv-progress {
    height: 20px;
}

.x-card-video-container:fullscreen .xv-progress-buffered,
.x-card-video-container:fullscreen .xv-progress-filled {
    height: 4px;
}

/* ═══════════════════════════════════════════════════
   REMAINING CARD PARTS
   ═══════════════════════════════════════════════════ */

/* ── Quote tweet ── */
.x-card-quote {
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    font-size: 13px;
    line-height: 1.35;
}

.x-card-quote-author {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 3px;
    font-size: 12px;
}

.x-card-quote-author strong {
    color: var(--text-main);
}

.x-card-quote p {
    margin: 0;
    color: var(--text-main);
    opacity: 0.8;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Timestamp ── */
.x-card-timestamp {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none !important;
}

.x-card-timestamp:hover {
    text-decoration: underline !important;
    color: var(--text-main);
}

/* ── Placeholder ── */
.x-card-placeholder {
    padding: 12px;
    background: var(--surface-hover);
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: x-card-pulse 1.8s ease-in-out infinite;
}

.x-card-placeholder.error {
    animation: none;
    opacity: 0.65;
}

@keyframes x-card-pulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

@media (max-width: 480px) {

    .x-card-inner {
        padding: 10px;
    }

    .x-card-avatar img {
        height: 28px;
        width: 28px;
    }

    .x-card-name {
        font-size: 13px;
    }

    .x-card-handle {
        font-size: 11px;
    }

    .x-card-content {
        font-size: 13px;
    }

    .x-card-grid-single .x-card-photo {
        max-height: 200px;
    }

    .x-card-grid-double .x-card-photo,
    .x-card-grid-triple .x-card-photo {
        max-height: 160px;
    }

    .x-card-grid-quad .x-card-photo {
        max-height: 110px;
    }

    .x-card-video-container,
    .x-card-video-container video {
        max-height: 240px;
    }

    .xv-time {
        font-size: 9px;
        min-width: 55px;
    }

    .xv-btn svg {
        width: 14px;
        height: 14px;
    }
}