/* 背景画：星夜烛光（assets/bg/，程序绘制的原创图，来源见该目录 README.md）。
   几层都在粒子层 #particles（z-index 0）与内容之下，不接收点击，不进分享图与打印。
   body::before 静态底图：四角金色卷草贴在视口四角（不随裁切变形）；底图横屏、竖屏各一张；
                叠一层当前主题底色（--bg）让不同卡面主题的色调协调，中间内容区再压暗一些，保证文字对比度。
   body::after  烛光：与底图同构图的光晕层，系统未开「减少动态效果」时轻轻闪动（只动 opacity）。
   竖屏（手机）另有 html::after 一弯新月：内容铺满整宽，亮月不能压在标题和说明文字后面，所以不画进底图，
                放在页头的空处——首页在标题与右上按钮之间，其余页面（左边返回、中间标题）在右上角；切换页面时缓缓移过去。
                竖屏只留下方两角卷草（上方两角正好压着返回按钮与页头按钮），烛光也调暗一些（文字会滚到底部）。 */
:root { --bg-tint: rgba(0,0,0,0); --bg-corner: clamp(110px, 21vmin, 250px); }
@supports (color: color-mix(in srgb, red 50%, transparent)) {
  :root { --bg-tint: color-mix(in srgb, var(--bg, #080A0D) 26%, transparent); }
}
body::before, body::after {
  content: ""; position: fixed; left: 0; top: 0; width: 100%; height: 100vh; height: 100lvh;
  z-index: -1; pointer-events: none;
}
body::before {
  background:
    url("assets/bg/corner-tl.svg") left 6px top 6px / var(--bg-corner) no-repeat,
    url("assets/bg/corner-tr.svg") right 6px top 6px / var(--bg-corner) no-repeat,
    url("assets/bg/corner-bl.svg") left 6px bottom 6px / var(--bg-corner) no-repeat,
    url("assets/bg/corner-br.svg") right 6px bottom 6px / var(--bg-corner) no-repeat,
    radial-gradient(ellipse 26% 60% at 50% 42%, rgba(4,5,12,.42), rgba(4,5,12,0) 100%),
    linear-gradient(var(--bg-tint), var(--bg-tint)),
    url("assets/bg/night-landscape.webp") center / cover no-repeat,
    var(--bg, #080A0D);
}
body::after { background: url("assets/bg/night-landscape-glow.webp") center / cover no-repeat; opacity: .85; }
@media (orientation: portrait) {
  :root { --bg-corner: clamp(84px, 24vmin, 180px); }
  body::before {
    background:
      url("assets/bg/corner-bl.svg") left 4px bottom 4px / var(--bg-corner) no-repeat,
      url("assets/bg/corner-br.svg") right 4px bottom 4px / var(--bg-corner) no-repeat,
      linear-gradient(to bottom, rgba(4,5,12,.1), rgba(4,5,12,.45) 22%, rgba(4,5,12,.5) 68%, rgba(4,5,12,.3)),
      linear-gradient(var(--bg-tint), var(--bg-tint)),
      url("assets/bg/night-portrait.webp") center bottom / cover no-repeat,   /* 平板竖屏比图宽，靠底对齐保住烛台 */
      var(--bg, #080A0D);
  }
  body::after { background: url("assets/bg/night-portrait-glow.webp") center bottom / cover no-repeat; opacity: .6; }
  html::after {
    content: ""; position: fixed; z-index: -1; pointer-events: none;
    top: calc(env(safe-area-inset-top) - 6px); right: 12px; width: 76px; height: 76px;
    background: url("assets/bg/night-moon.webp") center / contain no-repeat;
  }
  html:has(body [data-screen="home"]:not([hidden]))::after { transform: translateX(calc(50px - 50vw)); }
}
@media (prefers-reduced-motion: no-preference) {
  body::after { will-change: opacity; animation: tarot-bg-candle 3.6s ease-in-out infinite; }
  html::after { transition: transform .9s cubic-bezier(.3,.7,.2,1); }
  @media (orientation: portrait) { body::after { animation-name: tarot-bg-candle-soft; } }
}
@keyframes tarot-bg-candle {
  0%, 100% { opacity: .85; }
  18% { opacity: .7; }
  32% { opacity: .95; }
  47% { opacity: .78; }
  63% { opacity: 1; }
  80% { opacity: .74; }
}
@keyframes tarot-bg-candle-soft {
  0%, 100% { opacity: .6; }
  18% { opacity: .5; }
  32% { opacity: .66; }
  47% { opacity: .55; }
  63% { opacity: .7; }
  80% { opacity: .52; }
}
@media print { body::before, body::after, html::after { display: none; } }
