/**
 * 檔案名稱: semantic-related-posts.css
 * 功能說明: 智能相關文章推薦系統前端樣式
 * 版本: 1.0.0
 * 作者: TKT Team
 * 最後更新: 2024-12-19
 */

/* 1. 主容器樣式 */
.tkt-semantic-related-posts {
    margin: 30px 0;
    padding: 25px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8e8e8;
    position: relative;
    overflow: hidden;
}

.tkt-semantic-related-posts::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

/* 2. 標題樣式 */
.tkt-semantic-title {
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 20px 0;
    padding: 0;
    position: relative;
    display: flex;
    align-items: center;
}

.tkt-semantic-title::before {
    content: '🧠';
    margin-right: 10px;
    font-size: 20px;
}

.tkt-semantic-title::after {
    content: '';
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg, #667eea 0%, transparent 100%);
    margin-left: 15px;
}

/* 3. 容器佈局 */
.tkt-semantic-container {
    display: grid;
    gap: 20px;
}

/* 3.1 網格佈局 */
.tkt-semantic-layout-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* 3.2 列表佈局 */
.tkt-semantic-layout-list {
    grid-template-columns: 1fr;
}

/* 3.3 卡片佈局 */
.tkt-semantic-layout-card {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* 4. 文章項目樣式 */
.tkt-semantic-item {
    background: #ffffff;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #f0f0f0;
    position: relative;
    display: flex;
    flex-direction: column;
}

.tkt-semantic-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    border-color: #667eea;
}

/* 4.1 列表佈局的項目樣式 */
.tkt-semantic-layout-list .tkt-semantic-item {
    flex-direction: row;
    align-items: center;
    padding: 15px;
}

.tkt-semantic-layout-list .tkt-semantic-item:hover {
    transform: translateX(5px);
}

/* 5. 縮圖樣式 */
.tkt-semantic-thumbnail {
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
}

.tkt-semantic-layout-grid .tkt-semantic-thumbnail,
.tkt-semantic-layout-card .tkt-semantic-thumbnail {
    height: 180px;
}

.tkt-semantic-layout-list .tkt-semantic-thumbnail {
    width: 120px;
    height: 80px;
    flex-shrink: 0;
    margin-right: 15px;
    border-radius: 8px;
}

.tkt-semantic-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.tkt-semantic-item:hover .tkt-semantic-thumbnail img {
    transform: scale(1.05);
}

.tkt-semantic-thumbnail::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tkt-semantic-item:hover .tkt-semantic-thumbnail::after {
    opacity: 1;
}

/* 6. 內容區域樣式 */
.tkt-semantic-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tkt-semantic-layout-list .tkt-semantic-content {
    padding: 0;
}

/* 7. 文章標題樣式 */
.tkt-semantic-post-title {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
}

.tkt-semantic-post-title a {
    color: #2c3e50;
    text-decoration: none;
    transition: color 0.3s ease;
    display: block;
}

.tkt-semantic-post-title a:hover {
    color: #667eea;
}

.tkt-semantic-layout-list .tkt-semantic-post-title {
    font-size: 16px;
    margin-bottom: 8px;
}

/* 8. 摘要樣式 */
.tkt-semantic-excerpt {
    color: #6c757d;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 15px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tkt-semantic-layout-list .tkt-semantic-excerpt {
    -webkit-line-clamp: 2;
    margin-bottom: 10px;
}

/* 9. 相關度分數樣式 */
.tkt-semantic-score {
    margin-bottom: 12px;
    position: relative;
}

.tkt-score-bar {
    height: 6px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.tkt-score-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.tkt-score-text {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
    display: block;
    font-weight: 500;
}

/* 10. 語義標籤樣式 */
.tkt-semantic-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.tkt-tag {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.tkt-tag-category {
    background: rgba(52, 152, 219, 0.1);
    color: #3498db;
    border: 1px solid rgba(52, 152, 219, 0.2);
}

.tkt-tag-cluster {
    background: rgba(155, 89, 182, 0.1);
    color: #9b59b6;
    border: 1px solid rgba(155, 89, 182, 0.2);
}

.tkt-tag-content {
    background: rgba(46, 204, 113, 0.1);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.2);
}

.tkt-tag:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 11. 載入動畫 */
.tkt-semantic-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #6c757d;
}

.tkt-semantic-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 12. 錯誤狀態樣式 */
.tkt-semantic-error {
    text-align: center;
    padding: 30px;
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(231, 76, 60, 0.1);
}

.tkt-semantic-error::before {
    content: '⚠️';
    display: block;
    font-size: 24px;
    margin-bottom: 10px;
}

/* 13. 響應式設計 */
@media (max-width: 768px) {
    .tkt-semantic-related-posts {
        margin: 20px 0;
        padding: 20px 15px;
        border-radius: 8px;
    }
    
    .tkt-semantic-title {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    .tkt-semantic-container {
        gap: 15px;
    }
    
    .tkt-semantic-layout-grid,
    .tkt-semantic-layout-card {
        grid-template-columns: 1fr;
    }
    
    .tkt-semantic-layout-list .tkt-semantic-item {
        flex-direction: column;
        text-align: center;
    }
    
    .tkt-semantic-layout-list .tkt-semantic-thumbnail {
        width: 100%;
        height: 150px;
        margin-right: 0;
        margin-bottom: 15px;
    }
    
    .tkt-semantic-layout-list .tkt-semantic-content {
        padding: 0 15px 15px 15px;
    }
    
    .tkt-semantic-post-title {
        font-size: 16px;
    }
    
    .tkt-semantic-excerpt {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .tkt-semantic-related-posts {
        margin: 15px 0;
        padding: 15px 10px;
    }
    
    .tkt-semantic-title {
        font-size: 18px;
        flex-direction: column;
        text-align: center;
    }
    
    .tkt-semantic-title::after {
        display: none;
    }
    
    .tkt-semantic-content {
        padding: 15px;
    }
    
    .tkt-semantic-tags {
        justify-content: center;
    }
}

/* 14. 深色模式支援 */
@media (prefers-color-scheme: dark) {
    .tkt-semantic-related-posts {
        background: #1a1a1a;
        border-color: #333;
        color: #e0e0e0;
    }
    
    .tkt-semantic-title {
        color: #ffffff;
    }
    
    .tkt-semantic-item {
        background: #2a2a2a;
        border-color: #404040;
    }
    
    .tkt-semantic-item:hover {
        border-color: #667eea;
        background: #333;
    }
    
    .tkt-semantic-post-title a {
        color: #ffffff;
    }
    
    .tkt-semantic-post-title a:hover {
        color: #667eea;
    }
    
    .tkt-semantic-excerpt {
        color: #b0b0b0;
    }
    
    .tkt-score-text {
        color: #b0b0b0;
    }
    
    .tkt-semantic-thumbnail {
        background: #333;
    }
}

/* 15. 打印樣式 */
@media print {
    .tkt-semantic-related-posts {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    
    .tkt-semantic-item {
        box-shadow: none;
        border: 1px solid #ddd;
        margin-bottom: 10px;
        page-break-inside: avoid;
    }
    
    .tkt-semantic-thumbnail {
        display: none;
    }
    
    .tkt-semantic-tags {
        display: none;
    }
    
    .tkt-semantic-score {
        display: none;
    }
}

/* 16. 高對比度模式 */
@media (prefers-contrast: high) {
    .tkt-semantic-related-posts {
        border: 2px solid #000;
    }
    
    .tkt-semantic-item {
        border: 1px solid #000;
    }
    
    .tkt-semantic-post-title a {
        color: #000;
        text-decoration: underline;
    }
    
    .tkt-tag {
        border: 1px solid #000;
        background: #fff;
        color: #000;
    }
}

/* 17. 動畫效果 */
.tkt-semantic-item {
    animation: fadeInUp 0.6s ease-out;
}

.tkt-semantic-item:nth-child(1) { animation-delay: 0.1s; }
.tkt-semantic-item:nth-child(2) { animation-delay: 0.2s; }
.tkt-semantic-item:nth-child(3) { animation-delay: 0.3s; }
.tkt-semantic-item:nth-child(4) { animation-delay: 0.4s; }
.tkt-semantic-item:nth-child(5) { animation-delay: 0.5s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 18. 無障礙設計 */
.tkt-semantic-item:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.tkt-semantic-post-title a:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    border-radius: 4px;
}

/* 19. 減少動畫偏好 */
@media (prefers-reduced-motion: reduce) {
    .tkt-semantic-item,
    .tkt-semantic-thumbnail img,
    .tkt-tag,
    .tkt-score-bar {
        transition: none;
        animation: none;
    }
    
    .tkt-semantic-item:hover {
        transform: none;
    }
    
    .tkt-score-bar::after {
        animation: none;
    }
}

/* 20. 自定義屬性支援 */
.tkt-semantic-related-posts {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --text-color: #2c3e50;
    --text-light: #6c757d;
    --border-color: #e8e8e8;
    --background-color: #ffffff;
    --hover-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* 使用自定義屬性 */
.tkt-semantic-title {
    color: var(--text-color);
}

.tkt-semantic-post-title a {
    color: var(--text-color);
}

.tkt-semantic-post-title a:hover {
    color: var(--primary-color);
}

.tkt-semantic-excerpt {
    color: var(--text-light);
}

.tkt-semantic-item {
    background: var(--background-color);
    border-color: var(--border-color);
}

.tkt-semantic-item:hover {
    box-shadow: var(--hover-shadow);
    border-color: var(--primary-color);
}