/* ============================================================
   资讯库 · handler.xin
   移动优先 · 无框架 · 亮暗双主题
   ============================================================ */

:root {
  --bg:          #f8f9fa;
  --bg-elev:     #ffffff;
  --border:      #e6e8eb;
  --border-soft: #eef0f2;
  --text:        #16181d;
  --text-2:      #5b626e;
  --text-3:      #8a919e;
  --accent:      #3b5bdb;
  --accent-soft: #eef1fd;
  --shadow:      0 1px 2px rgba(16, 18, 22, .04), 0 4px 12px rgba(16, 18, 22, .05);
  --shadow-hi:   0 2px 4px rgba(16, 18, 22, .05), 0 12px 28px rgba(16, 18, 22, .09);
  --radius:      14px;
  --maxw:        760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0e1116;
    --bg-elev:     #161a21;
    --border:      #252b34;
    --border-soft: #1e242c;
    --text:        #e8eaee;
    --text-2:      #9aa3b0;
    --text-3:      #6d7684;
    --accent:      #7c93f8;
    --accent-soft: #1b2233;
    --shadow:      0 1px 2px rgba(0, 0, 0, .4);
    --shadow-hi:   0 2px 6px rgba(0, 0, 0, .5), 0 14px 30px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "SF Pro Text",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI",
               Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- 页头 ---------- */

.masthead {
  padding: calc(28px + env(safe-area-inset-top)) 0 18px;
}

.masthead .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  color: var(--accent);
  text-decoration: none;
}

.brand-mark svg { display: block; width: 100%; height: 100%; }

.brand-text { min-width: 0; }

.brand-text h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 680;
  letter-spacing: -.015em;
  line-height: 1.25;
}

.brand-sub {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
  letter-spacing: .01em;
}

.stat {
  flex: 0 0 auto;
  font-size: 12.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- 搜索 + 分类 ---------- */

.controls {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 10px 0 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}

.controls.is-stuck { border-bottom-color: var(--border-soft); }

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 13px;
  width: 17px;
  height: 17px;
  color: var(--text-3);
  pointer-events: none;
}

#search {
  width: 100%;
  height: 42px;
  padding: 0 38px 0 38px;
  font-size: 16px; /* 防止 iOS 聚焦缩放 */
  font-family: inherit;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
  -webkit-appearance: none;
  appearance: none;
}

#search::placeholder { color: var(--text-3); }

#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

#search::-webkit-search-cancel-button { display: none; }

.clear-btn {
  position: absolute;
  right: 8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 19px;
  line-height: 1;
  color: var(--text-3);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-family: inherit;
}

.clear-btn:hover { color: var(--text); background: var(--border-soft); }

/* 作者样式的 display 会覆盖 UA 对 [hidden] 的处理，需显式声明 */
.clear-btn[hidden] { display: none; }

.chips {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 13px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-2);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .14s, background .14s, border-color .14s;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover { color: var(--text); border-color: var(--text-3); }

.chip[aria-pressed="true"] {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 560;
}

@media (prefers-color-scheme: dark) {
  .chip[aria-pressed="true"] { color: #0e1116; }
}

/* ---------- 列表 ---------- */

main { padding: 18px 0 8px; }

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  display: block;
  padding: 16px 17px 15px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-hi);
    border-color: var(--border);
  }
  .card:hover .card-title { color: var(--accent); }
}

.card:active { transform: scale(.994); }

.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 12px;
  color: var(--text-3);
}

.card-cat {
  display: inline-block;
  padding: 1.5px 7px;
  font-size: 11.5px;
  font-weight: 560;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  letter-spacing: .01em;
}

.card-date { margin-left: auto; font-variant-numeric: tabular-nums; }

.card-title {
  margin: 0 0 6px;
  font-size: 16.5px;
  font-weight: 620;
  line-height: 1.42;
  letter-spacing: -.008em;
  transition: color .14s ease;
  overflow-wrap: break-word;
}

.card-summary {
  margin: 0;
  font-size: 13.8px;
  line-height: 1.62;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: break-word;
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 11.8px;
  color: var(--text-3);
  flex-wrap: wrap;
}

.card-source {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55%;
}

.tag {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  color: var(--text-3);
  background: var(--border-soft);
  border-radius: 4px;
}

@media (prefers-color-scheme: dark) {
  .tag { background: #1c222b; }
}

mark {
  padding: 0 1px;
  color: inherit;
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  border-radius: 2px;
}

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

.empty {
  padding: 56px 20px;
  text-align: center;
}

.empty-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

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

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

.site-footer {
  padding: 26px 0 calc(34px + env(safe-area-inset-bottom));
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

.site-footer .dot { margin: 0 6px; opacity: .5; }

/* ---------- 大屏微调 ---------- */

@media (min-width: 640px) {
  .masthead { padding-top: 44px; }
  .brand-mark { width: 42px; height: 42px; }
  .brand-text h1 { font-size: 23px; }
  .card { padding: 19px 21px 18px; }
  .card-title { font-size: 17.5px; }
  .card-summary { font-size: 14.2px; }
}

/* ---------- 入场动画（仅首屏播放，筛选时不重播） ---------- */

.list.anim .card {
  animation: rise .3s cubic-bezier(.22,.68,.32,1) backwards;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
