/*
Theme Name: NavDeck
Theme URI: https://example.com/navdeck
Author: NavDeck
Author URI: https://example.com
Description: 轻量导航站主题。分类卡片式网址导航，支持即时搜索、暗色模式、响应式布局，站点数据在 links.json 中维护。
Version: 1.0.0
Requires at least: 5.9
Tested up to: 6.7
Requires PHP: 7.4
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: navdeck
Tags: one-column, custom-colors, full-width-template
*/

:root {
  --nd-bg: #f5f6fa;
  --nd-panel: #ffffff;
  --nd-panel-2: #fafbff;
  --nd-ink: #12141c;
  --nd-ink-2: #3b4152;
  --nd-muted: #737a8c;
  --nd-line: #e6e8f1;
  --nd-brand: #4c6ef5;
  --nd-brand-2: #7c5cff;
  --nd-shadow: 0 1px 2px rgba(18, 20, 28, .04), 0 8px 24px -12px rgba(18, 20, 28, .16);
  --nd-shadow-h: 0 10px 28px -12px rgba(18, 20, 28, .24);
  --nd-radius: 16px;
}

html[data-theme="dark"] {
  --nd-bg: #0d1017;
  --nd-panel: #161a23;
  --nd-panel-2: #1b2029;
  --nd-ink: #eef1f7;
  --nd-ink-2: #c2c8d6;
  --nd-muted: #8b93a7;
  --nd-line: #262c38;
  --nd-brand: #7c93ff;
  --nd-brand-2: #a78bfa;
  --nd-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -16px rgba(0, 0, 0, .8);
  --nd-shadow-h: 0 14px 34px -14px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--nd-bg);
  color: var(--nd-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }

.nd-wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 22px;
}

/* ---------- 背景光斑 ---------- */
.nd-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.nd-bg i {
  position: absolute;
  display: block;
  width: 46vw;
  height: 46vw;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .42;
}
.nd-bg i:first-child {
  top: -18vw;
  left: -10vw;
  background: radial-gradient(circle at 30% 30%, #8ea6ff, transparent 68%);
}
.nd-bg i:last-child {
  top: 6vw;
  right: -14vw;
  background: radial-gradient(circle at 60% 40%, #c9a8ff, transparent 66%);
}
html[data-theme="dark"] .nd-bg i { opacity: .22; }

.nd-header,
.nd-main,
.nd-footer { position: relative; z-index: 1; }

/* ---------- 顶栏 ---------- */
.nd-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid transparent;
  background: var(--nd-bg);
  background: color-mix(in srgb, var(--nd-bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  transition: border-color .2s ease;
}
.nd-header.is-stuck { border-bottom-color: var(--nd-line); }

.nd-header-in {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 66px;
}

.nd-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .2px;
  flex: 0 0 auto;
}
.nd-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--nd-brand), var(--nd-brand-2));
  box-shadow: 0 6px 16px -6px rgba(76, 110, 245, .7);
}
.nd-logo-text {
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nd-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 460px;
  margin-left: auto;
}
.nd-search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--nd-muted);
  fill: none;
  stroke-width: 2;
  pointer-events: none;
}
.nd-search input {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 38px;
  border-radius: 12px;
  border: 1px solid var(--nd-line);
  background: var(--nd-panel);
  color: var(--nd-ink);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
  appearance: none;
}
.nd-search input::placeholder { color: var(--nd-muted); }
.nd-search input:focus {
  border-color: var(--nd-brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--nd-brand) 18%, transparent);
}
.nd-search input::-webkit-search-cancel-button { display: none; }
.nd-search button {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--nd-muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease, background-color .15s ease;
}
.nd-search.has-value button { opacity: 1; }
.nd-search button:hover { background: var(--nd-panel-2); color: var(--nd-ink); }

.nd-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.nd-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--nd-line);
  background: var(--nd-panel);
  color: var(--nd-ink-2);
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color .18s ease, transform .18s ease, color .18s ease;
}
.nd-icon-btn:hover { border-color: var(--nd-brand); color: var(--nd-brand); transform: translateY(-1px); }

html[data-theme="light"] .nd-moon,
html[data-theme="dark"] .nd-sun { display: none; }

/* ---------- Hero ---------- */
.nd-main { padding-bottom: 40px; }

.nd-hero { padding: 54px 0 30px; }
.nd-kicker {
  margin: 0 0 12px;
  font-size: 11.5px;
  letter-spacing: .22em;
  font-weight: 700;
  color: var(--nd-brand);
  text-transform: uppercase;
}
.nd-hero h1 {
  margin: 0 0 14px;
  font-size: clamp(28px, 4.4vw, 44px);
  line-height: 1.18;
  letter-spacing: -.02em;
  font-weight: 800;
}
.nd-hero h1 span {
  background: linear-gradient(120deg, var(--nd-brand), var(--nd-brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.nd-sub {
  margin: 0 0 22px;
  max-width: 620px;
  color: var(--nd-muted);
  font-size: 15px;
}

.nd-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.nd-stats span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--nd-line);
  background: var(--nd-panel);
  color: var(--nd-ink-2);
  font-size: 12.5px;
}
.nd-stats b { color: var(--nd-ink); font-weight: 700; }

/* ---------- 分类区块 ---------- */
.nd-sec { margin-top: 34px; }

.nd-sec-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.nd-sec-head h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.nd-sec-ico {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: hsl(var(--h) 62% 46%);
  background: hsl(var(--h) 90% 95%);
  border: 1px solid hsl(var(--h) 80% 88%);
}
html[data-theme="dark"] .nd-sec-ico {
  color: hsl(var(--h) 78% 72%);
  background: hsl(var(--h) 40% 18%);
  border-color: hsl(var(--h) 34% 26%);
}
.nd-sec-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--nd-muted);
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--nd-line);
  background: var(--nd-panel);
  font-variant-numeric: tabular-nums;
}

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

/* ---------- 卡片 ---------- */
.nd-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  border-radius: var(--nd-radius);
  border: 1px solid var(--nd-line);
  background: var(--nd-panel);
  box-shadow: var(--nd-shadow);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
  min-width: 0;
}
.nd-card:hover,
.nd-card:focus-visible {
  transform: translateY(-2px);
  border-color: hsl(var(--h) 70% 62% / .55);
  box-shadow: var(--nd-shadow-h);
  outline: none;
}

.nd-ico {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: hsl(var(--h) 88% 95%);
  border: 1px solid hsl(var(--h) 76% 88%);
  overflow: hidden;
}
html[data-theme="dark"] .nd-ico {
  background: hsl(var(--h) 38% 17%);
  border-color: hsl(var(--h) 32% 26%);
}
.nd-ico b {
  font-size: 15px;
  font-weight: 700;
  color: hsl(var(--h) 58% 45%);
  line-height: 1;
}
html[data-theme="dark"] .nd-ico b { color: hsl(var(--h) 74% 74%); }
.nd-ico img {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 23px;
  height: 23px;
  padding: 1px;
  border-radius: 7px;
  object-fit: contain;
  background: hsl(var(--h) 88% 96%);
}
html[data-theme="dark"] .nd-ico img { background: hsl(var(--h) 38% 17%); }

.nd-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.nd-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--nd-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nd-name em {
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--nd-muted);
  background: var(--nd-panel-2);
  border: 1px solid var(--nd-line);
  flex: 0 0 auto;
}
.nd-desc {
  font-size: 12px;
  color: var(--nd-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 空状态 / 页脚 ---------- */
.nd-empty {
  margin: 56px auto;
  text-align: center;
  color: var(--nd-muted);
  font-size: 14px;
  padding: 34px 20px;
  border: 1px dashed var(--nd-line);
  border-radius: var(--nd-radius);
  background: var(--nd-panel);
  max-width: 520px;
}

.nd-footer {
  margin-top: 60px;
  padding: 26px 0 40px;
  border-top: 1px solid var(--nd-line);
  color: var(--nd-muted);
  font-size: 12.5px;
}
.nd-footer .nd-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  justify-content: space-between;
}
.nd-footer p { margin: 0; }
.nd-tip code {
  font-size: 11.5px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--nd-panel-2);
  border: 1px solid var(--nd-line);
  color: var(--nd-ink-2);
}

/* ---------- 内页 ---------- */
.nd-page {
  max-width: 820px;
  margin: 44px auto 0;
  background: var(--nd-panel);
  border: 1px solid var(--nd-line);
  border-radius: var(--nd-radius);
  padding: 34px 38px;
  box-shadow: var(--nd-shadow);
}
.nd-page h1 { margin-top: 0; font-size: 26px; letter-spacing: -.01em; }
.nd-page h2 { font-size: 19px; margin-top: 1.6em; }
.nd-page a { color: var(--nd-brand); text-decoration: underline; text-underline-offset: 2px; }
.nd-page img { border-radius: 12px; }
.nd-page blockquote {
  margin: 1.4em 0;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--nd-brand);
  color: var(--nd-ink-2);
}
.nd-page pre {
  background: var(--nd-panel-2);
  border: 1px solid var(--nd-line);
  border-radius: 12px;
  padding: 14px 16px;
  overflow: auto;
  font-size: 13px;
}
.nd-page code { font-size: .92em; }
.nd-404 { text-align: center; }
.nd-404 b { display: block; font-size: 54px; line-height: 1; color: var(--nd-brand); }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .nd-header-in { height: auto; padding: 12px 0; flex-wrap: wrap; gap: 10px; }
  .nd-search { order: 3; flex: 1 0 100%; max-width: none; margin-left: 0; }
  .nd-actions { margin-left: auto; }
  .nd-hero { padding: 34px 0 22px; }
  .nd-grid { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 9px; }
  .nd-page { padding: 22px 18px; margin-top: 24px; }
}

@media (max-width: 520px) {
  .nd-wrap { padding: 0 15px; }
  .nd-grid { grid-template-columns: 1fr; }
  .nd-sec { margin-top: 26px; }
  .nd-desc { display: none; }
  .nd-card { padding: 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
