/**
 * DTM用語集 デザインブラッシュアップ v3.1
 * - プレミアム・イボGの一言デザイン
 * - View数表示
 * - レコメンドセクション（スマホはみ出し修正）
 * - 「役に立った」投票ボックス
 * - ランキングセクション
 */

/* ===========================================
   全体レイアウト
   =========================================== */
/* シングルページ用（本文の読みやすさ優先） */
.single-glossary .l-article__body {
    max-width: 800px;
    margin: 0 auto;
}

/* アーカイブページ用（全幅使用） */
.post-type-archive-glossary .l-article__body,
.tax-glossary_category .l-article__body {
    max-width: none;
    width: 100%;
}

/* ===========================================
   ヘッダー部分
   =========================================== */
.glossary-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #eee;
}
.glossary-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #333;
}
.glossary-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.glossary-reading { color: #666; font-size: 0.9rem; }
.glossary-english { color: #888; font-size: 1rem; font-style: italic; }

/* 難易度バッジ */
.glossary-difficulty { padding: 2px 10px; border-radius: 4px; font-size: 0.8rem; font-weight: bold; color: #fff; }
.difficulty-beginner { background: #52b788; }
.difficulty-intermediate { background: #f39c12; }
.difficulty-advanced { background: #e74c3c; }

.glossary-alias {
    font-size: 0.9rem;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    display: inline-block;
    color: #555;
}

/* View数表示（ヘッダー内） */
.glossary-view-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: #888;
    margin-left: auto;
}
.glossary-view-count svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

/* ===========================================
   解説文セクション
   =========================================== */
.glossary-commentary { margin: 2.5em 0; }
.glossary-commentary .commentary-content {
    font-size: 1.05rem;
    line-height: 1.8;
    color: #2c3e50 !important;
}
.glossary-md-h3 {
    font-size: 1.4em;
    padding-left: 12px;
    border-left: 5px solid #f39c12;
    margin: 2em 0 1em;
}

/* ===========================================
   【重要】イボGの一言 プレミアムデザイン
   =========================================== */
.glossary-ibo-comments {
    margin: 5em 0 3em !important;
    clear: both;
}

.ibo-comments-box {
    background: #fff !important;
    border: 1px solid #f39c12 !important;
    border-radius: 16px !important;
    position: relative !important;
    padding: 0 !important;
    box-shadow: 0 10px 30px rgba(243, 156, 18, 0.15) !important;
    overflow: visible !important;
}

.ibo-comments-header {
    background: linear-gradient(90deg, #f39c12 0%, #fbc531 100%) !important;
    padding: 10px 20px 10px 95px !important;
    display: flex !important;
    align-items: center !important;
    border-radius: 14px 14px 0 0 !important;
    color: #fff !important;
    height: 60px !important;
    position: relative;
}

.ibo-avatar {
    position: absolute !important;
    left: 15px !important;
    top: -30px !important;
    width: 70px !important;
    height: 70px !important;
    border-radius: 50% !important;
    border: 4px solid #fff !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    background: #fff !important;
    overflow: hidden !important;
    z-index: 10 !important;
}

.ibo-avatar img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

.ibo-label {
    font-weight: 700 !important;
    font-size: 1.1rem !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.ibo-comments-content {
    padding: 25px 25px 25px !important;
    font-size: 1.05rem !important;
    line-height: 1.7 !important;
    color: #444 !important;
    font-weight: 500 !important;
    position: relative;
}

.ibo-comments-content::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 40px;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid #fff;
}

/* ===========================================
   「役に立った」投票ボックス
   =========================================== */
.glossary-helpful-box {
    margin: 2em 0;
    padding: 20px;
    background: linear-gradient(135deg, #fef9e7 0%, #fff 100%);
    border: 1px solid #f39c12;
    border-radius: 12px;
    text-align: center;
}

.helpful-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.helpful-question {
    font-size: 0.95rem;
    color: #555;
    font-weight: 500;
}

.helpful-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.3);
}

.helpful-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(243, 156, 18, 0.4);
}

.helpful-btn:disabled {
    cursor: default;
}

.helpful-btn.voted {
    background: linear-gradient(135deg, #52b788 0%, #40916c 100%);
    box-shadow: 0 4px 12px rgba(82, 183, 136, 0.3);
}

.helpful-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.helpful-btn.loading::after {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
}

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

.helpful-icon {
    font-size: 1.1em;
}

.helpful-count {
    font-size: 0.85em;
    opacity: 0.9;
}

.helpful-message {
    margin-top: 12px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: opacity 0.3s ease;
}

.helpful-message.success {
    background: #d4edda;
    color: #155724;
}

.helpful-message.error {
    background: #f8d7da;
    color: #721c24;
}

/* ===========================================
   レコメンドセクション（1列3段 - サイドバー対応）
   =========================================== */
.glossary-recommendations-section {
    margin: 3em 0;
    padding: 30px;
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    border-radius: 16px;
    border: 1px solid #e9ecef;
}

.glossary-recommendations-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f39c12;
}

.glossary-recommendations-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.glossary-recommendation-block {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    border-left: 4px solid #f39c12;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden;
    box-sizing: border-box;
}

.glossary-recommendation-block.collaborative {
    border-left-color: #3b82f6;
}

.glossary-recommendation-block.same-category {
    border-left-color: #f39c12;
}

.glossary-recommendation-block.same-difficulty {
    border-left-color: #52b788;
}

.recommendation-block-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.recommendation-icon {
    font-size: 1.1em;
}

.recommendation-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    overflow: hidden;
}

.recommendation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.2s;
    box-sizing: border-box;
    min-width: 0;
    overflow: hidden;
}

.recommendation-item:hover {
    border-color: #f39c12;
    background: #fff;
}

.recommendation-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #f39c12;
    color: #fff;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.collaborative .recommendation-rank {
    background: #3b82f6;
}

.same-difficulty .recommendation-rank {
    background: #52b788;
}

.recommendation-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.2s;
    min-width: 0;
}

.recommendation-link:hover {
    color: #f39c12;
}

.recommendation-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recommendation-difficulty {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.recommendation-category {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    background: #e9ecef;
    color: #666;
    flex-shrink: 0;
}

.recommendation-score,
.recommendation-views {
    font-size: 11px;
    color: #888;
    flex-shrink: 0;
}

/* ===========================================
   アーカイブページ 用語カード（4列グリッド）
   =========================================== */
.glossary-terms {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.glossary-term-item {
    margin: 0;
}

.glossary-term-link {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 0;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    min-height: 60px;
    overflow: hidden;
}

.glossary-term-link:hover {
    border-color: #f39c12;
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.15);
    transform: translateY(-2px);
}

/* 左側：用語名＋英語名 */
.glossary-term-link .term-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
}

.term-title {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.term-english {
    font-size: 0.8rem;
    color: #888;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 右側：難易度タグ（縦書き） */
.term-difficulty {
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    padding: 8px 6px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 2px;
    flex-shrink: 0;
    border-radius: 0 7px 7px 0;
}

/* アーカイブページ その他スタイル */
.glossary-archive-header {
    text-align: center;
    margin-bottom: 30px;
}

.glossary-archive-title {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.glossary-archive-desc {
    color: #666;
    font-size: 0.95rem;
}

.glossary-search-box {
    margin-bottom: 20px;
}

.glossary-search-box input {
    width: 100%;
    padding: 14px 20px;
    border: 2px solid #e9ecef;
    border-radius: 30px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.glossary-search-box input:focus {
    outline: none;
    border-color: #f39c12;
}

.glossary-index {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.glossary-index-item {
    padding: 8px 14px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: all 0.2s;
}

.glossary-index-item:hover {
    background: #f39c12;
    border-color: #f39c12;
    color: #fff;
}

.glossary-index-item.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.glossary-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 30px;
}

.cat-filter-label {
    font-size: 0.9rem;
    color: #666;
}

.glossary-cat-filter {
    padding: 6px 14px;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    background: #fff;
    color: #666;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.glossary-cat-filter:hover,
.glossary-cat-filter.active {
    background: #f39c12;
    border-color: #f39c12;
    color: #fff;
}

.glossary-group {
    margin-bottom: 40px;
}

.glossary-group-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f39c12;
    padding: 10px 20px;
    background: linear-gradient(90deg, #fff9e6 0%, transparent 100%);
    border-left: 4px solid #f39c12;
    margin-bottom: 20px;
}

/* ===========================================
   ランキングセクション（アーカイブ用）
   =========================================== */
.glossary-ranking-section {
    background: linear-gradient(135deg, #fff9e6 0%, #fff 100%);
    border: 1px solid #f39c12;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 30px;
}

.glossary-ranking-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(243, 156, 18, 0.2);
}

.glossary-ranking-icon {
    font-size: 24px;
}

.glossary-ranking-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.glossary-ranking-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.glossary-ranking-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.glossary-ranking-item:hover {
    background: #fff9e6;
    border-color: #f39c12;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.15);
}

.glossary-ranking-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    background: #e9ecef;
    color: #666;
}

.glossary-ranking-rank.gold {
    background: linear-gradient(135deg, #f4d03f 0%, #e9a825 100%);
    color: #1a1a2e;
}

.glossary-ranking-rank.silver {
    background: linear-gradient(135deg, #c0c0c0 0%, #a8a8a8 100%);
    color: #1a1a2e;
}

.glossary-ranking-rank.bronze {
    background: linear-gradient(135deg, #cd7f32 0%, #b87333 100%);
    color: #fff;
}

.glossary-ranking-name {
    font-weight: 500;
}

.glossary-ranking-views {
    font-size: 0.8rem;
    color: #888;
    margin-left: auto;
}

/* ===========================================
   レスポンシブ対応
   =========================================== */

/* 大画面（1200px以上）: 4列グリッド */
@media (max-width: 1200px) {
    .glossary-terms {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 中画面（992px以下）: 3列→2列 */
@media (max-width: 992px) {
    .glossary-terms {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* タブレット（768px以下） */
@media (max-width: 768px) {
    .glossary-ranking-section {
        padding: 16px;
    }
    
    .glossary-ranking-list {
        flex-direction: column;
    }
    
    .glossary-ranking-item {
        width: 100%;
    }
    
    .glossary-recommendations-section {
        padding: 16px;
        margin: 2em 0;
    }
    
    .glossary-recommendations-title {
        font-size: 1.1rem;
    }
    
    .glossary-recommendation-block {
        padding: 14px;
    }
    
    .recommendation-block-title {
        font-size: 0.9rem;
        margin-bottom: 12px;
    }
    
    .recommendation-list {
        grid-template-columns: 1fr;
    }
    
    .recommendation-item {
        padding: 8px 10px;
        gap: 8px;
    }
    
    .recommendation-rank {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }
    
    .recommendation-name {
        font-size: 0.9rem;
    }
    
    .recommendation-difficulty,
    .recommendation-category {
        font-size: 9px;
        padding: 2px 5px;
    }
    
    .recommendation-score,
    .recommendation-views {
        font-size: 10px;
    }
    
    .helpful-inner {
        flex-direction: column;
        gap: 12px;
    }
    
    .glossary-meta {
        gap: 8px;
    }
    
    .glossary-view-count {
        width: 100%;
        margin-top: 8px;
        margin-left: 0;
        justify-content: flex-start;
    }
    
    .glossary-terms {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .glossary-term-link {
        min-height: 50px;
    }
    
    .glossary-term-link .term-info {
        padding: 10px 12px;
    }
    
    .term-title {
        font-size: 0.85rem;
    }
    
    .term-english {
        font-size: 0.75rem;
    }
    
    .term-difficulty {
        padding: 6px 4px;
        font-size: 10px;
    }
    
    .glossary-index {
        gap: 4px;
    }
    
    .glossary-index-item {
        padding: 6px 10px;
        font-size: 0.9rem;
    }
}

/* スマートフォン（480px以下） */
@media (max-width: 480px) {
    .glossary-terms {
        grid-template-columns: 1fr;
    }
    
    .glossary-archive-title {
        font-size: 1.5rem;
    }
    
    /* レコメンドセクション - 狭い画面対応 */
    .glossary-recommendations-section {
        padding: 12px;
        margin: 1.5em 0;
    }
    
    .glossary-recommendations-title {
        font-size: 1rem;
        margin-bottom: 16px;
    }
    
    .glossary-recommendations-grid {
        gap: 14px;
    }
    
    .glossary-recommendation-block {
        padding: 12px;
        border-radius: 10px;
    }
    
    .recommendation-block-title {
        font-size: 0.85rem;
        margin-bottom: 10px;
        gap: 6px;
    }
    
    .recommendation-icon {
        font-size: 1em;
    }
    
    .recommendation-item {
        padding: 8px;
        gap: 6px;
    }
    
    .recommendation-rank {
        width: 20px;
        height: 20px;
        font-size: 10px;
        border-radius: 4px;
    }
    
    .recommendation-link {
        gap: 6px;
    }
    
    .recommendation-name {
        font-size: 0.85rem;
    }
    
    .recommendation-difficulty,
    .recommendation-category {
        font-size: 8px;
        padding: 1px 4px;
    }
    
    .recommendation-score,
    .recommendation-views {
        font-size: 9px;
    }
}
