@charset 'UTF-8';

/* =========================================================
   トレンド（trend.html）
   ※ 更新ボタン（.refresh-btn）・.section の基本形は sns-detail.css
   ========================================================= */

/* ---------- ページ見出し ---------- */
.trend-page {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.trend-page .page-head p,
.trend-page .page-head h1 {
    margin: 0;
}

.trend-page .top-title {
    margin-top: 8px;
    font-size: 30px;
    font-weight: 900;
    line-height: 1.4;
}

.trend-page .page-lead {
    margin-top: 4px;
    font-size: 14px;
    color: var(--text-2);
}

/* ---------- カード（Xトレンド / Instagramトレンド音源） ---------- */
.trend-contents {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.x-trend,
.instagram-audio-trend {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    padding: 22px 24px;
    border-radius: 22px;
    border: 1px solid var(--line-soft);
    background: var(--surface);
}

.trend-card-head {
    align-items: center;
    gap: 12px;
}

.trend-card-head h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 17px;
    font-weight: 900;
    line-height: 1.4;
}

.trend-card-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    box-sizing: border-box;
    padding: 6px;
    border-radius: 9px;
    border: 1px solid var(--line-soft);
    background: #fff;
}

.trend-card-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.trend-card-head .refresh-btn {
    height: 38px;
    padding: 0 14px;
    font-size: 13px;
}

.trend-card-head .refresh-btn::before {
    font-size: 17px;
    width: 17px;
}

#updated-at,
#ig-audio-updated-at {
    margin: 0;
    font-family: var(--font-family-en);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    white-space: nowrap;
}

/* ---------- キーワード通知 ---------- */
.trend-watch-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid var(--line-soft);
    background: var(--surface-2);
}

.trend-watch-panel p {
    margin: 0;
}

.trend-watch-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.trend-watch-header h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 14px;
    font-weight: 900;
}

.trend-watch-header h4 .material-symbols-outlined {
    font-size: 19px;
    color: var(--accent-ink);
}

.trend-watch-count-label {
    padding: 2px 10px;
    border-radius: 100px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-family: var(--font-family-en);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-2);
    white-space: nowrap;
}

.trend-watch-description {
    font-size: 12px;
    line-height: 1.8;
    color: var(--text-3);
}

.trend-watch-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.trend-watch-list:empty {
    display: none;
}

.trend-watch-empty {
    font-size: 13px;
    color: var(--text-3);
}

.trend-watch-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 6px 0 14px;
    box-sizing: border-box;
    border-radius: 100px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

.trend-watch-chip-type {
    padding: 2px 8px;
    border-radius: 100px;
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.trend-watch-chip-remove {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--line-soft);
    color: var(--text-2);
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.trend-watch-chip-remove:hover {
    background: var(--line);
    color: var(--text);
}

.trend-watch-add-row {
    display: flex;
    gap: 8px;
}

.trend-watch-add-row input {
    flex: 1;
    min-width: 0;
    height: 42px;
    padding: 0 14px;
    box-sizing: border-box;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
}

.trend-watch-add-row input::placeholder {
    color: var(--text-3);
}

.trend-watch-select-wrap {
    position: relative;
    flex-shrink: 0;
}

.trend-watch-select-wrap::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 14px;
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--text-3);
    border-bottom: 2px solid var(--text-3);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}

.trend-watch-add-row select {
    appearance: none;
    -webkit-appearance: none;
    height: 42px;
    padding: 0 36px 0 14px;
    box-sizing: border-box;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.trend-watch-add-btn {
    flex-shrink: 0;
    height: 42px;
    padding: 0 18px;
    border: none;
    border-radius: 12px;
    background: var(--ink);
    color: var(--ink-contrast);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.trend-watch-add-btn:hover {
    opacity: 0.88;
}

.trend-watch-add-btn:disabled {
    background: var(--line);
    color: var(--text-3);
    cursor: not-allowed;
    opacity: 1;
}

/* ---------- 一覧（2列。JSが display:block を付ける） ---------- */
#trend-list,
#ig-audio-list {
    column-count: 2;
    column-gap: 24px;
}

#trend-list:has(> .trend-empty),
#ig-audio-list:has(> .trend-empty) {
    column-count: 1;
}

#header-loading[style*="block"],
#ig-audio-loading[style*="block"] {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.trend-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    min-height: 58px;
    box-sizing: border-box;
    padding: 11px 10px;
    border-bottom: 1px solid var(--line-soft);
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    break-inside: avoid;
    transition: background var(--transition-fast);
}

a.trend-item:hover {
    background: var(--surface-2);
}

/* リンク先（X・Instagram）を開けることを示すアイコン */
a.trend-item::after {
    content: 'open_in_new';
    order: 3;
    flex-shrink: 0;
    margin-left: auto;
    width: 16px;
    overflow: hidden;
    font-family: 'Material Symbols Outlined';
    font-feature-settings: 'liga';
    font-size: 16px;
    line-height: 1;
    color: var(--text-3);
    opacity: 0.6;
}

.trend-rank {
    order: 0;
    flex-shrink: 0;
    width: 30px;
    text-align: center;
    font-family: var(--font-family-en);
    font-size: 15px;
    font-weight: 800;
    color: var(--text-3);
}

/* 1〜3位は黒い角丸の中にシアンの数字 */
.trend-item:nth-child(-n+3) .trend-rank {
    height: 30px;
    line-height: 30px;
    border-radius: 9px;
    background: var(--ink);
    color: var(--accent);
    font-size: 14px;
}

[data-theme="dark"] .trend-item:nth-child(-n+3) .trend-rank {
    color: #00768F;
}

.trend-body {
    order: 2;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.trend-name {
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trend-item:nth-child(-n+3) .trend-name {
    font-size: 15px;
    font-weight: 900;
}

.trend-meta {
    font-size: 11px;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trend-meta:empty {
    display: none;
}

/* トレンド音源は、順位の後ろに音符アイコンを付ける */
#ig-audio-list .trend-item::before {
    content: 'music_note';
    order: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    overflow: hidden;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-family: 'Material Symbols Outlined';
    font-feature-settings: 'liga';
    font-size: 18px;
    line-height: 1;
}

/* 空の状態・取得失敗 */
.trend-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 28px 10px;
    color: var(--text-2);
    font-size: 13px;
    line-height: 1.8;
    text-align: center;
}

.trend-empty a {
    color: var(--accent-ink);
    font-weight: 700;
}

.trend-empty-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-size: 24px;
}

/* ---------- 狭い画面 ---------- */
@media (max-width: 1000px) {
    #trend-list,
    #ig-audio-list {
        column-count: 1;
    }
}

@media (max-width: 768px) {
    .trend-page {
        gap: 16px;
    }

    .trend-page .top-title {
        font-size: 24px;
    }

    .trend-page .page-lead {
        font-size: 13px;
    }

    .x-trend,
    .instagram-audio-trend {
        padding: 16px;
        border-radius: 18px;
    }

    .trend-card-head {
        flex-direction: row;
        align-items: center;
    }

    .trend-card-head h3 {
        font-size: 15px;
    }

    .trend-card-icon {
        width: 28px;
        height: 28px;
        padding: 5px;
    }

    /* 更新日時はボタンの下に回して、見出しの横幅を確保する */
    .trend-card-head .refresh-btn-area {
        flex-direction: column-reverse;
        align-items: flex-end;
        gap: 4px;
    }

    .trend-card-head .refresh-btn {
        height: 34px;
        padding: 0 12px;
    }

    #updated-at,
    #ig-audio-updated-at {
        font-size: 11px;
    }

    .trend-watch-panel {
        padding: 12px 14px;
    }

    .trend-watch-add-row {
        flex-wrap: wrap;
    }

    .trend-watch-add-row input {
        flex-basis: 100%;
    }

    .trend-watch-select-wrap {
        flex: 1;
    }

    .trend-watch-add-row select {
        width: 100%;
    }
}
