/*!
 * 墨泪导航 - 主题切换按钮（浅色 / 深色 / 跟随系统）
 * 首页模板与详情页共用
 */

/* ---------- 主题切换按钮 ---------- */
.theme-switch {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

/* 首页（default 模板）：桌面端贴在导航栏时钟右侧 */
.navbar .theme-switch {
    margin-left: 14px;
}

@media screen and (max-width: 992px) {
    /* 移动端导航折叠，固定到右上角 */
    .navbar .theme-switch {
        position: fixed;
        top: 10px;
        right: 48px;
        margin-left: 0;
        z-index: 10002;
    }
}

.theme-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 50%;
    background: rgba(18, 20, 26, .32);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background .25s ease, transform .15s ease, box-shadow .25s ease;
}

.theme-btn:hover {
    background: rgba(18, 20, 26, .58);
    transform: translateY(-1px);
}

.theme-btn:focus-visible {
    outline: 2px solid #4e6ef2;
    outline-offset: 2px;
}

.theme-btn svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* 依据用户选择显示对应图标 */
.theme-btn .ico {
    display: none;
}

html[data-theme-pref="light"] .theme-btn .ico-light,
html[data-theme-pref="dark"] .theme-btn .ico-dark,
html[data-theme-pref="auto"] .theme-btn .ico-auto {
    display: block;
}

/* ---------- 下拉菜单 ---------- */
.theme-menu {
    position: absolute;
    top: 42px;
    left: 0;
    z-index: 10002;
    min-width: 132px;
    padding: 6px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .2s ease, transform .2s ease, visibility .2s;
}

.theme-switch.open .theme-menu {
    opacity: 1;
    visibility: visible;
    transform: none;
}

html[data-theme="dark"] .theme-menu {
    background: rgba(26, 29, 36, .94);
    border: 1px solid rgba(255, 255, 255, .08);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .55);
}

.theme-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #333;
    font-size: 13px;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

.theme-menu button:hover {
    background: rgba(0, 0, 0, .06);
}

html[data-theme="dark"] .theme-menu button {
    color: #e6e8ec;
}

html[data-theme="dark"] .theme-menu button:hover {
    background: rgba(255, 255, 255, .1);
}

.theme-menu button.active {
    color: #4e6ef2;
    font-weight: 600;
}

html[data-theme="dark"] .theme-menu button.active {
    color: #8fb2ff;
}

.theme-menu .chk {
    margin-left: auto;
    font-size: 11px;
    opacity: 0;
    color: #4e6ef2;
}

.theme-menu button.active .chk {
    opacity: 1;
}

@media screen and (max-width: 992px) {
    .theme-menu {
        left: auto;
        right: 0;
    }
}
