/**
 * 全局导航样式
 * Global Navigation Styles for 《绛唇解语花》
 *
 * 包含：浮动按钮、导航菜单、面包屑、快捷键面板
 */

/* ========================================
   CSS 变量定义
   ======================================== */
:root {
    --nav-primary: #B76E79;
    --nav-secondary: #D4A5A5;
    --nav-bg: #FFFFFF;
    --nav-shadow: 0 4px 20px rgba(183, 110, 121, 0.15);
    --nav-radius: 16px;
    --nav-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   浮动导航按钮
   Floating Navigation Button
   ======================================== */
.floating-nav-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--nav-primary), var(--nav-secondary));
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(183, 110, 121, 0.3);
    z-index: 999;
    transition: var(--nav-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.floating-nav-button:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 24px rgba(183, 110, 121, 0.4);
}

.floating-nav-button:active {
    transform: scale(0.95) rotate(90deg);
}

/* 脉冲动画 */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(183, 110, 121, 0.3);
    }
    50% {
        box-shadow: 0 4px 16px rgba(183, 110, 121, 0.6), 0 0 0 10px rgba(183, 110, 121, 0.1);
    }
}

.floating-nav-button.pulse {
    animation: pulse 2s infinite;
}

/* ========================================
   导航菜单
   Navigation Menu
   ======================================== */
.navigation-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 380px;
    max-width: 90vw;
    height: 100vh;
    background: var(--nav-bg);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.navigation-menu.active {
    right: 0;
}

/* 菜单头部 */
.nav-menu-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--nav-primary), var(--nav-secondary));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav-menu-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.nav-close-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: var(--nav-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-close-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* 搜索框 */
.nav-menu-search {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.nav-menu-search input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: var(--nav-transition);
    background: white;
}

.nav-menu-search input:focus {
    outline: none;
    border-color: var(--nav-primary);
    box-shadow: 0 0 0 3px rgba(183, 110, 121, 0.1);
}

/* 菜单内容 */
.nav-menu-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-menu-content::-webkit-scrollbar {
    width: 6px;
}

.nav-menu-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.nav-menu-content::-webkit-scrollbar-thumb {
    background: var(--nav-secondary);
    border-radius: 3px;
}

.nav-menu-content::-webkit-scrollbar-thumb:hover {
    background: var(--nav-primary);
}

/* 导航分组 */
.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    padding: 0.5rem 1.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--nav-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    background: #f9f9f9;
}

/* 章节列表 */
.nav-chapter-list,
.nav-tool-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-chapter-item,
.nav-tool-item {
    transition: var(--nav-transition);
}

.nav-chapter-link,
.nav-tool-link {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.9rem 1.5rem;
    color: #333;
    text-decoration: none;
    transition: var(--nav-transition);
    border-left: 3px solid transparent;
}

.nav-chapter-link:hover,
.nav-tool-link:hover {
    background: #f5f5f5;
    border-left-color: var(--nav-primary);
    padding-left: 2rem;
}

.nav-chapter-icon,
.nav-tool-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.nav-chapter-number {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    background: var(--nav-secondary);
    color: white;
    border-radius: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.nav-chapter-title,
.nav-tool-title {
    flex: 1;
    font-size: 0.95rem;
}

/* 当前章节高亮 */
.nav-chapter-item.current .nav-chapter-link {
    background: linear-gradient(90deg, rgba(183, 110, 121, 0.1), transparent);
    border-left-color: var(--nav-primary);
    font-weight: 600;
}

/* 快捷操作 */
.nav-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: 0 1.5rem;
}

.nav-action-btn {
    padding: 0.8rem 1.2rem;
    background: white;
    border: 2px solid var(--nav-secondary);
    color: var(--nav-primary);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--nav-transition);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-action-btn:hover {
    background: var(--nav-primary);
    color: white;
    border-color: var(--nav-primary);
    transform: translateX(4px);
}

/* 菜单底部 */
.nav-menu-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
    text-align: center;
    color: #666;
    font-size: 0.8rem;
}

/* ========================================
   面包屑导航
   Breadcrumb Navigation
   ======================================== */
.breadcrumb-nav {
    padding: 1rem 0;
    margin-bottom: 1.5rem;
}

.breadcrumb-list {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.breadcrumb-item {
    font-size: 0.9rem;
}

.breadcrumb-link {
    color: var(--nav-primary);
    text-decoration: none;
    transition: var(--nav-transition);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
}

.breadcrumb-link:hover {
    background: rgba(139, 69, 19, 0.1);
    text-decoration: underline;
}

.breadcrumb-separator {
    color: #999;
    user-select: none;
}

.breadcrumb-current {
    color: #666;
    font-weight: 600;
}

.breadcrumb-category {
    color: #888;
    font-size: 0.85rem;
}

/* ========================================
   快捷键帮助面板
   Keyboard Shortcuts Panel
   ======================================== */
.shortcuts-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.shortcuts-content {
    background: white;
    border-radius: var(--nav-radius);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.shortcuts-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--nav-primary), var(--nav-secondary));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shortcuts-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.shortcuts-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: var(--nav-transition);
}

.shortcuts-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.shortcuts-body {
    padding: 2rem;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

.shortcut-group {
    margin-bottom: 2rem;
}

.shortcut-group:last-child {
    margin-bottom: 0;
}

.shortcut-group h4 {
    color: var(--nav-primary);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e0e0e0;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    background: #f9f9f9;
    border-radius: 8px;
    transition: var(--nav-transition);
}

.shortcut-item:hover {
    background: #f0f0f0;
}

.shortcut-item kbd {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background: white;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--nav-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 40px;
    text-align: center;
}

.shortcut-item span {
    flex: 1;
    color: #333;
}

/* ========================================
   响应式设计
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .floating-nav-button {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .navigation-menu {
        width: 100%;
        max-width: 100%;
    }

    .breadcrumb-nav {
        padding: 0.8rem 0;
    }

    .breadcrumb-list {
        font-size: 0.85rem;
    }

    .shortcuts-content {
        width: 95%;
        max-height: 90vh;
    }

    .shortcuts-body {
        padding: 1.5rem 1rem;
    }

    .shortcut-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* ========================================
   打印样式
   Print Styles
   ======================================== */
@media print {
    .floating-nav-button,
    .navigation-menu,
    .shortcuts-panel {
        display: none !important;
    }

    .breadcrumb-nav {
        display: none;
    }
}

/* ========================================
   无障碍增强
   Accessibility Enhancements
   ======================================== */
.nav-chapter-link:focus,
.nav-tool-link:focus,
.nav-action-btn:focus,
.breadcrumb-link:focus {
    outline: 3px solid var(--nav-primary);
    outline-offset: 2px;
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    .floating-nav-button {
        border: 2px solid white;
    }

    .nav-chapter-link,
    .nav-tool-link {
        border-bottom: 1px solid #e0e0e0;
    }
}

/* 减少动画模式 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   章节目录导航 - 滑出式面板
   Chapter TOC Navigation - Slide Panel
   ======================================== */

/* 目录触发按钮 */
.toc-trigger {
    position: fixed;
    bottom: 90px;
    left: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--nav-primary);
    transition: var(--nav-transition);
    z-index: 100;
}

.toc-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(183, 110, 121, 0.25);
}

.toc-trigger:active {
    transform: scale(0.95);
}

.toc-trigger svg {
    width: 22px;
    height: 22px;
}

/* 按钮上的进度环 */
.toc-trigger-progress {
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: conic-gradient(
        var(--nav-primary) var(--progress, 0%),
        transparent var(--progress, 0%)
    );
    opacity: 0.2;
    pointer-events: none;
}

@media (max-width: 768px) {
    .toc-trigger {
        bottom: 150px;
        left: 16px;
        width: 44px;
        height: 44px;
    }
}

/* 目录面板遮罩 */
.toc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.toc-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 目录面板 */
.toc-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: white;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.toc-panel.active {
    transform: translateX(0);
}

/* 面板头部 */
.toc-panel-header {
    padding: 1.5rem;
    border-bottom: 1px solid #F5E6E8;
    background: linear-gradient(180deg, #FDF8F8 0%, white 100%);
}

.toc-panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toc-panel-title h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--nav-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc-panel-title h3 svg {
    width: 20px;
    height: 20px;
}

.toc-panel-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #F5E6E8;
    border-radius: 50%;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 1.25rem;
}

.toc-panel-close:hover {
    background: var(--nav-secondary);
    color: white;
}

/* 章节信息 */
.toc-chapter-info {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 8px;
    border: 1px solid #F5E6E8;
}

.toc-chapter-info .chapter-number {
    font-size: 0.75rem;
    color: var(--nav-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toc-chapter-info .chapter-name {
    font-size: 1rem;
    font-weight: 600;
    color: #2D2D2D;
    margin-top: 0.25rem;
}

/* 阅读进度条 */
.toc-progress-bar {
    margin-top: 0.75rem;
    height: 4px;
    background: #F5E6E8;
    border-radius: 2px;
    overflow: hidden;
}

.toc-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--nav-primary), var(--nav-secondary));
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* 面板内容区域 */
.toc-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

/* 目录列表 */
.toc-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-nav-item {
    position: relative;
}

.toc-nav-item a {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: #666;
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.toc-nav-item a:hover {
    background: #FDF8F8;
    color: var(--nav-primary);
}

/* 当前位置高亮 */
.toc-nav-item.active a {
    background: linear-gradient(90deg, #FDF8F8 0%, white 100%);
    color: var(--nav-primary);
    border-left-color: var(--nav-primary);
    font-weight: 500;
}

/* 层级样式 */
.toc-nav-item[data-level="1"] a {
    font-weight: 600;
    font-size: 1rem;
}

.toc-nav-item[data-level="2"] a {
    padding-left: 2.5rem;
    font-size: 0.9375rem;
}

.toc-nav-item[data-level="3"] a {
    padding-left: 3.5rem;
    font-size: 0.875rem;
    color: #888;
}

/* 序号标记 */
.toc-nav-number {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background: #F5E6E8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--nav-primary);
}

.toc-nav-item.active .toc-nav-number {
    background: var(--nav-primary);
    color: white;
}

.toc-nav-item[data-level="2"] .toc-nav-number,
.toc-nav-item[data-level="3"] .toc-nav-number {
    width: 8px;
    height: 8px;
    background: var(--nav-secondary);
    opacity: 0.5;
}

.toc-nav-item[data-level="2"].active .toc-nav-number,
.toc-nav-item[data-level="3"].active .toc-nav-number {
    background: var(--nav-primary);
    opacity: 1;
}

/* 标题文字 */
.toc-nav-text {
    flex: 1;
    line-height: 1.4;
}

/* 面板底部 */
.toc-panel-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #F5E6E8;
    background: #FFFAF5;
}

.toc-nav-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.toc-nav-btn {
    padding: 0.625rem 1rem;
    border: 1px solid var(--nav-secondary);
    background: white;
    color: var(--nav-primary);
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.toc-nav-btn:hover:not(:disabled) {
    background: var(--nav-primary);
    color: white;
    border-color: var(--nav-primary);
}

.toc-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toc-nav-btn svg {
    width: 16px;
    height: 16px;
}

/* 快捷键提示 */
.toc-shortcuts {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed #F5E6E8;
    font-size: 0.75rem;
    color: #888;
    text-align: center;
}

.toc-shortcuts kbd {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    background: white;
    border: 1px solid #F5E6E8;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.6875rem;
    margin: 0 0.125rem;
}

/* 滚动条美化 */
.toc-panel-content::-webkit-scrollbar {
    width: 6px;
}

.toc-panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.toc-panel-content::-webkit-scrollbar-thumb {
    background: var(--nav-secondary);
    border-radius: 3px;
}

.toc-panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--nav-primary);
}

/* 隐藏原有的内联目录 */
.toc-container {
    display: none !important;
}

/* 打印时隐藏 */
@media print {
    .toc-trigger,
    .toc-overlay,
    .toc-panel {
        display: none !important;
    }
}
