/* ==========================================================================
   tree-hole.css — 暖心树洞页专用（配合 portal.css）
   注意：类名一律 th- 前缀。
   历史上这个页面用的是 .loader / .card / header / h1 这类通用名，
   其中 .loader 与全屏加载层（position:fixed; inset:0; z-index:2050）同名，
   会把整页内容盖住 —— 这是本次必须改掉的核心冲突。
   ========================================================================== */

/* ---------- 洞口 ---------- */
.th-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: .5rem 0 1.75rem;
}

.th-hole {
    position: relative;
    display: grid;
    place-items: center;
    width: 148px;
    height: 148px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 32%, #1B2334 0%, #0A0E16 72%);
    border: 1px solid rgba(23, 225, 230, .20);
    box-shadow:
        inset 0 18px 36px rgba(0, 0, 0, .85),
        inset 0 -2px 12px rgba(23, 225, 230, .10),
        0 0 44px -14px rgba(23, 225, 230, .40);
    color: var(--pg-t3);
    font-size: 13px;
    line-height: 1.8;
    letter-spacing: .04em;
}

/* 洞口的呼吸光：全页唯一的循环动画，且幅度极小 */
.th-hole::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 1px solid rgba(23, 225, 230, .10);
    animation: th-breathe 5s ease-in-out infinite alternate;
}

@keyframes th-breathe {
    from {
        transform: scale(.985);
        opacity: .45;
    }

    to {
        transform: scale(1.02);
        opacity: .9;
    }
}

.th-hero-text {
    margin: 1.5rem 0 0;
    font-size: 14px;
    line-height: 1.8;
    color: var(--pg-t2);
}

.th-actions {
    margin-top: 1.5rem;
    width: 100%;
    max-width: 22rem;
}

/* ---------- 列表 ---------- */
.th-list {
    display: grid;
    gap: .875rem;
    margin-top: 1.75rem;
}

.th-list-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .25rem;
}

.th-list-title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .08em;
    color: var(--pg-t3);
    text-transform: none;
}

.th-count {
    font-size: 12px;
    color: var(--pg-t3);
    font-variant-numeric: tabular-nums;
}

.th-card {
    padding: 1.125rem 1.25rem;
    border-radius: 12px;
    background: var(--pg-card);
    border: 1px solid var(--pg-line);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
    transition: border-color 160ms ease, background-color 160ms ease;
    /* 列表可以长到上百条，让浏览器跳过视口外卡片的绘制与布局。
       用 auto 而不是 hidden：内容高度不可预测，contain-intrinsic-size 只给占位估值 */
    content-visibility: auto;
    contain-intrinsic-size: auto 160px;
}

@media (hover: hover) and (pointer: fine) {
    .th-card:hover {
        background: var(--pg-card-2);
        border-color: rgba(23, 225, 230, .26);
    }
}

.th-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .75rem;
}

.th-anon {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    font-size: 12.5px;
    color: var(--pg-cyan-soft);
    letter-spacing: .02em;
}

.th-time {
    flex: 0 0 auto;
    font-size: 11.5px;
    color: var(--pg-t3);
    font-variant-numeric: tabular-nums;
}

.th-content {
    font-size: 14px;
    line-height: 1.75;
    color: var(--pg-t1);
    white-space: pre-wrap;
    word-break: break-word;
}

/* 长文折叠：用 line-clamp 而不是固定高度，行数随字号自适应。
   -webkit-box 是 Safari 唯一可靠的实现，Chrome/Edge 也走这套前缀。
   行数必须与 TreeHolePaging.CollapseLines 一致（4）。 */
.th-content-clamped {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    overflow: hidden;
}

.th-expand {
    display: inline-block;
    margin-top: .375rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--pg-cyan-soft);
    font-family: inherit;
    font-size: 12.5px;
    line-height: 1.6;
    cursor: pointer;
    opacity: .85;
    transition: opacity 150ms ease;
}

.th-expand:hover {
    opacity: 1;
    text-decoration: underline;
}

.th-expand:focus-visible {
    outline: 2px solid var(--pg-cyan);
    outline-offset: 2px;
    border-radius: 4px;
}

/* 展开更早的心事 */
.th-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    min-height: 44px;
    padding: 0 1rem;
    border-radius: 12px;
    border: 1px dashed rgba(152, 164, 187, .28);
    background: transparent;
    color: var(--pg-t2);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.th-more:hover {
    color: var(--pg-t1);
    border-color: rgba(23, 225, 230, .40);
    background: rgba(23, 225, 230, .06);
}

.th-more:focus-visible {
    outline: 3px solid var(--pg-cyan);
    outline-offset: 2px;
}

.th-heart {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    margin-top: .875rem;
    padding: .25rem .625rem;
    border-radius: 999px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, .03);
    color: var(--pg-t3);
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 90ms ease;
}

.th-heart:hover {
    color: #FF9AA2;
    background: rgba(255, 154, 162, .10);
    border-color: rgba(255, 154, 162, .26);
}

.th-heart:active {
    transform: scale(.96);
}

.th-heart:focus-visible {
    outline: 2px solid var(--pg-cyan);
    outline-offset: 2px;
}

/* 冷却中：消息已送出，等服端回执。禁用但保留"已经抱过"的暖色反馈，
   否则用户会以为按钮坏了。 */
.th-heart:disabled {
    cursor: default;
}

.th-heart:disabled:hover {
    color: var(--pg-t3);
    background: rgba(255, 255, 255, .03);
    border-color: transparent;
}

.th-heart-busy,
.th-heart-busy:hover {
    color: #FF9AA2;
    background: rgba(255, 154, 162, .10);
    border-color: rgba(255, 154, 162, .26);
    opacity: .75;
}

/* ---------- 加载态 ---------- */
.th-loading {
    display: flex;
    justify-content: center;
    gap: .5rem;
    padding: 2.25rem 0;
}

.th-loading span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--pg-cyan);
    opacity: .35;
    animation: th-dot 1.1s ease-in-out infinite;
}

.th-loading span:nth-child(2) {
    animation-delay: .15s;
}

.th-loading span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes th-dot {
    0%, 100% {
        opacity: .25;
        transform: translateY(0);
    }

    50% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

/* ---------- 模态框 ---------- */
.th-modal {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(6, 9, 16, .74);
}

.th-modal-card {
    width: min(34rem, 100%);
    max-height: 88vh;
    overflow-y: auto;
    padding: 1.5rem;
    border-radius: 16px;
    background: var(--pg-card);
    border: 1px solid var(--pg-line);
    box-shadow: 0 28px 60px -28px rgba(0, 0, 0, .95);
}

.th-modal-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.th-modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: .04em;
}

.th-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--pg-t3);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: color 150ms ease, background-color 150ms ease;
}

.th-modal-close:hover {
    color: var(--pg-t1);
    background: rgba(255, 255, 255, .06);
}

.th-modal-close:focus-visible {
    outline: 2px solid var(--pg-cyan);
    outline-offset: 2px;
}

.th-modal-foot {
    margin-top: 1.5rem;
}

/* ---------- 底部说明 ---------- */
.th-foot {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--pg-line);
    text-align: center;
    font-size: 12px;
    line-height: 1.9;
    color: var(--pg-t3);
}

@media (max-width: 640px) {
    .th-hole {
        width: 124px;
        height: 124px;
        font-size: 12.5px;
    }

    .th-card {
        padding: 1rem 1.125rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .th-hole::after,
    .th-loading span {
        animation: none;
    }
}

/* ==========================================================================
   整页不出现滚动条
   --------------------------------------------------------------------------
   原来的问题是 .pg-body 自身 overflow-y:auto，而 hero + 列表全堆在一列里，
   内容一多整页就出现滚动条。这里改成：
   - 页面固定，不滚
   - hero / 列表标题 / 页脚 都不压缩（flex:0 0 auto）
   - 列表占满剩余高度，内部滚动，滚动条视觉隐藏
   ========================================================================== */

.th-page .pg-body {
    overflow: hidden;
    /* 纵向 flex：让 .pg-wrap 在纵轴上被撑满。
       注意必须写 flex-direction，默认 row 会让 wrap 在横向被拉伸，
       卡片跟着变宽，而且纵向高度依然不确定。 */
    display: flex;
    flex-direction: column;
}

.th-page .pg-wrap {
    /* 基准写 0：auto 会以内容高度为基准，收缩不足时列表仍会顶出容器 */
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.25rem 1rem;
}

/* hero 压缩：洞口 148 → 104，几处间距同步收紧，一屏能多放两行 */
.th-page .th-hero {
    flex: 0 0 auto;
    padding: 0 0 1rem;
}

.th-page .th-hole {
    width: 104px;
    height: 104px;
    font-size: 11.5px;
    line-height: 1.7;
}

.th-page .th-hero-text {
    margin-top: 1rem;
    font-size: 13px;
    line-height: 1.7;
}

.th-page .th-actions {
    margin-top: 1rem;
    max-width: 20rem;
}

.th-page .th-list-head {
    flex: 0 0 auto;
    margin-bottom: .5rem;
}

/* 列表：吃掉剩余高度，自己滚；滚动条隐藏但滚动能力保留 */
.th-page .th-list {
    /* 同上：basis 0 才能严格按容器剩余高度分配，列表才会真正滚动 */
    flex: 1 1 0;
    min-height: 0;
    margin-top: .625rem;
    padding-bottom: .25rem;
    gap: .625rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.th-page .th-list::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.th-page .th-foot {
    flex: 0 0 auto;
    margin-top: .5rem;
    padding-top: .625rem;
    font-size: 11px;
    line-height: 1.7;
}

/* 卡片在树洞页略收紧，让 5~6 条能完整落在一屏 */
.th-page .th-card {
    padding: 1rem 1.125rem;
}

.th-page .th-heart {
    margin-top: .625rem;
}
