/**
 * 主站壳（index.php）：氛围背景、沉浸式页面（会员中心 / 无限画布「全部项目」）、登录后的进场。
 * 配套脚本：includes/ambient_shell.js（背景与进场）、includes/index_spa.js 的 syncShellChrome()（按页面切换 body 类）。
 *
 * 选择器刻意写成 html… body… 的长形式：壳页的深色样式（design-dark*.css）大量使用 !important，
 * 这里需要更高的优先级才能把那几层底色让出来。
 */

/* ── 背景：只在需要的页面显示，垫在所有内容下面 ── */
#siteAmbient {
    display: none;
    z-index: -1;
}

html.amb-on #siteAmbient {
    display: block;
}

html.amb-on {
    background: var(--amb-bg-solid);
}

html.amb-on body,
html.amb-on body .container,
html.amb-on body .content-wrapper,
html.amb-on body .main-wrapper,
html.amb-on body .main-content,
html.amb-on body .content-frame {
    background: transparent !important;
}

/* 工作台：两团光晕不跟着鼠标走，停在各自的原位当环境光（数值与 ambient_bg.css 里的初始位置一致）。
   ambient_bg.js 仍会往行内样式里写鼠标位置，这里用 !important 压住；离开工作台后恢复跟随。
   粒子与鼠标之间的连线不受影响。 */
html body.page-workbench #siteAmbient .amb-bg-glow--a {
    transform: translate3d(50vw, 30vh, 0) !important;
}

html body.page-workbench #siteAmbient .amb-bg-glow--b {
    transform: translate3d(78vw, 72vh, 0) !important;
}

/* ── 沉浸式页面：不显示左侧导航，左上角的按钮变成「返回」 ── */
html body.shell-immersive .sidebar {
    width: 0 !important;
    min-width: 0 !important;
    border-right-width: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

html body.shell-immersive .sidebar > * {
    opacity: 0 !important;
    pointer-events: none !important;
}

html body.shell-immersive .main-wrapper {
    flex: 1;
}

html body.shell-immersive .sidebar-toggle-fab {
    display: flex !important;
}

/* 手机上左上角本来是抽屉菜单按钮，沉浸式页面里让给返回按钮 */
html body.shell-immersive .mobile-menu-toggle {
    display: none !important;
}

.sidebar-toggle-fab .fab-icon-back {
    display: none;
}

html body.shell-immersive .sidebar-toggle-fab .fab-icon-menu {
    display: none;
}

html body.shell-immersive .sidebar-toggle-fab .fab-icon-back {
    display: block;
}

/* 无限画布首页顶部那条 50px 的滚动遮罩：「全部项目」打开时会盖住它的标题栏 */
html body.canvas-hub-all-open .main-content::before {
    display: none !important;
}

/* ── 左上角按钮在氛围背景上的质感（工作台 / 会员中心 / 全部项目） ── */
html.amb-on body .sidebar-toggle-fab {
    border-radius: 12px;
    background: rgba(28, 28, 30, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: none !important;
    -webkit-backdrop-filter: saturate(180%) blur(20px) !important;
    backdrop-filter: saturate(180%) blur(20px) !important;
    color: rgba(255, 255, 255, 0.82) !important;
    transition: background 0.25s ease, border-color 0.25s ease, color 0.2s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html.amb-on body .sidebar-toggle-fab svg {
    color: inherit !important;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html.amb-on body .sidebar-toggle-fab:hover {
    background: rgba(44, 44, 48, 0.78) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
}

html.amb-on body.shell-immersive .sidebar-toggle-fab:hover svg {
    transform: translateX(-2px);
}

html.amb-on body .sidebar-toggle-fab:active {
    transform: scale(0.94);
}

html.amb-on[data-theme="light"] body .sidebar-toggle-fab {
    background: rgba(255, 255, 255, 0.72) !important;
    border-color: rgba(15, 18, 40, 0.1) !important;
    color: rgba(29, 29, 31, 0.78) !important;
}

html.amb-on[data-theme="light"] body .sidebar-toggle-fab:hover {
    background: rgba(255, 255, 255, 0.96) !important;
    border-color: rgba(15, 18, 40, 0.18) !important;
    color: #1d1d1f !important;
}

/* ── 登录后的进场 ── */
/* 只给 html 上底色：body 必须保持透明（见上方 html.amb-on body），否则会盖住 z-index:-1 的 #siteAmbient */
html.amb-intro {
    background: #0a0a0c !important;
}

/* 进场期间只留背景：顶栏、左上角按钮、侧栏、客服按钮等先不显示。
   通往子页 iframe 的那一条（.container > .content-wrapper > .main-wrapper > .main-content）不隐藏：
   工作台自己把内容压到几乎全透明（home_workbench.css 的 hw-intro-wait），这样浏览器会提前把它画好，
   放行时直接开始动画，不会在第一帧才去绘制整页内容而顿一下。 */
html.amb-intro body > *:not(#siteAmbient):not(.container),
html.amb-intro body > .container > *:not(.content-wrapper),
html.amb-intro body > .container > .content-wrapper > *:not(.main-wrapper),
html.amb-intro body > .container > .content-wrapper > .main-wrapper > *:not(.main-content) {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* 工作台还没报到（它的首屏脚本调 AmbientShell.introArm()，那时它已经是「几乎全透明」的等待状态）之前，
   子页区域也先不显示：不让加载到一半的 iframe 露出来 */
html.amb-intro:not(.amb-intro-armed) body > .container .main-content {
    opacity: 0 !important;
}

/* 放行：上面这些一起淡入。子页所在的容器不参与（它的内容由工作台自己的动画带出来，
   两层透明度动画叠在一起既多一层离屏合成，也会让工作台显得出来得慢）。 */
html.amb-intro-reveal body > *:not(#siteAmbient):not(.container),
html.amb-intro-reveal body > .container > *:not(.content-wrapper),
html.amb-intro-reveal body > .container > .content-wrapper > *:not(.main-wrapper),
html.amb-intro-reveal body > .container > .content-wrapper > .main-wrapper > *:not(.main-content) {
    animation: ambShellReveal 0.45s ease both;
}

@keyframes ambShellReveal {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    html.amb-on body .sidebar-toggle-fab,
    html.amb-on body .sidebar-toggle-fab svg {
        transition: none;
    }

    html.amb-intro-reveal body > *:not(#siteAmbient):not(.container),
    html.amb-intro-reveal body > .container > *:not(.content-wrapper),
    html.amb-intro-reveal body > .container > .content-wrapper > *:not(.main-wrapper),
    html.amb-intro-reveal body > .container > .content-wrapper > .main-wrapper > *:not(.main-content) {
        animation: none;
    }
}
