/* ============================================================
   硬见 · 智能硬件产品笔记 — Editorial Stylesheet
   Aesthetic: Technical Editorial / Dark refined magazine
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700;9..144,900&family=Noto+Serif+SC:wght@400;500;600;700;900&family=Noto+Sans+SC:wght@300;400;500;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- Design Tokens ---------- */
:root {
  /* Dark theme (default) */
  --bg: #0a0a0b;
  --bg-soft: #101013;
  --bg-elevated: #16161a;
  --surface: #1c1c21;
  --surface-hover: #232329;

  --text: #ebe6da;
  --text-muted: #9b9586;
  --text-faint: #65605a;

  --accent: #c9a227;
  --accent-soft: rgba(201, 162, 39, 0.14);
  --accent-glow: rgba(201, 162, 39, 0.35);

  --border: #26262c;
  --border-light: #34343b;

  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
  --shadow-card: 0 12px 40px -12px rgba(0, 0, 0, 0.6);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --maxw: 1200px;
  --maxw-article: 760px;

  --font-display: 'Fraunces', 'Noto Serif SC', serif;
  --font-serif: 'Noto Serif SC', 'Fraunces', serif;
  --font-sans: 'Noto Sans SC', -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme='light'] {
  --bg: #f6f3ec;
  --bg-soft: #efebdf;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-hover: #faf7f0;

  --text: #1d1b16;
  --text-muted: #6c665a;
  --text-faint: #a39d8e;

  --accent: #a87f0f;
  --accent-soft: rgba(168, 127, 15, 0.12);
  --accent-glow: rgba(168, 127, 15, 0.3);

  --border: #e4ded0;
  --border-light: #d6cfbe;

  --shadow-lg: 0 30px 60px -25px rgba(80, 65, 30, 0.25);
  --shadow-card: 0 12px 40px -18px rgba(80, 65, 30, 0.22);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul, ol { list-style: none; }

/* ---------- Grain / Atmosphere ---------- */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.035;
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: overlay;
}
[data-theme='light'] body::before { opacity: 0.025; }

/* ---------- Navbar ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 40px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s var(--ease);
}
.nav-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: -0.01em;
  display: flex; align-items: baseline; gap: 10px;
}
.nav-logo .mark {
  display: inline-block;
  width: 9px; height: 9px;
  background: var(--accent);
  border-radius: 2px;
  transform: rotate(45deg);
  box-shadow: 0 0 14px var(--accent-glow);
}
.nav-logo small {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.nav-links { display: flex; align-items: center; gap: 28px; }
.nav-links a {
  font-size: 0.92rem;
  color: var(--text-muted);
  transition: color 0.2s var(--ease);
  position: relative;
}
.nav-links a:hover { color: var(--text); }
.nav-links a::after {
  content: ''; position: absolute; bottom: -6px; left: 0;
  width: 0; height: 1.5px; background: var(--accent);
  transition: width 0.3s var(--ease);
}
.nav-links a:hover::after { width: 100%; }
.theme-toggle {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: all 0.25s var(--ease);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 180px 40px 100px;
  max-width: var(--maxw);
  margin: 0 auto;
  overflow: hidden;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 28px;
  opacity: 0; animation: rise 0.8s var(--ease) 0.1s forwards;
}
.hero-eyebrow::before {
  content: ''; width: 36px; height: 1px; background: var(--accent);
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 7vw, 5.4rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin-bottom: 28px;
  opacity: 0; animation: rise 0.9s var(--ease) 0.2s forwards;
}
.hero h1 em {
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
}
.hero p {
  max-width: 620px;
  font-size: 1.12rem;
  color: var(--text-muted);
  line-height: 1.8;
  opacity: 0; animation: rise 0.9s var(--ease) 0.35s forwards;
}
.hero-stats {
  margin-top: 56px;
  display: flex; gap: 56px;
  opacity: 0; animation: rise 0.9s var(--ease) 0.5s forwards;
}
.hero-stat .num {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.hero-stat .lbl {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 8px;
  letter-spacing: 0.05em;
}

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

/* ---------- Section heading ---------- */
.section-head {
  max-width: var(--maxw);
  margin: 40px auto 36px;
  padding: 0 40px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.section-head .count {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-faint);
}

/* ---------- Category filter ---------- */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.filter-chip {
  padding: 7px 16px;
  font-size: 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.25s var(--ease);
  background: transparent;
}
.filter-chip:hover { border-color: var(--border-light); color: var(--text); }
.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1a1a;
  font-weight: 500;
}

/* ---------- Article grid ---------- */
.grid {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 40px 80px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 28px;
}
.card {
  grid-column: span 4;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform 0.4s var(--ease), border-color 0.3s var(--ease), box-shadow 0.4s var(--ease);
  opacity: 0;
  animation: cardIn 0.7s var(--ease) forwards;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
.card:hover {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow: var(--shadow-card);
}
.card.featured { grid-column: span 12; flex-direction: row; }
.card-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-soft);
}
.card.featured .card-cover {
  flex: 0 0 46%;
  aspect-ratio: auto;
  min-height: 320px;
}
.card-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.7s var(--ease);
}
.card:hover .card-cover img { transform: scale(1.06); }
.card-cover::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.4), transparent 55%);
  opacity: 0.6;
}
.card-body {
  padding: 22px 24px 26px;
  display: flex; flex-direction: column; gap: 12px;
  flex: 1;
}
.card.featured .card-body { padding: 36px 40px; justify-content: center; flex: 1; }
.card-tag {
  display: inline-flex; align-items: center;
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}
.card-tag::before {
  content: ''; width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 8px;
}
.card-title {
  font-family: var(--font-serif);
  font-size: 1.18rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card.featured .card-title { font-size: 2rem; line-height: 1.2; -webkit-line-clamp: 3; }
.card-excerpt {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card.featured .card-excerpt { -webkit-line-clamp: 4; font-size: 1rem; }
.card-meta {
  margin-top: auto;
  display: flex; align-items: center; gap: 16px;
  font-size: 0.82rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}
.card-meta .dot { width: 3px; height: 3px; background: var(--text-faint); border-radius: 50%; }
.read-more {
  margin-top: 8px;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
  transition: gap 0.3s var(--ease);
}
.card:hover .read-more { gap: 14px; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 50px 40px;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
}
.footer .mark {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ============================================================
   ARTICLE PAGE
   ============================================================ */
.reading-progress {
  position: fixed; top: 0; left: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), #e6c25a);
  z-index: 200;
  width: 0;
  transition: width 0.1s linear;
  box-shadow: 0 0 12px var(--accent-glow);
}
.article-cover {
  position: relative;
  width: 100%;
  height: 62vh;
  min-height: 440px;
  overflow: hidden;
}
.article-cover img {
  width: 100%; height: 100%; object-fit: cover;
}
.article-cover::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(10,10,11,0.2) 0%, rgba(10,10,11,0.55) 55%, var(--bg) 100%);
}
.article-cover-inner {
  position: absolute; bottom: 0; left: 0; right: 0;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 40px 60px;
}
.article-cover-inner .cat {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 18px;
  font-family: var(--font-mono);
}
.article-cover-inner h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4.5vw, 3.4rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  max-width: 820px;
}
.article-meta-bar {
  display: flex; align-items: center; gap: 22px;
  margin-top: 22px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.article-meta-bar .sep { color: var(--text-faint); }

.article-layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 60px 40px 100px;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 70px;
  align-items: start;
}
.article-content {
  min-width: 0;
  max-width: var(--maxw-article);
}

/* ---------- Markdown content styles ---------- */
.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4 {
  font-family: var(--font-serif);
  color: var(--text);
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.article-content h2 {
  font-size: 1.9rem;
  font-weight: 700;
  margin: 56px 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.article-content h2::before {
  content: ''; position: absolute; bottom: -1px; left: 0;
  width: 48px; height: 2px; background: var(--accent);
}
.article-content h3 {
  font-size: 1.38rem;
  font-weight: 600;
  margin: 40px 0 16px;
  color: var(--text);
}
.article-content h4 {
  font-size: 1.12rem;
  font-weight: 600;
  margin: 28px 0 12px;
  color: var(--accent);
}
.article-content p {
  margin: 16px 0;
  font-size: 1.03rem;
  line-height: 1.9;
  color: var(--text);
}
.article-content strong { color: var(--text); font-weight: 600; }
.article-content a {
  color: var(--accent);
  border-bottom: 1px solid var(--accent-soft);
  transition: border-color 0.2s;
}
.article-content a:hover { border-bottom-color: var(--accent); }

.article-content ul, .article-content ol {
  margin: 16px 0 16px 4px;
  padding-left: 24px;
}
.article-content ul { list-style: none; padding-left: 0; }
.article-content ul li {
  position: relative;
  padding-left: 22px;
  margin: 8px 0;
  line-height: 1.8;
}
.article-content ul li::before {
  content: ''; position: absolute; left: 0; top: 0.75em;
  width: 7px; height: 7px;
  background: var(--accent);
  transform: rotate(45deg);
  opacity: 0.8;
}
.article-content ol { list-style: decimal; }
.article-content ol li { margin: 8px 0; line-height: 1.8; padding-left: 6px; }

.article-content blockquote {
  margin: 24px 0;
  padding: 18px 24px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
  font-size: 0.97rem;
  line-height: 1.8;
}
.article-content blockquote p { margin: 6px 0; }

.article-content hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 48px 0;
  position: relative;
}
.article-content hr::after {
  content: '§';
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg);
  color: var(--text-faint);
  padding: 0 14px;
  font-family: var(--font-serif);
  font-size: 1rem;
}

.article-content img {
  margin: 28px auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}

/* Tables */
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.92rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.article-content thead {
  background: var(--surface);
}
.article-content th {
  text-align: left;
  padding: 14px 16px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--accent);
  font-family: var(--font-serif);
}
.article-content td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  line-height: 1.7;
}
.article-content tbody tr:last-child td { border-bottom: none; }
.article-content tbody tr:hover { background: var(--accent-soft); }
.article-content tbody tr:hover td { color: var(--text); }

/* Code */
.article-content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--accent);
}
.article-content pre {
  margin: 24px 0;
  padding: 20px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
.article-content pre code {
  background: none; border: none; padding: 0; color: var(--text);
  font-size: 0.88rem; line-height: 1.7;
}

/* ---------- TOC ---------- */
.toc-wrap {
  position: sticky;
  top: 100px;
}
.toc-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.toc-list { font-size: 0.88rem; }
.toc-list a {
  display: block;
  padding: 6px 0 6px 14px;
  color: var(--text-muted);
  border-left: 2px solid var(--border);
  transition: all 0.2s var(--ease);
  line-height: 1.5;
}
.toc-list a:hover { color: var(--text); border-color: var(--border-light); }
.toc-list a.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.toc-list .toc-h3 { padding-left: 30px; font-size: 0.83rem; }

/* Back to top */
.back-top {
  position: fixed;
  bottom: 30px; right: 30px;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: grid; place-items: center;
  opacity: 0; pointer-events: none;
  transform: translateY(10px);
  transition: all 0.3s var(--ease);
  z-index: 90;
}
.back-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.back-top:hover { color: var(--accent); border-color: var(--accent); }

/* Prev / Next */
.article-nav {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 40px 80px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.article-nav a {
  display: block;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: all 0.3s var(--ease);
}
.article-nav a:hover { border-color: var(--accent); transform: translateY(-3px); }
.article-nav .label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.article-nav .t {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.4;
}
.article-nav .next { text-align: right; }

/* ---------- Loading ---------- */
.loading {
  display: grid; place-items: center;
  min-height: 50vh;
  font-family: var(--font-mono);
  color: var(--text-muted);
  letter-spacing: 0.1em;
}
.loading::after {
  content: '';
  margin-left: 12px;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .card { grid-column: span 6; }
  .article-layout { grid-template-columns: 1fr; gap: 40px; }
  .toc-wrap { display: none; }
}
@media (max-width: 720px) {
  .nav { padding: 14px 20px; }
  .nav-links { display: none; }
  .hero { padding: 140px 20px 70px; }
  .hero-stats { gap: 32px; }
  .section-head { padding: 0 20px; }
  .grid { padding: 0 20px 60px; gap: 20px; }
  .card { grid-column: span 12; }
  .card.featured { flex-direction: column; }
  .card.featured .card-cover { flex: none; aspect-ratio: 16/9; min-height: auto; }
  .card.featured .card-body { padding: 24px; }
  .card.featured .card-title { font-size: 1.5rem; }
  .article-cover { height: 52vh; min-height: 360px; }
  .article-cover-inner { padding: 0 20px 40px; }
  .article-layout { padding: 40px 20px 70px; }
  .article-nav { grid-template-columns: 1fr; padding: 0 20px 60px; }
  .article-nav .next { text-align: left; }
  .article-content h2 { font-size: 1.55rem; }
  .article-content table { font-size: 0.82rem; }
  .article-content th, .article-content td { padding: 10px 8px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

::selection { background: var(--accent); color: #1a1a1a; }
