/* ============================================================
   导航页 · 样式
   部署文件：guideline/assets/css/app.css
   ============================================================ */

:root {
  --wallpaper-fallback: url("../img/wallpaper.png");

  --text: #f1f4fb;
  --text-dim: rgba(241, 244, 251, 0.66);
  --text-faint: rgba(241, 244, 251, 0.42);

  --glass-bg: rgba(255, 255, 255, 0.07);
  --glass-bg-hover: rgba(255, 255, 255, 0.13);
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-border-hover: rgba(255, 255, 255, 0.32);
  --glass-highlight: rgba(255, 255, 255, 0.28);

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --shadow-soft: 0 10px 32px rgba(0, 0, 0, 0.28);
  --shadow-lift: 0 18px 42px rgba(0, 0, 0, 0.38);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --fade-ms: 1100ms;

  --content-width: 1200px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: #050810;
  -webkit-text-size-adjust: 100%;
}

/* .card / .cat 使用了 display 布局，需要显式覆盖 hidden 属性 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--text);
  font-family: "Inter", "SF Pro SC", "PingFang SC", "Microsoft YaHei",
    system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ---------------------------- 背景层 ---------------------------- */

.wallpaper {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: #050810;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0;
  transform: scale(1.04); /* 轻微放大，避免淡入时边缘露底 */
  transition: opacity var(--fade-ms) var(--ease);
  will-change: opacity;
  pointer-events: none;
}

/* 本地兜底壁纸：先于任何脚本绘制，保证首屏不空 */
#wp-a {
  background-image: var(--wallpaper-fallback);
}

.wallpaper.is-active {
  opacity: 1;
}

/* 云端随机壁纸层：透明容器，叠在本地兜底壁纸之上、遮罩之下。
   模块会往里追加 <img class="rw-wallpaper-image"> 并在加载成功后淡入。 */
.wallpaper-cloud {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: transparent;
}

/* 遮罩：提升文字与玻璃卡片的对比度 */
.wallpaper-veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(
      130% 90% at 50% -10%,
      rgba(4, 6, 12, 0.02) 0%,
      rgba(4, 6, 12, 0.32) 62%,
      rgba(4, 6, 12, 0.56) 100%
    ),
    linear-gradient(
      180deg,
      rgba(4, 6, 12, 0.28) 0%,
      rgba(4, 6, 12, 0.06) 32%,
      rgba(4, 6, 12, 0.52) 100%
    );
}

/* ---------------------------- 布局 ---------------------------- */

.app {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 32px) clamp(16px, 4vw, 40px) 56px;
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 3.5vw, 40px);
}

/* ---------------------------- 磨砂玻璃 ---------------------------- */

.glass {
  background:
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.14) 0%,
      rgba(255, 255, 255, 0.05) 46%,
      rgba(255, 255, 255, 0.03) 100%
    ),
    var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow:
    var(--shadow-soft),
    inset 0 1px 0 var(--glass-highlight),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04);
  -webkit-backdrop-filter: blur(22px) saturate(165%);
  backdrop-filter: blur(22px) saturate(165%);
}

/* ---------------------------- 顶栏 ---------------------------- */

.topbar {
  position: sticky;
  top: clamp(12px, 2vw, 20px);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(18px, 2.4vw, 26px);
  border-radius: var(--radius-lg);
}

.brand {
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: clamp(20px, 2.3vw, 26px);
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 1.25;
  text-wrap: balance;
}

.brand-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

/* 搜索框 */

.search {
  position: relative;
  flex: 0 1 340px;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}

.search:focus-within {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.32);
  box-shadow: 0 0 0 3px rgba(140, 180, 255, 0.16);
}

.search-icon {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--text-faint);
}

.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  letter-spacing: 0.01em;
}

.search input::placeholder {
  color: var(--text-faint);
}

.search.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.search input::-webkit-search-cancel-button {
  appearance: none;
}

.search-kbd {
  flex: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-faint);
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
}

/* ---------------------------- 分类 ---------------------------- */

.nav-root {
  display: flex;
  flex-direction: column;
  gap: clamp(28px, 3.6vw, 44px);
}

.cat {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 2px;
}

.cat-title {
  margin: 0;
  flex: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: rgba(241, 244, 251, 0.9);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.4);
}

.cat-count {
  flex: none;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.cat-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.16),
    rgba(255, 255, 255, 0.02)
  );
}

.cat-desc {
  margin: -6px 0 0 2px;
  font-size: 12.5px;
  color: var(--text-faint);
}

/* ---------------------------- 卡片 ---------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 15px 16px 16px;
  border-radius: var(--radius-md);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.28s var(--ease), background 0.28s var(--ease),
    border-color 0.28s var(--ease), box-shadow 0.28s var(--ease);
}

.card::after {
  /* hover 时从左上角晕开的柔光 */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    120% 120% at 0% 0%,
    rgba(255, 255, 255, 0.16),
    rgba(255, 255, 255, 0) 58%
  );
  transition: opacity 0.28s var(--ease);
}

.card:hover {
  transform: translateY(-3px);
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
  box-shadow: var(--shadow-lift), inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.card:hover::after {
  opacity: 1;
}

.card:active {
  transform: translateY(-1px);
}

.card:focus-visible {
  outline: 2px solid rgba(150, 190, 255, 0.85);
  outline-offset: 3px;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.card-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    radial-gradient(120% 120% at 20% 0%, rgba(255, 255, 255, 0.18), transparent 60%),
    rgba(255, 255, 255, 0.07);
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  overflow: hidden;
  white-space: nowrap;
}

.card-name {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-arrow {
  flex: none;
  width: 15px;
  height: 15px;
  color: var(--text-dim);
  opacity: 0;
  transform: translate(-4px, 4px);
  transition: opacity 0.28s var(--ease), transform 0.28s var(--ease);
}

.card:hover .card-arrow,
.card:focus-visible .card-arrow {
  opacity: 1;
  transform: translate(0, 0);
}

.card-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* ---------------------------- 空状态 ---------------------------- */

.empty {
  padding: clamp(32px, 6vw, 64px) 24px;
  border-radius: var(--radius-lg);
  text-align: center;
}

.empty-icon {
  width: 26px;
  height: 26px;
  margin-bottom: 10px;
  color: var(--text-faint);
}

.empty-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
}

.empty-text {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
}

.empty-text code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

/* ---------------------------- 页脚 ---------------------------- */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: auto;
  padding: 0 4px;
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: 0.03em;
}

/* ---------------------------- 滚动条 ---------------------------- */

html {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
  background-color: rgba(255, 255, 255, 0.22);
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.32);
}

/* ---------------------------- 响应式 ---------------------------- */

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    gap: 14px;
  }

  .brand {
    flex: 1 1 auto;
  }

  .search {
    flex: 1 1 100%;
  }

  .search-kbd {
    display: none;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

@media (max-width: 420px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------- 降低动效 ---------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }

  /* 壁纸保留短淡入，避免硬切；仍不产生位移类动效 */
  .wallpaper {
    transition-duration: 320ms !important;
  }

  .rw-wallpaper-image {
    transition-duration: 320ms !important;
  }
}
