﻿/* ════════════════════════════════════════════════════════════
   百科系统样式 — 高亮词条 + 浮窗 + 主页 + 详情页
   2026-07-16 新增：Bishoujo 百科系统
   ════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────
   1. 高亮词条（全站通用）
   ───────────────────────────────────────────── */

.pedia-term {
    /* 2026-07-16 修复：不改变原有文字颜色，仅用下划线标识百科词条 */
    border-bottom: 1px dashed var(--gold-dark);
    cursor: help;
    transition: background-color 0.2s, border-color 0.2s;
    padding: 0 1px;
    border-radius: 2px;
}

.pedia-term:hover,
.pedia-term:focus-visible {
    background: rgba(212, 175, 55, 0.12);
    border-bottom-color: var(--gold-light);
    outline: none;
}

/* 浮窗内的相关术语链接（嵌套悬浮） */
.pedia-tooltip-term-link {
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 2px 8px;
    font-size: 12px;
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    color: var(--text-gold);
    cursor: pointer;
    transition: background 0.2s;
}

.pedia-tooltip-term-link:hover {
    background: rgba(212, 175, 55, 0.25);
}

/* ─────────────────────────────────────────────
   2. 浮窗（CK3 风格）
   ───────────────────────────────────────────── */

.pedia-tooltip {
    position: absolute;
    z-index: 10000;
    min-width: 280px;
    max-width: 380px;
    padding: 0;
    background: linear-gradient(180deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    border: 1px solid var(--border-gold);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(212, 175, 55, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    font-family: "Noto Sans SC", sans-serif;
}

.pedia-tooltip-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.pedia-tooltip-title {
    padding: 10px 14px 6px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-gold);
    border-bottom: 1px solid var(--border-subtle);
}

.pedia-tooltip-category {
    padding: 4px 14px 8px;
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pedia-tooltip-summary {
    padding: 8px 14px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.pedia-tooltip-formula {
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-primary);
    border-top: 1px solid var(--border-subtle);
}

.pedia-tooltip-formula code {
    display: inline-block;
    margin-top: 4px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    font-family: "Consolas", "Monaco", monospace;
    font-size: 11px;
    color: var(--gold-light);
    word-break: break-all;
}

.pedia-tooltip-related {
    padding: 8px 14px;
    border-top: 1px solid var(--border-subtle);
}

.pedia-tooltip-related-label {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.pedia-tooltip-detail-link {
    display: block;
    padding: 8px 14px;
    text-align: right;
    font-size: 12px;
    color: var(--text-gold);
    text-decoration: none;
    border-top: 1px solid var(--border-subtle);
    transition: background 0.2s;
}

.pedia-tooltip-detail-link:hover {
    background: rgba(212, 175, 55, 0.1);
    color: var(--gold-light);
}

/* 嵌套层级视觉区分（第1层、第2层、第3层） */
.pedia-tooltip[data-nesting-level="1"] {
    border-color: var(--border-medium);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

.pedia-tooltip[data-nesting-level="2"] {
    border-color: var(--border-subtle);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    max-width: 320px;
}

/* ─────────────────────────────────────────────
   3. 百科主页
   ───────────────────────────────────────────── */

.pedia-page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 48px;
    animation: pediaPageEnter 0.4s ease;
}

@keyframes pediaPageEnter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.pedia-page-header {
    text-align: center;
    margin-bottom: 24px;
}

.pedia-page-header h1 {
    font-size: 32px;
    font-weight: 900;
    color: var(--text-gold);
    margin: 0 0 8px;
    font-family: "Noto Serif SC", serif;
    letter-spacing: 2px;
}

.pedia-page-subtitle {
    font-size: 14px;
    color: var(--text-tertiary);
    margin: 0;
}

.pedia-page-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.pedia-search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s;
}

.pedia-search-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

.pedia-search-input::placeholder {
    color: var(--text-tertiary);
}

.pedia-category-select {
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.pedia-category-select:focus {
    outline: none;
    border-color: var(--gold);
}

.pedia-page-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 分类分组 */
.pedia-category-group {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.pedia-category-group:hover {
    border-color: var(--border-medium);
}

.pedia-category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.pedia-category-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.pedia-category-icon {
    font-size: 18px;
}

.pedia-category-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.pedia-category-count {
    padding: 2px 10px;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-gold);
    font-weight: 600;
}

.pedia-category-toggle {
    color: var(--text-tertiary);
    font-size: 12px;
    transition: transform 0.2s;
}

/* 术语卡片网格 */
.pedia-term-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    padding: 0 18px 18px;
}

.pedia-term-card {
    padding: 14px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pedia-term-card:hover,
.pedia-term-card:focus-visible {
    background: rgba(212, 175, 55, 0.08);
    border-color: var(--border-gold);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    outline: none;
}

.pedia-term-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-gold);
}

.pedia-term-card-summary {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    flex: 1;
}

.pedia-term-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.pedia-term-card-tag {
    padding: 1px 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-size: 10px;
    color: var(--text-tertiary);
}

.pedia-term-card-formula-badge {
    font-size: 10px;
    color: var(--text-gold);
    margin-top: 4px;
}

/* 空状态 */
.pedia-empty {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-tertiary);
}

.pedia-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.pedia-empty-hint {
    font-size: 12px;
    margin-top: 8px;
    color: var(--text-tertiary);
}

/* ─────────────────────────────────────────────
   4. 术语详情页
   ───────────────────────────────────────────── */

.pedia-detail-container {
    max-width: 880px;
    margin: 0 auto;
    padding: 16px 16px 48px;
    animation: pediaPageEnter 0.4s ease;
}

.pedia-detail-nav {
    margin-bottom: 16px;
}

.pedia-detail-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.pedia-detail-back-btn:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: var(--border-gold);
    color: var(--text-gold);
}

.pedia-detail-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.pedia-detail-title {
    font-size: 28px;
    font-weight: 900;
    color: var(--text-gold);
    margin: 0 0 10px;
    font-family: "Noto Serif SC", serif;
}

.pedia-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.pedia-detail-category-badge {
    padding: 3px 10px;
    background: rgba(212, 175, 55, 0.12);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-gold);
    font-weight: 600;
}

.pedia-detail-tag {
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-tertiary);
}

.pedia-detail-section {
    margin-bottom: 24px;
    padding: 16px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}

.pedia-detail-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-gold);
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.pedia-detail-summary {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

.pedia-detail-body {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.pedia-detail-body p {
    margin: 0 0 10px;
}

.pedia-detail-body p:last-child {
    margin-bottom: 0;
}

/* ─────────────────────────────────────────────
   详情页 Markdown 列表/表格样式（2026-07-16 新增）
   用于 renderPediaContent 渲染出的有序/无序列表与表格
   风格：金色标记 + 暗色背景，与百科页面整体一致
   ───────────────────────────────────────────── */

.pedia-detail-body .pedia-md-list,
.pedia-detail-body ul,
.pedia-detail-body ol {
    margin: 0 0 10px;
    padding-left: 22px;
}

.pedia-detail-body .pedia-md-list:last-child,
.pedia-detail-body ul:last-child,
.pedia-detail-body ol:last-child {
    margin-bottom: 0;
}

.pedia-detail-body .pedia-md-list li,
.pedia-detail-body ul li,
.pedia-detail-body ol li {
    margin-bottom: 6px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.pedia-detail-body .pedia-md-list li:last-child,
.pedia-detail-body ul li:last-child,
.pedia-detail-body ol li:last-child {
    margin-bottom: 0;
}

/* 有序列表数字使用金色 */
.pedia-detail-body ol {
    list-style: decimal;
}

.pedia-detail-body ol li::marker {
    color: var(--gold-light);
    font-weight: 700;
}

/* 无序列表标记使用金色 */
.pedia-detail-body ul {
    list-style: disc;
}

.pedia-detail-body ul li::marker {
    color: var(--gold-light);
}

/* Markdown 表格 */
.pedia-detail-body .pedia-md-table {
    width: 100%;
    margin: 0 0 10px;
    border-collapse: collapse;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    overflow: hidden;
}

.pedia-detail-body .pedia-md-table:last-child {
    margin-bottom: 0;
}

.pedia-detail-body .pedia-md-table th,
.pedia-detail-body .pedia-md-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    line-height: 1.5;
}

.pedia-detail-body .pedia-md-table th {
    background: rgba(212, 175, 55, 0.1);
    color: var(--text-gold);
    font-weight: 700;
    border-bottom: 1px solid var(--border-gold);
}

.pedia-detail-body .pedia-md-table tbody tr:last-child td {
    border-bottom: none;
}

.pedia-detail-body .pedia-md-table tbody tr:hover {
    background: rgba(212, 175, 55, 0.05);
}

/* 管理员专享区内表格微调（红色调，与 admin 区风格一致） */
.pedia-detail-admin-section .pedia-md-table th {
    background: rgba(255, 100, 100, 0.1);
    color: #ffb0b0;
    border-bottom-color: rgba(255, 100, 100, 0.3);
}

.pedia-detail-admin-section .pedia-md-table tbody tr:hover {
    background: rgba(255, 100, 100, 0.05);
}

.pedia-detail-formula {
    margin: 0;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    overflow-x: auto;
}

.pedia-detail-formula code {
    font-family: "Consolas", "Monaco", monospace;
    font-size: 13px;
    color: var(--gold-light);
    white-space: pre-wrap;
    word-break: break-all;
}

.pedia-detail-related-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.pedia-detail-related-item {
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.pedia-detail-related-item:hover,
.pedia-detail-related-item:focus-visible {
    background: rgba(212, 175, 55, 0.08);
    border-color: var(--border-gold);
    outline: none;
}

.pedia-detail-related-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-gold);
    margin-bottom: 4px;
}

.pedia-detail-related-summary {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 4px;
}

.pedia-detail-related-category {
    font-size: 10px;
    color: var(--text-tertiary);
}

.pedia-detail-code-refs {
    margin: 0;
    padding-left: 20px;
    list-style: none;
}

.pedia-detail-code-ref {
    font-family: "Consolas", "Monaco", monospace;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    border-left: 2px solid var(--border-gold);
}

.pedia-detail-code-ref::before {
    content: "? ";
    color: var(--text-gold);
}

/* 错误状态 */
.pedia-detail-error {
    text-align: center;
    padding: 64px 16px;
    color: var(--text-tertiary);
}

.pedia-detail-error-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.pedia-detail-error h2 {
    color: var(--text-primary);
    margin: 0 0 8px;
}

.pedia-detail-error p {
    color: var(--text-tertiary);
    margin: 0 0 16px;
}

/* ─────────────────────────────────────────────
   5. 移动端适配
   ───────────────────────────────────────────── */

@media (max-width: 768px) {
    .pedia-page-container,
    .pedia-detail-container {
        padding: 16px 12px 32px;
    }

    .pedia-page-header h1 {
        font-size: 24px;
    }

    .pedia-page-toolbar {
        flex-direction: column;
    }

    .pedia-search-input,
    .pedia-category-select {
        width: 100%;
    }

    .pedia-term-grid {
        grid-template-columns: 1fr;
        padding: 0 12px 12px;
    }

    .pedia-detail-title {
        font-size: 22px;
    }

    .pedia-detail-section {
        padding: 12px 14px;
    }

    .pedia-detail-related-list {
        grid-template-columns: 1fr;
    }

    /* 浮窗在移动端铺满宽度 */
    .pedia-tooltip {
        min-width: 240px;
        max-width: calc(100vw - 32px);
    }
}

/* ─────────────────────────────────────────────
   6. 圆圈进度条 Spinner（问题1：悬浮3秒触发机制）
   ───────────────────────────────────────────── */

.pedia-term-spinner {
    position: absolute;
    pointer-events: none;
    z-index: 10100;  /* 2026-07-16：高于 .pedia-tooltip(10000)，确保嵌套术语的 spinner 不被浮窗遮挡 */
    width: 16px;
    height: 16px;
    animation: pedia-spinner-fade-in 0.1s ease;
}

@keyframes pedia-spinner-fade-in {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* 2026-07-16 新增：禁止嵌套图标（自身嵌套时显示叉号） */
.pedia-term-forbidden {
    position: absolute;
    pointer-events: none;
    z-index: 10100;  /* 与 spinner 同层级，高于 .pedia-tooltip(10000) */
    width: 16px;
    height: 16px;
    animation: pedia-spinner-fade-in 0.1s ease;
}

.pedia-term-spinner svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* 进度圆环：延迟时间内从空到满（stroke-dashoffset 37.7 → 0）
   animation-duration 由 pedia.js 根据用户设置动态设置（默认1.5秒） */
.pedia-spinner-progress {
    animation: pedia-spinner-fill linear forwards;
    animation-duration: 1500ms; /* 默认值，JS 会覆盖 */
}

@keyframes pedia-spinner-fill {
    from { stroke-dashoffset: 37.7; }
    to { stroke-dashoffset: 0; }
}

/* ─────────────────────────────────────────────
   7. 管理员专享区域样式（权限重构：字段级权限，管理员内容单独分区）
   ───────────────────────────────────────────── */

/* 详情页管理员专享区域 */
.pedia-detail-admin-section {
    border: 1px solid rgba(220, 60, 60, 0.4) !important;
    background: linear-gradient(135deg, rgba(220, 60, 60, 0.04) 0%, var(--bg-card) 100%) !important;
    position: relative;
}

.pedia-detail-admin-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, rgba(220, 60, 60, 0.6) 0%, rgba(220, 60, 60, 0.2) 100%);
    border-radius: 10px 10px 0 0;
}

.pedia-detail-admin-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px dashed rgba(220, 60, 60, 0.3);
}

.pedia-detail-admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: linear-gradient(135deg, rgba(220, 60, 60, 0.15) 0%, rgba(180, 40, 40, 0.25) 100%);
    border: 1px solid rgba(220, 60, 60, 0.6);
    border-radius: 12px;
    font-size: 11px;
    color: #ff8888;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 0 8px rgba(220, 60, 60, 0.3);
}

.pedia-detail-subsection {
    margin-bottom: 16px;
}

.pedia-detail-subsection:last-child {
    margin-bottom: 0;
}

.pedia-detail-subsection .pedia-detail-section-title {
    color: #ff9999;
}

.pedia-detail-admin-section .pedia-detail-body {
    color: rgba(255, 200, 200, 0.9);
}

.pedia-detail-admin-section .pedia-detail-code-ref {
    border-left-color: rgba(220, 60, 60, 0.6);
    color: rgba(255, 200, 200, 0.85);
}

.pedia-detail-admin-section .pedia-detail-code-ref::before {
    color: #ff8888;
}
