/* Context右键菜单 - 前台样式 */

/* ===== 站点级深色模式 =====
 * 深色模式由主题接管（html.dark / html[data-theme="dark"]），
 * 插件不施加整页滤镜，只让菜单/提示外观跟随站点深色状态切换。
 */

/* ===== 右键菜单本体 ===== */
/* 重置：隔离主题全局样式干扰 */
.jc-cm,
.jc-cm * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.jc-cm ul,
.jc-cm menu,
.jc-cm dir {
    list-style: none;
    -webkit-margin-before: 0;
    -webkit-margin-after: 0;
    -webkit-padding-start: 0;
}

.jc-cm a {
    text-decoration: none;
    color: inherit;
}

.jc-cm[data-theme="light"] {
    --cm-bg: #ffffff;
    --cm-text: #1f2328;
    --cm-muted: #656d76;
    --cm-hover: #f0f2f5;
    --cm-hover-text: #1f2328;
    --cm-accent: #0969da;
    --cm-border: rgba(27, 31, 36, 0.12);
    --cm-sep: #e5e7eb;
    --cm-shadow: 0 10px 28px rgba(31, 35, 40, 0.18), 0 2px 8px rgba(31, 35, 40, 0.1);
}

.jc-cm[data-theme="dark"] {
    --cm-bg: #1c2128;
    --cm-text: #e6edf3;
    --cm-muted: #8b949e;
    --cm-hover: #30363d;
    --cm-hover-text: #ffffff;
    --cm-accent: #58a6ff;
    --cm-border: rgba(255, 255, 255, 0.12);
    --cm-sep: #30363d;
    --cm-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.jc-cm[data-theme="auto"] {
    --cm-bg: #ffffff;
    --cm-text: #1f2328;
    --cm-muted: #656d76;
    --cm-hover: #f0f2f5;
    --cm-hover-text: #1f2328;
    --cm-accent: #0969da;
    --cm-border: rgba(27, 31, 36, 0.12);
    --cm-sep: #e5e7eb;
    --cm-shadow: 0 10px 28px rgba(31, 35, 40, 0.18), 0 2px 8px rgba(31, 35, 40, 0.1);
}

@media (prefers-color-scheme: dark) {
    .jc-cm[data-theme="auto"] {
        --cm-bg: #1c2128;
        --cm-text: #e6edf3;
        --cm-muted: #8b949e;
        --cm-hover: #30363d;
        --cm-hover-text: #ffffff;
        --cm-accent: #58a6ff;
        --cm-border: rgba(255, 255, 255, 0.12);
        --cm-sep: #30363d;
        --cm-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
    }
}

/* 站点深色模式开启时，菜单跟随切换为深色外观（auto / dark 主题适用，强制浅色的用户不受影响） */
html.dark .jc-cm[data-theme="auto"],
html[data-theme="dark"] .jc-cm[data-theme="auto"],
html.dark .jc-cm[data-theme="dark"],
html[data-theme="dark"] .jc-cm[data-theme="dark"] {
    --cm-bg: #1c2128;
    --cm-text: #e6edf3;
    --cm-muted: #8b949e;
    --cm-hover: #30363d;
    --cm-hover-text: #ffffff;
    --cm-accent: #58a6ff;
    --cm-border: rgba(255, 255, 255, 0.12);
    --cm-sep: #30363d;
    --cm-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.jc-cm {
    position: fixed;
    left: 0;
    top: 0;
    display: none;
    z-index: 2147483646;
    min-width: 190px;
    max-width: 300px;
    padding: 5px;
    background: var(--cm-bg);
    border: 1px solid var(--cm-border);
    border-radius: 10px;
    box-shadow: var(--cm-shadow);
    color: var(--cm-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    line-height: 1.5;
    -webkit-user-select: none;
    user-select: none;
}

.jc-cm.jc-show {
    display: block;
    -webkit-animation: jc-cm-pop 0.12s ease-out;
    animation: jc-cm-pop 0.12s ease-out;
}

@-webkit-keyframes jc-cm-pop {
    from {
        opacity: 0;
        -webkit-transform: scale(0.96);
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        -webkit-transform: scale(1);
        transform: scale(1);
    }
}

@keyframes jc-cm-pop {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.jc-cm-menu {
    list-style: none;
    max-height: min(560px, 82vh);
    overflow-y: auto;
    overflow-x: hidden;
}

.jc-cm-menu::-webkit-scrollbar {
    width: 8px;
}

.jc-cm-menu::-webkit-scrollbar-thumb {
    background: var(--cm-muted);
    border-radius: 8px;
    opacity: 0.6;
}

.jc-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 7px;
    cursor: pointer;
    color: var(--cm-text);
    white-space: nowrap;
}

.jc-item.jc-disabled {
    opacity: 0.55;
    cursor: default;
}

.jc-item:hover,
.jc-item.jc-focused {
    background: var(--cm-hover);
    color: var(--cm-hover-text);
}

.jc-item:hover .jc-item-sub .jc-item,
.jc-item.jc-open .jc-item-sub .jc-item {
    background: transparent;
}

.jc-item.jc-open > .jc-item-sub .jc-item:hover {
    background: var(--cm-hover);
}

.jc-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    color: var(--cm-muted);
}

.jc-item:hover > .jc-ic,
.jc-item.jc-focused > .jc-ic {
    color: var(--cm-accent);
}

.jc-ic svg {
    width: 16px;
    height: 16px;
    display: block;
}

.jc-label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jc-caret {
    display: inline-block;
    color: var(--cm-muted);
    font-size: 10px;
    margin-left: 8px;
    transform: rotate(-90deg);
}

.jc-item.jc-open > .jc-caret,
.jc-item:hover > .jc-caret {
    transform: rotate(0deg);
    color: var(--cm-accent);
}

/* 二级菜单 */
.jc-item-sub {
    position: absolute;
    left: 100%;
    top: -5px;
    list-style: none;
    min-width: 190px;
    max-width: 320px;
    max-height: min(480px, 78vh);
    overflow-y: auto;
    background: var(--cm-bg);
    border: 1px solid var(--cm-border);
    border-radius: 10px;
    box-shadow: var(--cm-shadow);
    padding: 5px;
    display: none;
    margin-left: 6px;
}

.jc-item:hover > .jc-item-sub,
.jc-item.jc-open > .jc-item-sub {
    display: block;
}

.jc-item.jc-sub-left > .jc-item-sub {
    left: auto;
    right: 100%;
    margin-left: 0;
    margin-right: 6px;
}

.jc-item.jc-sub-left > .jc-caret {
    transform: rotate(180deg);
}

.jc-item-sub .jc-item {
    white-space: normal;
}

/* 子菜单中的链接项 */
.jc-item-sub a.jc-item {
    text-decoration: none;
}

/* 分割线 */
.jc-sep {
    height: 1px;
    margin: 5px 8px;
    background: var(--cm-sep);
}

/* 小贴士提示 */
.jc-toast {
    position: fixed;
    left: 50%;
    bottom: 42px;
    transform: translateX(-50%);
    z-index: 2147483647;
    background: rgba(24, 28, 33, 0.92);
    color: #fff;
    font-size: 13px;
    line-height: 1;
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    max-width: 70vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.jc-toast.jc-show {
    opacity: 1;
}

@media (max-width: 480px) {
    .jc-cm {
        min-width: 170px;
    }
}
