/* =================================
カード基本スタイル（幅は親に任せる）
================================= */
.motif-card{
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    padding: 0; /* figureは全幅、bodyにpaddingを移動 */
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    font-size: 90%;
    position: relative;
    min-width: 0; /* グリッドセル幅を維持 */
    overflow: hidden;
    word-break: break-word;
}

/* デバッグ用ID表示（本番時は display: none に変更） */
.motif-card__debug-id{
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(255, 0, 0, 0.8);
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    z-index: 10;
    font-weight: bold;
    display: none; /* 本番時はこの行を有効化 */
}

/* カード内共通設定 */
/* マウスオーバー時 */
.motif-card a:hover{
    text-decoration: none;
    filter: brightness(1.1);
    transition: var(--transition-base);
}
/* ふりがな */
.motif-card ruby rt{
    color: var(--color-text-muted);
}
/* 書籍イメージ */
.motif-card__figure{
    /* iOS対応：aspect-ratioが幅を縮めるのを防ぐ */
    width: 100%;
    min-width: 100%;
    padding: var(--space-sm);
    background: var(--bg-light);
    /* aspect-ratioではなくheightで高さを固定 */
    height: 260px;
    overflow: hidden;
    box-sizing: border-box;
    /* 中央配置：flexbox方式（iOS対応） */
    display: flex;
    align-items: center;
    justify-content: center;
    /* 読み込み中スピナーの基準位置 */
    position: relative;
}
.motif-card__figure img{
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
    /* 読み込み完了でふわっと表示 */
    opacity: 1;
    transition: opacity var(--transition-fast);
}

/* 読み込み中スピナー */
.motif-card__image-loading{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--color-text-muted, #999);
    font-size: 1.5rem;
    pointer-events: none;
}
/* 読み込み中は画像を隠してスピナーを見せる */
.motif-card__figure.is-loading img{
    opacity: 0;
}
.motif-card__figure:not(.is-loading) .motif-card__image-loading{
    display: none;
}

/* タイトル（主文様名） */
.motif-card__pattern{
    margin: 0 0 var(--space-sm);
    display: flex;
    flex-direction: column;
}
/* ふりがな（上段・小さく薄く） */
.motif-card__pattern-furigana{
    font-size: 0.6rem;
    color: var(--color-text-light);
    word-break: break-word;
    line-height: 1.4;
    font-weight: normal;
    margin-bottom: -0.1rem;
}
/* 漢字（下段） */
.motif-card__pattern-text{
    word-break: break-word;
    line-height: 1.4;
}

/* 書籍名 */
.motif-card__book{
    margin-bottom: var(--space-sm);
}
/* タグ */
.motif-card__tags{
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-2xs);
    margin-bottom: var(--space-md);
}
.motif-card__tags li a{
    background: var(--color-accent-light);
    margin-right: var(--space-xs);
    border-radius: var(--border-radius-sm);
    padding: var(--space-2xs) var(--space-sm);
    font-size: 90%;
}
/* 大分類 小分類 */
.motif-card__meta{
    margin-bottom: var(--space-md);
    min-width: 0;
}
.motif-card__meta-item{
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-bottom: var(--space-xs);
    min-width: 0;
}
.motif-card__meta-item dt,
.motif-card__meta-item dd{
    min-width: 0;
    word-break: break-word;
}
/* DOIへのリンク */
.motif-card__doi{
    display: block;
    margin-bottom: var(--space-md);
    color: var(--color-ama);
    text-decoration: underline;
}
/* ●を追加 */
.motif-card__doi::before {
    content: "●";
    margin-right: 0.25em;
}

/* カラー：色相環グラデーション */
.motif-card__doi[data-color="color"]::before {
    background: conic-gradient(
        hsl(0, 100%, 50%),
        hsl(60, 100%, 50%),
        hsl(120, 100%, 50%),
        hsl(180, 100%, 50%),
        hsl(240, 100%, 50%),
        hsl(300, 100%, 50%),
        hsl(360, 100%, 50%)
    );
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* モノクロ：放射状グラデーション */
.motif-card__doi[data-color="mono"]::before {
    background: radial-gradient(
        circle,
        hsl(0, 0%, 75%) 0%,
        hsl(0, 0%, 50%) 50%,
        hsl(0, 0%, 20%) 100%
    );
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.motif-card__doi::after{
    content: "\f35d";
    font-family: var(--font-family-icon);
    font-weight: 900;
    font-size: 80%;
    margin-left: var(--space-2xs);
}
/* Viewerボタン（下揃え） */
.motif-card__actions{
    margin-top: auto;
    min-height: 36px; /* ボタンがない場合も高さを確保 */
    padding: var(--space-md);
    padding-top: 0;
}

/* Viewerボタン：白藍 */
.motif-card__btn--viewer{
    background: var(--bg-info);
    border-color: var(--bg-info);
    color: var(--color-text);
}
.motif-card__btn--viewer:hover{
    background: var(--color-info);
    border-color: var(--color-info);
    color: var(--color-text);
}

/* デバッグ用: Viewerファイルが見つからない場合（本番時は削除） */
.motif-card__btn--missing{
    background: #dc3545 !important;
    border-color: #dc3545 !important;
    animation: pulse-missing 1s infinite;
}
@keyframes pulse-missing {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* カード内ボディ（flex-growで余白を吸収） */
.motif-card__body{
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: var(--space-md);
    padding-bottom: 0;
}
/* 資料情報グループ（書名・刊写年・DOI）を下寄せ */
.motif-card__material-info{
    margin-top: auto;
    margin-bottom: var(--space-md);
}
/* 書名・刊写年・DOI各行 */
.motif-card__material-item{
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: var(--space-xs);
}
.motif-card__material-item:last-child{
    margin-bottom: 0;
}
.motif-card__material-item dt{
    white-space: nowrap;
}
.motif-card__material-item dd{
    min-width: 0;
    word-break: break-word;
}
/* 書名（縦並び） */
.motif-card__book-value{
    display: flex;
    flex-direction: column;
}
.motif-card__book-furigana{
    font-size: 0.5rem;
    color: var(--color-text-light);
    word-break: break-word;
    line-height: 1;
    margin-bottom: -0.1rem;
}
.motif-card__book-text{
    word-break: break-word;
    line-height: 1.4;
}
/* DOI（グループ内） */
.motif-card__material-info .motif-card__doi{
    margin-top: 0;
    margin-bottom: 0;
}
/* =================================
グリッド表示（category/tagページ用）
================================= */
.motif-grid{
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-lg);
}
@media (max-width: 1280px) {
    .motif-grid{
        grid-template-columns: repeat(4, 1fr);
    }
}
@media (max-width: 992px) {
    .motif-grid{
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 768px) {
    .motif-grid{
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 480px) {
    .motif-grid{
        grid-template-columns: 1fr;
    }
}

/* =================================
検索キーワードハイライト
================================= */
.highlight,
mark.highlight{
    background: #ffff00;
    color: #000;
    padding: 0 0.1em;
    border-radius: 2px;
}

.motif-card__tags li a.highlight{
    background: #ffff00;
    color: #000;
    padding: var(--space-2xs) var(--space-sm);
    border-radius: var(--border-radius-sm);
}

.motif-card__tags li a.highlight:hover{
    background: #ffe566;
}