/* =====================================================================
   styles.css — 入口页（index.html）的设计系统。

   **样式对着 iLovePDF 的首页做**：白色顶栏（见 site-nav.css + site-nav.js）+
   一条淡粉的 hero（居中大标题、灰副标题、一排分类筛选药丸）+ 紧凑的工具卡片
   网格（图标在左上角、标题、两行说明）+ 深色多列页脚。工具页那边另有一份
   assets/pdf/pdf.css，用的是同一套 token。

   零外部依赖：不加载任何第三方字体、图标或脚本。
   No external requests. System fonts only.
   ===================================================================== */

/* ---------- 设计令牌 / Design tokens ---------- */
:root {
  --page:          #f7f7fb;   /* 整页底色：卡片靠它浮起来 */
  --bg:            #ffffff;
  --bg-elevated:   #ffffff;
  --bg-sunken:     #f5f5fa;
  --bg-hover:      #eceef4;

  --text:          #242424;
  --text-muted:    #707078;
  --text-faint:    #9a9aa2;

  --border:        #e8e9eb;
  --border-strong: #d4d6d9;

  /* 主色是 iLovePDF 那一支红 */
  --accent:        #e5322d;
  --accent-hover:  #c62a26;
  --accent-soft:   #fdeceb;

  --local:         #0d7a45;   /* 纯本地 */
  --local-soft:    #e4f6ec;
  --cdn:           #a9660a;   /* 需联网加载库 */
  --cdn-soft:      #fdf1dd;
  --network:       #a4262c;   /* 发送数据至第三方 */
  --network-soft:  #fbe9e9;

  --hero:          linear-gradient(180deg, #fde4df 0%, #fdf1ef 58%, var(--page) 100%);
  --foot-bg:       #1f1f26;
  --foot-fg:       #b9b9c2;
  --foot-strong:   #ffffff;
  --foot-line:     #33333b;

  --radius:        12px;
  --radius-sm:     8px;
  --radius-pill:   99px;
  --shadow:        0 1px 3px rgba(16,17,20,.06), 0 6px 18px rgba(16,17,20,.05);
  --shadow-lg:     0 4px 10px rgba(16,17,20,.08), 0 18px 40px rgba(16,17,20,.12);

  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page:          #101114;
    --bg:            #1c1d21;
    --bg-elevated:   #1c1d21;
    --bg-sunken:     #26272c;
    --bg-hover:      #26272c;
    --text:          #e8e9eb;
    --text-muted:    #9a9ba1;
    --text-faint:    #6f7076;
    --border:        #2a2b30;
    --border-strong: #3d3e44;
    --accent:        #ff6b64;
    --accent-hover:  #ff8b85;
    --accent-soft:   #2c1a19;
    --local:         #4ecb8c;
    --local-soft:    #12291d;
    --cdn:           #e0a44e;
    --cdn-soft:      #2b2216;
    --network:       #ef8a7a;
    --network-soft:  #2c1a18;
    --hero:          linear-gradient(180deg, #2c1a19 0%, #201416 58%, var(--page) 100%);
    --foot-bg:       #16171b;
    --foot-fg:       #9a9ba1;
    --foot-strong:   #e8e9eb;
    --foot-line:     #2a2b30;
    --shadow:        0 1px 3px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
    --shadow-lg:     0 4px 10px rgba(0,0,0,.5), 0 18px 40px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --page:          #101114;
  --bg:            #1c1d21;
  --bg-elevated:   #1c1d21;
  --bg-sunken:     #26272c;
  --bg-hover:      #26272c;
  --text:          #e8e9eb;
  --text-muted:    #9a9ba1;
  --text-faint:    #6f7076;
  --border:        #2a2b30;
  --border-strong: #3d3e44;
  --accent:        #ff6b64;
  --accent-hover:  #ff8b85;
  --accent-soft:   #2c1a19;
  --local:         #4ecb8c;
  --local-soft:    #12291d;
  --cdn:           #e0a44e;
  --cdn-soft:      #2b2216;
  --network:       #ef8a7a;
  --network-soft:  #2c1a18;
  --hero:          linear-gradient(180deg, #2c1a19 0%, #201416 58%, var(--page) 100%);
  --foot-bg:       #16171b;
  --foot-fg:       #9a9ba1;
  --foot-strong:   #e8e9eb;
  --foot-line:     #2a2b30;
  --shadow:        0 1px 3px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
  --shadow-lg:     0 4px 10px rgba(0,0,0,.5), 0 18px 40px rgba(0,0,0,.5);
}

/* ---------- 基础 / Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; background: var(--page); overflow-x: clip; }
body {
  margin: 0; background: none; color: var(--text);
  font-family: var(--sans); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 700; line-height: 1.25; letter-spacing: -.02em; }
p { margin: 0 0 1em; }
code, kbd { font-family: var(--mono); font-size: .88em; }
kbd {
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 4px; padding: .1em .4em; font-size: .82em;
}
::selection { background: var(--accent-soft); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ---------- Hero ---------- */
/* iLovePDF 首页最上面是一条淡粉的渐变带：居中标题 + 灰副标题 + 一排筛选药丸，
   往下渐渐化进页面底色。 */
.hero {
  background: var(--hero);
  padding: 46px 0 30px; margin-bottom: 8px;
  text-align: center;
}
.hero h1 {
  font-size: 40px; margin: 0 0 14px; letter-spacing: -.025em;
}
.hero .lede {
  max-width: 62ch; margin: 0 auto 26px;
  font-size: 17px; line-height: 1.75; color: var(--text-muted);
}
.hero .footnote {
  max-width: 74ch; margin: 22px auto 0; font-size: 12.5px;
  color: var(--text-faint); line-height: 1.8;
}
/* hero 里那两枚小徽章：100% client-side / 100% 免费。
   放在副标题下面、分类药丸上面 —— 是「这一站卖什么」的一句话总结。 */
.hero .hbadges {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 10px;
  margin: 0 0 18px;
}
.hero .hbadges span {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 16px; border-radius: 999px;
  background: color-mix(in srgb, var(--bg-elevated) 82%, transparent);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text);
}

/* ---------- 分类筛选药丸 ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin: 0 0 26px;
}
.chip {
  font: inherit; font-size: 13.5px; cursor: pointer;
  background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 9px 18px; display: inline-flex; align-items: center; gap: 7px;
  box-shadow: var(--shadow);
  transition: background .12s, border-color .12s, color .12s, transform .12s;
}
.chip:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.chip[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.chip .dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--tile, var(--text-faint));
}
.chip[aria-pressed="true"] .dot { background: #fff; }
.chip .count { font-size: .88em; opacity: .65; font-variant-numeric: tabular-nums; }

/* ---------- 分组标题 ---------- */
.sec-title {
  margin: 40px 0 14px; font-size: 15px; font-weight: 700;
  color: var(--text); display: flex; align-items: center; gap: 9px;
}
.sec-title::before {
  content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%;
  background: var(--tile, var(--text-faint));
}
.sec-title .n { font-weight: 500; font-size: 13px; color: var(--text-faint); }
.section { margin: 0 0 8px; scroll-margin-top: 84px; }

/* ---------- 工具卡片 ---------- */
/* iLovePDF 的卡片很紧凑：图标在左上角、然后是标题和两行说明。
   一屏要摆下二十几个工具，卡片就不能做成大块头。 */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
}
.card {
  display: flex; flex-direction: column; gap: 7px;
  background: var(--bg-elevated); border-radius: var(--radius);
  padding: 16px 16px 14px; color: inherit; position: relative;
  box-shadow: var(--shadow);
  transition: box-shadow .16s, transform .16s;
}
.card:hover {
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow-lg); transform: translateY(-2px);
}
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card .top { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.card h3 {
  margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em;
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
}
/* 图标：和 iLovePDF 一样是彩色的图形摆在左上角，没有底色块。
   图来自 assets/site/icons.js 那一套自绘 SVG，颜色用分类色（--tile），
   所以一屏卡片扫过去能看出「这几张是一类」—— emoji 做不到这一点。 */
.card .ic {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center;
  color: var(--tile, var(--text-muted));
}
.card .ic svg { width: 28px; height: 28px; display: block; }
.card p {
  margin: 0; font-size: 12.5px; color: var(--text-muted); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .foot {
  margin-top: auto; padding-top: 8px; display: flex; align-items: center;
  gap: 8px; flex-wrap: wrap;
}
.card .slug {
  font-family: var(--mono); font-size: 11px; color: var(--text-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 空状态 ---------- */
.empty {
  text-align: center; padding: 56px 20px; color: var(--text-muted);
  background: var(--bg-sunken); border-radius: var(--radius);
}
.empty .chip { background: var(--bg-elevated); }


/* ---------- 页脚 ---------- */
/* iLovePDF 的页脚是一整块深色，里面五列链接。这里同样五列 —— 每一列是一个
   分类，列里的每一条是一个工具（数据从 tools-data.js 来）。 */
.site-footer {
  margin-top: 56px; background: var(--foot-bg); color: var(--foot-fg);
  padding: 40px 0 26px; font-size: 13px;
}
.site-footer .cols {
  display: grid; gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.site-footer h4 {
  color: var(--foot-strong); font-size: 12px; letter-spacing: .08em;
  margin: 0 0 12px; font-weight: 700;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 7px; }
.site-footer a { color: var(--foot-fg); }
.site-footer a:hover { color: var(--foot-strong); }
.site-footer .bottom {
  margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--foot-line);
  display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center;
  color: var(--foot-fg); font-size: 12px;
}
.site-footer .bottom .grow { flex: 1 1 auto; }

/* ---------- 回到顶部 ---------- */
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 40;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-elevated); border: 0;
  color: var(--text-muted); cursor: pointer; display: grid; place-items: center;
  box-shadow: var(--shadow-lg); font-size: 17px; padding: 0;
  opacity: 0; pointer-events: none; transition: opacity .18s, color .12s;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { color: var(--accent); }

/* ---------- 窄屏 ---------- */
@media (max-width: 900px) {
  .hero { padding: 34px 0 22px; }
  .hero h1 { font-size: 30px; }
  .hero .lede { font-size: 15.5px; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .grid { grid-template-columns: 1fr; }
  .to-top { right: 12px; bottom: 12px; }
}

@media print {
  .to-top, .filters { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}
