/**
 * 站点结构样式 - 头部、底部、导航栏
 */

/* 含顶栏的页面：模板 body padding 不作用于顶栏上方 */
body:has(.site-header) {
    padding-top: 0;
}

/* 站点头部 */
.site-header {
    width: 100%;
    position: relative;
    background: linear-gradient(135deg, #1a0a0a 0%, #8b1a1a 100%);
    box-shadow: var(--shadow-md);
    z-index: 100;
    margin-bottom: var(--space-md, 12px);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    gap: var(--space-sm, 8px);
    height: 48px;
    position: relative;
}

.site-logo {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--space-sm, 8px);
    flex-shrink: 0;
    align-self: center;
}

.site-logo img {
    height: 36px;
    border-radius: var(--radius-md, 8px);
}

.site-header .header-nav {
    display: flex;
    gap: 0;
    flex-wrap: nowrap;
    align-items: stretch;
    align-self: stretch;
    margin-left: auto;
}

.site-header .header-nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 0 14px;
    border-radius: 0;
    font-size: 0.9rem;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: auto;
    line-height: 1;
    box-sizing: border-box;
    border: none;
}

.site-header .header-nav a i {
    width: 1em;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.92em;
    line-height: 1;
}

.site-header .header-nav a:hover,
.site-header .header-nav a.active {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

.site-header .header-nav a.active {
    font-weight: 600;
    box-shadow: inset 0 -2px 0 rgba(253, 187, 45, 0.9);
}

.site-header .header-nav a.header-nav-points {
    background: rgba(7, 193, 96, 0.22);
    color: #d4fce6;
    font-weight: 600;
}

.site-header .header-nav a.header-nav-points:hover {
    background: rgba(7, 193, 96, 0.38);
    color: #fff;
}

.header-mobile-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: auto;
    align-self: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: var(--radius-md, 8px);
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.header-mobile-toggle .nav-toggle-icon {
    display: block;
    pointer-events: none;
}

.header-mobile-toggle:hover,
.header-mobile-toggle:focus-visible {
    background: rgba(255, 255, 255, 0.1);
}

/* margin-left 已合并到 .header-nav */

/* 移动端导航 */
@media (max-width: 768px) {
    .site-header {
        margin-bottom: 8px;
    }

    .header-inner {
        padding: 0 12px;
        flex-wrap: nowrap;
    }

    .site-logo {
        min-width: 0;
        flex: 1 1 auto;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-mobile-toggle {
        display: flex;
        position: relative;
        z-index: 502;
    }

    .header-nav {
        display: none;
        margin-left: 0;
        position: absolute;
        top: 48px;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #1a0a0a 0%, #8b1a1a 100%);
        flex-direction: column;
        padding: 8px 12px;
        gap: 2px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.25);
        z-index: 501;
    }

    .header-nav.open {
        display: flex;
    }

    .site-header .header-nav a {
        height: auto;
        min-height: 44px;
        padding: 12px 16px;
        border-radius: var(--radius-md, 8px);
        font-size: 0.95rem;
        justify-content: flex-start;
        box-shadow: none;
    }

    .site-header .header-nav a.active {
        background: rgba(255,255,255,0.15);
        box-shadow: inset 3px 0 0 rgba(253, 187, 45, 0.9);
    }
}

@media (max-width: 480px) {
    .header-inner {
        padding: 0 10px;
    }
    .site-logo {
        font-size: 1rem;
    }
    .site-header .header-nav a {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

@media (max-width: 375px) {
    .header-inner {
        height: 44px;
    }
    .site-logo {
        font-size: 0.9rem;
        gap: var(--space-xs, 4px);
    }
    .site-header .header-nav a {
        padding: var(--space-sm, 8px) var(--space-md, 12px);
        font-size: 0.85rem;
    }
    .header-mobile-toggle {
        font-size: 1.3rem;
        padding: 6px 8px;
    }
}

/* 站点底部 */
.site-footer {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    background: linear-gradient(135deg, #1a0a0a 0%, #8b1a1a 100%);
    color: rgba(255,255,255,0.8);
    padding: 16px 15px 18px;
    margin-top: auto;
    overflow-x: clip;
}

.footer-inner {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
    box-sizing: border-box;
}

.footer-copy {
    font-size: 0.78rem;
    opacity: 0.75;
    line-height: 1.55;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.footer-copy p {
    margin: 3px 0;
}

.footer-icp-text a,
.footer-icp-text a:visited {
    color: inherit;
    text-decoration: none;
}

.footer-icp-text a:hover {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: underline;
}

.footer-icp-text:empty {
    display: none;
}

.footer-points-entry {
    margin-top: 8px;
}

.footer-points-entry a {
    color: #86efac;
    text-decoration: none;
    font-weight: 600;
}

.footer-points-entry a:hover {
    color: #bbf7d0;
    text-decoration: underline;
}

/* 首页：页脚与 .container 同宽，不铺满整屏 */
body.home-page {
    overflow-x: clip;
}

body.home-page .site-footer {
    width: 100%;
    max-width: 1200px;
    margin: 8px auto 12px;
    padding: 0 6px;
    background: transparent;
}

body.home-page .site-footer .footer-inner {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 10px 12px;
}

@media (max-width: 480px) {
    body.home-page .site-footer {
        padding: 0 6px;
        margin-bottom: 8px;
    }
}

/* 右侧微信浮窗 */
.wechat-float {
    position: fixed;
    right: 0;
    top: 58%;
    transform: translateY(-50%);
    z-index: 880;
    display: none;
}

.wechat-float.is-ready {
    display: block;
}

.wechat-float-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 44px;
    padding: 10px 6px;
    border: none;
    border-radius: 10px 0 0 10px;
    background: linear-gradient(180deg, #08c461 0%, #06a854 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: -2px 2px 14px rgba(0, 0, 0, 0.18);
    transition: width 0.2s, background 0.2s;
}

.wechat-float-tab:hover,
.wechat-float-tab[aria-expanded="true"] {
    background: linear-gradient(180deg, #06ad56 0%, #059648 100%);
    width: 48px;
}

/* 走势页等模板内联 button{} 不应影响右侧浮窗 */
.wechat-float .wechat-float-tab {
    height: auto;
    min-height: 0;
    line-height: 1.2;
    border: none;
    background: linear-gradient(180deg, #08c461 0%, #06a854 100%);
    color: #fff;
    box-shadow: -2px 2px 14px rgba(0, 0, 0, 0.18);
}

.wechat-float .wechat-float-tab:hover,
.wechat-float .wechat-float-tab[aria-expanded="true"] {
    background: linear-gradient(180deg, #06ad56 0%, #059648 100%);
}

.wechat-float .wechat-float-panel-close {
    height: auto;
    min-height: 0;
    line-height: 1;
    border: none;
    background: transparent;
    color: #999;
    box-shadow: none;
    display: block;
    padding: 0;
}

.wechat-float-tab-text {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 1px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.wechat-float-tab-text:empty::before {
    content: '加微信';
}

.wechat-float-panel[hidden] {
    display: none !important;
}

.wechat-float-panel:not([hidden]) {
    display: block;
}

.wechat-float-panel-backdrop {
    display: none;
}

.wechat-float-panel-card {
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    width: 132px;
    padding: 10px 10px 12px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.wechat-float-panel-card::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 8px solid transparent;
    border-left-color: #fff;
}

.wechat-float-panel-title {
    margin: 0 0 8px;
    font-size: 12px;
    color: #333;
    line-height: 1.3;
}

.wechat-float-panel-title:empty {
    display: none;
}

.wechat-float-panel-close {
    position: absolute;
    top: 2px;
    right: 4px;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: #999;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.wechat-float-panel-close:hover {
    color: #333;
}

.wechat-float-img,
.footer-wechat-img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
}

@media (max-width: 768px) {
    .wechat-float {
        top: auto;
        bottom: calc(96px + env(safe-area-inset-bottom, 0px));
        transform: none;
    }

    .wechat-float-tab {
        width: 40px;
        padding: 8px 5px;
        border-radius: 8px 0 0 8px;
    }

    .wechat-float-panel-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: -1;
    }

    .wechat-float-panel-card {
        position: fixed;
        right: auto;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: min(72vw, 200px);
    }

    .wechat-float-panel-card::after {
        display: none;
    }
}

/* ===== 阅读量 ===== */
.page-view-count {
    font-size: 0.82rem;
    font-weight: normal;
    color: #888;
    white-space: nowrap;
}
.page-view-count:empty {
    display: none;
}

.page-view-top {
    max-width: 100%;
    margin: 0 auto 0;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid #eee;
    font-size: 0.88rem;
    color: #666;
    box-sizing: border-box;
}
.page-view-top__title {
    font-weight: 600;
    color: #333;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 仅首页等带阅读量的标题用 flex（标题 + 阅读量） */
.page-header h1:has(.page-view-count),
.page-title-row h1:has(.page-view-count),
.page-title-row h2:has(.page-view-count),
.channel-title-row h1:has(.page-view-count) {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.channel-title-row {
    text-align: center;
}

.channel-title-row h1 {
    text-align: center;
}

.page-header h1 .page-view-count,
.page-title-row h1 .page-view-count,
.page-title-row h2 .page-view-count,
.channel-title-row h1 .page-view-count {
    margin-left: auto;
    flex-shrink: 0;
}

.info-title-row {
    flex: 1;
    min-width: 0;
}
.info-bar .page-view-count {
    color: rgba(255, 255, 255, 0.78);
    margin-left: auto;
    flex-shrink: 0;
}

.article-meta .page-view-count {
    color: #999;
}

.home-page .site-branding .branding-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
}

.home-page .site-branding .branding-text h1 {
    display: block;
}

.home-page .site-branding .branding-actions .page-view-count {
    margin-left: 0;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85rem;
}

/* 首页无顶栏导航，品牌区即页头；与页脚保持相同左右边距 */
body.home-page .container {
    padding-top: 8px;
    padding-left: 6px;
    padding-right: 6px;
    box-sizing: border-box;
}

@media (max-width: 480px) {
    body.home-page .container {
        padding-left: 6px;
        padding-right: 6px;
    }
}

@media (max-width: 768px) {
    .page-view-top {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    .page-header h1 .page-view-count,
    .channel-title-row h1 .page-view-count {
        margin-left: 0;
        width: 100%;
    }

    /* 微信 / 移动端：品牌标题居中（覆盖 .branding-head 横排） */
    .home-page .site-branding .branding-wrapper {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
    }

    .home-page .site-branding .branding-text {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .home-page .site-branding .branding-head {
        width: 100%;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .home-page .site-branding .branding-text h1 {
        width: 100%;
        text-align: center;
        font-size: 1.25rem;
        line-height: 1.35;
    }

    .home-page .site-branding .branding-actions {
        margin-left: 0;
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px 12px;
    }

    .home-page .site-branding .subtitle {
        width: 100%;
        text-align: center;
    }
}
