/**
 * 汉字知识图谱 - 样式文件
 * Character Knowledge Graph - Styles
 * 4K优化、中心-放射状布局
 */

/* ========================================
   容器和布局
   ======================================== */

.knowledge-graph-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-primary);
    font-family: 'Source Han Sans CN', 'Noto Sans SC', -apple-system, sans-serif;
}

.graph-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ========================================
   控制面板
   ======================================== */

.control-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 320px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 12px;
    padding: 20px;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease;
}

.control-panel.collapsed {
    transform: translateX(calc(100% + 20px));
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-header h3 {
    margin: 0;
    font-size: 18px;
    color: white;
}

.btn-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s ease;
}

.btn-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(180deg);
}

.panel-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.panel-body::-webkit-scrollbar {
    width: 6px;
}

.panel-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

/* ========================================
   控制组件
   ======================================== */

.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    margin-bottom: 8px;
}

.control-select {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    font-size: 14px;
    cursor: pointer;
}

.control-select:focus {
    outline: none;
    border-color: var(--accent);
}

.control-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    -webkit-appearance: none;
}

.control-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-slider::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
    transform: scale(1.2);
}

/* 模式按钮 */
.mode-buttons {
    display: flex;
    gap: 8px;
}

.btn-mode {
    flex: 1;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-mode:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-mode.active {
    background: var(--accent);
    border-color: var(--accent);
}

/* 速度预设 */
.speed-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 8px;
}

.btn-preset {
    padding: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-preset:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 操作按钮 */
.btn-action {
    width: 100%;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-action:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.btn-action:last-child {
    margin-bottom: 0;
}

/* 链接按钮 */
.btn-link {
    display: block;
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    text-align: center;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.3s ease;
}

.btn-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(-2px);
}

/* ========================================
   中心字信息面板
   ======================================== */

.center-info {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 500;
}

.info-char {
    font-size: 180pt;
    font-weight: 900;
    color: var(--text-primary);
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    line-height: 1;
    transition: all 0.5s ease;
}

.info-pinyin {
    font-size: 48pt;
    color: var(--text-secondary);
    margin-top: 20px;
}

.info-meta {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
}

.meta-item {
    font-size: 28pt;
    color: var(--text-tertiary);
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 8px;
}

/* ========================================
   路径历史
   ======================================== */

.path-history {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.8);
    padding: 12px 20px;
    border-radius: 50px;
    max-width: 80vw;
    overflow-x: auto;
    z-index: 1000;
}

.history-label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    white-space: nowrap;
}

.history-items {
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.history-items::-webkit-scrollbar {
    height: 4px;
}

.history-items::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.history-item {
    display: inline-block;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.history-item.active {
    background: var(--accent);
    border-color: var(--accent);
}

/* ========================================
   SVG 节点样式
   ======================================== */

.node-circle {
    fill: var(--bg-tertiary);
    stroke: var(--accent);
    stroke-width: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.node-circle:hover {
    fill: var(--accent);
    stroke-width: 4px;
    filter: drop-shadow(0 0 12px var(--accent));
}

.node-text {
    fill: var(--text-primary);
    font-size: 48px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    user-select: none;
}

.node-pinyin {
    fill: var(--text-secondary);
    font-size: 18px;
    text-anchor: middle;
    pointer-events: none;
}

.link-line {
    stroke: var(--accent);
    stroke-width: 2px;
    stroke-opacity: 0.4;
    fill: none;
}

.link-label {
    fill: var(--text-tertiary);
    font-size: 14px;
    text-anchor: middle;
}

/* ========================================
   布局切换器
   ======================================== */

.layout-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.btn-layout {
    flex: 1;
    padding: 10px 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-layout:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent);
}

.btn-layout.active {
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
}

/* ========================================
   导出按钮
   ======================================== */

.btn-export {
    flex: 1;
    padding: 10px 16px;
    background: rgba(52, 211, 153, 0.2);
    border: 2px solid rgba(52, 211, 153, 0.5);
    border-radius: 8px;
    color: rgb(52, 211, 153);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 8px;
}

.btn-export:last-child {
    margin-right: 0;
}

.btn-export:hover {
    background: rgba(52, 211, 153, 0.3);
    border-color: rgb(52, 211, 153);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 211, 153, 0.3);
}

.btn-export:active {
    transform: translateY(0);
}

/* ========================================
   节点详情卡片
   ======================================== */

.detail-card {
    position: fixed;
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 16px 20px;
    z-index: 2000;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    min-width: 200px;
    animation: fadeInCard 0.2s ease;
}

@keyframes fadeInCard {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.detail-char {
    font-size: 48px;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    margin-bottom: 8px;
}

.detail-pinyin {
    font-size: 18px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.detail-info {
    font-size: 14px;
    color: var(--text-tertiary);
}

.detail-weight {
    margin-bottom: 8px;
}

.detail-weight span {
    color: var(--accent);
    font-weight: 600;
}

.detail-action {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========================================
   提示浮层
   ======================================== */

.tip-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.tip-content {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 16px;
    max-width: 500px;
    text-align: center;
}

.tip-content h2 {
    color: var(--text-primary);
    margin-bottom: 24px;
}

.tip-content ul {
    list-style: none;
    padding: 0;
    text-align: left;
    margin-bottom: 24px;
}

.tip-content li {
    color: var(--text-secondary);
    font-size: 18px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.tip-content kbd {
    background: var(--bg-tertiary);
    padding: 4px 12px;
    border-radius: 4px;
    font-family: monospace;
    color: var(--accent);
}

.btn-tip {
    padding: 12px 32px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    cursor: pointer;
}

.btn-tip:hover {
    background: var(--accent-hover);
}

/* ========================================
   响应式
   ======================================== */

/* 4K */
@media (min-width: 3840px) {
    .info-char {
        font-size: 240pt;
    }
    .info-pinyin {
        font-size: 60pt;
    }
    .meta-item {
        font-size: 36pt;
    }
    .node-text {
        font-size: 64px;
    }
}

/* 1080P */
@media (min-width: 1920px) and (max-width: 3839px) {
    .info-char {
        font-size: 150pt;
    }
    .info-pinyin {
        font-size: 40pt;
    }
    .meta-item {
        font-size: 24pt;
    }
    .node-text {
        font-size: 40px;
    }
}

/* MacBook */
@media (max-width: 1919px) {
    .info-char {
        font-size: 120pt;
    }
    .info-pinyin {
        font-size: 32pt;
    }
    .control-panel {
        width: 280px;
    }
}

/* Tablet/Mobile */
@media (max-width: 1023px) {
    .control-panel {
        width: 100%;
        top: auto;
        bottom: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
    }

    .info-char {
        font-size: 80pt;
    }

    .path-history {
        bottom: auto;
        top: 80px;
    }
}
