/* ==============================================
    動態頁：會員首頁 Feed、追蹤文章、熱門創作共用
    卡片本身的樣式（.content-card）在 site.css，和作品列表共用
    分頁標籤、列表、空狀態參考 Material Design 3（primary tabs、list、empty state），顏色沿用網站主題變數
==============================================
*/

/* site.css 對所有 nav 加了導覽列漸層與圓角，動態頁的 nav 不要 */
nav.feed-tabs,
nav.feed-pager {
    background-image: none;
    border-radius: 0;
}

/* 分頁標籤（Material primary tabs） */
.feed-tabs {
    border-bottom: 1px solid var(--border-color);
    display: flex;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}

    .feed-tabs::-webkit-scrollbar {
        display: none;
    }

.feed-tabs__tab {
    align-items: center;
    color: var(--tag-count-color);
    display: flex;
    flex: 1 0 auto;
    font-weight: 500;
    gap: .5rem;
    justify-content: center;
    min-height: 3rem;
    padding: 0 1rem;
    position: relative;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
    white-space: nowrap;
}

    .feed-tabs__tab:hover {
        background-color: rgba(var(--primary-accent-rgb), .08);
        color: var(--text-color);
    }

    .feed-tabs__tab:focus-visible {
        background-color: rgba(var(--primary-accent-rgb), .12);
        outline: 2px solid var(--primary-accent);
        outline-offset: -2px;
    }

    .feed-tabs__tab:active {
        background-color: rgba(var(--primary-accent-rgb), .16);
    }

    /* 指示線：和圖示加文字一樣寬，貼齊底線，上方圓角 */
    .feed-tabs__tab::after {
        background-color: transparent;
        border-radius: 3px 3px 0 0;
        bottom: 0;
        content: "";
        height: 3px;
        left: 50%;
        position: absolute;
        transform: translateX(-50%);
        width: calc(100% - 2rem);
    }

.feed-tabs__tab--active,
.feed-tabs__tab--active:hover {
    color: var(--primary-accent);
}

    .feed-tabs__tab--active::after {
        background-color: var(--primary-accent);
    }

.feed-tabs__icon {
    font-size: 1rem;
}

/* 頁面標題、說明 */
.feed-page-title {
    align-items: center;
    display: flex;
    font-size: 1.5rem;
    font-weight: 700;
    gap: .6rem;
    margin-bottom: .5rem;
}

    .feed-page-title i {
        color: var(--primary-accent);
    }

.feed-caption {
    color: var(--tag-count-color);
    font-size: .875rem;
    margin-bottom: 1rem;
}

/* 空狀態 */
.feed-empty {
    align-items: center;
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding: 3rem 1.5rem;
    text-align: center;
}

.feed-empty__icon {
    align-items: center;
    background-color: rgba(var(--primary-accent-rgb), .12);
    border-radius: 50%;
    color: var(--primary-accent);
    display: flex;
    font-size: 1.5rem;
    height: 4rem;
    justify-content: center;
    margin-bottom: .5rem;
    width: 4rem;
}

.feed-empty__title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.feed-empty__text {
    color: var(--tag-count-color);
    margin: 0 0 .75rem;
    max-width: 28rem;
}

.home-feed {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    padding-bottom: 1rem;
}

/* 區塊 */
.feed-section__header {
    align-items: baseline;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: .85rem;
}

.feed-section__title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

    .feed-section__title i {
        color: var(--primary-accent);
        margin-right: .5rem;
    }

.feed-section__more {
    font-size: .875rem;
    white-space: nowrap;
}

.feed-section__empty {
    background-color: var(--card-bg-color);
    border: 1px dashed var(--border-color);
    border-radius: .75rem;
    color: var(--tag-count-color);
    margin: 0;
    padding: 1rem 1.25rem;
}

/* 繼續閱讀：橫向捲動 */
.feed-scroller {
    display: grid;
    gap: 1rem;
    grid-auto-columns: minmax(220px, 260px);
    grid-auto-flow: column;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: .25rem .25rem 1rem;
    scroll-snap-type: x mandatory;
}

.feed-scroller__item {
    scroll-snap-align: start;
}

/* 卡片網格 */
.feed-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* 投票進行中 */
.feed-votings {
    display: grid;
    gap: .75rem;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    list-style: none;
    margin: 0;
    padding: 0;
}

.feed-voting {
    align-items: center;
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-accent);
    border-radius: .75rem;
    display: flex;
    gap: .75rem;
    justify-content: space-between;
    padding: .75rem 1rem;
}

.feed-voting--urgent {
    border-left-color: var(--bs-danger);
}

.feed-voting__link {
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-width: 0;
    text-decoration: none;
}

    .feed-voting__link:hover .feed-voting__title {
        color: var(--primary-accent);
    }

.feed-voting__title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feed-voting__source {
    color: var(--tag-count-color);
    font-size: .8125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feed-voting__remaining {
    color: var(--primary-accent);
    flex-shrink: 0;
    font-size: .875rem;
    font-weight: 600;
}

    .feed-voting__remaining i {
        margin-right: .35rem;
    }

.feed-voting--urgent .feed-voting__remaining {
    color: var(--bs-danger);
}

/* 冷啟動：選喜歡的分類（選項用 site.css 的 .category-chip） */
.feed-type-picker {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: .75rem;
    margin-bottom: 1rem;
    padding: .75rem 1rem;
}

.feed-type-picker__summary {
    cursor: pointer;
    font-weight: 600;
}

.feed-type-picker__form {
    align-items: flex-end;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: .75rem;
}

.feed-type-picker__options {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

/* 熱門排名：卡片左上角的名次，前三名用主題色 */
.feed-grid--ranked {
    counter-reset: feed-rank;
}

    .feed-grid--ranked > .content-card {
        counter-increment: feed-rank;
        position: relative;
    }

        .feed-grid--ranked > .content-card::before {
            align-items: center;
            background-color: rgba(0, 0, 0, .6);
            border-radius: .5rem;
            color: #fff;
            content: counter(feed-rank);
            display: flex;
            font-size: .875rem;
            font-weight: 700;
            height: 1.75rem;
            justify-content: center;
            left: .5rem;
            min-width: 1.75rem;
            padding: 0 .4rem;
            pointer-events: none;
            position: absolute;
            top: .5rem;
            z-index: 2;
        }

        .feed-grid--ranked > .content-card:nth-child(-n+3)::before {
            background-color: var(--primary-accent);
        }

/* 追蹤文章：列表 */
.article-list {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.article-item {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    display: flex;
    gap: 1rem;
    padding: 1rem 1.25rem;
    position: relative;
    transition: border-color .15s ease, box-shadow .15s ease;
}

    .article-item:hover {
        border-color: rgba(var(--primary-accent-rgb), .6);
        box-shadow: var(--card-hover-shadow);
    }

    .article-item:focus-within {
        border-color: var(--primary-accent);
    }

.article-item__main {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: .4rem;
    min-width: 0;
}

.article-item__header {
    align-items: center;
    display: flex;
    font-size: .875rem;
    gap: .5rem;
    min-width: 0;
}

/* 作者、標籤連結疊在整張卡片的連結上面，才點得到 */
.article-item__author {
    align-items: center;
    color: var(--text-color);
    display: flex;
    font-weight: 500;
    gap: .5rem;
    min-width: 0;
    position: relative;
    text-decoration: none;
    z-index: 1;
}

    .article-item__author:hover .article-item__author-name {
        color: var(--primary-accent);
        text-decoration: underline;
    }

.article-item__author-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.article-item__avatar {
    border-radius: 50%;
    flex-shrink: 0;
    height: 2rem;
    object-fit: cover;
    width: 2rem;
}

.article-item__avatar--initial {
    align-items: center;
    background-color: rgba(var(--primary-accent-rgb), .18);
    color: var(--primary-accent);
    display: inline-flex;
    font-size: .875rem;
    font-weight: 700;
    justify-content: center;
}

.article-item__time {
    color: var(--tag-count-color);
    flex-shrink: 0;
}

    .article-item__time::before {
        content: "·";
        margin-right: .5rem;
    }

.article-item__title {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.4;
    margin: 0;
}

/* 標題連結延伸成整張卡片的點擊範圍 */
.article-item__link {
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    color: var(--text-color);
    display: -webkit-box;
    overflow: hidden;
    text-decoration: none;
}

    .article-item__link::after {
        border-radius: 1rem;
        content: "";
        inset: 0;
        position: absolute;
    }

    .article-item__link:hover {
        color: var(--primary-accent);
    }

    .article-item__link:focus-visible {
        outline: none;
    }

.article-item__preview {
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    color: var(--tag-count-color);
    display: -webkit-box;
    font-size: .9375rem;
    line-height: 1.6;
    margin: 0;
    overflow: hidden;
}

.article-item__footer {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    font-size: .8125rem;
    gap: .4rem;
    margin-top: .25rem;
}

.article-item__tag {
    background-color: rgba(var(--primary-accent-rgb), .1);
    border-radius: .5rem;
    color: var(--primary-accent);
    padding: .15rem .55rem;
    position: relative;
    text-decoration: none;
    z-index: 1;
}

    .article-item__tag:hover {
        background-color: rgba(var(--primary-accent-rgb), .2);
    }

.article-item__stats {
    color: var(--tag-count-color);
    display: flex;
    gap: .9rem;
    margin-left: auto;
}

    .article-item__stats i {
        margin-right: .2rem;
    }

.article-item__thumbnail {
    align-self: center;
    border-radius: .75rem;
    flex-shrink: 0;
    height: 6rem;
    object-fit: cover;
    width: 8rem;
}

/* 追蹤文章：上一頁／下一頁 */
.feed-pager {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.feed-pager__button {
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--primary-accent);
    display: inline-flex;
    font-weight: 500;
    gap: .5rem;
    min-height: 2.5rem;
    padding: 0 1.25rem;
    text-decoration: none;
}

    .feed-pager__button:hover {
        background-color: rgba(var(--primary-accent-rgb), .08);
        color: var(--primary-accent);
    }

.feed-pager__status {
    color: var(--tag-count-color);
    font-size: .875rem;
}

@media (max-width: 575.98px) {
    .home-feed {
        gap: 2rem;
    }

    .feed-grid {
        gap: .75rem;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .feed-scroller {
        grid-auto-columns: 72%;
    }

    .content-card__body {
        padding: .6rem .65rem .7rem;
    }

    .content-card__title {
        font-size: .9375rem;
    }

    .feed-voting {
        align-items: flex-start;
        flex-direction: column;
        gap: .35rem;
    }

    .feed-tabs {
        margin-bottom: 1rem;
    }

    .feed-tabs__tab {
        font-size: .9375rem;
        padding: 0 .75rem;
    }

        .feed-tabs__tab::after {
            width: calc(100% - 1.5rem);
        }

    .article-item {
        gap: .75rem;
        padding: .85rem 1rem;
    }

    .article-item__title {
        font-size: 1rem;
    }

    .article-item__thumbnail {
        align-self: flex-start;
        height: 4.5rem;
        width: 4.5rem;
    }
}

@media (min-width: 768px) {
    /* 寬螢幕：標籤靠左，不撐滿整列 */
    .feed-tabs__tab {
        flex: 0 0 auto;
        min-width: 9rem;
    }
}
