/*
 * 浏览风格选择：照片轮换 / 简洁模式 / 圣诞模式
 *
 * - 首次进入且站点已启用背景轮换时弹出选择框，选择写入 localStorage（jx_ui_mode）
 * - 选择「简洁模式」时由 <html data-ui-mode="plain"> 关闭背景层并还原不透明底色，
 *   在 head 内联脚本中尽早应用，避免刷新时先闪一下照片背景
 * - 选择「圣诞模式」时由 <html data-ui-mode="xmas"> 换成纯 CSS 雪地背景（见 christmas.css），
 *   同时关闭照片轮换层，不加载任何照片
 * - 页脚提供「界面风格」入口，可随时重新选择
 */

/* ── 简洁模式：关闭背景层，还原页面底色 ─────────────────────────────── */
html[data-ui-mode="plain"] .jx-site-bg {
    display: none !important;
}

html[data-ui-mode="plain"] body.jx-has-site-bg {
    background: var(--bg);
}

html[data-ui-mode="plain"] body.jx-has-site-bg #jx-page-root {
    background-color: var(--bg);
}

/* ── 圣诞模式：关闭照片轮换层，让雪地背景透出来 ─────────────────────── */
html[data-ui-mode="xmas"] .jx-site-bg {
    display: none !important;
}

html[data-ui-mode="xmas"] body,
html[data-ui-mode="xmas"] body.jx-has-site-bg {
    background: transparent;
}

html[data-ui-mode="xmas"] #jx-page-root {
    background-color: transparent;
}

/* ── 弹窗 ─────────────────────────────────────────────────────────── */
.jx-ui-mode-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.jx-ui-mode-modal[hidden] {
    display: none;
}

.jx-ui-mode-modal__backdrop {
    position: absolute;
    inset: 0;
    background: var(--overlay, rgba(15, 23, 42, 0.45));
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    animation: jx-ui-mode-fade 0.2s ease both;
}

.jx-ui-mode-modal__dialog {
    position: relative;
    width: 100%;
    max-width: 720px;
    padding: 1.75rem;
    background: var(--surface-primary, #ffffff);
    color: var(--text, #1f2937);
    border: 1px solid var(--border, #e5e2dc);
    border-radius: var(--radius-xl, 20px);
    box-shadow: var(--shadow-md, 0 24px 64px rgba(15, 23, 42, 0.22));
    animation: jx-ui-mode-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.jx-ui-mode-modal__title {
    margin: 0 0 0.375rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.jx-ui-mode-modal__desc {
    margin: 0 0 1.25rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-secondary, #6b7280);
}

.jx-ui-mode-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.jx-ui-mode-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.375rem;
    padding: 0.875rem;
    text-align: left;
    background: var(--bg-elevated, #ffffff);
    color: inherit;
    border: 1px solid var(--border, #e5e2dc);
    border-radius: var(--radius-lg, 14px);
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.jx-ui-mode-option:hover {
    border-color: var(--accent, #0f7b6c);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

.jx-ui-mode-option:focus-visible {
    outline: 2px solid var(--accent, #0f7b6c);
    outline-offset: 2px;
}

.jx-ui-mode-option.is-selected {
    border-color: var(--accent, #0f7b6c);
    box-shadow: inset 0 0 0 1px var(--accent, #0f7b6c);
}

.jx-ui-mode-option__preview {
    display: block;
    width: 100%;
    height: 64px;
    margin-bottom: 0.125rem;
    border-radius: 10px;
    border: 1px solid var(--border, #e5e2dc);
    overflow: hidden;
}

.jx-ui-mode-option__preview--photo {
    background:
        radial-gradient(120% 90% at 18% 16%, rgba(255, 214, 153, 0.95) 0%, rgba(255, 214, 153, 0) 52%),
        radial-gradient(110% 90% at 82% 22%, rgba(88, 148, 190, 0.9) 0%, rgba(88, 148, 190, 0) 58%),
        linear-gradient(150deg, #3c6e8f 0%, #7fa7bd 42%, #d9b18a 68%, #6d4f3a 100%);
}

.jx-ui-mode-option__preview--plain {
    background:
        linear-gradient(180deg, var(--bg, #ffffff) 0%, var(--bg, #ffffff) 100%);
    position: relative;
}

.jx-ui-mode-option__preview--plain::after {
    content: "";
    position: absolute;
    inset: 14px 16px auto 16px;
    height: 6px;
    border-radius: 999px;
    background: var(--border, #d7d3cc);
    box-shadow:
        0 14px 0 0 var(--border, #d7d3cc),
        0 28px 0 0 var(--border, #d7d3cc);
    opacity: 0.7;
}

/* 圣诞模式预览：雪地 + 松树 + 月亮，纯 CSS 绘制 */
.jx-ui-mode-option__preview--xmas {
    position: relative;
    background:
        radial-gradient(circle at 76% 26%, #fffdf0 0 6.5px, rgba(255, 253, 240, 0) 7.5px),
        radial-gradient(circle at 76% 26%, rgba(255, 253, 224, 0.55) 0 11px, rgba(255, 253, 224, 0) 12px),
        linear-gradient(180deg, #bfe0f7 0%, #d9ecfb 52%, #f2f9ff 74%, #ffffff 100%);
}

.jx-ui-mode-option__preview--xmas::before {
    content: "";
    position: absolute;
    left: 16%;
    bottom: 16%;
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 24px solid #1b6f47;
    filter: drop-shadow(0 2px 0 rgba(255, 255, 255, 0.85));
}

.jx-ui-mode-option__preview--xmas::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 16px;
    background:
        radial-gradient(13px 9px at 13px 9px, #ffffff 0 72%, rgba(255, 255, 255, 0) 73%) repeat-x 0 0 / 26px 16px,
        linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(232, 242, 251, 0.9) 55%, #e8f2fb 100%);
}

html[data-theme="dark"] .jx-ui-mode-option__preview--xmas {
    background:
        radial-gradient(circle at 76% 26%, #f8fbff 0 6.5px, rgba(248, 251, 255, 0) 7.5px),
        radial-gradient(circle at 76% 26%, rgba(248, 251, 255, 0.4) 0 11px, rgba(248, 251, 255, 0) 12px),
        linear-gradient(180deg, #14284a 0%, #244a76 52%, #5d8bb4 78%, #dfeaf6 100%);
}

.jx-ui-mode-option__name {
    font-size: 0.9375rem;
    font-weight: 650;
}

.jx-ui-mode-option__hint {
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-muted, #8a8f98);
}

.jx-ui-mode-modal__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1.125rem;
}

.jx-ui-mode-modal__foot p {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-muted, #8a8f98);
}

.jx-ui-mode-modal__later {
    padding: 0.25rem 0;
    font-size: 0.8125rem;
    color: var(--text-secondary, #6b7280);
    background: none;
    border: 0;
    cursor: pointer;
    white-space: nowrap;
}

.jx-ui-mode-modal__later:hover {
    color: var(--text, #1f2937);
    text-decoration: underline;
}

body.jx-ui-mode-open {
    overflow: hidden;
}

/* ── 个人中心等页面的「界面风格」直选 ───────────────────────────── */
.jx-ui-style {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding: 0.875rem 1rem;
    background: var(--bg-elevated, #ffffff);
    border: 1px solid var(--border, #e5e2dc);
    border-radius: var(--radius-lg, 14px);
}

.jx-ui-style__text {
    min-width: 0;
}

.jx-ui-style__title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 650;
    color: var(--text, #1f2937);
}

.jx-ui-style__desc {
    margin: 0.25rem 0 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-secondary, #6b7280);
}

.jx-ui-style__options {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.jx-ui-style__btn {
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    background: var(--surface-primary, #ffffff);
    border: 1px solid var(--border, #e5e2dc);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.jx-ui-style__btn:hover {
    color: var(--text, #1f2937);
    border-color: var(--accent, #0f7b6c);
}

.jx-ui-style__btn:focus-visible {
    outline: 2px solid var(--accent, #0f7b6c);
    outline-offset: 2px;
}

.jx-ui-style__btn.is-active {
    color: var(--accent, #0f7b6c);
    border-color: var(--accent, #0f7b6c);
    background: var(--accent-soft, rgba(35, 131, 226, 0.12));
}

/* 页脚的「界面风格」入口 */
.jx-footer__ui-switch {
    padding: 0;
    font: inherit;
    font-size: 0.75rem;
    color: var(--text-muted, #8a8f98);
    background: none;
    border: 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.jx-footer__ui-switch:hover {
    color: var(--text, #1f2937);
}

@keyframes jx-ui-mode-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes jx-ui-mode-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

/* 三项并排时在中等宽度开始收成单列，避免文字被挤成两三行 */
@media (max-width: 680px) {
    .jx-ui-mode-options {
        grid-template-columns: 1fr;
    }

    .jx-ui-mode-option__preview {
        height: 56px;
    }
}

@media (max-width: 520px) {
    .jx-ui-mode-modal__dialog {
        padding: 1.375rem;
    }

    .jx-ui-mode-option__preview {
        height: 52px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .jx-ui-mode-modal__backdrop,
    .jx-ui-mode-modal__dialog,
    .jx-ui-mode-option {
        animation: none !important;
        transition: none !important;
    }
}
