/**
 * Novel-Plus Homepage - Standalone Styles
 *
 * 独立首页样式，用于默认 BookStack 主题下显示自定义首页。
 * 将 --np-* 变量映射到 BookStack 默认 CSS 变量，
 * 使首页布局与 BookStack 原生配色一致。
 *
 * 此文件由 functions.php 中间件在默认主题模式下自动注入。
 */

/* ========================================
   1. CSS 变量映射 - 使用 BookStack 默认色
   ======================================== */

:root {
    /* 主色调 - 跟随 BookStack 设置 */
    --np-primary: var(--color-primary, #1f5fad);
    --np-primary-light: var(--color-primary-light, #1f5fad26);
    --np-primary-lighter: var(--color-primary-light, #1f5fad26);
    --np-primary-dark: var(--color-primary, #1f5fad);

    /* 背景色 - BookStack 默认 */
    --np-bg-body: #f5f5f5;
    --np-bg-page: #ffffff;
    --np-bg-card: #ffffff;
    --np-bg-hover: #f8f8f8;
    --np-bg-soft: #f5f5f5;

    /* 文字色 */
    --np-text-primary: #333333;
    --np-text-secondary: #666666;
    --np-text-muted: #999999;
    --np-text-light: #cccccc;

    /* 边框色 */
    --np-border: #e0e0e0;
    --np-border-dark: #d0d0d0;

    /* 阴影 */
    --np-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --np-shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);

    /* 圆角 */
    --np-radius-sm: 4px;
    --np-radius-md: 4px;
    --np-radius-lg: 8px;

    /* 字体 */
    --np-font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --np-font-code: "JetBrains Mono", "Fira Code", "Source Code Pro", Consolas, monospace;
}

/* 覆盖 BookStack 默认 body 布局，让页脚可见 */
body {
    height: auto !important;
    min-height: 100vh;
}

#content {
    flex: 1 !important;
}

/* ========================================
   2. 首页布局样式（无 body.np-active 前缀）
   ======================================== */

/* ---- 首页容器 ---- */

.np-home {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}

/* 通用段落标题 */
.np-home-section {
    margin-bottom: 28px;
}

.np-home-section__title {
    font-size: 20px;
    font-weight: 700;
    color: var(--np-text-primary);
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.np-home-section__title svg {
    fill: var(--np-primary);
    width: 20px;
    height: 20px;
}

.np-home-section__icon {
    display: inline-flex;
    align-items: center;
}

.np-home-section__icon svg {
    fill: var(--np-primary);
    width: 20px;
    height: 20px;
}

/* ---- 精选书籍横向滚动 ---- */

.np-home-hero {
    padding: 24px;
    overflow: hidden;
}

.np-home-books-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}

.np-home-book-card {
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s;
}

.np-home-book-card__cover {
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: var(--np-radius-md);
    overflow: hidden;
    box-shadow: var(--np-shadow-md);
    margin-bottom: 8px;
    background: var(--np-bg-soft);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.np-home-book-card__no-cover {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--np-primary), var(--np-primary-dark));
    color: #fff;
    font-size: 42px;
    font-weight: 700;
}

.np-home-book-card__no-cover--sm {
    font-size: 24px;
}

.np-home-book-card__name {
    font-size: 13px;
    font-weight: 500;
    color: var(--np-text-primary);
    line-height: 1.4;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---- 书架分类（标签切换） ---- */

.np-home-shelf-tabs {
    padding: 0;
    overflow: hidden;
}

.np-home-shelf-tabs__nav {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--np-border);
    overflow-x: auto;
    scrollbar-width: thin;
}

.np-home-shelf-tabs__tab {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--np-text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
}

.np-home-shelf-tabs__tab:hover {
    color: var(--np-primary);
}

.np-home-shelf-tabs__tab.is-active {
    color: var(--np-primary);
    border-bottom-color: var(--np-primary);
}

.np-home-shelf-tabs__body {
    position: relative;
}

.np-home-shelf-tabs__panel {
    display: none;
    padding: 20px 24px;
    gap: 24px;
}

.np-home-shelf-tabs__panel.is-active {
    display: flex;
}

/* 左侧：封面 + 简介 */
.np-home-shelf-tabs__info {
    flex: 0 0 220px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.np-home-shelf-tabs__cover {
    width: 220px;
    height: 140px;
    border-radius: var(--np-radius-md);
    overflow: hidden;
    background: var(--np-bg-soft);
}

.np-home-shelf-tabs__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.np-home-shelf-tabs__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--np-primary-light), var(--np-primary));
    color: rgba(255,255,255,0.7);
}

.np-home-shelf-tabs__placeholder svg {
    width: 48px;
    height: 48px;
    fill: rgba(255,255,255,0.7);
}

.np-home-shelf-tabs__meta {
    flex: 1;
}

.np-home-shelf-tabs__name {
    font-size: 17px;
    font-weight: 600;
    margin: 0 0 6px 0;
}

.np-home-shelf-tabs__name a {
    color: var(--np-text-primary);
    text-decoration: none;
}

.np-home-shelf-tabs__name a:hover {
    color: var(--np-primary);
}

.np-home-shelf-tabs__desc {
    font-size: 13px;
    line-height: 1.6;
    margin: 0;
}

/* 右侧：书籍文字列表 */
.np-home-shelf-tabs__books {
    flex: 1;
    min-width: 0;
}

.np-home-shelf-tabs__list {
    display: flex;
    flex-direction: column;
}

.np-home-shelf-tabs__item {
    display: grid;
    grid-template-columns: 130px 1fr auto;
    gap: 6px;
    padding: 5px 0;
    text-decoration: none !important;
    color: inherit !important;
    border-bottom: 1px dashed var(--np-border);
    transition: background-color 0.15s;
    align-items: baseline;
}

.np-home-shelf-tabs__item:last-child {
    border-bottom: none;
}

.np-home-shelf-tabs__item:hover {
    background-color: var(--np-bg-hover);
}

.np-home-shelf-tabs__item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--np-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.np-home-shelf-tabs__item-name svg {
    width: 16px;
    height: 16px;
    fill: var(--np-primary);
    flex-shrink: 0;
}

.np-home-shelf-tabs__item:hover .np-home-shelf-tabs__item-name {
    color: var(--np-primary);
}

.np-home-shelf-tabs__item-excerpt {
    font-size: 13px;
    line-height: 1.5;
    color: var(--np-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.np-home-shelf-tabs__item-stats {
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
    color: var(--np-text-muted);
}

.np-home-shelf-tabs__empty {
    padding: 40px 0;
    text-align: center;
    width: 100%;
    font-size: 14px;
}

/* ---- 底部双栏：最近更新 + 动态 ---- */

.np-home-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 32px;
    align-items: stretch;
}

.np-home-bottom .card {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
}

.np-home-recent__list {
    display: flex;
    flex-direction: column;
}

.np-home-recent__item {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--np-border);
    transition: background-color 0.15s;
}

.np-home-recent__item:last-child {
    border-bottom: none;
}

.np-home-recent__item:hover {
    background-color: var(--np-bg-hover);
    margin: 0 -8px;
    padding-left: 8px;
    padding-right: 8px;
    border-radius: var(--np-radius-sm);
}

.np-home-recent__icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
}

.np-home-recent__icon svg {
    width: 14px;
    height: 14px;
    fill: var(--np-primary);
}

.np-home-recent__time {
    flex: 0 0 62px;
    font-size: 12px;
    color: var(--np-text-muted);
    font-variant-numeric: tabular-nums;
    font-family: var(--np-font-code);
}

.np-home-recent__name {
    font-size: 14px;
    color: var(--np-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 书籍名称链接 - 主题色 */
.np-home-recent__name a.np-home-recent__book {
    color: var(--np-primary);
    font-size: 12px;
    flex-shrink: 0;
    text-decoration: none;
}

.np-home-recent__name a.np-home-recent__book:hover {
    text-decoration: underline;
}

/* 分隔符 */
.np-home-recent__sep {
    color: var(--np-text-light);
    margin: 0 4px;
}

/* 页面标题链接 - 正文色，hover 时变主题色 */
.np-home-recent__name > a:not(.np-home-recent__book) {
    color: var(--np-text-primary);
    text-decoration: none;
}

.np-home-recent__name > a:not(.np-home-recent__book):hover {
    color: var(--np-primary);
    text-decoration: underline;
}

/* ---- 动态列表 ---- */

.np-home-activity .activity-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--np-border);
}

.np-home-activity .activity-list-item:last-child {
    border-bottom: none;
}

.np-home-activity .activity-list-item > div:first-child {
    flex: 0 0 auto;
}

.np-home-activity .activity-list-item .avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
}

.np-home-activity .activity-list-item > div:last-child {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.np-home-activity .activity-list-item > div:last-child br {
    display: none;
}

.np-home-activity .activity-list-item > div:last-child .text-muted {
    margin-left: 6px;
    font-size: 12px;
}

.np-home-activity .activity-list-item > div:last-child .text-muted svg {
    width: 12px;
    height: 12px;
    vertical-align: -1px;
    fill: var(--np-text-muted);
}

/* ---- "查看全部" 链接 ---- */

.np-home .card-footer-link {
    display: block;
    text-align: center;
    padding: 10px 0 4px;
    font-size: 13px;
    color: var(--np-primary);
    text-decoration: none;
    border-top: 1px solid var(--np-border);
    margin-top: auto;
}

.np-home .card-footer-link:hover {
    text-decoration: underline;
}

/* ---- 响应式 ---- */

@media (max-width: 700px) {
    .np-home-shelf-tabs__panel {
        flex-direction: column;
    }
    .np-home-shelf-tabs__info {
        flex: none;
        flex-direction: row;
        align-items: flex-start;
    }
    .np-home-shelf-tabs__cover {
        width: 100px;
        height: 100px;
        flex-shrink: 0;
    }
    .np-home-shelf-tabs__item {
        grid-template-columns: 1fr;
        gap: 2px;
    }
}

@media (max-width: 880px) {
    .np-home-bottom {
        grid-template-columns: 1fr;
    }
    .np-home-books-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ========================================
   页脚增强 - 默认主题下的页脚样式
   ======================================== */

footer {
    padding: 1.5rem 1rem 2rem;
    text-align: center;
}

.np-footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.np-footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 16px;
}

.np-footer-links a {
    font-size: 13px;
    color: #666;
    text-decoration: none;
    transition: color 0.2s;
}

.np-footer-links a:hover {
    color: var(--color-primary, #1f5fad);
}

.np-footer-copyright {
    font-size: 12px;
    color: #999;
    line-height: 1.5;
}

.np-footer-copyright a {
    color: #666;
    text-decoration: none;
}

.np-footer-copyright a:hover {
    color: var(--color-primary, #1f5fad);
}

.np-footer-powered {
    font-size: 12px;
    color: #999;
}

.np-footer-powered a {
    color: #666;
    text-decoration: none;
    font-weight: 500;
}

.np-footer-powered a:hover {
    color: var(--color-primary, #1f5fad);
}
