/*
Theme Name: NavStack
Theme URI: https://ai.meilizixun.com
Description: 自适应拟态风格网址导航主题 — 自包含、SEO 友好、PHP 8 兼容
Version: 2.0.0
Requires at least: 5.4
Tested up to: 6.5
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: i_theme
*/

/* ============================================================
   1. 设计变量(浅色拟态)
   ============================================================ */
:root{
  --bg:#e8ebf2;
  --surface:#e8ebf2;
  --surface-2:#eef1f7;
  --shadow-dark:#c5c9d2;
  --shadow-light:#ffffff;
  --text:#3a3f51;
  --text-soft:#6b7280;
  --text-muted:#5f6573;  /* 对比度 4.89:1,满足 WCAG AA(原 #9aa0ac 仅 2.20:1) */
  --accent:#3f51d8;      /* 对比度 5.21:1(浅底)/6.21:1(白字按钮),满足 AA(原 #5b6ef5 仅 3.52:1) */
  --accent-soft:#e9ecff;
  --danger:#ef5777;
  --ok:#26c281;
  --radius:16px;
  --radius-sm:10px;
  --radius-lg:24px;
  --sh-raised:7px 7px 15px var(--shadow-dark), -7px -7px 15px var(--shadow-light);
  --sh-raised-sm:4px 4px 9px var(--shadow-dark), -4px -4px 9px var(--shadow-light);
  --sh-pressed:inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light);
  --sh-pressed-sm:inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
  --sh-hover:5px 5px 12px var(--shadow-dark), -5px -5px 12px var(--shadow-light);
  --sidebar-w:232px;
  --topbar-h:64px;
  --maxw:1240px;
  --sysfont:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  --mono:"SFMono-Regular",Consolas,"Liberation Mono",monospace;
}

/* ============================================================
   2. Reset & 基础排版
   ============================================================ */
*,*::before,*::after{box-sizing:border-box}
html{scroll-behavior:smooth;-webkit-text-size-adjust:100%}
body{
  margin:0;
  font-family:var(--sysfont);
  font-size:15px;
  line-height:1.6;
  color:var(--text);
  background:var(--bg);
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
  overflow-x:hidden;
}
img{max-width:100%;height:auto;display:block}
a{color:var(--accent);text-decoration:none;transition:color .18s ease}
a:hover{color:var(--text)}
h1,h2,h3,h4,h5,h6{margin:0 0 .5em;font-weight:700;line-height:1.3;color:var(--text)}
p{margin:0 0 1em}
ul,ol{margin:0 0 1em;padding-left:1.2em}
button{font-family:inherit;cursor:pointer;border:0;background:none;color:inherit}
input,textarea,select{font-family:inherit;font-size:inherit}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:6px}
.ioi{vertical-align:middle;flex:none}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}

/* ============================================================
   3. 整体布局(侧栏 + 主区,Grid)
   ============================================================ */
.app{
  display:grid;
  grid-template-columns:var(--sidebar-w) 1fr;
  min-height:100vh;
}
.main{
  min-width:0;            /* 防止 grid 子项溢出 */
  display:flex;
  flex-direction:column;
}
.main-inner{
  width:100%;
  max-width:var(--maxw);
  margin:0 auto;
  padding:24px 28px 96px;
}

/* ============================================================
   4. 侧边导航栏
   ============================================================ */
.sidebar{
  position:sticky;
  top:0;
  align-self:start;
  height:100vh;
  background:var(--bg);
  display:flex;
  flex-direction:column;
  border-right:1px solid rgba(0,0,0,.03);
  z-index:40;
}
.nav-logo{
  height:var(--topbar-h);
  display:flex;
  align-items:center;
  gap:10px;
  padding:0 22px;
  flex:none;
}
.nav-logo img{height:34px;width:auto}
.nav-logo .site-name{font-weight:800;font-size:1.05rem;color:var(--text)}
.nav-scroll{flex:1;overflow-y:auto;overflow-x:hidden;padding:8px 14px 24px;scrollbar-width:thin}
.nav-scroll::-webkit-scrollbar{width:6px}
.nav-scroll::-webkit-scrollbar-thumb{background:var(--shadow-dark);border-radius:6px}
.nav-section-label{font-size:.7rem;letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);padding:14px 12px 6px;font-weight:700}
.nav-menu{list-style:none;margin:0;padding:0}
.nav-item{margin:3px 0;position:relative}
.nav-link{
  display:flex;
  align-items:center;
  gap:11px;
  padding:10px 12px;
  border-radius:var(--radius-sm);
  color:var(--text-soft);
  font-weight:600;
  font-size:.92rem;
  transition:all .16s ease;
}
.nav-link .ioi{width:19px;height:19px;color:var(--text-muted);transition:color .16s}
.nav-link:hover{color:var(--text);background:var(--surface-2)}
.nav-link:hover .ioi{color:var(--accent)}
.nav-link.is-active{color:var(--accent);box-shadow:var(--sh-pressed-sm)}
.nav-link.is-active .ioi{color:var(--accent)}
/* 二级菜单 */
.nav-sub{list-style:none;margin:0;padding:2px 0 6px 30px;max-height:0;overflow:hidden;transition:max-height .28s ease}
.nav-item.open .nav-sub{max-height:600px}
.nav-item.open > .nav-link .ioi.chev{transform:rotate(0deg)}
.nav-link .ioi.chev{margin-left:auto;width:16px;height:16px;transform:rotate(-90deg);transition:transform .22s ease}
.nav-sub .nav-link{padding:7px 12px;font-size:.85rem;font-weight:500}
.nav-sub .nav-link::before{content:"";width:5px;height:5px;border-radius:50%;background:var(--text-muted);flex:none;transition:background .16s}
.nav-sub .nav-link:hover::before{background:var(--accent)}

/* ============================================================
   5. 顶部栏
   ============================================================ */
.topbar{
  position:sticky;top:0;z-index:30;
  height:var(--topbar-h);
  display:flex;align-items:center;gap:16px;
  padding:0 24px;
  background:rgba(232,235,242,.78);
  backdrop-filter:saturate(160%) blur(12px);
  -webkit-backdrop-filter:saturate(160%) blur(12px);
  box-shadow:0 4px 14px rgba(150,157,175,.16);
}
.icon-btn{
  width:42px;height:42px;border-radius:12px;
  display:inline-flex;align-items:center;justify-content:center;
  color:var(--text-soft);
  background:var(--surface);
  box-shadow:var(--sh-raised-sm);
  transition:all .15s ease;
}
.icon-btn:hover{color:var(--accent)}
.icon-btn:active{box-shadow:var(--sh-pressed-sm)}
.icon-btn .ioi{width:20px;height:20px}
/* 导航切换按钮:默认隐藏(桌面侧栏常驻),仅移动端显示 */
.topbar .nav-toggle{display:none}

/* 顶部品牌区(logo + 站名) */
.topbar-brand{
  display:inline-flex;align-items:center;gap:10px;flex:none;
  color:var(--text);text-decoration:none;
}
.topbar-brand img{height:30px;width:auto;display:block}
.topbar-brand .brand-name{font-weight:800;font-size:1rem;letter-spacing:.2px;white-space:nowrap}

/* 顶部搜索框(拟态凹槽) */
.topbar-search{
  display:flex;align-items:center;gap:8px;
  flex:0 1 380px;margin:0 auto;
  max-width:380px;width:100%;
  padding:9px 14px;border-radius:var(--radius-sm);
  background:var(--surface);
  box-shadow:var(--sh-pressed-sm);
  transition:box-shadow .18s ease;
}
.topbar-search:focus-within{box-shadow:var(--sh-pressed-sm),0 0 0 2px var(--accent-soft)}
.topbar-search .search-ico{color:var(--text-muted);flex:none;width:16px;height:16px}
.topbar-search input{
  border:0;outline:0;background:transparent;
  width:100%;min-width:0;
  font:inherit;font-size:.9rem;color:var(--text);
}
.topbar-search input::placeholder{color:var(--text-muted)}

.topbar .crumb{font-weight:700;color:var(--text);font-size:1rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:50vw}
.topbar .spacer{flex:1}
.topbar .ext-link{display:inline-flex;align-items:center;gap:6px;font-weight:600;font-size:.88rem;color:var(--text-soft)}

/* 移动端遮罩 */
.scrim{position:fixed;inset:0;background:rgba(40,44,60,.34);backdrop-filter:blur(2px);opacity:0;visibility:hidden;transition:opacity .25s;z-index:45}
body.nav-open .scrim{opacity:1;visibility:visible}

/* ============================================================
   6. 拟态基础元件
   ============================================================ */
.neu{background:var(--surface);border-radius:var(--radius);box-shadow:var(--sh-raised)}
.neu-inset{background:var(--surface);border-radius:var(--radius);box-shadow:var(--sh-pressed)}

.btn-neu{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  padding:11px 20px;border-radius:var(--radius-sm);
  font-weight:700;font-size:.92rem;color:var(--text);
  background:var(--surface);box-shadow:var(--sh-raised-sm);
  transition:all .15s ease;
}
.btn-neu:hover{color:var(--accent)}
.btn-neu:active{box-shadow:var(--sh-pressed-sm)}
.btn-neu.is-primary{color:var(--accent)}
.btn-neu .ioi{width:18px;height:18px}

/* ============================================================
   7. 搜索工具
   ============================================================ */
.search-wrap{margin:6px 0 26px}
.search-box{
  display:flex;align-items:center;gap:12px;
  padding:8px 8px 8px 22px;
  background:var(--surface);
  border-radius:var(--radius-lg);
  box-shadow:var(--sh-pressed);
}
.search-box .ioi.search{width:22px;height:22px;color:var(--text-muted);flex:none}
.search-box input{
  flex:1;border:0;background:transparent;outline:none;
  font-size:1.02rem;color:var(--text);padding:10px 0;min-width:0;
}
.search-box input::placeholder{color:var(--text-muted)}
.search-box .btn-go{
  width:52px;height:52px;border-radius:16px;flex:none;
  display:inline-flex;align-items:center;justify-content:center;
  color:#fff;background:var(--accent);
  box-shadow:5px 5px 12px var(--shadow-dark),-5px -5px 12px var(--shadow-light);
  transition:transform .12s ease,box-shadow .12s;
}
.search-box .btn-go:active{transform:scale(.95);box-shadow:var(--sh-pressed-sm)}
.search-box .btn-go .ioi{width:22px;height:22px}
/* 引擎选择 */
.engine-bar{display:flex;flex-wrap:wrap;gap:10px;margin-top:16px}
.engine-chip{
  padding:7px 16px;border-radius:30px;font-size:.85rem;font-weight:700;
  color:var(--text-soft);background:var(--surface);box-shadow:var(--sh-raised-sm);
  cursor:pointer;transition:all .15s ease;user-select:none;
}
.engine-chip:hover{color:var(--accent)}
.engine-chip.is-active{color:var(--accent);box-shadow:var(--sh-pressed-sm)}
.engine-group{display:none}
.engine-group.is-active{display:block}
.engine-tabs{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}
.engine-tab{padding:5px 14px;border-radius:20px;font-size:.78rem;font-weight:700;color:var(--text-muted);background:transparent;border:0;cursor:pointer;transition:all .15s}
.engine-tab:hover{color:var(--accent)}
.engine-tab.is-active{color:var(--accent);background:var(--surface);box-shadow:var(--sh-raised-sm)}

/* ============================================================
   8. 内容区:分类标题 + 卡片网格
   ============================================================ */
.section-head{
  display:flex;align-items:center;gap:12px;
  margin:34px 0 16px;
  scroll-margin-top:80px;
}
.section-head .ioi{width:20px;height:20px;color:var(--accent)}
.section-head h2{margin:0;font-size:1.18rem;font-weight:800}
.section-head .more{
  margin-left:auto;font-size:.82rem;font-weight:700;color:var(--text-muted);
  padding:5px 14px;border-radius:20px;box-shadow:var(--sh-raised-sm);
}
.section-head .more:hover{color:var(--accent)}

.card-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(220px,1fr));
  gap:18px;
}
.site-card{
  display:flex;align-items:center;gap:14px;
  padding:16px 18px;
  background:var(--surface);
  border-radius:var(--radius);
  box-shadow:var(--sh-raised);
  color:var(--text);
  transition:transform .18s ease,box-shadow .18s ease;
  height:100%;
}
.site-card:hover{
  transform:translateY(-3px);
  box-shadow:var(--sh-hover);
  color:var(--text);
}
.site-card .thumb{
  width:46px;height:46px;border-radius:14px;flex:none;
  object-fit:cover;background:var(--surface-2);
  box-shadow:var(--sh-raised-sm);padding:8px;
}
.site-card .meta{min-width:0;flex:1;display:flex;flex-direction:column;overflow:hidden}
.site-card .t-name{font-weight:700;font-size:.96rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.site-card .t-desc{font-size:.8rem;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:2px 0 0}

/* 空状态 */

/* 分页 */
.posts-nav{margin:28px 0;text-align:center}
.posts-nav .page-numbers{display:inline-block;padding:8px 14px;margin:0 3px;border-radius:12px;font-weight:700;font-size:.88rem;color:var(--text-soft);background:var(--surface);box-shadow:var(--sh-raised-sm);transition:all .15s}
.posts-nav .page-numbers:hover{color:var(--accent)}
.posts-nav .page-numbers.current{color:#fff;background:var(--accent);box-shadow:none}
.posts-nav .page-numbers.dots{box-shadow:none;background:transparent}

.nothing{
  padding:30px;text-align:center;color:var(--text-muted);
  background:var(--surface);border-radius:var(--radius);box-shadow:var(--sh-pressed-sm);
}

/* ============================================================
   9. 公告
   ============================================================ */
.bulletin{
  display:flex;align-items:center;gap:12px;
  padding:12px 20px;margin-bottom:8px;
  background:var(--surface);border-radius:var(--radius);box-shadow:var(--sh-raised-sm);
}
.bulletin .ioi{width:18px;height:18px;color:var(--accent);flex:none}
.bulletin .bn-list{display:flex;gap:22px;overflow:hidden;flex:1}
.bulletin a{color:var(--text-soft);font-size:.88rem;font-weight:600}
.bulletin a:hover{color:var(--accent)}
.bulletin .bn-close{width:32px;height:32px;border-radius:10px}
.bulletin .bn-date{color:var(--text-muted);font-weight:500}

/* ============================================================
   10. 友情链接
   ============================================================ */
.flink{display:flex;flex-wrap:wrap;gap:12px;margin-top:8px}
.flink a{
  padding:8px 16px;border-radius:30px;font-size:.85rem;font-weight:600;
  color:var(--text-soft);background:var(--surface);box-shadow:var(--sh-raised-sm);
  transition:all .15s;
}
.flink a:hover{color:var(--accent);box-shadow:var(--sh-pressed-sm)}

/* ============================================================
   11. 网址详情页
   ============================================================ */
.detail-card{padding:30px;margin-bottom:24px}
.detail-top{display:flex;flex-wrap:wrap;gap:24px;align-items:center}
.detail-thumb{
  width:96px;height:96px;border-radius:24px;flex:none;
  object-fit:cover;background:var(--surface-2);
  box-shadow:var(--sh-raised);padding:18px;
}
.detail-body{flex:1;min-width:240px}
.detail-cats{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:8px}
.detail-cats a{
  font-size:.76rem;font-weight:700;padding:4px 12px;border-radius:20px;
  color:var(--accent);background:var(--accent-soft);
}
.detail-body h1{font-size:1.6rem;margin:0 0 6px}
.detail-desc{color:var(--text-soft);margin:0 0 16px}
.detail-actions{display:flex;flex-wrap:wrap;gap:12px}
.detail-content{margin-top:26px;padding-top:24px;border-top:1px solid rgba(0,0,0,.06);line-height:1.85}
.detail-content h2,.detail-content h3{margin-top:1.4em}
.related{margin-top:30px}

/* ============================================================
   12. 评论
   ============================================================ */
.comments-area{margin-top:34px}
.comment{padding:16px 20px;margin-bottom:14px;background:var(--surface);border-radius:var(--radius);box-shadow:var(--sh-raised-sm)}
.comment .c-author{font-weight:700}
.comment .c-meta{font-size:.78rem;color:var(--text-muted);margin-bottom:6px}
.comment .children{list-style:none;padding-left:0;margin-top:14px}
.comment .children .comment{box-shadow:var(--sh-pressed-sm)}
.comment-form .neu-inset{padding:18px;margin-top:10px}
.comment-form input,.comment-form textarea{
  width:100%;padding:11px 14px;margin-bottom:12px;border:0;border-radius:12px;
  background:var(--surface);box-shadow:var(--sh-pressed-sm);outline:none;color:var(--text);
}
.comment-form input:focus,.comment-form textarea:focus{box-shadow:var(--sh-pressed),0 0 0 2px var(--accent-soft)}
.comment-list{list-style:none;padding:0;margin:0}
.comment-body{position:relative}
.comment .c-text{margin:4px 0 8px;line-height:1.7;color:var(--text-soft)}
.comment .c-reply a{font-size:.8rem;font-weight:700;color:var(--accent)}
.comment .c-date{margin-left:8px;font-size:.78rem;color:var(--text-muted)}
.comments-title{font-size:1.1rem;font-weight:800;margin:0 0 16px}
.comment-reply-title{font-size:1rem;font-weight:800;margin:0 0 12px}
.comment-form .submit{padding:11px 28px;border:0;border-radius:var(--radius-sm);font-weight:700;color:#fff;background:var(--accent);box-shadow:5px 5px 12px var(--shadow-dark),-5px -5px 12px var(--shadow-light);cursor:pointer}
.comment-form .submit:active{box-shadow:var(--sh-pressed-sm)}
.comment-form .comment-form-comment{margin:0 0 4px}
.no-comments{color:var(--text-muted);font-style:italic}


/* ============================================================
   13. 投稿表单
   ============================================================ */
.contribute{padding:30px}
.contribute label{display:block;font-weight:700;font-size:.85rem;margin:0 0 6px;color:var(--text-soft)}
.contribute .field{margin-bottom:18px}
.contribute input,.contribute textarea,.contribute select{
  width:100%;padding:12px 16px;border:0;border-radius:12px;
  background:var(--surface);box-shadow:var(--sh-pressed-sm);outline:none;color:var(--text);
}
.contribute input:focus,.contribute textarea:focus{box-shadow:var(--sh-pressed),0 0 0 2px var(--accent-soft)}

/* ============================================================
   14. 页脚 + 回到顶部
   ============================================================ */
.footer{
  padding:22px 28px;text-align:center;color:var(--text-muted);font-size:.82rem;
  border-top:1px solid rgba(0,0,0,.04);
}
.footer a{color:var(--text-soft)}
.to-top{
  position:fixed;right:24px;bottom:24px;z-index:35;
  width:48px;height:48px;border-radius:16px;
  display:inline-flex;align-items:center;justify-content:center;
  color:var(--accent);background:var(--surface);box-shadow:var(--sh-raised);
  opacity:0;visibility:hidden;transform:translateY(10px);transition:all .25s ease;
}
.to-top.show{opacity:1;visibility:visible;transform:none}
.to-top:active{box-shadow:var(--sh-pressed)}

/* ============================================================
   15. 提示泡(Tooltip)
   ============================================================ */
.tip{position:relative}
.tip-tip{
  position:absolute;bottom:calc(100% + 10px);left:50%;transform:translateX(-50%) translateY(6px);
  background:var(--text);color:#fff;padding:8px 12px;border-radius:10px;font-size:.8rem;
  white-space:nowrap;opacity:0;visibility:hidden;transition:all .18s ease;pointer-events:none;z-index:60;
  box-shadow:0 8px 20px rgba(0,0,0,.18);
}
.tip-tip img{border-radius:8px}
.tip:hover .tip-tip,.tip:focus-within .tip-tip{opacity:1;visibility:visible;transform:translateX(-50%)}

/* ============================================================
   16. 工具类
   ============================================================ */
.text-center{text-align:center}
.mt-0{margin-top:0!important}
.mb-0{margin-bottom:0!important}
.hide{display:none!important}
.chip{display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;font-size:.78rem;font-weight:700;background:var(--accent-soft);color:var(--accent)}
.ad-slot{margin:18px 0;padding:14px;text-align:center;border-radius:var(--radius);background:var(--surface-2)}
.entry-content{line-height:1.85}
.entry-content img{border-radius:12px;margin:1em 0}
.entry-content a{color:var(--accent);text-decoration:underline;text-underline-offset:2px}
.breadcrumbs{font-size:.82rem;color:var(--text-muted);margin-bottom:14px}
.breadcrumbs a{color:var(--text-soft)}

/* ============================================================
   17. 响应式
   ============================================================ */
@media (max-width:1024px){
  :root{--sidebar-w:210px}
  .main-inner{padding:20px 22px 90px}
}
@media (max-width:860px){
  .app{grid-template-columns:1fr}
  .sidebar{
    position:fixed;top:0;left:0;width:280px;height:100vh;
    transform:translateX(-105%);transition:transform .3s cubic-bezier(.4,0,.2,1);
    box-shadow:14px 0 40px rgba(0,0,0,.16);
  }
  body.nav-open .sidebar{transform:none}
  .main-inner{padding:18px 16px 84px}
  .card-grid{grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px}
  .detail-top{gap:16px}
  .topbar .ext-link{display:none}
  .topbar .nav-toggle{display:inline-flex}
  .topbar-brand{display:none}
  .topbar-search{margin:0;flex:1;max-width:none}
}
@media (max-width:480px){
  body{font-size:14px}
  .card-grid{grid-template-columns:1fr 1fr;gap:10px}
  .site-card{padding:12px;gap:10px}
  .site-card .thumb{width:38px;height:38px;border-radius:11px;padding:6px}
  .site-card .t-name{font-size:.88rem}
  .search-box{padding:6px 6px 6px 16px}
  .search-box .btn-go{width:44px;height:44px}
  .detail-thumb{width:72px;height:72px}
}
@media (prefers-reduced-motion:reduce){
  *{animation:none!important;transition:none!important;scroll-behavior:auto!important}
}
