/* ============================================================================
   tag.css —— 标签页（`/tags/` 与 `/tag/<name>/`；P96 立）

   底盘照 policy.css 那类**简单文档页**（导航条居中品牌 + 650px 外壳），但两点不同：
     · wrapper 走**文档流型**（skill §2.5-B）：内容长由**文档**承接滚动，
       `min-height` 撑满短内容；🔴 **不得声明任何 overflow**（那是 sticky 祖先链红线，
       本页虽无吸顶，也照 B 型规范走 —— 将来要加吸顶不会踩雷）。
     · 本页**零自研 JS**（网格是服务端渲染的真锚点 `<a>`，爬虫直接跟）。

   🔴 与个人页网格的**四个值刻意复制**：列数（2 / ≥651 三列）、`gap`、瓦片
      `aspect-ratio: 4 / 5`、`border-radius: 8px` —— 逐值对拍有守卫测试钉着
      （`TagPageContractTests.test_tag_grid_matches_the_profile_grid_values`）。
      改这里必须同时看 profile.css 的 `.image-grid` / `.image-card`。
   ⚠️ 列数与缩略图档位是配着调的（P49 算式：卡片宽 × 目标 DPR ≤ THUMB_MAX_EDGE）。
      本页外壳 650px 封顶与个人页相同 ⇒ 现档位（640）继续成立；**改封顶或列数前先算一遍**。
   ============================================================================ */

:root {
    /* 底盘（值照 policy.css / 个人页既有档） */
    --tp-bg: #eeeeee;          /* = policy.css --bg-color */
    --tp-nav-h: 50px;          /* = policy.css --nav-height（≤640 档 44px） */
    --tp-ink: #1d2731;         /* = policy.css --title-color */
    --tp-text: #334455;
    --tp-muted: #6a7c8d;       /* = policy.css --muted-color */
    --tp-card: #ffffff;

    /* 网格（四值与个人页网格对拍，见文件头） */
    --tp-grid-gap: 6px;        /* = profile.css .image-grid 的 gap */
    --tp-tile-radius: 8px;     /* = .image-card 的 border-radius */
    --tp-tile-ratio: 4 / 5;    /* = .image-card 的 aspect-ratio */

    --tp-gutter: 12px;
    --tp-dur: 0.22s;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: #1a1a1a;   /* 桌面列侧描边（= policy.css 同款） */
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--tp-text);
}

/* 文档流型外壳：短内容撑满、长内容由文档承接；🔴 绝不声明 overflow */
.tag-wrapper {
    max-width: 650px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    background: var(--tp-bg);
    padding-bottom: calc(var(--tp-gutter) + env(safe-area-inset-bottom));
}

/* 导航条：与登录/注册/政策页同一条基线（居中品牌 + 50/≤640:44 + 1.5em/1.3em） */
.tag-navbar {
    height: var(--tp-nav-h);
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.tag-navbar h1 {
    margin: 0;
    font-size: 1.5em;
    color: #1f1f1f;
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.1);
}

.home-link {
    color: inherit;
    text-decoration: none;
}

@media (hover: hover) {
    .home-link:hover {
        color: #1f1f1f;
    }
}

.tag-content {
    padding: clamp(10px, 3vw, 16px);
}

/* ---- 头部区（标签名 + 张数/返回链）---- */
.tag-head {
    padding: 2px 2px 12px;
}

.tag-head-name {
    margin: 0;
    font-size: 1.35em;
    color: var(--tp-ink);
    overflow-wrap: anywhere;   /* 长标签名（用户内容）不许撑破 320 */
}

.tag-head-meta {
    margin: 6px 0 0;
    color: var(--tp-muted);
    font-size: 12px;
}

.tag-head-link {
    color: inherit;
    text-decoration: underline;
}

/* ---- 网格（列数与 profile.css .image-grid 对拍）---- */
.tag-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--tp-grid-gap);
}

@media only screen and (min-width: 651px) {
    .tag-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.tag-tile {
    display: block;
    aspect-ratio: var(--tp-tile-ratio);
    border-radius: var(--tp-tile-radius);
    overflow: hidden;
    background: #eef2ee;
    transition: box-shadow var(--tp-dur) ease;
}

.tag-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
}

@media (hover: hover) {
    .tag-tile:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    }
}

.tag-tile:active {
    opacity: 0.92;
}

/* ---- 分页 ---- */
.tag-pager {
    margin: 16px 0 4px;
    display: flex;
    justify-content: center;
}

.tag-pager-link {
    display: inline-block;
    min-height: 44px;      /* 触控目标（视觉是胶囊，命中区即本体） */
    line-height: 42px;
    padding: 0 22px;
    border-radius: 999px;
    background: var(--tp-card);
    border: 1px solid rgba(143, 179, 154, 0.28);
    color: var(--tp-text);
    text-decoration: none;
    font-size: 14px;
}

@media (hover: hover) {
    .tag-pager-link:hover {
        border-color: #98e0ac;
    }
}

/* ---- 索引页列表 ---- */
.tag-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tag-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 44px;      /* 整行即触控目标 */
    padding: 6px 12px;
    margin-bottom: 6px;
    border-radius: 12px;
    background: var(--tp-card);
    border: 1px solid rgba(143, 179, 154, 0.14);
}

@media (hover: hover) {
    .tag-list-item:hover {
        background: #f5f5f5;
    }
}

.tag-list-link {
    color: var(--tp-ink);
    text-decoration: none;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.tag-list-count {
    flex: 0 0 auto;
    color: var(--tp-muted);
    font-size: 12px;
}

.tag-empty {
    color: var(--tp-muted);
    padding: 24px 4px;
}

.tag-foot-note {
    margin-top: 18px;
    color: var(--tp-muted);
    font-size: 12px;
    line-height: 1.5;
}

/* ⚠️ reduced-motion 覆盖块必须写在**基础规则之后**（同特异性后者胜；P75/P43 教训）。 */
@media (prefers-reduced-motion: reduce) {
    .tag-tile {
        transition: none;
    }
}

@media only screen and (max-width: 640px) {
    .tag-navbar {
        height: 44px;
    }
    .tag-navbar h1 {
        font-size: 1.3em;
    }
}
