/* ============================================
RemUp 样式系统 v4.0 - 智能注卡优化版
============================================ */

/* 基础变量定义 */
:root {
    /* 主色调 */
    --remup-primary: #3498db;
    --remup-secondary: #2ecc71;
    --remup-accent: #e74c3c;
    --remup-gray: #95a5a6;
    --remup-light-gray: #ecf0f1;
    
    /* 卡片颜色 */
    --card-bg: #ffffff;
    --card-shadow: rgba(0, 0, 0, 0.08);
    --card-border: #e0e0e0;
    
    /* 区域线颜色 */
    --region-line: #bdc3c7;
    --region-title: #7f8c8d;
    
    /* 字体 */
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Microsoft YaHei', sans-serif;
    --font-mono: 'Consolas', 'Monaco', 'Courier New', monospace;
    
    /* 阅读优化变量 */
    --font-size-base: 14px;
    --font-size-large: 1.3em;
    --font-size-small: 0.85em;
    --line-height-comfort: 1.5;
    --spacing-compact: 0.8rem;
    
    /* 新增注卡变量 */
    --popup-top: 0;
    --popup-left: 0;
}

/* 重置和基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    font-size: var(--font-size-base);
    line-height: var(--line-height-comfort);
    color: #2c3e50;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 15px;
    min-height: 100vh;
}

.container {
    max-width: none;
    width: 100%;
    margin: 0 auto;
    padding: 15px;
}

/* 页面标题样式 */
.page-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
}

.page-header h1 {
    color: var(--remup-primary);
    margin-bottom: 8px;
    font-size: 2em;
}

/* 主题选择器样式 */
.theme-selector-container {
    text-align: right;
    margin-bottom: 20px;
    padding: 10px;
}

.theme-selector-container label {
    margin-right: 10px;
    font-weight: 500;
    color: var(--remup-gray);
}

#themeSelector {
    padding: 5px 10px;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    background: white;
    color: #2c3e50;
}

/* 字体放大样式 */
.size-1-2 {
    font-size: 1.2em;
    display: inline-block;
    line-height: 1.3;
}

.size-1-5 {
    font-size: 1.5em;
    display: inline-block;
    line-height: 1.3;
    font-weight: 500;
}

.size-1-2, .size-1-5 {
    transition: font-size 0.2s ease;
}

/* ============================================
    主卡样式
============================================ */
.card {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 3px 15px var(--card-shadow);
    border: 1px solid var(--card-border);
    padding: 20px;
    margin-bottom: 25px;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    min-width: 0;
    font-size: var(--font-size-base);
}

.card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.card h2 {
    color: var(--remup-primary);
    border-bottom: 2px solid var(--remup-primary);
    padding-bottom: 8px;
    margin-bottom: 12px;
    font-size: 1.5em;
    position: relative;
    padding-left: 12px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
    display: flex;
    align-items: center;
}

.card h2::before {
    content: '<+';
    color: var(--remup-gray);
    font-family: var(--font-mono);
    font-size: 0.7em;
    margin-right: 6px;
    opacity: 0.7;
    flex-shrink: 0;
}

.card h2::after {
    content: '/+>';
    color: var(--remup-gray);
    font-family: var(--font-mono);
    font-size: 0.7em;
    margin-left: 6px;
    opacity: 0.7;
    flex-shrink: 0;
}

.card-title-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
    标签系统
============================================ */
.labels-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
    margin-bottom: 15px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    min-height: 32px;
    align-items: center;
}

.labels-container:empty {
    display: none;
}

.label {
    display: inline-flex;
    align-items: center;
    background: #f8f9fa;
    border-radius: 16px;
    padding: 6px 12px;
    text-decoration: none;
    color: #495057;
    font-size: 0.85em;
    transition: all 0.3s ease;
    max-width: 200px;
    overflow: hidden;
    border: 1px solid #dee2e6;
    position: relative;
    flex-shrink: 0;
    white-space: nowrap;
    line-height: 1;
}

.label:hover {
    background: #e9ecef;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    z-index: 3;
}

.label[href]:not(.label[href=""]) {
    border: 1.5px solid var(--remup-primary);
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
    cursor: pointer;
}

.label[href]:not(.label[href=""]):hover {
    background: linear-gradient(135deg, #e6f3ff 0%, #d4eaff 100%);
    box-shadow: 0 3px 8px rgba(52, 152, 219, 0.2);
}

.label[href]:not(.label[href=""])::after {
    content: '↗';
    margin-left: 4px;
    font-size: 0.9em;
    color: var(--remup-primary);
    opacity: 0.8;
    flex-shrink: 0;
}

.label-symbol {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--remup-primary);
    margin-right: 6px;
    font-size: 0.8em;
    font-weight: bold;
    color: var(--remup-primary);
    flex-shrink: 0;
}

.label-content {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* 标签类型颜色映射 */
.label.default .label-symbol {
    border-color: var(--remup-primary);
    color: var(--remup-primary);
}
.label.important .label-symbol {
    border-color: var(--remup-accent);
    color: var(--remup-accent);
}
.label.reference .label-symbol {
    border-color: #3498db;
    color: #3498db;
}
.label.question .label-symbol {
    border-color: #f39c12;
    color: #f39c12;
}
.label.info .label-symbol {
    border-color: var(--remup-gray);
    color: var(--remup-gray);
}

.label-link {
    color: inherit;
    text-decoration: none;
    margin-right: 3px;
}

.label-link:hover {
    text-decoration: underline;
}

/* ============================================
    区域系统
============================================ */
.region {
    margin: 20px 0;
    position: relative;
}

.region-line {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--region-line) 20%, 
        var(--region-line) 80%, 
        transparent 100%);
    margin: 8px 0 15px 0;
    position: relative;
}

.region-title {
    position: absolute;
    top: -8px;
    left: 8px;
    background: var(--card-bg);
    padding: 0 8px;
    font-size: 0.8em;
    font-weight: bold;
    color: var(--region-title);
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.region-content {
    margin-top: 12px;
    position: relative;
}

/* ============================================
    列表样式
============================================ */
.region-content ul,
.region-content ol {
    margin: 0;
    padding: 0;
    list-style-type: none;
}

.region-content li {
    position: relative;
    padding-left: 1.2em;
    margin-bottom: 0.4em;
    font-size: 0.95em;
}

.region-content ul li::before {
    content: '';
    position: absolute;
    left: 0.2em;
    top: 0.5em;
    width: 0.35em;
    height: 0.35em;
    border-radius: 50%;
    background-color: var(--remup-primary);
}

.region-content ol {
    counter-reset: li-counter;
}

.region-content ol li::before {
    content: counter(li-counter) ".";
    counter-increment: li-counter;
    position: absolute;
    left: 0;
    color: var(--remup-primary);
    font-weight: bold;
    font-size: 0.9em;
}

/* ============================================
    内容样式
============================================ */
.content {
    line-height: var(--line-height-comfort);
    font-size: var(--font-size-base);
    position: relative;
}

.content p {
    margin-bottom: 12px;
    font-size: 0.95em;
}

/* ============================================
    代码块样式
============================================ */
.code-block {
    background: #2d3748;
    color: #e2e8f0;
    padding: 15px;
    border-radius: 6px;
    margin: 15px 0;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85em;
    line-height: 1.4;
    position: relative;
    z-index: 1;
}

.code-block pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.keyword { color: #c678dd; font-weight: bold; }
.number { color: #d19a66; }
.string { color: #98c379; }
.comment { color: #5c6370; font-style: italic; }

/* ============================================
    内联代码样式 (inline-code)
============================================ */
.inline-code {
    display: inline;
    background: #f1f3f4;
    color: #d73a49;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #e1e4e8;
    font-family: var(--font-mono);
    font-size: 0.85em;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
    position: relative;
    z-index: 1;
    transition: all 0.2s ease;
}

/* 内联代码悬停效果 */
.inline-code:hover {
    background: #e8eaed;
    border-color: #d0d7de;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 内联代码与注卡系统的兼容 */
.annotation .inline-code {
    background: rgba(255, 255, 255, 0.2);
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 0.8em;
    padding: 1px 4px;
}

/* 内联代码在列表中的样式 */
.region-content li .inline-code {
    margin: 0 2px;
    vertical-align: middle;
}

/* 内联代码的键盘快捷键样式 */
kbd.inline-code {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #495057;
    border: 1px solid #ced4da;
    border-bottom: 2px solid #adb5bd;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-weight: 600;
}

/* 内联代码的响应式设计 */
@media (max-width: 768px) {
    .inline-code {
        padding: 1px 4px;
        font-size: 0.8em;
        word-break: break-all;
    }
}

/* 内联代码的打印优化 */
@media print {
    .inline-code {
        background: #f8f9fa;
        color: #000;
        border: 1px solid #dee2e6;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ============================================
    行内解释样式
============================================ */
.inline-explanation {
    display: block;
    color: #7f8c8d;
    opacity: 0.7;
    font-size: 0.85em;
    font-style: italic;
    margin-top: 8px;
    margin-bottom: 12px;
    padding-left: 16px;
    position: relative;
    white-space: normal;
    word-wrap: break-word;
    z-index: 1;
}

.inline-explanation::before {
    content: '>>';
    position: absolute;
    left: 0;
    color: var(--remup-gray);
    font-family: var(--font-mono);
    font-size: 0.8em;
}

/* ============================================
    注卡系统 - 纯CSS实现版本
============================================ */
.annotation-container {
    position: relative;
    display: inline;
    cursor: pointer;
}

.annotation {
    color: #2980b9;
    border-bottom: 1px dashed #2980b9;
    padding: 1px 3px;
    border-radius: 2px;
    background: rgba(52, 152, 219, 0.08);
    transition: all 0.2s ease;
    cursor: pointer;
}

.annotation:hover {
    background: rgba(52, 152, 219, 0.15);
    border-bottom-style: solid;
}

/* 注卡弹出层 - 纯CSS控制 */
.annotation-popup {
    position: absolute;
    z-index: 10000;
    background: white;
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    padding: 12px;
    width: 280px;
    max-width: 90vw;
    max-height: 60vh;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    font-size: 0.85em;
    line-height: 1.4;
    color: #2c3e50;
    
    /* 初始隐藏状态 */
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    visibility: hidden;
    
    /* 定位在触发元素正下方 */
    top: 100%;
    left: 0;
    margin-top: 5px;
}


/* 核心：CSS悬停显示逻辑 */
.annotation-container:hover .annotation-popup {
    display: block;
    opacity: 1;
    visibility: visible;
}

.annotation-popup.active .annotation-popup:hover{
    display: block;
    opacity: 1;
    visibility: visible;
}
/* 返回链接样式 */
.back-to-source {
    display: block;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #f0f0f0;
    font-size: 0.75em;
    color: #3498db;
    text-align: center;
    text-decoration: none;
}

.back-to-source:hover {
    text-decoration: underline;
}
/* ============================================
    归档系统
============================================ */
.archive-section {
    width: 100%;
    margin-bottom: 25px;
}

.archive-title {
    font-size: 1.7em;
    margin-bottom: 15px;
    color: #2c3e50;
    border-bottom: 2px solid var(--remup-primary);
    padding-bottom: 8px;
    position: relative;
}

.archive-title::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: var(--remup-primary);
}

.archive-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    width: 100%;
}

.archive-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8e8e8;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.archive-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.12);
    border-color: var(--remup-primary);
}

.archive-card-title {
    font-size: 1.3em;
    color: var(--remup-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
}

.archive-card-content {
    flex: 1;
    margin-bottom: 15px;
    color: #5a6c7d;
    font-size: 0.95em;
    line-height: 1.5;
}

.archive-card-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 0.9em;
    font-weight: 500;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    margin-top: auto;
}

.archive-card-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.archive-card-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
    background: linear-gradient(135deg, #2980b9 0%, #2471a3 100%);
}

.archive-card-link:hover::before {
    left: 100%;
}

.archive-card-link:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.archive-card-link::after {
    content: '→';
    margin-left: 8px;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.archive-card-link:hover::after {
    transform: translateX(3px);
}

/* ============================================
    注点归档样式
============================================ */
.vibe-archive {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border-left: 4px solid var(--remup-primary);
}

.vibe-archive-title {
    color: #2c3e50;
    font-size: 1.4em;
    margin-bottom: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.vibe-archive-title::before {
    content: '📚';
    margin-right: 10px;
    font-size: 1.2em;
}

.vibe-archive-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.vibe-archive-card {
    background: white;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border-left: 3px solid #3498db;
    transition: all 0.2s ease;
}

.vibe-archive-card:hover {
    transform: translateX(3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.vibe-archive-item {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
}

.vibe-archive-item:last-child {
    border-bottom: none;
}

.vibe-archive-item::before {
    content: '•';
    color: var(--remup-primary);
    margin-right: 8px;
    font-weight: bold;
}

.vibe-link {
    color: var(--remup-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.vibe-link:hover {
    color: #2980b9;
    text-decoration: underline;
    transform: translateX(2px);
}

.vibe-link::after {
    content: '↗';
    margin-left: 4px;
    font-size: 0.9em;
}

/* ============================================
    响应式设计
============================================ */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .archive-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .archive-card {
        padding: 15px;
    }
    
    .archive-card-title {
        font-size: 1.2em;
    }
    
    .vibe-archive-cards {
        grid-template-columns: 1fr;
    }
    
    .vibe-archive {
        padding: 15px;
        margin: 15px 0;
    }
    
    /* 移动端注卡优化 */
    .annotation-popup {
        width: 280px;
        max-width: 95vw;
        left: 150% !important;
        transform: translateX(-50%) !important;
        right: auto;
    }
    
    .annotation {
        cursor: pointer;
    }
    
    .annotation-container:hover .annotation-popup {
        display: block;
    }
    
    .annotation.active + .annotation-popup {
        display: block;
    }
}

@media (min-width: 1024px) {
    .archive-cards {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 18px;
    }
    
    .vibe-archive-cards {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
        font-size: 13px;
    }
    
    .archive-card-link {
        padding: 8px 16px;
        font-size: 0.85em;
    }
    
    .vibe-archive-item {
        font-size: 0.85em;
    }
    
    .annotation-popup {
        width: 260px;
        padding: 10px;
        font-size: 0.8em;
    }
    
    .annotation {
        padding: 2px 4px;
        font-size: 0.9em;
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .archive-cards {
        grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    }
}

/* ============================================
    工具类
============================================ */
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mb-1 { margin-bottom: 8px; }

/* 滚动锚点偏移 */
:target {
    scroll-margin-top: 15px;
    background-color: rgba(255, 255, 0, 0.15);
    transition: background-color 0.3s ease;
}

/* 焦点样式 */
.card:focus {
    outline: 2px solid var(--remup-primary);
    outline-offset: 1px;
}

/* 打印优化 */
@media print {
    body {
        background: white;
        padding: 0;
        font-size: 12pt;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }
    
    .labels-container {
        border-bottom: 1px solid #ddd;
    }
    
    .annotation-popup {
        display: block !important;
        position: relative;
        width: 100%;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}