/* ============================================================
   Site background: "deep sea" (default) + "grid" (alternative)
   Pure CSS, zero images, GPU-friendly.
   ============================================================ */

/* ---------- 1. page canvas ---------- */
body {
  background-color: #d8ecfb;
  background-image:
    radial-gradient(1100px 520px at 50% -6%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 70%),
    url("/img/water-ripples.svg"),
    linear-gradient(rgba(216, 236, 251, 0.58), rgba(216, 236, 251, 0.74)),
    url("/img/background.jpg");
  background-repeat: no-repeat, repeat, no-repeat, no-repeat;
  background-size: auto, 240px 240px, cover, cover;
  background-attachment: scroll, scroll, fixed, fixed;
  transition: background-color 0.4s ease;
}

html[data-theme="dark"] body {
  background-color: #0f161e;
  background-image:
    radial-gradient(1100px 520px at 50% -6%, #16232f 0%, rgba(22, 35, 47, 0) 72%),
    radial-gradient(680px 520px at -6% 34%, rgba(75, 151, 221, 0.1), transparent 72%),
    radial-gradient(680px 520px at 106% 62%, rgba(75, 151, 221, 0.08), transparent 72%),
    linear-gradient(rgba(15, 22, 30, 0.82), rgba(15, 22, 30, 0.9)),
    url("/img/background.jpg");
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
  background-size: auto, auto, auto, cover, cover;
  background-attachment: scroll, fixed, fixed, fixed, fixed;
}

/* ---------- 2. hero: light rays + floating dust ---------- */
#page-header::before {
  content: '';
  position: absolute;
  inset: -20% -10%;
  background: repeating-linear-gradient(
    104deg,
    transparent 0 420px,
    rgba(255, 255, 255, 0.06) 420px 640px,
    transparent 640px 900px
  );
  mix-blend-mode: soft-light;
  filter: blur(1.5px);
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 82%);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 82%);
  animation: bg-ray 46s linear infinite;
  pointer-events: none;
  z-index: 0;
}

#page-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.55) 0 1px, transparent 1.6px),
    radial-gradient(circle, rgba(255, 255, 255, 0.4) 0 1px, transparent 1.6px),
    radial-gradient(circle, rgba(255, 255, 255, 0.3) 0 1px, transparent 1.6px);
  background-size: 260px 220px, 180px 160px, 340px 300px;
  background-position: 0 0, 90px 40px, 160px 120px;
  animation: bg-dust 26s ease-in-out infinite alternate;
  pointer-events: none;
  opacity: 0.85;
  z-index: 0;
}

@keyframes bg-ray {
  to { transform: translateX(-360px); }
}

@keyframes bg-dust {
  from { transform: translateY(0); }
  to { transform: translateY(-16px); }
}

/* ---------- 3. "grid" alternative ---------- */
html[data-bg="pattern"] body {
  background-color: #d8ecfb;
  background-image: radial-gradient(circle, #b9dcf3 1px, transparent 1px);
  background-size: 22px 22px;
  background-attachment: scroll;
}

html[data-theme="dark"][data-bg="pattern"] body {
  background-color: #0e141b;
  background-image: radial-gradient(circle, #1e2c3a 1px, transparent 1px);
  background-size: 22px 22px;
}

html[data-bg="pattern"] #page-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(44, 90, 110, 0.34), rgba(44, 90, 110, 0.06));
  mix-blend-mode: normal;
  animation: none;
  z-index: 0;
}

html[data-bg="pattern"] #page-header::after {
  display: none;
}

/* ---------- 4. content area: waterline + floating cards ---------- */
#content-inner {
  position: relative;
  z-index: 1;
  background-image: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.5) 0,
    rgba(255, 255, 255, 0.18) 150px,
    rgba(255, 255, 255, 0) 320px
  );
  background-repeat: no-repeat;
}

/* wave edge: the sea surface where the hero meets the content */
#content-inner::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -47px;
  height: 48px;
  background: #d8ecfb;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 48' preserveAspectRatio='none'%3E%3Cpath d='M0 26 Q 40 8 80 26 T 160 26 L160 48 L0 48 Z' fill='%23fff'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 48' preserveAspectRatio='none'%3E%3Cpath d='M0 26 Q 40 8 80 26 T 160 26 L160 48 L0 48 Z' fill='%23fff'/%3E%3C/svg%3E");
  -webkit-mask-size: 160px 48px;
  mask-size: 160px 48px;
  -webkit-mask-repeat: repeat-x;
  mask-repeat: repeat-x;
  pointer-events: none;
}

html[data-theme="dark"] #content-inner::before {
  background: #0f161e;
}

html[data-theme="dark"] #content-inner {
  background-image: linear-gradient(
    180deg,
    rgba(5, 12, 20, 0.42) 0,
    rgba(5, 12, 20, 0.16) 150px,
    rgba(5, 12, 20, 0) 360px
  );
}

#recent-posts > .recent-post-item,
#aside-content .card-widget {
  border-radius: 18px;
  box-shadow: 0 10px 32px rgba(31, 66, 110, 0.07);
  transition: transform 0.28s ease, box-shadow 0.28s ease;
}

#recent-posts > .recent-post-item:hover,
#aside-content .card-widget:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(31, 66, 110, 0.12);
}

html[data-theme="dark"] #recent-posts > .recent-post-item,
html[data-theme="dark"] #aside-content .card-widget {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

#recent-posts > .recent-post-item {
  margin-bottom: 22px;
}

@media (min-width: 1500px) {
  #content-inner {
    max-width: 1240px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* ---------- 5. 页面底部工具条（背景切换 + 反馈）---------- */
/* 不再浮在窗口右下角，避免遮住正文 / 侧栏按钮 */
.bottom-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 16px 8px;
}

.bg-toggle,
.fb-btn {
  padding: 5px 14px;
  border: 1px solid #dbe6f2;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #3a556d;
  font: 12px/1.7 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.bg-toggle:hover,
.fb-btn:hover {
  border-color: #4b97dd;
  color: #2f7fd0;
}

html[data-theme="dark"] .bg-toggle,
html[data-theme="dark"] .fb-btn {
  background: rgba(26, 36, 48, 0.9);
  border-color: #2d3c50;
  color: #c9d8e8;
}

@media (max-width: 767px) {
  .bottom-tools {
    padding: 14px 12px 6px;
    gap: 8px;
  }

  .bg-toggle,
  .fb-btn {
    font-size: 11px;
    padding: 4px 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #page-header::before,
  #page-header::after {
    animation: none !important;
  }

  #recent-posts > .recent-post-item,
  #aside-content .card-widget {
    transition: none;
  }
}

/* ============================================================
   Halloween variant：暗紫夜色 + 蝙蝠 + 南瓜灯（纯 CSS，无图片）
   ============================================================ */
html[data-bg="halloween"] body {
  background-color: #140b1c;
  background-image:
    radial-gradient(900px 480px at 50% -8%, rgba(255, 158, 66, 0.14) 0%, rgba(255, 158, 66, 0) 68%),
    radial-gradient(700px 520px at -8% 30%, rgba(126, 74, 196, 0.20), transparent 70%),
    radial-gradient(700px 520px at 108% 62%, rgba(58, 168, 128, 0.14), transparent 70%),
    linear-gradient(180deg, #1a0f24 0%, #120b19 55%, #0c1410 100%);
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
  background-size: auto, auto, auto, cover;
  background-attachment: scroll, fixed, fixed, fixed;
  transition: background-color 0.5s ease;
}

/* 蝙蝠：三只，用 border 拼出翅膀，各自飘 */
html[data-bg="halloween"] body::before,
html[data-bg="halloween"] body::after {
  content: '';
  position: fixed;
  z-index: 1;
  pointer-events: none;
  width: 34px;
  height: 14px;
  background:
    radial-gradient(circle at 50% 40%, #0b0710 0 3px, transparent 3px),
    conic-gradient(from 200deg at 50% 100%, #0b0710 0 14deg, transparent 14deg 166deg, #0b0710 166deg 180deg);
  filter: drop-shadow(0 0 6px rgba(255, 150, 60, 0.25));
  opacity: 0.75;
  animation: halloween-bat 18s linear infinite;
}

html[data-bg="halloween"] body::before {
  top: 18%;
  left: -6%;
}

html[data-bg="halloween"] body::after {
  top: 46%;
  left: -12%;
  transform: scale(0.8);
  animation-duration: 26s;
  animation-delay: -9s;
}

@keyframes halloween-bat {
  0%   { transform: translate3d(0, 0, 0) scale(1) rotate(-6deg); }
  25%  { transform: translate3d(30vw, -26px, 0) scale(1.05) rotate(6deg); }
  50%  { transform: translate3d(60vw, 14px, 0) scale(0.95) rotate(-4deg); }
  75%  { transform: translate3d(88vw, -18px, 0) scale(1.02) rotate(5deg); }
  100% { transform: translate3d(115vw, 6px, 0) scale(1) rotate(-6deg); }
}

/* 头图：暖橙月光 */
html[data-bg="halloween"] #page-header::before {
  background:
    radial-gradient(520px 300px at 76% 22%, rgba(255, 176, 84, 0.30), transparent 70%),
    radial-gradient(720px 420px at 20% 70%, rgba(126, 74, 196, 0.24), transparent 72%);
  mix-blend-mode: screen;
}

/* 南瓜灯：挂在页面右下角的装饰（纯 SVG 内联） */
html[data-bg="halloween"]::after {
  content: '';
  position: fixed;
  right: 18px;
  bottom: 96px;
  width: 54px;
  height: 54px;
  z-index: 2;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><ellipse cx='32' cy='36' rx='24' ry='21' fill='%23f28a1f'/><path d='M32 15c2-5 6-6 9-3' stroke='%236b4a1a' stroke-width='3' fill='none' stroke-linecap='round'/><path d='M18 33l8-6-8-1z' fill='%23201206'/><path d='M46 33l-8-6 8-1z' fill='%23201206'/><path d='M22 45q10 8 20 0' stroke='%23201206' stroke-width='3' fill='none' stroke-linecap='round'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 12px rgba(255, 150, 50, 0.55));
  animation: halloween-glow 3.2s ease-in-out infinite;
}

@keyframes halloween-glow {
  0%, 100% { opacity: 0.85; filter: drop-shadow(0 0 10px rgba(255, 150, 50, 0.45)); }
  50%      { opacity: 1;    filter: drop-shadow(0 0 18px rgba(255, 170, 70, 0.75)); }
}

/* 深色模式下再压暗一点，避免刺眼 */
html[data-theme="dark"][data-bg="halloween"] body {
  background-color: #0d0713;
}

/* 鲸鱼娘气泡换成南瓜色描边 */
html[data-bg="halloween"] .wg-bubble {
  border-color: #a85e1d;
  background: linear-gradient(180deg, #241626 0%, #1b1120 100%);
  color: #ffe9cf;
}

html[data-bg="halloween"] .wg-bubble::after {
  background: #1b1120;
  border-color: #a85e1d;
}

@media (prefers-reduced-motion: reduce) {
  html[data-bg="halloween"] body::before,
  html[data-bg="halloween"] body::after,
  html[data-bg="halloween"]::after { animation: none; }
}

/* 头图也要换：Butterfly 给 #page-header 写了内联 background-image，必须 !important */
html[data-bg="halloween"] #page-header {
  background-image:
    radial-gradient(520px 340px at 78% 26%, rgba(255, 186, 96, 0.42) 0%, rgba(255, 186, 96, 0) 62%),
    radial-gradient(900px 560px at 12% 78%, rgba(126, 74, 196, 0.45) 0%, rgba(126, 74, 196, 0) 70%),
    linear-gradient(170deg, #1d1029 0%, #170d20 48%, #0f1a14 100%) !important;
  background-size: cover, cover, cover !important;
  background-position: center !important;
}

/* 头图里的光带换成暗紫调 */
html[data-bg="halloween"] #page-header::before {
  background:
    radial-gradient(480px 300px at 74% 24%, rgba(255, 176, 84, 0.26), transparent 70%),
    radial-gradient(640px 420px at 18% 72%, rgba(126, 74, 196, 0.22), transparent 72%);
}

/* 底部波浪压暗，避免白得跳 */
html[data-bg="halloween"] #page-header::after {
  filter: brightness(0.55) sepia(0.25) hue-rotate(255deg);
}

/* 海底生物在万圣节收起来，免得像鱼缸 */
html[data-bg="halloween"] .sea-creature,
html[data-bg="halloween"] .sea-creatures {
  opacity: 0.18;
}

/* 内容区与页脚也压暗，避免往下滚还是蓝色 */
html[data-bg="halloween"] #body-wrap { background: #120b19; }
html[data-bg="halloween"] #footer { background: #0c1410; }
html[data-bg="halloween"] #footer .footer-copyright,
html[data-bg="halloween"] #footer a { color: #cbb9dd; }
html[data-bg="halloween"] .card-widget,
html[data-bg="halloween"] .recent-post-item { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); }

/* ============================================================
   节日主题框架
   ------------------------------------------------------------
   加一个节日：
     1) bg-switch.js 的 THEMES 里加 { key, label, from:[月,日], to:[月,日] }
     2) 在这里写 html[data-bg="<key>"] 的规则（头图要用 !important 覆盖内联样式）
   ============================================================ */

/* ---------- 圣诞 ---------- */
html[data-bg="christmas"] #page-header {
  background-image:
    radial-gradient(560px 340px at 72% 24%, rgba(255, 235, 200, 0.28) 0%, rgba(255, 235, 200, 0) 66%),
    radial-gradient(720px 480px at 16% 74%, rgba(30, 90, 60, 0.42) 0%, rgba(30, 90, 60, 0) 72%),
    linear-gradient(170deg, #0b2018 0%, #0a1a14 52%, #101a22 100%) !important;
  background-size: cover, cover, cover !important;
  background-position: center !important;
}

html[data-bg="christmas"] #page-header::after {
  filter: brightness(0.6) hue-rotate(90deg) saturate(0.8);
}

html[data-bg="christmas"] #body-wrap { background: #0a1a14; }
html[data-bg="christmas"] #footer { background: #071310; }

/* 飘雪 */
html[data-bg="christmas"] body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 12% 8%, #fff, transparent),
    radial-gradient(2px 2px at 28% 22%, rgba(255,255,255,.9), transparent),
    radial-gradient(1.6px 1.6px at 46% 4%, #fff, transparent),
    radial-gradient(2px 2px at 64% 16%, rgba(255,255,255,.85), transparent),
    radial-gradient(1.8px 1.8px at 82% 10%, #fff, transparent);
  background-size: 100% 100%;
  opacity: 0.55;
  animation: xmas-snow 9s linear infinite;
}

@keyframes xmas-snow {
  from { transform: translateY(-8%); }
  to   { transform: translateY(8%); }
}

/* 圣诞树剪影（右下角，纯 CSS 三角） */
html[data-bg="christmas"]::after {
  content: '';
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: 0;
  height: 0;
  border-left: 22px solid transparent;
  border-right: 22px solid transparent;
  border-bottom: 46px solid #14503a;
  z-index: 2;
  pointer-events: none;
  filter: drop-shadow(0 0 10px rgba(80, 220, 150, 0.35));
}

html[data-bg="christmas"] .wg-bubble {
  border-color: #1f6b4a;
  background: linear-gradient(180deg, #10241c 0%, #0c1b15 100%);
  color: #e8fff2;
}

html[data-bg="christmas"] .wg-bubble::after {
  background: #0c1b15;
  border-color: #1f6b4a;
}

/* ---------- 元旦 ---------- */
html[data-bg="newyear"] #page-header {
  background-image:
    radial-gradient(600px 360px at 70% 22%, rgba(255, 214, 120, 0.34) 0%, rgba(255, 214, 120, 0) 64%),
    radial-gradient(760px 500px at 14% 76%, rgba(196, 60, 60, 0.34) 0%, rgba(196, 60, 60, 0) 72%),
    linear-gradient(170deg, #241016 0%, #1a0c12 55%, #10131c 100%) !important;
  background-size: cover, cover, cover !important;
  background-position: center !important;
}

html[data-bg="newyear"] #page-header::after {
  filter: brightness(0.6) sepia(0.2) hue-rotate(320deg);
}

html[data-bg="newyear"] #body-wrap { background: #1a0c12; }
html[data-bg="newyear"] #footer { background: #12070c; }

/* 金色纸屑 */
html[data-bg="newyear"] body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    radial-gradient(3px 3px at 18% 12%, #ffd479, transparent),
    radial-gradient(2.6px 2.6px at 38% 30%, #ffb648, transparent),
    radial-gradient(3px 3px at 58% 8%, #fff0c2, transparent),
    radial-gradient(2.4px 2.4px at 76% 26%, #ffd479, transparent),
    radial-gradient(3px 3px at 92% 14%, #ffb648, transparent);
  opacity: 0.6;
  animation: newyear-fall 12s linear infinite;
}

@keyframes newyear-fall {
  from { transform: translateY(-10%) rotate(0deg); }
  to   { transform: translateY(10%) rotate(8deg); }
}

html[data-bg="newyear"] .wg-bubble {
  border-color: #b8862f;
  background: linear-gradient(180deg, #2a1418 0%, #1e0f13 100%);
  color: #ffe9c9;
}

html[data-bg="newyear"] .wg-bubble::after {
  background: #1e0f13;
  border-color: #b8862f;
}
