/* ============================================
   components.css - 通用组件样式
   包含：按钮、卡片、SVG、模态框、Toast等
   ============================================ */

/* 通用按钮 */
button {
    padding: 12px 22px;
    background: var(--btn-primary);
    color: white;
    border: none;
    border-radius: 40px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: 0.2s;
    border: 1px solid transparent;
}
button.secondary {
    background: var(--btn-secondary);
    color: var(--text-primary);
}
button:hover {
    background: var(--btn-primary-hover);
    transform: scale(1.02);
}
button.secondary:hover { background: var(--btn-secondary-hover); }

/* 卡片网格 */
.glyph-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(calc(130px * var(--card-scale)), 1fr));
    gap: calc(12px * var(--card-scale));
}
.card {
    position: relative;
    background: var(--bg-card);
    border-radius: calc(10px * var(--card-scale));
    padding: calc(8px * var(--card-scale)) calc(6px * var(--card-scale)) calc(6px * var(--card-scale));
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: 0.1s;
    break-inside: avoid;
    font-size: calc(12px * var(--card-scale));
    cursor: pointer;
}
.card:hover { box-shadow: var(--shadow-hover); }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: calc(6px * var(--card-scale));
}
.glyph-char {
    font-size: calc(18px * var(--card-scale));
    font-weight: bold;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.glyph-char[data-long="true"] {
    font-size: calc(12px * var(--card-scale));
}
.unicode {
    color: var(--unicode-text);
    background: var(--unicode-bg);
    padding: calc(2px * var(--card-scale)) calc(6px * var(--card-scale));
    border-radius: calc(20px * var(--card-scale));
    font-size: calc(10px * var(--card-scale));
    font-family: monospace;
}

svg {
    width: 100%;
    height: calc(90px * var(--card-scale));
    border: 1px solid var(--svg-border);
    border-radius: calc(6px * var(--card-scale));
    background: var(--bg-card);
}

/* 叠加路径 */
.overlay-svg .old-path {
    fill: var(--old-fill-rgba, color-mix(in srgb, var(--old-custom, #d1242f) 65%, transparent));
    mix-blend-mode: var(--blend-mode);
}
.overlay-svg .new-path {
    fill: var(--new-fill-rgba, color-mix(in srgb, var(--new-custom, #0969da) 65%, transparent));
    mix-blend-mode: var(--blend-mode);
}

.card.card-missing {
    border: 2px solid #d4a72c !important;
    box-shadow: 0 0 0 1px rgba(212, 167, 44, 0.3);
}
.card.missing-old .old-path,
.card.missing-new .new-path { opacity: 0.3; }
.overlay-svg text {
    fill: #d4a72c;
    font-weight: bold;
}

/* 复制按钮 */
.card-copy-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: var(--bg-controls);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    box-shadow: none;
    padding: 0;
}
.card:hover .card-copy-btn { opacity: 1; }
.card-copy-btn:hover {
    background: var(--btn-primary);
    color: white;
    border-color: var(--btn-primary);
    transform: none;
}

/* Toast */
.copy-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--btn-primary);
    color: white;
    padding: 8px 20px;
    border-radius: 40px;
    font-size: 14px;
    box-shadow: var(--shadow-hover);
    z-index: 9999;
    animation: fadeInOut 2s ease forwards;
}
@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* 放大模态框 */
.zoom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.zoom-content {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    position: relative;
    box-shadow: var(--shadow-hover);
    border: 1px solid var(--border-light);
}
.zoom-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 32px;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}
.zoom-close:hover { color: var(--btn-cancel); }
.zoom-char-large {
    font-size: 48px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-primary);
}
.zoom-unicode {
    text-align: center;
    margin-bottom: 15px;
    font-family: monospace;
    color: var(--unicode-text);
    background: var(--unicode-bg);
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}
.zoom-svg-container {
    width: 300px;
    height: 300px;
    margin: 0 auto;
}
.zoom-svg-container svg {
    width: 100%;
    height: 100%;
    border: 1px solid var(--svg-border);
    border-radius: 8px;
    background: var(--bg-card);
}
.zoom-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
    font-size: 14px;
}
.zoom-legend-old { color: var(--old-custom); }
.zoom-legend-new { color: var(--new-custom); }
.zoom-nav-hint {
    text-align: center;
    margin-top: 15px;
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* TTC 选择弹窗 */
.ttc-select-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}
.ttc-select-modal {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    min-width: 320px;
    max-width: 90vw;
    box-shadow: var(--shadow-hover);
    border: 1px solid var(--border-light);
    text-align: center;
}
.ttc-select-modal h3 { margin: 0 0 16px 0; color: var(--text-primary); }
.ttc-select-modal p { margin: 0 0 20px 0; color: var(--text-secondary); }
.ttc-select-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}
.ttc-font-btn {
    padding: 10px 20px;
    background: var(--btn-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    cursor: pointer;
}
.ttc-font-btn:hover {
    background: var(--btn-primary);
    color: white;
}
.ttc-cancel-btn {
    padding: 8px 24px;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
}
.ttc-cancel-btn:hover {
    background: var(--btn-cancel);
    color: white;
}

/* 新手引导 */
.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: fadeIn 0.2s ease;
}
.onboarding-card {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 28px 32px;
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow-hover);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.onboarding-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.onboarding-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}
.onboarding-close {
    background: transparent;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
    box-shadow: none;
}
.onboarding-close:hover {
    background: var(--btn-secondary-hover);
    color: var(--text-primary);
    transform: none;
}
.onboarding-content p {
    margin: 0 0 20px 0;
    color: var(--text-secondary);
    line-height: 1.5;
}
.onboarding-features {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}
.feature-item {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 15px;
}
.feature-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--legend-bg);
    border-radius: 8px;
    font-size: 18px;
}
.onboarding-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.dont-show-again {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
}
.dont-show-again input {
    accent-color: var(--btn-primary);
    width: 16px;
    height: 16px;
    margin: 0;
}
.onboarding-start-btn {
    padding: 10px 28px;
    background: var(--btn-primary);
    color: white;
    border: none;
    border-radius: 40px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: 0.2s;
}
.onboarding-start-btn:hover {
    background: var(--btn-primary-hover);
    transform: scale(1.02);
}