/**
 * 智能菜单样式 - Typecho Handsome 主题版
 * Smart Menu for Typecho Handsome Theme
 * Version: 1.5.0
 * 
 * 使用方法：将此文件内容添加到 Handsome 主题设置 -> 开发者设置 -> 自定义CSS
 * 或者在 header.php 中引入此文件
 */

/* ==================== 基础样式覆盖 ==================== */
/* 全局禁用浏览器默认选择 */
* {
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent;
}

/* 输入框和文本框保持可选 */
input, textarea, [contenteditable="true"] {
    -webkit-user-select: text !important;
    user-select: text !important;
}

/* ==================== 自定义菜单 ==================== */
#smartMenu {
    position: fixed;
    z-index: 99999;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.1);
    min-width: 150px;
    padding: 6px 0;
    display: none;
    touch-action: none;
    transform-origin: top center;
    animation: smartMenuShow 0.2s ease-out;
}

#smartMenu.show {
    display: block;
}

#smartMenu.from-bottom {
    transform-origin: bottom center;
    animation: smartMenuShowBottom 0.2s ease-out;
}

@keyframes smartMenuShow {
    from { opacity: 0; transform: scale(0.9) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes smartMenuShowBottom {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.smart-menu-header {
    padding: 10px 14px;
    font-size: 12px;
    color: #888;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 6px;
}

.smart-menu-header i {
    color: #4caf50;
}

.smart-menu-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #333;
    transition: all 0.15s;
    position: relative;
    overflow: hidden;
}

.smart-menu-item:hover {
    background: rgba(0, 150, 136, 0.1);
}

.smart-menu-item:active {
    background: rgba(0, 150, 136, 0.2);
    transform: scale(0.98);
}

.smart-menu-item i {
    width: 18px;
    text-align: center;
    color: #009688;
    font-size: 14px;
}

.smart-menu-divider {
    height: 1px;
    background: #eee;
    margin: 4px 0;
}

/* ==================== Toast 提示 ==================== */
#smartToast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: rgba(50, 50, 50, 0.95);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 13px;
    z-index: 999999;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    max-width: 90vw;
}

#smartToast.show {
    transform: translateX(-50%) translateY(0);
}

#smartToast.success {
    background: linear-gradient(135deg, #4caf50, #45a049);
}

#smartToast.error {
    background: linear-gradient(135deg, #f44336, #d32f2f);
}

#smartToast.info {
    background: linear-gradient(135deg, #2196f3, #1976d2);
}

/* ==================== 选择手柄 ==================== */
.smart-handle {
    position: fixed;
    width: 24px;
    height: 24px;
    z-index: 99998;
    display: none;
    cursor: grab;
    touch-action: none;
    transition: transform 0.1s ease;
}

.smart-handle:active {
    cursor: grabbing;
    transform: scale(1.2);
}

.smart-handle.active {
    transform: scale(1.3);
}

.smart-handle-inner {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #009688 0%, #00796b 100%);
    box-shadow: 0 2px 8px rgba(0, 150, 136, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.smart-handle-inner::after {
    content: '';
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

/* ==================== 放大镜 ==================== */
#smartMagnifier {
    position: fixed;
    z-index: 99997;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 10px;
    padding: 8px 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    font-size: 18px;
    font-family: monospace;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.15s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 2px;
    border: 2px solid #009688;
}

#smartMagnifier.show {
    opacity: 1;
    transform: translateY(0);
}

#smartMagnifier .mag-char {
    padding: 2px 3px;
    border-radius: 3px;
}

#smartMagnifier .mag-char.current {
    background: linear-gradient(135deg, #009688, #00796b);
    color: white;
    font-weight: bold;
}

#smartMagnifier .mag-char.neighbor {
    color: #999;
}

/* ==================== 模式指示器 ==================== */
#smartModeIndicator {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(0, 150, 136, 0.95);
    color: white;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 12px;
    z-index: 99996;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 150, 136, 0.3);
}

#smartModeIndicator.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==================== 字符选择样式 ==================== */
.smart-char {
    display: inline;
    position: relative;
    transition: background-color 0.1s;
}

.smart-char.selected {
    background-color: rgba(0, 150, 136, 0.25) !important;
    border-bottom: 2px solid #009688 !important;
    border-radius: 0;
    padding-bottom: 1px;
    margin-bottom: -1px;
    font-weight: inherit;
    font-style: inherit;
    color: inherit;
    text-decoration: inherit;
}

.smart-char-container {
    display: inline;
}

/* ==================== MD 样式保留 ==================== */
.smart-md-wrapper {
    display: inline;
}

strong.smart-md-wrapper .smart-char,
b.smart-md-wrapper .smart-char {
    font-weight: bold !important;
}

em.smart-md-wrapper .smart-char,
i.smart-md-wrapper .smart-char {
    font-style: italic !important;
}

code.smart-md-wrapper .smart-char {
    font-family: 'Consolas', 'Monaco', monospace !important;
    color: #e91e63 !important;
}

del.smart-md-wrapper .smart-char,
s.smart-md-wrapper .smart-char {
    text-decoration: line-through !important;
}

a.smart-md-wrapper .smart-char {
    color: #009688 !important;
}

mark.smart-md-wrapper .smart-char {
    background: rgba(255, 241, 118, 0.6) !important;
}

mark.smart-md-wrapper .smart-char.selected {
    background: rgba(255, 200, 50, 0.7) !important;
}

/* ==================== 代码块选中 ==================== */
pre .smart-char.selected,
.highlight .smart-char.selected {
    background-color: rgba(0, 150, 136, 0.3) !important;
    border-bottom-color: #4db6ac !important;
}

/* ==================== 长按特效 ==================== */
.smart-ripple {
    position: fixed;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 150, 136, 0.4) 0%, transparent 70%);
    pointer-events: none;
    z-index: 99990;
    animation: smartRipple 0.6s ease-out forwards;
}

@keyframes smartRipple {
    0% { transform: scale(0); opacity: 1; }
    100% { transform: scale(3); opacity: 0; }
}

/* ==================== 进度环 ==================== */
.smart-progress-ring {
    position: fixed;
    width: 50px;
    height: 50px;
    pointer-events: none;
    z-index: 99991;
    transform: translate(-50%, -50%);
    transition: opacity 0.2s, transform 0.2s;
}

.smart-progress-ring svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 6px rgba(0, 150, 136, 0.3));
}

.smart-progress-ring .progress-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 3;
}

.smart-progress-ring .progress-bar {
    fill: none;
    stroke: #009688;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.05s linear;
}

.smart-progress-ring .progress-center {
    fill: rgba(0, 150, 136, 0.5);
    transition: transform 0.1s, opacity 0.1s;
    transform-origin: center;
}

.smart-progress-ring.complete .progress-bar {
    stroke: #4caf50;
}

.smart-progress-ring.complete .progress-center {
    fill: #4caf50;
}

@keyframes smartRingComplete {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
}

.smart-progress-ring.complete {
    animation: smartRingComplete 0.3s ease-out forwards;
}

/* ==================== Handsome 主题适配 ==================== */
/* 文章内容区域可选 - 支持多种可能的类名 */
.entry-content p,
.entry-content li,
.entry-content td,
.entry-content th,
.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6,
.entry-content blockquote,
.entry-content pre,
.entry-content code,
.post-content p,
.post-content li,
.post-content pre,
.article-content p,
.article-content li,
.content p,
.content li,
.panel-body p,
.panel-body li {
    cursor: text;
}

/* 评论区域可选 */
.comment-content p,
.comment-body p {
    cursor: text;
}

/* 暗色模式适配 */
[data-theme="dark"] #smartMenu,
.dark-theme #smartMenu {
    background: rgba(40, 40, 40, 0.98);
    color: #e0e0e0;
}

[data-theme="dark"] .smart-menu-item,
.dark-theme .smart-menu-item {
    color: #e0e0e0;
}

[data-theme="dark"] .smart-menu-item:hover,
.dark-theme .smart-menu-item:hover {
    background: rgba(0, 150, 136, 0.2);
}

[data-theme="dark"] .smart-menu-divider,
.dark-theme .smart-menu-divider {
    background: #444;
}

[data-theme="dark"] #smartMagnifier,
.dark-theme #smartMagnifier {
    background: rgba(40, 40, 40, 0.98);
    color: #e0e0e0;
}

[data-theme="dark"] code.smart-md-wrapper .smart-char,
.dark-theme code.smart-md-wrapper .smart-char {
    color: #ff79c6 !important;
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .smart-menu-item {
        padding: 14px 18px;
    }
    
    #smartMagnifier {
        font-size: 16px;
    }
}

