/* =====================================================
 * v2.2 扩展功能样式
 * ===================================================== */

/* -----------------------------------------------------
 * 1. 暗/亮主题切换
 * ----------------------------------------------------- */
.theme-toggle {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0073f5, #9900f5);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 20px rgba(0, 115, 245, 0.4);
    transition: all 0.3s;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(0, 115, 245, 0.5);
}

/* 亮色主题 */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
}

[data-theme="light"] body {
    background: var(--bg-primary);
    color: var(--text-primary);
}

[data-theme="light"] .glass-card,
[data-theme="light"] .glass-nav {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--border-color);
}

[data-theme="light"] .post-content,
[data-theme="light"] .post-title,
[data-theme="light"] h1, [data-theme="light"] h2, [data-theme="light"] h3 {
    color: var(--text-primary);
}

[data-theme="light"] p, [data-theme="light"] li {
    color: var(--text-secondary);
}

[data-theme="light"] .hero-section {
    background: linear-gradient(135deg, #f0f4ff 0%, #f5f0ff 100%);
}

[data-theme="light"] #bg-canvas {
    opacity: 0.3;
}

/* -----------------------------------------------------
 * 2. 代码复制按钮
 * ----------------------------------------------------- */
.code-block-wrapper {
    position: relative;
}

.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s;
}

.code-block-wrapper:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:hover {
    background: rgba(0, 115, 245, 0.3);
    color: #fff;
}

.code-copy-btn.copied {
    background: rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

/* -----------------------------------------------------
 * 3. 图片灯箱
 * ----------------------------------------------------- */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.3s;
}

.lightbox-close:hover {
    color: #fff;
    transform: scale(1.1);
}

.lightbox-caption {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    max-width: 80%;
    text-align: center;
}

/* -----------------------------------------------------
 * 4. 文章点赞
 * ----------------------------------------------------- */
.like-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.like-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

.like-btn.liked {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ef4444;
}

.like-btn i {
    transition: transform 0.3s;
}

.like-btn.liked i {
    animation: likeHeart 0.5s ease;
}

@keyframes likeHeart {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* -----------------------------------------------------
 * 5. 快捷键帮助
 * ----------------------------------------------------- */
.keyboard-help-btn {
    position: fixed;
    bottom: 156px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
    font-size: 18px;
    cursor: pointer;
    z-index: 999;
    transition: all 0.3s;
}

.keyboard-help-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.keyboard-help-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.keyboard-help-modal.active {
    opacity: 1;
    visibility: visible;
}

.keyboard-help-content {
    background: #1a1a1a;
    padding: 32px 40px;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
}

.keyboard-help-content h3 {
    font-size: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.keyboard-help-content table {
    width: 100%;
    border-collapse: collapse;
}

.keyboard-help-content td {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.keyboard-help-content td:first-child {
    width: 120px;
}

.keyboard-help-content kbd {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(0, 115, 245, 0.2);
    border: 1px solid rgba(0, 115, 245, 0.3);
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    color: #0073f5;
}

/* -----------------------------------------------------
 * 6. 目录悬浮
 * ----------------------------------------------------- */
.sidebar-widget.sticky {
    position: fixed;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar-widget.sticky::-webkit-scrollbar {
    width: 4px;
}

.sidebar-widget.sticky::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* -----------------------------------------------------
 * 7. 图片占位
 * ----------------------------------------------------- */
.img-placeholder {
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    transition: opacity 0.3s;
}

.img-placeholder.loaded {
    opacity: 0;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* -----------------------------------------------------
 * 8. 阅读模式
 * ----------------------------------------------------- */
.reading-mode-btn {
    position: fixed;
    bottom: 52px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
    font-size: 18px;
    cursor: pointer;
    z-index: 999;
    transition: all 0.3s;
}

.reading-mode-btn:hover {
    background: rgba(0, 115, 245, 0.3);
    color: #fff;
}

body.reading-mode {
    background: #0a0a0a !important;
}

body.reading-mode .glass-nav,
body.reading-mode .post-sidebar,
body.reading-mode .site-footer,
body.reading-mode .related-posts,
body.reading-mode .share-buttons,
body.reading-mode #bg-canvas {
    display: none !important;
}

body.reading-mode .post-content-card {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 60px;
    background: #111;
    border-radius: 16px;
}

body.reading-mode .post-hero {
    padding: 100px 0 40px;
}

/* -----------------------------------------------------
 * 9. 自定义 CSS/JS 后台配置输出的样式
 * ----------------------------------------------------- */
.custom-social-links {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.custom-social-links a {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    transition: all 0.3s;
}

.custom-social-links a:hover {
    background: linear-gradient(135deg, #0073f5, #9900f5);
    color: #fff;
    transform: translateY(-3px);
}

/* -----------------------------------------------------
 * 10. 响应式
 * ----------------------------------------------------- */
@media (max-width: 768px) {
    .theme-toggle,
    .keyboard-help-btn,
    .reading-mode-btn {
        width: 40px;
        height: 40px;
        right: 16px;
        font-size: 16px;
    }
    
    .theme-toggle { bottom: 80px; }
    .keyboard-help-btn { bottom: 130px; }
    .reading-mode-btn { bottom: 32px; }
    
    .keyboard-help-content {
        padding: 24px;
    }
    
    body.reading-mode .post-content-card {
        padding: 24px;
    }
}
