/* ============================================================
   古籍插件前台样式 (依赖于核心主题)
   ============================================================ */

.gj-page-wrap { box-sizing: border-box; margin-bottom: 40px; width: 100%; }
.gj-page-wrap * { box-sizing: border-box; }
.gj-page-wrap a { color: #2563eb; text-decoration: none; }
.gj-page-wrap a:hover { text-decoration: underline; }
.gj-page-wrap img { max-width: 100%; }

/* ---------- 面包屑 ---------- */
.gj-breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; font-size: 13px; color: #94a3b8; }
.gj-breadcrumb a { color: #64748b; padding: 2px 4px; border-radius: 4px; }
.gj-breadcrumb a:hover { color: #2563eb; text-decoration: none; background: #eff6ff; }
.gj-bc-sep { color: #cbd5e1; }
.gj-breadcrumb .gj-current { color: #1e293b; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }

/* ---------- 按钮与搜索通用 ---------- */
.gj-search { display: flex; gap: 8px; flex-wrap: wrap; }
.gj-search-wide { margin-bottom: 14px; }
.gj-search-input { flex: 1 1 240px; min-width: 0; padding: 10px 14px; border: 1px solid #e5e9f0; border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff; }
.gj-search-input:focus { outline: 0; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.gj-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; border-radius: 8px; border: 1px solid #e5e9f0; background: #fff; color: #1e293b !important; font-size: 14px; cursor: pointer; text-decoration: none !important; transition: all .15s; }
.gj-btn:hover { border-color: #2563eb; color: #2563eb !important; text-decoration: none !important; }
.gj-btn-primary { background: #1a4480; border-color: #1a4480; color: #fff !important; font-weight: 500; }
.gj-btn-primary:hover { background: #143566; border-color: #143566; color: #fff !important; }
.gj-btn-primary * { color: #fff !important; }
.gj-btn-block { display: flex; width: 100%; }
.gj-btn-disabled { opacity: .55; cursor: not-allowed; }
.gj-fav-btn { margin-top: 10px; }

/* ---------- 通用区 ---------- */
.gj-section { margin-bottom: 28px; }
.gj-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.gj-section-title { margin: 0 0 14px; font-size: 17px; font-weight: 700; color: #0f172a; }
.gj-section-head .gj-section-title { margin-bottom: 0; }
.gj-page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.gj-page-title { margin: 0; font-size: 22px; font-weight: 700; }
.gj-more { font-size: 13px; color: #2563eb; }
.gj-count { margin-bottom: 14px; font-size: 13px; color: #64748b; }
.gj-count strong { color: #2563eb; }

/* ---------- 分类标签 (用于列表页筛选) ---------- */
.gj-cats { display: flex; flex-wrap: wrap; gap: 10px; }
.gj-cat { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px; background: #fff; border: 1px solid #e5e9f0; color: #1e293b !important; font-size: 13.5px; transition: all .18s; }
.gj-cat:hover { border-color: #2563eb; color: #2563eb !important; background: #eff6ff; text-decoration: none !important; }
.gj-cat-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 18px; padding: 0 6px; border-radius: 999px; background: #eff6ff; color: #2563eb; font-size: 11px; font-weight: 600; }
.gj-cat:hover .gj-cat-count { background: #2563eb; color: #fff; }

/* ---------- 列表筛选 ---------- */
.gj-cat-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.gj-tag { display: inline-block; padding: 5px 14px; border-radius: 999px; background: #fff; border: 1px solid #e5e9f0; color: #64748b !important; font-size: 13px; }
.gj-tag:hover, .gj-tag.is-active { border-color: #2563eb; color: #2563eb !important; text-decoration: none !important; }

/* ============================================================
   ★ 列表卡片 (核心排版区域)
   ============================================================ */
.gj-grid { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.gj-card { 
    margin: 0; 
    /* ★ 浏览器性能优化：跳过屏幕外卡片的渲染计算，大幅提升首屏加载速度 */
    content-visibility: auto;
    contain-intrinsic-size: auto 146px; /* 预估高度，防止滚动条乱跳 */
}
.gj-card-link { 
    display: flex; 
    align-items: center; 
    gap: 20px; 
    padding: 18px 22px; 
    background: #fff; 
    border: 1px solid #e5e9f0; 
    border-radius: 14px; 
    color: inherit !important; 
    box-shadow: 0 1px 3px rgba(15,23,42,.04); 
    transition: all .2s; 
}
.gj-card-link:hover { 
    border-color: #bfdbfe; 
    box-shadow: 0 8px 24px rgba(37,99,235,.08); 
    transform: translateY(-2px); 
    text-decoration: none !important; 
}

/* 左侧图片：宽度填满容器，高度自适应，防止长图破坏整齐度 */
.gj-card-cover { 
    flex: 0 0 170px; 
    width: 170px; 
    background: #fff; 
    border: 1px solid #eef2f7;
    border-radius: 10px; 
    overflow: hidden; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}
.gj-card-cover img { 
    width: 100%; 
    height: auto; 
    max-height: 160px; 
    object-fit: cover; 
    object-position: top center; 
    display: block; 
}
.gj-card-cover-ph { color: #94a3b8; font-size: 13px; display: flex; align-items: center; justify-content: center; height: 100px; width: 100%;}

/* 右侧文本区 */
.gj-card-body { 
    flex: 1; 
    min-width: 0; 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
}

.gj-card-title { 
    margin: 0; 
    font-size: 16px; 
    font-weight: 600; 
    color: #0f172a; 
    display: -webkit-box; 
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical; 
    overflow: hidden; 
    line-height: 1.45; 
}
.gj-grid-lg .gj-card-title { font-size: 18px; font-weight: 700; }
.gj-card-link:hover .gj-card-title { color: #2563eb; }

.gj-card-meta { 
    display: flex; 
    flex-wrap: wrap; 
    align-items: center; 
    gap: 8px; 
    font-size: 12.5px; 
    color: #64748b; 
}
.gj-card-dynasty { color: #475569; font-weight: 500; }
.gj-card-dynasty::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #2563eb; opacity: .55; margin-right: 6px; }

.gj-card-summary { 
    margin: 0; 
    font-size: 13px; 
    line-height: 1.65; 
    color: #64748b; 
    display: -webkit-box; 
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical; 
    overflow: hidden; 
}
.gj-grid-lg .gj-card-summary { -webkit-line-clamp: 3; font-size: 13.5px; }

.gj-card-tags { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 6px; 
    margin-top: 2px; 
}
.gj-card-tags .gj-chip { 
    font-size: 11.5px; 
    padding: 3px 10px; 
}
.gj-chip { 
    display: inline-flex; 
    align-items: center; 
    padding: 2px 10px; 
    border-radius: 999px; 
    background: #eff6ff; 
    color: #2563eb; 
    font-size: 11.5px; 
    text-decoration: none !important; 
}
.gj-chip-soft { background: #f1f5f9; color: #64748b; }

/* ---------- 详情区 ---------- */
.gj-detail-main { padding: 22px 24px; background: #fff; border: 1px solid #e5e9f0; border-radius: 14px; margin-bottom: 16px; }
.gj-detail-title { margin: 0 0 10px; font-size: 24px; font-weight: 700; color: #0f172a; line-height: 1.35; }
.gj-detail-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: #64748b; margin-bottom: 10px; }
.gj-detail-meta em { font-style: normal; color: #94a3b8; }
.gj-detail-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 画廊 (单行滑动 + 左右导航) ---------- */
.gj-gallery {
    position: relative;
    background: #fff;
    border: 1px solid #e5e9f0;
    border-radius: 14px;
    margin-bottom: 16px;
    padding: 16px; 
    overflow: hidden;
}
.gj-gallery-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none; 
    -ms-overflow-style: none;
}
.gj-gallery-scroll::-webkit-scrollbar { display: none; }

.gj-gallery-item {
    flex: 0 0 auto;
    width: 200px; 
    aspect-ratio: 4 / 3;
    padding: 0;
    border: 1px solid #eef2f7;
    background: #f1f5f9;
    border-radius: 8px;
    overflow: hidden;
    cursor: zoom-in;
    transition: transform .2s, box-shadow .2s;
}
.gj-gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(37,99,235,.12);
}
.gj-gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

.gj-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.95);
    border: 1px solid #e5e9f0;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    color: #475569;
    font-size: 24px;
    line-height: 1;
    font-family: Arial, sans-serif;
    padding-bottom: 3px;
    transition: all .2s;
}
.gj-gallery-nav:hover {
    background: #fff;
    color: #2563eb;
    border-color: #bfdbfe;
    box-shadow: 0 6px 16px rgba(37,99,235,0.15);
}
.gj-gallery-nav.prev { left: 8px; }
.gj-gallery-nav.next { right: 8px; }
.gj-gallery-nav.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ---------- 左右栏 ---------- */
.gj-detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.gj-detail-left { min-width: 0; }
.gj-detail-right { min-width: 0; position: sticky; top: 20px; }
.gj-detail-block { margin-bottom: 20px; }
.gj-detail-right .gj-detail-block { background: #fff; border: 1px solid #e5e9f0; border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.gj-detail-right .gj-section-title { font-size: 15px; margin-bottom: 12px; }

/* 图书信息 */
.gj-book-info { margin: 0; padding: 0; }
.gj-book-info-item { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-bottom: 1px dashed #eef2f7; }
.gj-book-info-item:last-child { border-bottom: 0; }
.gj-book-info-key { margin: 0; font-weight: 600; color: #2563eb; font-size: 12.5px; }
.gj-book-info-val { margin: 0; font-size: 13px; color: #334155; word-break: break-word; line-height: 1.75; }
.gj-book-info-val p { margin: 0 0 4px; }
.gj-book-info-val p:last-child { margin-bottom: 0; }
.gj-book-info-val a { color: #2563eb; }

.gj-downloads { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.gj-downloads .gj-btn { font-size: 14px; padding: 10px 16px; }
.gj-detail-note { margin-top: 12px; padding: 9px 12px; border-radius: 8px; background: #f8fafc; border-left: 3px solid #2563eb; font-size: 12.5px; color: #64748b; line-height: 1.7; }

/* 正文内容 */
.gj-detail-content { padding: 22px 24px; background: #fff; border: 1px solid #e5e9f0; border-radius: 12px; font-size: 15px; line-height: 1.95; color: #334155; }
.gj-detail-content.gj-rich p { margin: 0 0 1em; }
.gj-detail-content.gj-rich p:last-child { margin-bottom: 0; }
.gj-detail-content.gj-rich h1, .gj-detail-content.gj-rich h2, .gj-detail-content.gj-rich h3 { margin: 1.2em 0 .6em; line-height: 1.4; color: #0f172a; }
.gj-detail-content.gj-rich a { color: #2563eb; }
.gj-detail-content.gj-rich img { max-width: 100%; height: auto; border-radius: 8px; display: block; margin: 1em auto; box-shadow: 0 2px 8px rgba(15,23,42,.06); }
.gj-detail-content.gj-rich blockquote { margin: 1em 0; padding: .4em 1em; border-left: 3px solid #2563eb; background: #f8fafc; color: #64748b; }
.gj-detail-content.gj-rich pre, .gj-detail-content.gj-rich code { background: #f1f5f9; border-radius: 4px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.gj-detail-content.gj-rich pre { padding: 12px 14px; overflow-x: auto; }
.gj-detail-content.gj-rich code { padding: 2px 6px; }
.gj-detail-content.gj-rich pre code { padding: 0; background: none; }
.gj-detail-content.gj-rich table { width: 100%; border-collapse: collapse; margin: 1em 0; }
.gj-detail-content.gj-rich th, .gj-detail-content.gj-rich td { border: 1px solid #e5e9f0; padding: 8px 10px; text-align: left; }
.gj-detail-content.gj-rich th { background: #f8fafc; }

.gj-empty { padding: 30px 0; text-align: center; color: #94a3b8; font-size: 14px; }

/* 分页 */
.gj-pager { margin-top: 24px; display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.gj-pager a, .gj-pager span { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 12px; border-radius: 8px; background: #fff; border: 1px solid #e5e9f0; color: #475569; font-size: 13.5px; text-decoration: none !important; }
.gj-pager a:hover { border-color: #2563eb; color: #2563eb; }
.gj-pager .current { background: #2563eb; border-color: #2563eb; color: #fff; }

/* 灯箱 */
.gj-lightbox { position: fixed; inset: 0; z-index: 99999; background: rgba(0, 0, 0, .92); display: flex; align-items: center; justify-content: center; padding: 60px 90px; animation: gjLbIn .2s ease-out; }
.gj-lightbox[hidden] { display: none; }
@keyframes gjLbIn { from { opacity: 0; } to { opacity: 1; } }
.gj-lb-inner { position: relative; max-width: 100%; max-height: 100%; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
#gjLbImg { max-width: 100%; max-height: 100%; object-fit: contain; display: block; border-radius: 4px; box-shadow: 0 20px 60px rgba(0, 0, 0, .55); }
.gj-lb-close, .gj-lb-prev, .gj-lb-next { position: fixed; z-index: 1; border: 0; background: rgba(255, 255, 255, .12); color: #fff; font-size: 24px; line-height: 1; cursor: pointer; border-radius: 50%; width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center; transition: background .2s; }
.gj-lb-close:hover, .gj-lb-prev:hover, .gj-lb-next:hover { background: rgba(255, 255, 255, .28); }
.gj-lb-close { top: 20px; right: 20px; font-size: 28px; }
.gj-lb-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.gj-lb-next { right: 20px; top: 50%; transform: translateY(-50%); }
.gj-lb-counter { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); color: #e2e8f0; font-size: 13px; background: rgba(0, 0, 0, .5); padding: 4px 14px; border-radius: 999px; }

/* ============================================================
   ★ 首页三栏布局
   ============================================================ */
.gj-index-wrap > .layout { padding: 0; }

/* 左栏卡片基础样式 */
.gj-index-left .gj-side-card {
    background: #fff;
    border: 1px solid #eef2f7;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.03);
    transition: transform 0.2s, box-shadow 0.2s;
}
.gj-index-left .gj-side-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}
.gj-index-left .gj-side-card:last-child { margin-bottom: 0; }

/* 仅针对搜索卡片：减小内边距以配合内嵌按钮 */
.gj-index-left .gj-side-card.gj-side-search-card {
    padding: 12px 14px;
}

/* 左栏：单行内嵌搜索框 */
.gj-side-search {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    margin: 0;
}
.gj-side-search-input {
    width: 100%;
    padding: 9px 42px 9px 14px; /* 右侧留出按钮空间 */
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 13.5px;
    font-family: inherit;
    background: #f8fafc;
    color: #1e293b;
    box-sizing: border-box;
    transition: all .2s;
    margin: 0;
}
.gj-side-search-input:focus {
    outline: 0;
    background: #fff;
    border-color: #bfdbfe;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
/* 内嵌小按钮 */
.gj-side-search-btn {
    position: absolute;
    right: 5px;
    top: 5px;
    bottom: 5px;
    width: 30px;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s;
    padding: 0;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}
.gj-side-search-btn:hover {
    background: #1d4ed8;
}
.gj-side-search-btn svg {
    width: 15px;
    height: 15px;
    display: block;
}

/* 左栏标题样式 */
.gj-side-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.4;
}
.gj-side-title::before {
    content: '';
    width: 4px;
    height: 16px;
    background: linear-gradient(180deg, #2563eb, #7c3aed);
    border-radius: 2px;
    flex-shrink: 0;
}

/* 左栏分类列表 */
.gj-side-cats {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.gj-side-cat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 10px;
    color: #475569 !important;
    font-size: 13.5px;
    text-decoration: none !important;
    transition: all .15s;
    line-height: 1.4;
}
.gj-side-cat:hover {
    background: #f0f7ff;
    color: #2563eb !important;
    text-decoration: none !important;
}
.gj-side-cat-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.gj-side-cat-name::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #cbd5e1;
    flex-shrink: 0;
    transition: background .15s;
}
.gj-side-cat:hover .gj-side-cat-name::before {
    background: #2563eb;
}
.gj-side-cat-count {
    flex-shrink: 0;
    font-size: 12px;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 2px 9px;
    border-radius: 12px;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
    transition: background .15s, color .15s;
}
.gj-side-cat:hover .gj-side-cat-count {
    background: #dbeafe;
    color: #2563eb;
    font-weight: 600;
}

/* 主题原生小工具兼容处理 */
.gj-index-left .gj-native-widgets .widget {
    border-radius: 16px;
    border: 1px solid #eef2f7;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.03);
    margin-bottom: 16px;
}
.gj-index-left .gj-native-widgets .widget:last-child { margin-bottom: 0; }

/* 窄屏筛选条 */
.gj-mobile-filter {
    display: none;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e5e9f0;
    border-radius: 12px;
}
.gj-mobile-filter .gj-search { width: 100%; }
.gj-mobile-filter .gj-cat-filter { margin-bottom: 0; }
.gj-mobile-filter .gj-search-input { padding: 8px 12px; font-size: 13.5px; }
.gj-mobile-filter .gj-btn { padding: 8px 16px; font-size: 13.5px; }

/* 响应式 */
@media (max-width: 1100px) {
    .gj-index-wrap .gj-index-left { display: none !important; }
    .gj-mobile-filter { display: flex; }
}
@media (max-width: 900px) {
    .gj-detail-grid { grid-template-columns: 1fr; }
    .gj-detail-right { position: static; order: 2; }
    .gj-detail-left { order: 1; }
    .gj-gallery-item { width: 160px; }
}
@media (max-width: 640px) {
    .gj-card-link { gap: 14px; padding: 14px; }
    .gj-card-cover { flex: 0 0 130px; width: 130px; }
    .gj-card-cover img { max-height: 130px; }
    .gj-detail-main { padding: 18px; }
    .gj-detail-title { font-size: 19px; }
    .gj-gallery-item { width: 130px; }
    .gj-gallery-nav { width: 30px; height: 30px; font-size: 20px; }
    .gj-gallery-nav.prev { left: 4px; }
    .gj-gallery-nav.next { right: 4px; }
    .gj-lightbox { padding: 56px 12px; }
    .gj-lb-close { top: 12px; right: 12px; width: 40px; height: 40px; }
    .gj-lb-prev { left: 6px; width: 38px; height: 38px; }
    .gj-lb-next { right: 6px; width: 38px; height: 38px; }
}