/* ============================================================
   云星壁纸 - 前端样式 (v1.6.5 引入平滑加载过渡状态)
   ============================================================ */

.nw-wallpaper-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---- 前端标题/简介 ---- */
.nw-frontend-header { text-align: center; margin-bottom: 28px; }
.nw-frontend-header h2 { font-size: 32px; font-weight: 700; color: #1e293b; margin: 0 0 10px 0; line-height: 1.3; }
.nw-frontend-header p { font-size: 15px; color: #64748b; margin: 0; line-height: 1.7; }

/* ---- 分类导航 ---- */
.nw-cat-nav { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 16px; padding: 0 4px; }
.nw-cat-btn {
    padding: 8px 22px; border: 1.5px solid rgba(36,188,226,.3); border-radius: 20px;
    background: rgba(255,255,255,.45); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    color: #475569; font-size: 14px; cursor: pointer; transition: all .25s ease; font-weight: 500; user-select: none;
}
.nw-cat-btn:hover { background: rgba(36,188,226,.1); border-color: #24bce2; color: #24bce2; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(36,188,226,.2); }
.nw-cat-btn.active { background: #24bce2; border-color: #24bce2; color: #fff; box-shadow: 0 4px 16px rgba(36,188,226,.35); }

/* ---- 排序导航 ---- */
.nw-sort-nav { display: flex; justify-content: center; align-items: center; gap: 16px; margin-bottom: 28px; font-size: 13px; color: #94a3b8; }
.nw-sort-btn { cursor: pointer; transition: color .2s; user-select: none; }
.nw-sort-btn:hover { color: #64748b; }
.nw-sort-btn.active { color: #24bce2; font-weight: 600; }
.nw-sort-divider { width: 1px; height: 12px; background: #cbd5e1; }

/* ---- 壁纸瀑布流核心布局 ---- */
.nw-grid {
    column-count: 4; /* 默认4列 */
    column-gap: 20px;
    display: block;
    width: 100%;
    transition: opacity 0.3s ease; /* 防止白屏的平滑过渡 */
}
/* 正在拉取新分类数据的保护层 */
.nw-grid.nw-updating {
    opacity: 0.4;
    pointer-events: none;
}

.nw-card {
    position: relative;
    overflow: hidden;
    break-inside: avoid;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    margin-bottom: 20px;
    transform: translateZ(0); /* 修复Safari渲染切割Bug */
}

/* ---- 卡片容器 ---- */
.nw-card-inner {
    position: relative; border-radius: 12px; overflow: hidden; background: #f1f5f9;
    background-image: linear-gradient(110deg, #e2e8f0 8%, #f1f5f9 18%, #e2e8f0 33%);
    background-size: 200% 100%; animation: nw-shimmer 1.5s infinite ease-in-out;
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid rgba(255,255,255,.6);
    box-shadow: 0 4px 20px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04); transition: transform .3s ease, box-shadow .3s ease;
}
.nw-card-inner.loaded-bg { background: rgba(255,255,255,.5); background-image: none; animation: none; }
.nw-card-inner:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(36,188,226,.12), 0 4px 10px rgba(0,0,0,.06); }

/* ---- 图片容器比例控制 ---- */
.nw-card-img-wrap { position: relative; width: 100%; overflow: hidden; background: #f1f5f9; }
.nw-card-img-wrap::before { content: ''; display: block; }
.nw-card.nw-landscape .nw-card-img-wrap::before { padding-top: 56.25%; }
.nw-card.nw-portrait .nw-card-img-wrap::before { padding-top: 177.78%; }

/* 增加了 pointer-events: none; 让鼠标无法点击到 img 标签，防止子比抓取 */
.nw-card-img-wrap img { pointer-events: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .45s ease, opacity .4s ease; opacity: 0; }

.nw-card-img-wrap img.loaded { opacity: 1; }
.nw-card-inner:hover .nw-card-img-wrap img { transform: scale(1.06); }
.nw-card-img-wrap.nw-img-error img { display: none; }
.nw-card-img-wrap.nw-img-error::after { content: '加载失败'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 13px; }

@keyframes nw-shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ---- 卡片悬浮层 & 数据展示 ---- */
.nw-card-overlay {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px;
    background: rgba(0,0,0,.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    opacity: 0; transition: opacity .3s ease; z-index: 2;
}
.nw-card-inner:hover .nw-card-overlay { opacity: 1; }
.nw-card-download {
    width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.25);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.4);
    color: #fff; font-size: 18px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .25s ease;
}
.nw-card-download:hover { background: #24bce2; border-color: #24bce2; transform: scale(1.1); box-shadow: 0 4px 16px rgba(36,188,226,.5); }

/* 数据展示栏 */
.nw-card-meta {
    position: absolute; bottom: 0; left: 0; right: 0; padding: 16px 10px 8px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7)); display: flex; justify-content: space-between;
    color: #fff; font-size: 12px; opacity: 0; transition: opacity .3s ease; z-index: 3; pointer-events: none;
}
.nw-card-inner:hover .nw-card-meta { opacity: 1; }
.nw-meta-item i { margin-right: 4px; font-size: 11px; }

/* ---- 卡片标题 ---- */
.nw-card-title { padding: 10px 12px; font-size: 13px; color: #475569; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(248,250,252,.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* ---- 加载更多 & 指示器 ---- */
.nw-load-more-wrap { text-align: center; margin-top: 32px; clear: both; }
.nw-load-more-btn {
    padding: 12px 48px; border: 1.5px solid rgba(36,188,226,.3); border-radius: 24px;
    background: rgba(255,255,255,.5); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    color: #24bce2; font-size: 15px; font-weight: 500; cursor: pointer; transition: all .25s ease; user-select: none;
}
.nw-load-more-btn:hover { background: #24bce2; border-color: #24bce2; color: #fff; box-shadow: 0 6px 20px rgba(36,188,226,.35); transform: translateY(-2px); }
.nw-load-more-btn:active { transform: scale(.97); }
.nw-load-more-btn.loading { pointer-events: none; opacity: .7; color: transparent; position: relative; }
.nw-load-more-btn.loading::after {
    content: ''; position: absolute; top: 50%; left: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
    border: 2px solid #24bce2; border-top-color: transparent; border-radius: 50%; animation: nw-spin .6s linear infinite;
}
.nw-loading { text-align: center; padding: 24px; clear: both; }
.nw-spinner { display: inline-block; width: 36px; height: 36px; border: 3px solid rgba(36,188,226,.15); border-top-color: #24bce2; border-radius: 50%; animation: nw-spin .7s linear infinite; }
@keyframes nw-spin { to { transform: rotate(360deg); } }
.nw-end-text { text-align: center; padding: 20px; color: #94a3b8; font-size: 13px; clear: both; }
.nw-error-text { text-align: center; padding: 16px; color: #ef4444; font-size: 13px; background: rgba(239,68,68,.06); border-radius: 8px; margin: 10px 0; clear: both; }

/* ---- 灯箱 ---- */
.nw-lightbox { position: fixed; inset: 0; z-index: 99999; display: none; align-items: center; justify-content: center; }
.nw-lightbox.active { display: flex; }
.nw-lightbox-bg { position: absolute; inset: 0; background: rgba(15,23,42,.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.nw-lightbox-content { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; z-index: 1; }
.nw-lb-img-wrap { max-width: 90vw; max-height: 85vh; display: flex; align-items: center; justify-content: center; position: relative; }

/* 为灯箱高清大图提供专属缓冲渲染状态 */
.nw-lb-loading::before {
    content: '';
    position: absolute;
    width: 44px; height: 44px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: #24bce2;
    border-radius: 50%;
    animation: nw-spin .8s linear infinite;
    z-index: 0;
}
#nw-lb-img { position: relative; z-index: 1; max-width: 90vw; max-height: 85vh; object-fit: contain; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); transition: opacity .3s ease; }

.nw-lb-close, .nw-lb-prev, .nw-lb-next, .nw-lb-download {
    position: absolute; display: flex; align-items: center; justify-content: center; width: 46px; height: 46px;
    border-radius: 50%; background: rgba(255,255,255,.12); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.2); color: #fff; font-size: 20px; cursor: pointer; transition: all .2s ease; z-index: 2; user-select: none;
}
.nw-lb-close:hover, .nw-lb-prev:hover, .nw-lb-next:hover, .nw-lb-download:hover { background: rgba(36,188,226,.6); border-color: #24bce2; transform: scale(1.1); }
.nw-lb-close { top: 20px; right: 20px; font-size: 26px; font-weight: 300; width: 42px; height: 42px; }
.nw-lb-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.nw-lb-prev:hover { transform: translateY(-50%) scale(1.1); }
.nw-lb-next { right: 20px; top: 50%; transform: translateY(-50%); }
.nw-lb-next:hover { transform: translateY(-50%) scale(1.1); }
.nw-lb-download { bottom: 30px; right: 30px; }
.nw-lb-counter { position: absolute; bottom: 36px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,.7); font-size: 13px; background: rgba(0,0,0,.3); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); padding: 4px 14px; border-radius: 12px; }

/* ---- 响应式列数控制 ---- */
@media (max-width: 1200px) { .nw-grid { column-count: 3; } }
@media (max-width: 900px) { .nw-grid { column-count: 2; } }
@media (max-width: 640px) {
    .nw-wallpaper-wrap { padding: 12px 10px; }
    .nw-grid { column-count: 2; column-gap: 10px; }
    .nw-card { margin-bottom: 10px; }
    .nw-cat-nav { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; gap: 6px; padding-bottom: 6px; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
    .nw-cat-nav::-webkit-scrollbar { display: none; }
    .nw-cat-btn { padding: 6px 14px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
    .nw-sort-nav { margin-bottom: 20px; }
    .nw-lb-close { top: 10px; right: 10px; }
    .nw-lb-prev { left: 10px; }
    .nw-lb-next { right: 10px; }
    .nw-lb-download { bottom: 20px; right: 16px; }
}

/* 夜间模式 */
.dark-theme .nw-card-inner, [data-theme="dark"] .nw-card-inner { background: rgba(30,41,59,.6); border-color: rgba(255,255,255,.08); }
.dark-theme .nw-card-title, [data-theme="dark"] .nw-card-title { color: #cbd5e1; background: rgba(15,23,42,.4); }