/* EmbedCard Styles */

:root {
    --embed-card-border: #e1e5e9;
    --embed-card-shadow: rgba(0, 0, 0, 0.1);
    --embed-card-shadow-hover: rgba(0, 0, 0, 0.15);
    --embed-card-bg: var(--editor-bg, var(--card-bg, #ffffff));
    --embed-card-text: var(--editor-text, var(--text-color, #333333));
    --embed-card-accent: var(--editor-accent, var(--accent-color, #00b4d8));
    --embed-card-font: var(--editor-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Noto Sans JP', sans-serif);
    --twitter-blue: #1da1f2;
    --twitter-hover: #1a8cd8;
    --twitter-border: #e1e8ed;
    --twitter-bg-hover: #f7f9fa;
}

.embed-card-wrapper {
    display: block !important;
    margin: 20px 0 !important;
    border: 1px solid var(--embed-card-border) !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    background-color: var(--embed-card-bg) !important;
    box-shadow: 0 2px 8px var(--embed-card-shadow) !important;
    position: relative !important;
    width: 100% !important;
    max-width: 600px !important;
    line-height: 1.4 !important;
    font-family: var(--embed-card-font) !important;
    font-size: 14px !important;
    color: var(--embed-card-text) !important;
    text-align: left !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    transition: all 0.3s ease !important;
    clear: both !important;
    animation: embedCardFadeIn 0.4s ease-out;
}

    .embed-card-wrapper:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 4px 16px var(--embed-card-shadow-hover) !important;
        border-color: var(--embed-card-accent) !important;
    }

    .embed-card-wrapper.compact {
        max-width: 400px !important;
    }

    .embed-card-wrapper.loading {
        opacity: 0.7 !important;
        pointer-events: none !important;
    }

        .embed-card-wrapper.loading::before {
            content: '' !important;
            position: absolute !important;
            top: 0 !important;
            left: -100% !important;
            width: 100% !important;
            height: 100% !important;
            background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent) !important;
            animation: shimmer 1.5s infinite !important;
            z-index: 1 !important;
        }

    .embed-card-wrapper.error {
        border-color: #dc3545 !important;
        background-color: rgba(220, 53, 69, 0.05) !important;
    }

/* YouTube */
.youtube-embed-wrapper {
    max-width: 800px !important;
    margin: 24px auto !important;
    background-color: #000000 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

    .youtube-embed-wrapper:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
    }

.youtube-embed-container {
    position: relative !important;
    width: 100% !important;
    height: 0 !important;
    padding-bottom: 56.25% !important;
    background-color: #000000 !important;
}

    .youtube-embed-container iframe {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border: none !important;
        border-radius: 0 !important;
    }

.ql-editor .youtube-embed-wrapper {
    pointer-events: none;
}

    .ql-editor .youtube-embed-wrapper.ql-selected {
        outline: 2px solid #ff0000 !important;
        outline-offset: 2px !important;
    }

.post-content .youtube-embed-wrapper {
    pointer-events: auto;
    margin: 32px auto !important;
}

/* Twitter */
.twitter-embed-wrapper {
    max-width: 550px !important;
    margin: 24px auto !important;
    border: 1px solid var(--twitter-border) !important;
    border-radius: 12px !important;
    background-color: #ffffff !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

    .twitter-embed-wrapper:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
        transform: translateY(-1px) !important;
    }

.twitter-embed-container {
    padding: 16px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif !important;
}

    .twitter-embed-container blockquote {
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        font-style: normal !important;
        background-color: transparent !important;
    }

        .twitter-embed-container blockquote.twitter-tweet {
            font-size: 15px !important;
            line-height: 1.5 !important;
            color: #14171a !important;
        }

            .twitter-embed-container blockquote.twitter-tweet p {
                margin: 0 0 16px 0 !important;
                padding: 0 !important;
                font-size: 15px !important;
                line-height: 1.5 !important;
                color: #14171a !important;
                word-wrap: break-word !important;
            }

            .twitter-embed-container blockquote.twitter-tweet a {
                color: var(--twitter-blue) !important;
                text-decoration: none !important;
                word-break: break-all !important;
            }

                .twitter-embed-container blockquote.twitter-tweet a:hover {
                    text-decoration: underline !important;
                    color: var(--twitter-hover) !important;
                }

            .twitter-embed-container blockquote.twitter-tweet > a:last-child {
                display: block !important;
                margin-top: 4px !important;
                font-size: 13px !important;
                color: #536471 !important;
            }

.twitter-embed-fallback {
    padding: 12px 16px !important;
    border-top: 1px solid var(--twitter-border) !important;
    text-align: center !important;
    background-color: var(--twitter-bg-hover) !important;
}

    .twitter-embed-fallback a {
        color: var(--twitter-blue) !important;
        text-decoration: none !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        transition: all 0.2s ease !important;
    }

        .twitter-embed-fallback a:hover {
            color: var(--twitter-hover) !important;
            transform: translateY(-1px) !important;
        }

        .twitter-embed-fallback a::before {
            content: '\f099' !important;
            font-family: 'Font Awesome 5 Brands' !important;
            font-weight: 400 !important;
            font-size: 16px !important;
        }

.embed-card {
    display: block !important;
    text-decoration: none !important;
    color: inherit !important;
    background-color: transparent !important;
    position: relative !important;
    overflow: hidden !important;
    width: 100% !important;
    height: auto !important;
    border: none !important;
    outline: none !important;
}

    .embed-card:hover {
        text-decoration: none !important;
        color: inherit !important;
    }

.embed-card-image {
    width: 100% !important;
    height: 0 !important;
    padding-bottom: 52.63% !important;
    position: relative !important;
    overflow: hidden !important;
    background-color: #f8f9fa !important;
    display: block !important;
    margin: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-top: 0 !important;
}

    .embed-card-image img {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        outline: none !important;
        transition: transform 0.3s ease !important;
    }

.embed-card-wrapper:hover .embed-card-image img {
    transform: scale(1.02) !important;
}

.embed-card-image:empty::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
}

.embed-card-image:empty::after {
    content: '\f0c1' !important;
    font-family: 'Font Awesome 5 Free' !important;
    font-weight: 900 !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    font-size: 20px !important;
    color: #adb5bd !important;
}

.embed-card-content {
    padding: 12px 16px !important;
    background-color: var(--embed-card-bg) !important;
    display: block !important;
    width: 100% !important;
    position: relative !important;
}

.embed-card-title {
    font-size: 15px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    margin: 0 0 6px 0 !important;
    padding: 0 !important;
    color: var(--embed-card-text) !important;
    display: block !important;
    max-height: 2.6em !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    word-break: break-word !important;
    transition: color 0.3s ease !important;
}

.embed-card-wrapper:hover .embed-card-title {
    color: var(--embed-card-accent) !important;
}

.embed-card-description {
    font-size: 13px !important;
    line-height: 1.4 !important;
    color: #6c757d !important;
    margin: 0 0 8px 0 !important;
    padding: 0 !important;
    max-height: 2.8em !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    word-break: break-word !important;
}

.embed-card-site {
    font-size: 11px !important;
    color: #adb5bd !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    font-weight: 500 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    line-height: 1 !important;
}

    .embed-card-site::before {
        content: '' !important;
        width: 8px !important;
        height: 8px !important;
        border-radius: 2px !important;
        background-color: var(--embed-card-accent) !important;
        opacity: 0.6 !important;
        flex-shrink: 0 !important;
        display: inline-block !important;
    }

@keyframes embedCardFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.embed-optimized-editor .ql-editor .embed-card-wrapper {
    margin: 20px 0 !important;
    clear: both !important;
}

    .embed-optimized-editor .ql-editor .embed-card-wrapper.ql-selected {
        outline: 2px solid var(--embed-card-accent) !important;
        outline-offset: 2px !important;
        border-radius: 8px !important;
    }

    .embed-optimized-editor .ql-editor p + .embed-card-wrapper,
    .embed-optimized-editor .ql-editor .embed-card-wrapper + p {
        margin-top: 16px !important;
    }

.post-content .embed-card-wrapper {
    margin: 24px 0 !important;
}

.post-content blockquote + .embed-card-wrapper,
.post-content .embed-card-wrapper + blockquote,
.post-content pre + .embed-card-wrapper,
.post-content .embed-card-wrapper + pre {
    margin-top: 2rem !important;
}

@media (max-width: 768px) {
    .embed-card-wrapper {
        margin: 16px 0 !important;
        max-width: 100% !important;
    }

    .embed-card-image {
        padding-bottom: 56.25% !important;
    }

    .embed-card-content {
        padding: 10px 14px !important;
    }

    .embed-card-title {
        font-size: 14px !important;
        -webkit-line-clamp: 2 !important;
    }

    .embed-card-description {
        font-size: 12px !important;
        -webkit-line-clamp: 2 !important;
        margin-bottom: 6px !important;
    }

    .embed-card-site {
        font-size: 8px !important;
    }

    .post-content .embed-card-wrapper {
        margin: 20px 0 !important;
    }

    .youtube-embed-wrapper {
        max-width: 100% !important;
        margin: 20px 0 !important;
        border-radius: 0 !important;
    }

    .post-content .youtube-embed-wrapper {
        margin: 24px 0 !important;
    }

    .twitter-embed-wrapper {
        max-width: 550px !important;
        margin: 24px auto !important;
        background-color: transparent !important;
    }
        .twitter-embed-wrapper blockquote.twitter-tweet {
            margin: 0 !important;
        }

    .ql-editor .twitter-embed-wrapper {
        pointer-events: none;
    }
        .ql-editor .twitter-embed-wrapper.ql-selected {
            outline: 2px solid var(--twitter-blue) !important;
            outline-offset: 2px !important;
        }

    .post-content .twitter-embed-wrapper {
        pointer-events: auto;
    }

    .twitter-embed-container {
        padding: 12px !important;
    }

        .twitter-embed-container blockquote.twitter-tweet {
            font-size: 14px !important;
        }

            .twitter-embed-container blockquote.twitter-tweet p {
                font-size: 14px !important;
                margin-bottom: 12px !important;
            }
    
    .twitter-embed-wrapper iframe {
        max-width: 100% !important;
        margin: 0 auto !important;
    }
}

@media (max-width: 480px) {
    .embed-card-wrapper {
        margin: 16px 0 !important;
    }

    .embed-card-image {
        padding-bottom: 60% !important;
    }

    .embed-card-content {
        padding: 8px 10px !important;
    }

    .embed-card-title {
        font-size: 13px !important;
        -webkit-line-clamp: 1 !important;
    }

    .embed-card-description {
        font-size: 11px !important;
        -webkit-line-clamp: 2 !important;
    }

    .twitter-embed-wrapper {
        margin: 16px 0 !important;
    }

    .twitter-embed-container {
        padding: 10px !important;
    }

    .twitter-embed-fallback {
        padding: 10px 12px !important;
    }

        .twitter-embed-fallback a {
            font-size: 13px !important;
        }
}

@media (prefers-reduced-motion: reduce) {
    .embed-card-wrapper {
        animation: none !important;
        transition: none !important;
    }

        .embed-card-wrapper:hover {
            transform: none !important;
        }

    .embed-card-image img {
        transition: none !important;
    }

    .embed-card-wrapper:hover .embed-card-image img {
        transform: none !important;
    }
}

.embed-card:focus {
    outline: 2px solid var(--embed-card-accent) !important;
    outline-offset: 2px !important;
}

@media print {
    .embed-card-wrapper {
        break-inside: avoid !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        background: white !important;
        color: black !important;
    }

        .embed-card-wrapper:hover {
            transform: none !important;
            box-shadow: none !important;
        }

    .embed-card-image img {
        transition: none !important;
    }

    .youtube-embed-wrapper {
        page-break-inside: avoid !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }

    .youtube-embed-container {
        padding-bottom: 0 !important;
        height: 200px !important;
        background: #f0f0f0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

        .youtube-embed-container iframe {
            display: none !important;
        }

        .youtube-embed-container::after {
            content: 'YouTube: ' attr(data-embed-url) !important;
            font-size: 14px !important;
            color: #666 !important;
        }

    .twitter-embed-wrapper {
        break-inside: avoid !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        background: white !important;
        color: black !important;
    }

    .twitter-embed-container blockquote.twitter-tweet,
    .twitter-embed-container blockquote.twitter-tweet p {
        color: black !important;
    }

        .twitter-embed-container blockquote.twitter-tweet a {
            color: #0066cc !important;
        }

    .twitter-embed-fallback {
        display: none !important;
    }
}