/* =============================================================================
   ByCode8 public themes: 月白 / 夜亭
   Loaded after landing.css and site.css.  The original 深色（默认）and 浅色
   token sets stay in landing.css; this file only adds the two new sets and
   turns the hard-coded decorative layers into theme-aware ones.
   ============================================================================= */

:root {
    --accent-soft: rgba(139, 92, 246, 0.12);
    --accent-soft-strong: rgba(139, 92, 246, 0.18);
    --accent-border: rgba(139, 92, 246, 0.3);
    --theme-navbar-bg: rgba(10, 14, 26, 0.85);
    --theme-hero-bg: #05070f;
    --theme-hero-glow-1: rgba(99, 102, 241, 0.18);
    --theme-hero-glow-2: rgba(139, 92, 246, 0.12);
    --theme-hero-sweep-1: rgba(96, 165, 250, 0.07);
    --theme-hero-sweep-2: rgba(139, 92, 246, 0.1);
    --theme-glass: rgba(10, 14, 26, 0.45);
    --theme-hero-shadow: rgba(5, 7, 15, 0.45);
    --theme-code-bg: #111827;
    --theme-code-header: rgba(0, 0, 0, 0.2);
    --theme-image-filter: brightness(1.08) saturate(1.1);
    --theme-er-line: #8b5cf6;
    --theme-er-glow: rgba(139, 92, 246, 0.55);
    --theme-er-current: #a5f3fc;
    --theme-er-current-glow: rgba(103, 232, 249, 0.95);
    --theme-er-spark: #bae6fd;
    --theme-er-spark-glow: #67e8f9;
    --theme-er-node: #a5f3fc;
    --theme-auth-glow-1: rgba(139, 92, 246, 0.15);
    --theme-auth-glow-2: rgba(59, 130, 246, 0.1);
    --theme-auth-card: rgba(26, 32, 53, 0.85);
    --theme-auth-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

:root[data-theme="light"] {
    --accent-soft: rgba(124, 58, 237, 0.08);
    --accent-soft-strong: rgba(124, 58, 237, 0.14);
    --accent-border: rgba(124, 58, 237, 0.25);
}

/* ---------- 月白：冷调纸白 / 月华青，配深墨文字 ---------- */
:root[data-theme="moonwhite"] {
    color-scheme: light;
    --bg-primary: #eef3f5;
    --bg-secondary: #f8fbfc;
    --bg-card: #ffffff;
    --bg-card-hover: #edf3f5;
    --border-color: #d8e3e7;
    --text-primary: #20343b;
    --text-secondary: #516b73;
    --text-muted: #82979d;
    --accent: #4f7c8a;
    --accent-light: #6d9aa6;
    --accent-dark: #3c626e;
    --accent-glow: rgba(79, 124, 138, 0.25);
    --gradient-1: linear-gradient(135deg, #4f7c8a 0%, #7696a0 52%, #b9a98c 100%);
    --gradient-2: linear-gradient(135deg, #3c626e 0%, #8aa8ae 100%);
    --gradient-hero: radial-gradient(ellipse at top, rgba(79, 124, 138, 0.12) 0%, transparent 52%);
    --shadow: 0 4px 20px rgba(32, 52, 59, 0.08);
    --shadow-glow: 0 0 30px rgba(79, 124, 138, 0.18);

    --accent-soft: rgba(79, 124, 138, 0.12);
    --accent-soft-strong: rgba(79, 124, 138, 0.2);
    --accent-border: rgba(79, 124, 138, 0.32);
    --theme-navbar-bg: rgba(238, 243, 245, 0.88);
    --theme-hero-bg: #eef3f5;
    --theme-hero-glow-1: rgba(79, 124, 138, 0.18);
    --theme-hero-glow-2: rgba(185, 169, 140, 0.14);
    --theme-hero-sweep-1: rgba(79, 124, 138, 0.05);
    --theme-hero-sweep-2: rgba(185, 169, 140, 0.08);
    --theme-glass: rgba(255, 255, 255, 0.6);
    --theme-hero-shadow: rgba(32, 52, 59, 0.1);
    --theme-code-bg: #f7fafb;
    --theme-code-header: rgba(32, 52, 59, 0.05);
    --theme-image-filter: brightness(1.02) saturate(0.86) contrast(0.96);
    --theme-er-line: #4f7c8a;
    --theme-er-glow: rgba(79, 124, 138, 0.45);
    --theme-er-current: #2f7f8c;
    --theme-er-current-glow: rgba(47, 127, 140, 0.55);
    --theme-er-spark: #3f6f7a;
    --theme-er-spark-glow: #2f7f8c;
    --theme-er-node: #4f7c8a;
    --theme-auth-glow-1: rgba(79, 124, 138, 0.14);
    --theme-auth-glow-2: rgba(185, 169, 140, 0.1);
    --theme-auth-card: rgba(255, 255, 255, 0.86);
    --theme-auth-shadow: 0 20px 60px rgba(32, 52, 59, 0.12);
}

/* ---------- 夜亭：深墨绿 / 灯笼暖金 ---------- */
:root[data-theme="nightpavilion"] {
    color-scheme: dark;
    --bg-primary: #08130f;
    --bg-secondary: #0e1e19;
    --bg-card: #132823;
    --bg-card-hover: #18332c;
    --border-color: #23423a;
    --text-primary: #eef5ef;
    --text-secondary: #a3b8ad;
    --text-muted: #6f8a7d;
    --accent: #c9a35b;
    --accent-light: #ddbe86;
    --accent-dark: #a8833f;
    --accent-glow: rgba(201, 163, 91, 0.32);
    --gradient-1: linear-gradient(135deg, #c9a35b 0%, #8aa77f 52%, #4e7a6b 100%);
    --gradient-2: linear-gradient(135deg, #a8833f 0%, #3f6b5b 100%);
    --gradient-hero: radial-gradient(ellipse at top, rgba(201, 163, 91, 0.12) 0%, transparent 50%);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(201, 163, 91, 0.25);

    --accent-soft: rgba(201, 163, 91, 0.12);
    --accent-soft-strong: rgba(201, 163, 91, 0.2);
    --accent-border: rgba(201, 163, 91, 0.34);
    --theme-navbar-bg: rgba(8, 19, 15, 0.88);
    --theme-hero-bg: #08130f;
    --theme-hero-glow-1: rgba(201, 163, 91, 0.16);
    --theme-hero-glow-2: rgba(78, 122, 107, 0.18);
    --theme-hero-sweep-1: rgba(78, 122, 107, 0.08);
    --theme-hero-sweep-2: rgba(201, 163, 91, 0.08);
    --theme-glass: rgba(8, 19, 15, 0.55);
    --theme-hero-shadow: rgba(0, 0, 0, 0.5);
    --theme-code-bg: #0d1c17;
    --theme-code-header: rgba(0, 0, 0, 0.22);
    --theme-image-filter: brightness(1.02) saturate(0.92);
    --theme-er-line: #c9a35b;
    --theme-er-glow: rgba(201, 163, 91, 0.5);
    --theme-er-current: #e2c88e;
    --theme-er-current-glow: rgba(226, 200, 142, 0.75);
    --theme-er-spark: #f0d9a8;
    --theme-er-spark-glow: #dfbe7a;
    --theme-er-node: #ddbe86;
    --theme-auth-glow-1: rgba(201, 163, 91, 0.14);
    --theme-auth-glow-2: rgba(78, 122, 107, 0.12);
    --theme-auth-card: rgba(19, 40, 35, 0.82);
    --theme-auth-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ---------- shared decorative layers for the two new themes ---------- */
:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .navbar {
    background: var(--theme-navbar-bg);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .hero {
    background: var(--theme-hero-bg);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .hero::before {
    background:
        radial-gradient(circle at 78% 42%, var(--theme-hero-glow-1), transparent 38%),
        radial-gradient(circle at 12% 18%, var(--theme-hero-glow-2), transparent 42%),
        var(--theme-hero-bg);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .hero::after {
    background: linear-gradient(115deg, transparent 35%, var(--theme-hero-sweep-1) 48%, var(--theme-hero-sweep-2) 50%, transparent 63%);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .hero h1,
:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .hero p {
    text-shadow: none;
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .hero-model-image {
    filter: var(--theme-image-filter);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) :is(.hero-badge, .section-tag) {
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--accent);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .feature-icon {
    background: var(--accent-soft);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .hero-flow {
    background: var(--theme-glass);
    border-color: var(--accent-border);
    box-shadow: 0 12px 40px var(--theme-hero-shadow);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .cta-box::before {
    background: radial-gradient(circle, var(--accent-soft) 0%, transparent 60%);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .hero-preview {
    box-shadow: 0 20px 60px var(--theme-hero-shadow);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .code-window {
    background: var(--theme-code-bg);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .code-window-header {
    background: var(--theme-code-header);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .auth-page::before {
    background: radial-gradient(circle, var(--theme-auth-glow-1) 0%, transparent 60%);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .auth-page::after {
    background: radial-gradient(circle, var(--theme-auth-glow-2) 0%, transparent 60%);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .auth-card {
    background: var(--theme-auth-card);
    box-shadow: var(--theme-auth-shadow);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .auth-input:focus {
    box-shadow: 0 0 0 3px var(--accent-soft-strong);
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .qrcode-refresh {
    background: var(--theme-glass);
    color: var(--text-primary);
}

/* ER-Model 线条与光点 */
:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .er-lines-base path {
    stroke: var(--theme-er-line);
    filter: drop-shadow(0 0 6px var(--theme-er-glow));
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .er-current path {
    stroke: var(--theme-er-current);
    filter: drop-shadow(0 0 5px var(--theme-er-current-glow)) drop-shadow(0 0 12px var(--theme-er-glow));
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .er-sparks circle {
    fill: var(--theme-er-spark);
    filter: drop-shadow(0 0 5px var(--theme-er-spark-glow)) drop-shadow(0 0 10px var(--theme-er-glow));
}

:root:is([data-theme="moonwhite"], [data-theme="nightpavilion"]) .er-nodes circle {
    fill: var(--theme-er-node);
}

:root[data-theme="moonwhite"] .hero-grid {
    opacity: 0.2;
}

:root[data-theme="nightpavilion"] .hero-grid {
    opacity: 0.32;
}

:root[data-theme="moonwhite"] .hero::after {
    opacity: 0.35;
}

:root[data-theme="nightpavilion"] .hero::after {
    opacity: 0.7;
}

/* 月白下的绿色状态标签用深一档，避免浅色文字看不清 */
:root[data-theme="moonwhite"] :is(.guestbook-identity-badge, .message-user-tag) {
    color: #047857;
}

/* =============================================================================
   Theme picker (shared by public pages, login and forgot-password)
   ============================================================================= */
.theme-picker {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.theme-picker .theme-toggle {
    width: auto;
    min-width: 44px;
    height: 38px;
    padding: 0 8px 0 10px;
    gap: 5px;
    border-radius: 999px;
    transform: none;
}

.theme-picker .theme-toggle:hover {
    transform: none;
}

.theme-toggle-icon {
    font-size: 1rem;
    line-height: 1;
}

.theme-toggle-caret {
    font-size: 0.62rem;
    line-height: 1;
    opacity: 0.55;
    transition: transform 0.2s ease;
}

.theme-picker.is-open .theme-toggle-caret {
    transform: rotate(180deg);
}

.theme-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1005;
    width: 202px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--bg-card);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
    animation: themeMenuIn 0.14s ease-out;
}

.theme-menu[hidden] {
    display: none;
}

@keyframes themeMenuIn {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.theme-menu-title {
    padding: 5px 9px 8px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 9px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.86rem;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.theme-option:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.theme-option[aria-checked="true"] {
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--text-primary);
}

.theme-option:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.theme-swatch {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.theme-swatch-dark {
    background: linear-gradient(135deg, #0a0e1a 0 50%, #8b5cf6 50% 100%);
}

.theme-swatch-light {
    background: linear-gradient(135deg, #f8fafc 0 50%, #7c3aed 50% 100%);
}

.theme-swatch-moonwhite {
    background: linear-gradient(135deg, #eef3f5 0 50%, #4f7c8a 50% 100%);
}

.theme-swatch-nightpavilion {
    background: linear-gradient(135deg, #08130f 0 50%, #c9a35b 50% 100%);
}

.theme-name {
    flex: 1;
    min-width: 0;
}

.theme-note {
    margin-left: 4px;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.theme-check {
    width: 14px;
    flex: 0 0 auto;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
    opacity: 0;
}

.theme-option[aria-checked="true"] .theme-check {
    opacity: 1;
}

@media (max-width: 768px) {
    .theme-picker .theme-toggle {
        min-width: 38px;
        padding: 0 8px;
    }

    .theme-toggle-caret {
        display: none;
    }

    .theme-menu {
        width: 188px;
    }
}
