/**
 * Custom Blog Card Styles
 */

/* 基本スタイル */
.cbc-card {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.3s ease;
    margin: 1.5em 0;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    max-width: 100%;
}

.cbc-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.cbc-link {
    display: flex;
    text-decoration: none;
    color: inherit;
}

.cbc-link:hover {
    text-decoration: none;
}

/* サムネイル */
.cbc-thumbnail {
    flex-shrink: 0;
    overflow: hidden;
    background-color: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cbc-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* コンテンツ */
.cbc-content {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 1.5em 1.25em;
    min-width: 0;
    flex: 1;
}

.cbc-site-name {
    font-size: 0.75em;
    color: #666;
    margin-bottom: 0.5em;
    font-weight: 500;
}

.cbc-title {
    font-size: 1.05em;
    font-weight: 700;
    line-height: 1.5;
    margin-bottom: 0.4em;
    color: #1a1a1a;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cbc-price {
    font-size: 1.1em;
    font-weight: 700;
    color: #c91;
    margin-bottom: 0.5em;
}

.cbc-description {
    font-size: 0.85em;
    line-height: 1.6;
    color: #666;
    margin-bottom: 0.6em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cbc-domain {
    font-size: 0.75em;
    color: #999;
    display: inline-block;
    margin-top: auto;
    padding: 0.25em 0;
}

.cbc-domain::before {
    content: "";
    display: none;
}

/* 横型レイアウト（デフォルト） */
.cbc-layout-horizontal .cbc-link {
    flex-direction: row;
}

.cbc-layout-horizontal .cbc-thumbnail {
    width: 280px;
    min-width: 280px;
    height: auto;
    order: 2;
}

.cbc-layout-horizontal .cbc-content {
    order: 1;
    flex: 1;
}

/* 縦型レイアウト */
.cbc-layout-vertical .cbc-link {
    flex-direction: column;
}

.cbc-layout-vertical .cbc-thumbnail {
    width: 100%;
    height: 200px;
}

.cbc-layout-vertical .cbc-content {
    padding: 1.5em;
}

.cbc-layout-vertical .cbc-title {
    font-size: 1.2em;
}

/* コンパクトレイアウト */
.cbc-layout-compact .cbc-link {
    flex-direction: row;
}

.cbc-layout-compact .cbc-thumbnail {
    width: 100px;
    height: 100px;
}

.cbc-layout-compact .cbc-content {
    padding: 0.75em 1em;
}

.cbc-layout-compact .cbc-title {
    font-size: 0.95em;
    -webkit-line-clamp: 1;
}

.cbc-layout-compact .cbc-description {
    font-size: 0.85em;
    -webkit-line-clamp: 1;
}

.cbc-layout-compact .cbc-domain {
    font-size: 0.8em;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    /* 横型レイアウトをモバイルでは縦型に */
    .cbc-layout-horizontal .cbc-link {
        flex-direction: column;
    }

    .cbc-layout-horizontal .cbc-thumbnail {
        width: 100%;
        min-width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
        order: 1;
    }

    .cbc-layout-horizontal .cbc-content {
        order: 2;
        padding: 1.25em 1em;
    }

    .cbc-layout-vertical .cbc-thumbnail {
        height: auto;
        aspect-ratio: 16 / 9;
    }

    /* コンパクトレイアウトはそのまま */
    .cbc-layout-compact .cbc-thumbnail {
        width: 80px;
        height: 80px;
    }
}

@media (max-width: 480px) {
    .cbc-content {
        padding: 1em;
    }

    .cbc-title {
        font-size: 1em;
    }

    .cbc-description {
        font-size: 0.85em;
    }

    .cbc-layout-compact .cbc-thumbnail {
        width: 70px;
        height: 70px;
    }

    .cbc-layout-compact .cbc-content {
        padding: 0.5em 0.75em;
    }
}

/* エラー表示 */
.cbc-error {
    padding: 1em;
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 4px;
    color: #c33;
    margin: 1em 0;
}

/* エディタ用スタイル */
.cbc-editor-wrapper {
    padding: 1em;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background-color: #f9f9f9;
}

.cbc-url-input {
    display: flex;
    gap: 10px;
    margin-bottom: 1em;
    align-items: flex-end;
}

.cbc-url-input .components-base-control {
    flex: 1;
}

.cbc-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2em;
}

.cbc-placeholder {
    padding: 2em;
    text-align: center;
    color: #999;
    border: 2px dashed #ddd;
    border-radius: 4px;
    background-color: #fff;
}

/* ブロックエディタでのプレビュー */
.editor-styles-wrapper .cbc-card {
    max-width: 100%;
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .cbc-card {
        background-color: #2a2a2a;
        border-color: #444;
    }

    .cbc-title {
        color: #e0e0e0;
    }

    .cbc-description {
        color: #b0b0b0;
    }

    .cbc-domain {
        color: #808080;
    }

    .cbc-thumbnail {
        background-color: #1a1a1a;
    }

    .cbc-editor-wrapper {
        background-color: #2a2a2a;
        border-color: #444;
    }

    .cbc-placeholder {
        background-color: #1a1a1a;
        border-color: #444;
        color: #808080;
    }
}

/* アクセシビリティ */
.cbc-link:focus {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

.cbc-link:focus:not(:focus-visible) {
    outline: none;
}

/* 印刷用スタイル */
@media print {
    .cbc-card {
        box-shadow: none;
        border: 1px solid #000;
        page-break-inside: avoid;
    }

    .cbc-card:hover {
        transform: none;
    }
}
