/**
 * A-19: KSP Semantic Trends Styles (Timeline Design)
 *
 * タイムライン型ランキング表示 - 構文の流れを視覚化
 */

#ksp-trends-widget {
    margin: 2rem 0;
    padding: 1.5rem;
    background: transparent;
    border-radius: 0;
    border: none;
    position: relative;
}

.ksp-trends-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.ksp-trends-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: #333;
    margin: 0;
    letter-spacing: 0.05em;
}

.ksp-trends-update {
    font-size: 0.7rem;
    color: #888;
    font-weight: normal;
    font-family: 'Courier New', monospace;
}

.ksp-trends-loading,
.ksp-trends-error {
    text-align: center;
    padding: 2rem;
    color: #888;
    font-size: 0.9rem;
}

.ksp-trends-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}

/* タイムライン縦線（点線） */
.ksp-trends-list::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: repeating-linear-gradient(
        to bottom,
        #d0d0d0 0px,
        #d0d0d0 4px,
        transparent 4px,
        transparent 8px
    );
}

.ksp-trends-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 0;
    background: transparent;
    border: none;
    border-radius: 0;
    position: relative;
    transition: all 0.3s ease;
}

.ksp-trends-item:hover {
    transform: translateX(4px);
}

/* ノード（丸） */
.ksp-trends-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
    font-weight: bold;
    color: white;
    background: #4A90E2;
    border-radius: 50%;
    flex-shrink: 0;
    z-index: 2;
    position: relative;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
    transition: all 0.4s ease;
}

/* トップ3に金銀銅メダル色 */
.ksp-trends-item:nth-child(1) .ksp-trends-rank {
    background: radial-gradient(circle at 30% 30%, #FFD700, #FFA500);
    box-shadow: 0 3px 12px rgba(255, 215, 0, 0.5);
    animation: pulse-gold 3s ease-in-out infinite;
}

.ksp-trends-item:nth-child(2) .ksp-trends-rank {
    background: radial-gradient(circle at 30% 30%, #E8E8E8, #A8A8A8);
    box-shadow: 0 3px 12px rgba(192, 192, 192, 0.5);
    animation: pulse-silver 3s ease-in-out infinite 0.5s;
}

.ksp-trends-item:nth-child(3) .ksp-trends-rank {
    background: radial-gradient(circle at 30% 30%, #E5A572, #B8732E);
    box-shadow: 0 3px 12px rgba(205, 127, 50, 0.5);
    animation: pulse-bronze 3s ease-in-out infinite 1s;
}

/* 呼吸アニメーション */
@keyframes pulse-gold {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 3px 12px rgba(255, 215, 0, 0.5);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 4px 16px rgba(255, 215, 0, 0.7);
    }
}

@keyframes pulse-silver {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 3px 12px rgba(192, 192, 192, 0.5);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 4px 16px rgba(192, 192, 192, 0.7);
    }
}

@keyframes pulse-bronze {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 3px 12px rgba(205, 127, 50, 0.5);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 4px 16px rgba(205, 127, 50, 0.7);
    }
}

.ksp-trends-item:hover .ksp-trends-rank {
    transform: scale(1.15);
    animation-play-state: paused;
}

/* コンテンツエリア */
.ksp-trends-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ksp-trends-term {
    font-size: 1.05rem;
    font-weight: 600;
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
    display: inline-block;
    position: relative;
}

.ksp-trends-term::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: #4A90E2;
    transition: width 0.3s ease;
}

.ksp-trends-term:hover {
    color: #4A90E2;
}

.ksp-trends-term:hover::after {
    width: 100%;
}

.ksp-trends-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: #888;
}

.ksp-trends-count {
    font-weight: 500;
    color: #666;
}

.ksp-trends-similarity {
    padding: 0.15rem 0.4rem;
    background: #f5f5f5;
    border-radius: 3px;
    font-size: 0.7rem;
    font-family: 'Courier New', monospace;
    color: #999;
}

.ksp-trends-recent {
    font-size: 0.75rem;
    color: #aaa;
    font-style: italic;
    margin-top: 0.25rem;
    padding-left: 0.5rem;
    border-left: 2px solid #e0e0e0;
}

/* ヒート度による微調整（控えめに） */
.ksp-trends-item.heat-high .ksp-trends-term {
    color: #d63031;
}

.ksp-trends-item.heat-high .ksp-trends-term:hover {
    color: #ff6b6b;
}

.ksp-trends-item.heat-medium .ksp-trends-term {
    color: #e17055;
}

.ksp-trends-item.heat-medium .ksp-trends-term:hover {
    color: #ffa94d;
}

.ksp-trends-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
    text-align: right;
}

.ksp-trends-total {
    font-size: 0.75rem;
    color: #999;
    font-family: 'Courier New', monospace;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    #ksp-trends-widget {
        padding: 1rem 0.5rem;
        margin: 1.5rem 0;
    }

    .ksp-trends-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .ksp-trends-title {
        font-size: 1.1rem;
    }

    .ksp-trends-list::before {
        left: 12px;
    }

    .ksp-trends-item {
        padding: 0.75rem 0;
        gap: 0.75rem;
    }

    .ksp-trends-rank {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }

    .ksp-trends-term {
        font-size: 0.95rem;
    }

    .ksp-trends-meta {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .ksp-trends-similarity {
        display: none; /* モバイルでは類似度非表示 */
    }

    .ksp-trends-recent {
        display: none; /* モバイルでは直近投稿非表示 */
    }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .ksp-trends-title {
        color: #e0e0e0;
    }

    .ksp-trends-update {
        color: #999;
    }

    .ksp-trends-list::before {
        background: repeating-linear-gradient(
            to bottom,
            #444 0px,
            #444 4px,
            transparent 4px,
            transparent 8px
        );
    }

    .ksp-trends-header {
        border-bottom-color: #444;
    }

    .ksp-trends-term {
        color: #e0e0e0;
    }

    .ksp-trends-term:hover {
        color: #5AA3E8;
    }

    .ksp-trends-term::after {
        background: #5AA3E8;
    }

    .ksp-trends-count {
        color: #aaa;
    }

    .ksp-trends-similarity {
        background: #2a2a2a;
        color: #888;
    }

    .ksp-trends-recent {
        color: #777;
        border-left-color: #444;
    }

    .ksp-trends-item.heat-high .ksp-trends-term {
        color: #ff8787;
    }

    .ksp-trends-item.heat-high .ksp-trends-term:hover {
        color: #ff6b6b;
    }

    .ksp-trends-item.heat-medium .ksp-trends-term {
        color: #ffb366;
    }

    .ksp-trends-item.heat-medium .ksp-trends-term:hover {
        color: #ffa94d;
    }

    .ksp-trends-footer {
        border-top-color: #444;
    }

    .ksp-trends-total {
        color: #888;
    }
}

/* ===== A-28: Trend Drift Optimizer Styles ===== */

.ksp-trends-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e0e0e0;
}

.ksp-trends-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #666;
    transition: all 0.3s;
    margin-bottom: -2px;
}

.ksp-trends-tab:hover {
    color: #333;
    background: rgba(90, 163, 232, 0.05);
}

.ksp-trends-tab.active {
    color: #5AA3E8;
    border-bottom-color: #5AA3E8;
    font-weight: 600;
}

/* Drift-specific styles */
.ksp-drift-list {
    /* Same as ksp-trends-list but with drift enhancements */
}

.ksp-drift-score {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: rgba(90, 163, 232, 0.1);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #5AA3E8;
    margin-left: 0.5rem;
}

.ksp-drift-value {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.drift-rising .ksp-drift-value {
    background: rgba(76, 175, 80, 0.15);
    color: #4CAF50;
}

.drift-falling .ksp-drift-value {
    background: rgba(244, 67, 54, 0.15);
    color: #F44336;
}

.drift-stable .ksp-drift-value {
    background: rgba(158, 158, 158, 0.15);
    color: #9E9E9E;
}

.ksp-trends-eidbo {
    font-size: 0.7rem;
    color: #9E9E9E;
    margin-top: 0.25rem;
    padding: 0.2rem 0.5rem;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 3px;
    display: inline-block;
}

.drift-rising {
    border-left-color: #4CAF50;
}

.drift-falling {
    border-left-color: #F44336;
}

.drift-stable {
    border-left-color: #9E9E9E;
}

@media (prefers-color-scheme: dark) {
    .ksp-trends-tabs {
        border-bottom-color: #444;
    }

    .ksp-trends-tab {
        color: #aaa;
    }

    .ksp-trends-tab:hover {
        color: #e0e0e0;
        background: rgba(90, 163, 232, 0.1);
    }

    .ksp-trends-tab.active {
        color: #5AA3E8;
    }

    .ksp-drift-score {
        background: rgba(90, 163, 232, 0.2);
        color: #7FB9F0;
    }

    .drift-rising .ksp-drift-value {
        background: rgba(76, 175, 80, 0.2);
        color: #81C784;
    }

    .drift-falling .ksp-drift-value {
        background: rgba(244, 67, 54, 0.2);
        color: #E57373;
    }

    .drift-stable .ksp-drift-value {
        background: rgba(158, 158, 158, 0.2);
        color: #BDBDBD;
    }

    .ksp-trends-eidbo {
        background: rgba(255, 255, 255, 0.05);
        color: #777;
    }
}
