/* ============================================================================
 * wallpaper.css —— 「我的」页壁纸功能样式（T4）
 *
 * ## 为什么样式必须放在这个文件里（⛔ 不能写在 js 里）
 * ```
 *   index.html 第 6 行有：
 *     <meta http-equiv="Content-Security-Policy"
 *           content="default-src 'self'; script-src 'self'; style-src 'self'; ...">
 *
 *   ★ style-src 'self' ⇒ **内联样式一律被拦**：
 *       · <style> 标签                 ✗
 *       · el.style.cssText = '...'     ✗（会被 CSP 拒绝，且**静默不生效**）
 *       · el.style.color = '...'       ✗
 *   ⇒ 所以本功能**所有**外观都写在 wallpaper.css 里，
 *     js 里只用 classList 切状态（加/删 class 不属于 style-src 管辖）。
 * ```
 *
 * ## 命名前缀
 * ```
 *   一律 wp- / agh-wp-：避免与 bundle 的 hash class 及其它 15 个补丁 css 撞名。
 * ```
 *
 * ## 移动端
 * ```
 *   默认双列；≥ 640px 三列；≥ 1024px 四列。
 *   小屏（< 380px）单列 —— 因为 2 列时每格只有 ~160px，缩略图看不清。
 * ```
 * ========================================================================== */

/* ── 「我的」页里的入口按钮 ───────────────────────────────────────────── */
.agh-wp-entry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  /* ★ 2026-10-30【反馈 645af9c0】原来 border:0 + 浅灰底 ⇒ 看着像残留元素。
   *   加一圈可见边框 + 更大的点击区，让它读起来"是个能点的地方"。
   *   ⛔ 不改颜色体系，只用 currentColor 描边，深浅色模式都自适应。
   */
  margin: 8px 0 0;
  min-height: 40px;
  padding: 10px 18px;
  border: 1px solid currentColor;
  border-radius: 10px;
  background: rgba(127, 127, 127, 0.14);
  color: inherit;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.16s ease, transform 0.12s ease;
}

.agh-wp-entry:hover {
  background: rgba(127, 127, 127, 0.22);
}

.agh-wp-entry:active {
  transform: scale(0.97);
}

.agh-wp-entry:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* ── 隐藏开关 ────────────────────────────────────────────────────────── */
/* ★ 为什么用 class 而不是 js 里写 style.display
 *   CSP style-src 'self' ⇒ el.style.display = 'none' 会被拒 ⇒ 静默失效
 *   ⇒ 一律用 classList.add/remove 切这两个类
 */
.agh-wp-hidden {
  display: none !important;
}

/* 面板打开时锁住页面滚动（加在 <html> 上） */
html.agh-wp-noscroll,
html.agh-wp-noscroll body {
  overflow: hidden;
}

/* ── 遮罩层 ──────────────────────────────────────────────────────────── */
.agh-wp-mask {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.62);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  overscroll-behavior: contain;
}

/* ── 面板 ────────────────────────────────────────────────────────────── */
.agh-wp-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1040px;
  max-height: min(86vh, 900px);
  border-radius: 16px;
  overflow: hidden;
  background: #14161a;
  color: #f2f4f7;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

/* 浅色主题跟随（bundle 用 html[data-theme] 或 .dark，两者都兜） */
html[data-theme="light"] .agh-wp-panel,
:root:not(.dark) .agh-wp-panel {
  background: #ffffff;
  color: #1c1f24;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
}

/* ── 头部 ────────────────────────────────────────────────────────────── */
.agh-wp-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(127, 127, 127, 0.22);
}

.agh-wp-title {
  flex: 1 1 auto;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.agh-wp-count {
  flex: 0 0 auto;
  font-size: 12px;
  opacity: 0.62;
  white-space: nowrap;
}

.agh-wp-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(127, 127, 127, 0.16);
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.agh-wp-close:hover {
  background: rgba(127, 127, 127, 0.28);
}

.agh-wp-close:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* ── 滚动区 + 网格 ───────────────────────────────────────────────────── */
.agh-wp-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 20px;
}

.agh-wp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 640px) {
  .agh-wp-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .agh-wp-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }
}

/* 极窄屏：2 列每格不足 160px，缩略图已看不出内容 ⇒ 回单列 */
@media (max-width: 379px) {
  .agh-wp-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── 单个格子 ────────────────────────────────────────────────────────── */
.agh-wp-cell {
  margin: 0;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(127, 127, 127, 0.1);
}

.agh-wp-thumb {
  display: block;
  width: 100%;
  /* 固定 4:5 竖屏比例 —— 17 张实测都是竖图（w/h ≈ 0.32~0.57）
     ★ 用 padding 撑高而不是写死 px，避免加载前后跳动（CLS） */
  aspect-ratio: 4 / 5;
  border: 0;
  padding: 0;
  background: rgba(127, 127, 127, 0.12);
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.agh-wp-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.22s ease;
}

.agh-wp-thumb:hover img {
  transform: scale(1.04);
}

.agh-wp-thumb:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -2px;
}

/* ── 大图预览 ────────────────────────────────────────────────────────── */
.agh-wp-view {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.94);
}

.agh-wp-view-img {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.agh-wp-view-img img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

.agh-wp-view-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(0, 0, 0, 0.6);
  color: #f2f4f7;
}

.agh-wp-meta {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  line-height: 1.5;
  opacity: 0.78;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agh-wp-dl {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 0;
  border-radius: 10px;
  background: #3d7eff;
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.16s ease, transform 0.12s ease;
}

.agh-wp-dl:hover {
  background: #2f6ae8;
}

.agh-wp-dl:active {
  transform: scale(0.97);
}

.agh-wp-dl:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.agh-wp-back {
  flex: 0 0 auto;
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 10px;
  background: transparent;
  color: #f2f4f7;
  font: inherit;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.agh-wp-back:hover {
  background: rgba(255, 255, 255, 0.12);
}

.agh-wp-back:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* ── 状态行（加载中 / 失败 / 空）─────────────────────────────────────── */
.agh-wp-state {
  padding: 26px 8px;
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
  opacity: 0.7;
}

/* ── 减少动效偏好 ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .agh-wp-entry,
  .agh-wp-thumb img,
  .agh-wp-dl {
    transition: none;
  }

  .agh-wp-entry:active,
  .agh-wp-dl:active {
    transform: none;
  }

  .agh-wp-thumb:hover img {
    transform: none;
  }
}

/* ── 打印时隐藏（壁纸面板不该出现在纸上）─────────────────────────────── */
@media print {
  .agh-wp-mask {
    display: none !important;
  }
}


/* ============================================================================
 * 壁纸设为页面背景（★ 2026-10-30【站长】「壁纸…还没做好」）
 *
 * ## 为什么全写在这里
 *   CSP 是 style-src 'self' ⇒ JS 里 ⛔ 不许 el.style.xxx / setProperty / <style>。
 *   ⇒ 全部外观在本文件；JS 只切 html 上的 className（classList）。
 *
 * ## 为什么只在 html.agh-wp-on 时把 body 背景让出来
 *   否则全站会变透明 —— 那是默认状态绝不该发生的事。
 * ========================================================================== */
html.agh-wp-on {
  background-attachment: fixed !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  background-size: cover !important;
}

html.agh-wp-on body {
  background: transparent !important;
}

/* ★★★ 2026-10-30【实测修复】还有一层把壁纸盖住了。
 *
 * 站点里有一个全屏固定层：
 *     .bg { position: fixed; inset: 0; z-index: 0;
 *           background-color: var(--bg-base);      ← 不透明底色
 *           background-image: var(--bg-glow-1), var(--bg-glow-2); }
 * 它铺满视口且**不透明**。而 `html` 的背景画在最底层的 canvas 上，
 * 永远在所有元素之下 ⇒ 只把 body 设透明**不够**，壁纸仍被 .bg 完全遮住。
 *
 * 实测症状（真实浏览器）：html 上确实有 `wp-1 agh-wp-on` 两个类，
 *   但页面看上去和没设壁纸一模一样 —— **类对了、图也在、就是看不见**。
 *
 * 修法：只在"已经启用壁纸"时把这个装饰层隐掉。
 *   ⛔ 不用 display:none（会改变层叠上下文，可能影响其它 fixed 元素）；
 *   ✅ 用 opacity:0 —— 不参与布局、不影响 z-index 关系，且可被过渡。
 *   ⛔ 默认状态（没有 agh-wp-on）完全不受影响。
 */
html.agh-wp-on .bg {
  opacity: 0 !important;
}

html.agh-wp-on.wp-1 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_1.jpg") !important; }
html.agh-wp-on.wp-2 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_2.jpg") !important; }
html.agh-wp-on.wp-3 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_3.jpg") !important; }
html.agh-wp-on.wp-4 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_4.jpg") !important; }
html.agh-wp-on.wp-5 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_5.jpg") !important; }
html.agh-wp-on.wp-6 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_6.jpg") !important; }
html.agh-wp-on.wp-7 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_7.jpg") !important; }
html.agh-wp-on.wp-8 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_8.jpg") !important; }
html.agh-wp-on.wp-9 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_9.jpg") !important; }
html.agh-wp-on.wp-10 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_10.jpg") !important; }
html.agh-wp-on.wp-11 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_11.jpg") !important; }
html.agh-wp-on.wp-12 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_12.jpg") !important; }
html.agh-wp-on.wp-13 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_13.jpg") !important; }
html.agh-wp-on.wp-14 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_14.jpg") !important; }
html.agh-wp-on.wp-15 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_15.jpg") !important; }
html.agh-wp-on.wp-16 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_16.jpg") !important; }
html.agh-wp-on.wp-17 { background-image: url("https://www.23-4.cn/dns-status/app/wallpapers/wp_17.jpg") !important; }

/* ── 「设为壁纸」/「取消壁纸」按钮（★ 2026-10-30 新增） ──────────────── */
.agh-wp-cell { position: relative; }

.agh-wp-set {
  display: block;
  width: 100%;
  margin: 6px 0 0;
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  color: #e5eaf3;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s ease, border-color .15s ease;
}

.agh-wp-set:hover { background: rgba(255, 255, 255, .18); }

.agh-wp-set.is-on {
  color: #dbeafe;
  background: rgba(59, 130, 246, .38);
  border-color: rgba(147, 197, 253, .55);
  font-weight: 700;
}

.agh-wp-clear {
  padding: 4px 10px;
  margin-right: 8px;
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  color: #e5eaf3;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex: none;
}

.agh-wp-clear:disabled {
  opacity: .45;
  cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  .agh-wp-set { transition: none; }
}

/* ★★★ 2026-10-31【站长 61fe434d】壁纸背景卡片折叠
 * 默认收起（.is-collapsed）：只留标题行，其余兄弟节点全遮。
 * ★ 用通配 ~ 兄弟选择器，⛔ 不依赖内部类名 ⇒ 卡片内容变了也不会失效。
 */
.agh-wp-card.is-collapsed > :not(.agh-wp-card-h) {
    display: none !important;
}
.agh-wp-card .agh-wp-card-h {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}
.agh-wp-card .agh-wp-card-h::after {
    content: "\25B8";
    display: inline-block;
    margin-left: 6px;
    font-weight: 400;
    opacity: .7;
    transition: transform .18s ease;
}
.agh-wp-card:not(.is-collapsed) .agh-wp-card-h::after {
    content: "\25BE";
}
