/* ============ 技术探索 · 列表与文章 ============ */

:root {
  --code-bg: rgba(255, 255, 255, 0.035);
  --code-head-bg: rgba(255, 255, 255, 0.02);
  --code-border: rgba(255, 255, 255, 0.14);
  --step-line: rgba(255, 255, 255, 0.14);
  --note-bg: rgba(29, 155, 240, 0.06);
  --note-border: rgba(29, 155, 240, 0.4);
}

:root[data-theme="light"] {
  --code-bg: rgba(0, 0, 0, 0.035);
  --code-head-bg: rgba(0, 0, 0, 0.02);
  --code-border: rgba(0, 0, 0, 0.14);
  --step-line: rgba(0, 0, 0, 0.14);
  --note-bg: rgba(29, 155, 240, 0.07);
  --note-border: rgba(29, 155, 240, 0.5);
}

/* ---- 列表页头部 ---- */
.tech-head { margin-bottom: 40px; }

.tech-intro {
  margin-top: 20px;
  max-width: 34em;
  font-size: 16px;
  color: var(--fg-secondary);
  line-height: 1.8;
}

/* ---- 筛选工具条 ---- */
.tech-toolbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding-bottom: 20px;
}

.tech-search {
  position: relative;
  flex: 1 1 260px;
  max-width: 420px;
}

.tech-search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-faint);
  pointer-events: none;
}

.tech-search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 38px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--fg);
  background: var(--card-bg);
  border: 1px solid var(--divider);
  border-radius: 9999px;
  transition: border-color 0.2s ease;
}

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

.tech-search input:hover,
.tech-search input:focus { border-color: var(--divider-strong); }

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

.tech-sort {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-faint);
}

.tech-sort select {
  height: 40px;
  padding: 0 32px 0 14px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--fg);
  background: var(--card-bg);
  border: 1px solid var(--divider);
  border-radius: 9999px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 17px center, right 12px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.tech-sort select option {
  background: var(--bg);
  color: var(--fg);
}

.tech-filters {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 18px 0;
  border-top: 1px solid var(--divider);
  flex-wrap: wrap;
}

.tech-filters .filter-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-faint);
  letter-spacing: 0.13px;
  min-width: 3.5em;
}

.tech-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font-size: 13px;
  color: var(--fg-secondary);
  background: none;
  border: 1px solid var(--divider);
  border-radius: 9999px;
  padding: 5px 14px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.chip:hover { color: var(--fg); border-color: var(--divider-strong); }

.chip[aria-pressed="true"] {
  color: var(--bg);
  background: var(--fg);
  border-color: var(--fg);
}

.chip-toggle {
  color: var(--fg-muted);
  border-style: dashed;
}

.chip .chip-count {
  font-family: var(--font-mono);
  font-size: 11px;
  margin-left: 6px;
  opacity: 0.6;
}

/* ---- 数量与重置 ---- */
.tech-count {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-faint);
  letter-spacing: 0.13px;
  padding: 14px 0 6px;
  border-top: 1px solid var(--divider);
}

.tech-reset {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--fg-secondary);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.tech-reset:hover { color: var(--fg); }

/* ---- 文章列表行 ---- */
.tech-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) auto;
  gap: 28px;
  padding: 30px 0;
  border-top: 1px solid var(--divider);
  align-items: start;
}

.tech-row:last-of-type { border-bottom: 1px solid var(--divider); }

.tech-row-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
}

.tech-date {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-muted);
}

.tech-cat {
  align-self: flex-start;
  font-size: 12px;
  color: var(--fg-secondary);
  border: 1px solid var(--divider);
  border-radius: 4px;
  padding: 2px 8px;
}

.tech-row-title {
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.2px;
  line-height: 1.35;
}

.tech-row-en {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-faint);
  letter-spacing: 0.13px;
  margin-top: 8px;
}

.tech-row-summary {
  margin-top: 12px;
  font-size: 15px;
  color: var(--fg-secondary);
  line-height: 1.75;
  max-width: 42em;
}

.tech-row-link {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.tech-row:hover .tech-row-link,
.tech-row:focus-within .tech-row-link { opacity: 1; transform: translateY(0); }

@media (hover: hover) and (pointer: fine) {
  .tech-row:hover { background: var(--hover-bg); }
  .tech-row:hover .tech-row-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
}

/* 首页精选：更紧凑的行 */
.tech-row--compact { grid-template-columns: 1fr auto; gap: 24px; padding: 26px 0; }
.tech-row--compact .tech-row-title { font-size: 19px; }
.tech-row--compact .tech-row-summary { margin-top: 10px; font-size: 14px; }
.tech-row--compact .tech-row-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-faint);
  letter-spacing: 0.13px;
  flex-wrap: wrap;
}
.tech-row--compact .tech-row-link { opacity: 1; transform: none; }

.tech-empty {
  padding: 56px 0;
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
  font-size: 15px;
  color: var(--fg-secondary);
  line-height: 1.8;
}

.tech-empty strong { color: var(--fg); font-weight: 500; }

/* ---- 文章页 ---- */
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

.article-head h1 {
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 500;
  letter-spacing: -0.8px;
  line-height: 1.2;
  max-width: 22em;
  margin-top: 24px;
}

.article-meta {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 26px;
  font-size: 13px;
  color: var(--fg-secondary);
}

.article-meta .tech-date,
.article-meta .article-reading {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-faint);
  letter-spacing: 0.13px;
}

.article-body { margin-top: 20px; }

.article-body .lede {
  margin-top: 40px;
  font-size: 17px;
  color: var(--fg-secondary);
  line-height: 1.85;
  max-width: 40em;
  padding-left: 20px;
  border-left: 1px solid var(--divider-strong);
}

.article-body h2 {
  margin-top: 64px;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.3px;
  line-height: 1.3;
  scroll-margin-top: 96px;
}

.article-body h3:not(.step-title) {
  margin-top: 44px;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.1px;
  display: flex;
  align-items: center;
  gap: 12px;
  scroll-margin-top: 96px;
}

.article-body h3:not(.step-title)::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--divider-strong);
  flex-shrink: 0;
}

.article-body p {
  margin-top: 18px;
  font-size: 16px;
  color: var(--fg-secondary);
  line-height: 1.85;
  max-width: 44em;
}

.article-body ul { list-style: none; margin-top: 18px; }

.article-body ul li {
  position: relative;
  padding: 6px 0 6px 24px;
  color: var(--fg-secondary);
  line-height: 1.8;
  max-width: 44em;
}

.article-body ul li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--fg-faint);
}

/* 正文内联链接：可见的下划线，悬停加深 */
.link-inline {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--divider-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: text-decoration-color 0.2s ease;
}

.link-inline:hover { text-decoration-color: var(--fg); }

/* ---- 步骤 ---- */
.steps {
  list-style: none;
  margin-top: 32px;
  counter-reset: step;
}

.step {
  position: relative;
  padding-left: 56px;
  padding-bottom: 40px;
}

.step:last-child { padding-bottom: 0; }

.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--divider-strong);
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-secondary);
  background: var(--bg);
}

.step::after {
  content: "";
  position: absolute;
  left: 16px;
  top: 40px;
  bottom: 8px;
  width: 1px;
  background: var(--step-line);
}

.step:last-child::after { display: none; }

.step-title {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.1px;
  line-height: 1.5;
  padding-top: 4px;
}

.step > .step-title { max-width: 40em; }

.step-body > p:first-child { margin-top: 12px; }

/* ---- 终端 / 文件片段 ---- */
.code-block {
  margin-top: 22px;
  border: 1px solid var(--code-border);
  border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 12px 9px 16px;
  background: var(--code-head-bg);
  border-bottom: 1px solid var(--code-border);
}

.code-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  letter-spacing: 0.13px;
  overflow-wrap: anywhere;
}

.code-copy {
  flex-shrink: 0;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--fg-secondary);
  background: none;
  border: 1px solid var(--divider);
  border-radius: 9999px;
  padding: 3px 12px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.code-copy:hover { color: var(--fg); border-color: var(--divider-strong); }

.code-block pre {
  margin: 0;
  padding: 16px;
  background: var(--code-bg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.code-block code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  color: var(--fg);
  white-space: pre;
  display: block;
}

/* ---- 配图 ---- */
.figure-card {
  margin-top: 24px;
  border: 1px solid var(--divider);
  border-radius: 12px;
  padding: 18px;
  background: var(--card-bg);
}

.figure-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  letter-spacing: 0.13px;
  margin-bottom: 14px;
}

.figure-card picture { display: block; }

.figure-card img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--divider);
}

.figure-card figcaption {
  margin-top: 14px;
  font-size: 13px;
  color: var(--fg-muted);
  line-height: 1.75;
  max-width: 52em;
}

.figure-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.figure-pair .figure-card { margin-top: 0; }

.figure-pair .figure-card img {
  width: auto;
  max-width: 100%;
  max-height: 460px;
  margin: 0 auto;
}

/* ---- 公式 ---- */
.formula-block {
  margin-top: 22px;
  border: 1px solid var(--divider);
  border-radius: 12px;
  padding: 18px 20px;
  background: var(--card-bg);
  max-width: 44em;
}

.formula-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-faint);
  letter-spacing: 0.13px;
  margin-bottom: 12px;
}

.formula-line {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 2;
  color: var(--fg);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
}

.formula-line + .formula-line { margin-top: 6px; }

/* ---- 提示框 ---- */
.note-box {
  margin-top: 22px;
  padding: 16px 18px;
  border-left: 2px solid var(--note-border);
  background: var(--note-bg);
  border-radius: 0 8px 8px 0;
}

.note-box p {
  margin-top: 0;
  font-size: 14px;
  color: var(--fg-secondary);
  line-height: 1.75;
}

.note-box .note-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  letter-spacing: 0.13px;
  margin-bottom: 8px;
}

/* ---- 目录 ---- */
.article-toc {
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 128px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-left: 1px solid var(--divider);
  padding: 0 8px 8px 24px;
}

.article-toc .toc-title {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-faint);
  letter-spacing: 0.13px;
  margin-bottom: 16px;
}

.article-toc ol { list-style: none; display: flex; flex-direction: column; gap: 12px; }

.article-toc a {
  font-size: 14px;
  color: var(--fg-muted);
  line-height: 1.5;
  transition: color 0.2s ease;
}

.article-toc a:hover,
.article-toc a.active { color: var(--fg); }

/* ---- 上一篇 / 下一篇 ---- */
.article-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 72px;
  padding-top: 28px;
  border-top: 1px solid var(--divider);
}

.article-nav a {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.article-nav .nav-dir {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-faint);
  letter-spacing: 0.13px;
}

.article-nav .nav-title {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
}

.article-nav a:hover .nav-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }

.article-nav .nav-next { text-align: right; align-items: flex-end; }

.article-nav .nav-empty { color: var(--fg-faint); font-size: 14px; }

/* ---- 响应式 ---- */
@media (min-width: 1024px) {
  .article-layout { grid-template-columns: minmax(0, 1fr) 220px; }
}

@media (max-width: 1023px) {
  .article-toc { display: none; }
}

@media (max-width: 860px) {
  .tech-row { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .tech-row-side {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding-top: 0;
  }
  .tech-row-link { opacity: 1; transform: none; align-self: flex-start; }
  .tech-row--compact { grid-template-columns: minmax(0, 1fr); }
  .figure-pair { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .tech-toolbar { gap: 12px; }
  .tech-search { max-width: none; }
  .tech-sort { width: 100%; justify-content: space-between; }
  .tech-filters { gap: 10px; }
  .tech-filters .filter-label { min-width: 100%; }
  .tech-row-title { font-size: 19px; }
  .step { padding-left: 44px; padding-bottom: 32px; }
  .step::before { width: 28px; height: 28px; font-size: 12px; }
  .step::after { left: 14px; top: 36px; }
  .figure-card { padding: 12px; }
  .article-body h2 { margin-top: 48px; font-size: 21px; }
  .code-block code { font-size: 12px; }
  .article-nav { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .article-nav .nav-next { text-align: left; align-items: flex-start; }
}

/* ---- 打印 ---- */
@media print {
  :root {
    --code-bg: #f7f7f7;
    --code-head-bg: #fff;
    --code-border: rgba(0, 0, 0, 0.25);
    --step-line: rgba(0, 0, 0, 0.2);
    --note-bg: #fff;
  }
  .tech-toolbar,
  .tech-filters,
  .article-toc,
  .code-copy { display: none !important; }
  .step, .code-block, .figure-card, .note-box { break-inside: avoid; }
  .code-block code { white-space: pre-wrap; overflow-wrap: anywhere; }
}
