/* ============================================
   PingSec 安全日报 — 暗色蓝橙主题 v4
   深色底 · PingSec 蓝 #00bfff · 琥珀橙 #ff8c00
   ============================================ */

/* ----- CSS Variables ----- */
:root {
  --bg: #0f1117;
  --bg-card: #161822;
  --bg-hover: #1c1f2e;
  --bg-code: #1a1d2a;
  --border: #2a2d3a;
  --border-hover: #3a3d4a;
  --text: #e1e4e8;
  --text-dim: #8b949e;
  --text-muted: #484f58;
  --primary: #00bfff;
  --primary-dim: #0088cc;
  --primary-glow: rgba(0, 191, 255, 0.12);
  --amber: #ff8c00;
  --red: #f85149;
  --green: #3fb950;
  --purple: #bc8cff;
  --max-w: 1080px;
  --content-w: 720px;
  --radius: 8px;
  --radius-sm: 6px;
  --font-sans: 'Inter', 'Noto Sans SC', 'PingFang SC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ----- Reset & Base ----- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

button, a, input, textarea, select {
  -webkit-tap-highlight-color: transparent;
  -webkit-focus-ring-color: transparent;
  outline: none;
}

::selection { background: var(--primary); color: #000; }
::-moz-selection { background: var(--primary); color: #000; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
  background: var(--bg);
}

/* ----- Custom Scrollbar ----- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }
::-webkit-scrollbar-corner { background: var(--bg); }
* { scrollbar-width: thin; scrollbar-color: var(--border) var(--bg); }

/* ----- Skip Link ----- */
.skip-link {
  position: fixed; top: -100px; left: 16px;
  background: var(--primary); color: #000;
  padding: 8px 16px; z-index: 9999; font-size: 0.8em;
  text-decoration: none; border-radius: var(--radius-sm);
  transition: top 0.2s;
}
.skip-link:focus { top: 10px; }

/* ----- Container ----- */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px;
}

/* ----- Header ----- */
header {
  padding: 28px 0 16px;
  margin-bottom: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,17,23,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 14px;
}

.header-text h1 {
  font-family: var(--font-sans);
  font-size: 1.1em; color: var(--primary);
  font-weight: 600; letter-spacing: -0.3px;
}

.header-text .prompt {
  color: var(--text-dim); font-size: 0.75em; margin-top: 3px;
  display: flex; align-items: center; gap: 4px;
  font-family: var(--font-mono);
}

.cursor {
  display: inline-block; width: 6px; height: 14px;
  background: var(--primary); animation: blink 1s step-end infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* ----- Navigation ----- */
nav { display: flex; gap: 2px; }

nav a {
  color: var(--text-dim); text-decoration: none;
  font-size: 0.78em; padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s;
  font-weight: 450;
}

nav a:hover { color: var(--text); background: var(--bg-hover); }
nav a.active { color: var(--primary); background: var(--primary-glow); }

/* ----- Search ----- */
.search-box {
  display: flex;
  position: relative;
  width: 180px;
  flex-shrink: 0;
}

.search-box input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 32px 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78em;
  font-family: var(--font-sans);
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--primary);
  background: var(--bg-hover);
}

.search-box .search-icon {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: 0.75em;
  pointer-events: none;
}

/* ----- Search Results (Overlay) ----- */
.search-results {
  display: none;
  position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-top: 4px;
  max-height: 360px; overflow-y: auto;
}

.search-results.active { display: block; }

.search-result-item {
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--bg);
  transition: background 0.15s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-hover); }
.search-result-title { font-size: 0.82em; color: var(--text); }
.search-result-title mark { background: var(--primary-glow); color: var(--primary); }
.search-result-meta { font-size: 0.68em; color: var(--text-dim); margin-top: 2px; }

/* ----- Category Tabs ----- */
.cat-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 0 0 20px;
}

.cat-tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 16px;
  min-width: 92px;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.78em; font-weight: 500;
  color: var(--text-dim); text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.cat-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-glow);
}

.cat-tab.active {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
}

.cat-count {
  background: rgba(255,255,255,0.12);
  padding: 1px 7px; border-radius: 10px;
  font-size: 0.82em;
}

.cat-tab.active .cat-count {
  background: rgba(0,0,0,0.2);
}

/* ----- Layout: Main + Sidebar ----- */
.blog-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 32px;
  align-items: start;
}

/* ----- Article Cards ----- */
.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  transition: border-color 0.2s, background 0.2s;
}

.article-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

.card-body { }

.card-top {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px;
}

.card-badge {
  font-size: 0.68em; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
  white-space: nowrap;
}

.card-badge.orange { background: rgba(255,140,0,0.15); color: var(--amber); }
.card-badge.red    { background: rgba(248,81,73,0.15); color: var(--red); }
.card-badge.blue   { background: rgba(0,191,255,0.12); color: var(--primary); }
.card-badge.green  { background: rgba(63,185,80,0.12); color: var(--green); }
.card-badge.purple { background: rgba(188,140,255,0.12); color: var(--purple); }

.card-date {
  font-size: 0.68em; color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}

.article-card h3 {
  font-size: 1em; font-weight: 600; line-height: 1.4;
  margin-bottom: 8px;
}

.article-card h3 a {
  color: var(--text); text-decoration: none;
  transition: color 0.2s;
}

.article-card h3 a:hover { color: var(--primary); }

.card-summary {
  font-size: 0.82em; color: var(--text-dim);
  line-height: 1.6; margin-bottom: 12px;
}

.card-footer {
  display: flex; align-items: center; justify-content: space-between;
}

.card-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
}

.card-tag {
  font-size: 0.65em; padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: color 0.2s, border-color 0.2s;
}

.card-tag:hover { color: var(--text-dim); border-color: var(--border-hover); }

.card-meta-right {
  font-size: 0.68em; color: var(--text-muted);
  white-space: nowrap;
}

/* ----- Sidebar ----- */
.sidebar {
  position: sticky;
  top: 100px;
}

.sidebar-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.sidebar-section h3 {
  font-size: 0.72em; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 1.4em; font-weight: 700; color: var(--primary);
  font-family: var(--font-mono);
}

.stat-label {
  font-size: 0.68em; color: var(--text-dim);
  margin-top: 2px;
}

.cat-stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  text-decoration: none; color: var(--text-dim);
  font-size: 0.82em;
  transition: color 0.2s;
  cursor: pointer;
}

.cat-stat-row:hover { color: var(--primary); }

.cat-stat-row + .cat-stat-row {
  border-top: 1px solid var(--bg);
}

.cat-stat-num {
  font-family: var(--font-mono);
  font-size: 0.82em; color: var(--text-muted);
}

.tag-cloud {
  display: flex; flex-wrap: wrap; gap: 6px;
}

.tag {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.72em;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text-dim);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.tag:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-glow);
}

.tag-orange:hover { border-color: var(--amber); color: var(--amber); background: rgba(255,140,0,0.1); }
.tag-red:hover { border-color: var(--red); color: var(--red); background: rgba(248,81,73,0.1); }

/* ----- Article Page ----- */
.article-page { max-width: var(--content-w); margin: 0 auto; }
.article-back {
  display: inline-block; margin-bottom: 20px;
  color: var(--text-dim); text-decoration: none;
  font-size: 0.82em; transition: color 0.2s;
}
.article-back:hover { color: var(--primary); }

.article-header {
  margin-bottom: 28px;
}

.article-header .meta {
  display: flex; gap: 12px; align-items: center;
  font-size: 0.78em; color: var(--text-dim);
  margin-top: 12px;
}

.article-header .meta span { display: flex; align-items: center; gap: 4px; }

.article-content {
  line-height: 1.8;
  font-size: 0.95em;
}

.article-content h2 {
  font-size: 1.25em;
  margin: 28px 0 14px;
  font-weight: 600;
  color: var(--primary);
  padding-left: 12px;
  border-left: 3px solid var(--primary);
}

.article-content h3 {
  font-size: 1.05em;
  margin: 22px 0 10px;
  font-weight: 600;
  color: var(--amber);
}

.article-content h4 {
  font-size: 0.95em;
  margin: 18px 0 8px;
  font-weight: 600;
  color: var(--text);
}

.article-content p {
  margin: 12px 0;
}

.article-content a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

.article-content a:hover {
  text-decoration: underline;
}

.article-content strong {
  color: var(--text);
  font-weight: 600;
}

.article-content code:not(pre code) {
  background: rgba(0,191,255,0.08);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: var(--font-mono);
}

/* ----- Code Blocks ----- */
.code-block-wrapper {
  margin: 18px 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg-code);
}

.code-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 14px;
  background: #131624;
}

.code-lang {
  font-size: 0.65em; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px;
  font-weight: 600;
}

.code-copy-btn {
  background: none;
  color: var(--text-dim); padding: 3px 10px;
  cursor: pointer; font-size: 0.68em; font-family: inherit;
  transition: color 0.2s;
}

.code-copy-btn:hover { color: var(--primary); }
.code-copy-btn.copied { color: var(--green); }

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

.code-block-wrapper pre code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  line-height: 1.6;
  color: var(--text);
  background: none;
  padding: 0;
}

/* Line numbers (hljs-line-numbers) */
.hljs-ln-numbers {
  color: var(--text-muted);
  text-align: right;
  padding-right: 14px !important;
  user-select: none;
  width: 1%;
}

.hljs-ln-code {
  padding-left: 0 !important;
}

/* ----- Tables ----- */
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.85em;
  border: 1px solid var(--border);
}

.article-content th {
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 8px 14px;
  font-weight: 600;
  color: var(--primary);
  text-align: left;
}

.article-content td {
  border: 1px solid var(--border);
  padding: 7px 14px;
}

.article-content tr:nth-child(even) td {
  background: rgba(255,255,255,0.015);
}

/* ----- Blockquote ----- */
.article-content blockquote {
  border-left: 3px solid var(--amber);
  margin: 16px 0;
  padding: 10px 16px;
  background: rgba(255,140,0,0.04);
  color: var(--text-dim);
  font-size: 0.9em;
}

/* ----- Horizontal Rule ----- */
.article-content hr {
  margin: 28px 0;
  border: none;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

/* ----- Article Navigation ----- */
.article-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin: 40px 0;
}

.article-nav-link {
  display: block;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
}

.article-nav-link:hover { border-color: var(--primary); background: var(--bg-hover); }

.nav-label {
  font-size: 0.72em; color: var(--text-muted);
  margin-bottom: 4px;
}

.nav-title {
  font-size: 0.85em; color: var(--text);
  font-weight: 500;
}

.article-nav-link:hover .nav-title { color: var(--primary); }

/* ----- Back to Top ----- */
#back-to-top {
  position: fixed; bottom: 28px; right: 28px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 1em;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s, border-color 0.2s, color 0.2s;
  transform: translateY(8px);
}

#back-to-top.visible {
  opacity: 1; pointer-events: auto;
  transform: translateY(0);
}

#back-to-top:hover { border-color: var(--primary); color: var(--primary); }

/* ----- Footer ----- */
footer {
  text-align: center;
  padding: 28px 0;
  margin-top: 48px;
  border-top: 1px solid var(--border);
  font-size: 0.75em;
  color: var(--text-muted);
}

/* ----- Empty State ----- */
.no-articles {
  text-align: center; padding: 48px 0;
  color: var(--text-muted);
}

.empty-icon { font-size: 2.5em; margin-bottom: 12px; }

/* ----- Mobile Responsive ----- */
@media (max-width: 768px) {
  .container { padding: 0 16px; }

  header { padding: 16px 0 10px; position: static; }
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .header-text { text-align: center; }
  .header-text h1 { font-size: 1em; }
  .header-text .prompt { justify-content: center; }

  .search-box { width: 100%; }
  .search-box input { font-size: 0.85em; padding: 10px 32px 10px 12px; }
  .search-results { position: absolute; top: 100%; left: 0; right: 0;
    max-height: 50vh; z-index: 200; }

  nav { justify-content: center; flex-wrap: wrap; }

  .blog-layout { grid-template-columns: 1fr; }
  .articles-column { order: 1; }
  .sidebar { order: 2; position: static; }
  .sidebar-section { margin-bottom: 12px; }

  .cat-tabs { justify-content: center; }
  .cat-tab { font-size: 0.72em; padding: 5px 12px; min-width: 0;
    flex: 0 1 auto; }

  .article-card { padding: 14px 16px; margin-bottom: 12px; }
  .article-card h3 { font-size: 0.9em; }
  .card-summary { font-size: 0.78em; }
  .card-top { flex-wrap: wrap; gap: 6px; }
  .card-date { margin-left: 0; }
  .card-footer { flex-direction: column; align-items: flex-start; gap: 8px; }

  .article-page { max-width: 100%; padding: 0; }
  .article-header h1 { font-size: 1.15em !important; }
  .article-content { font-size: 0.88em; }
  .article-content pre { padding: 12px 14px; }
  .article-content pre code { font-size: 0.75em; }
  .code-block-wrapper { margin: 12px 0; }

  .article-nav { grid-template-columns: 1fr; gap: 10px; }

  #back-to-top { bottom: 16px; right: 16px; width: 36px; height: 36px; }

  .stat-grid { grid-template-columns: repeat(4, 1fr); }

  footer { font-size: 0.7em; padding: 20px 0; }
}

@media (max-width: 480px) {
  body { font-size: 14px; }
  .cat-tab { font-size: 0.68em; padding: 4px 10px; }
  .article-card { padding: 12px 14px; }
  .card-badge { font-size: 0.62em; padding: 2px 8px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ----- Print ----- */
@media print {
  .sidebar, #back-to-top, nav, .article-nav, .code-copy-btn, .terminal-bar, .skip-link { display: none !important; }
  .blog-layout { grid-template-columns: 1fr; }
  body { font-size: 12pt; color: #000; background: #fff; }
  .article-card { border: 1px solid #ddd; break-inside: avoid; }
  .article-content a { color: #000; text-decoration: underline; }
  .article-content code { background: #f4f4f4; border: 1px solid #ddd; color: #000; }
  .article-content pre { background: #f8f8f8; border: 1px solid #ddd; }
  .article-content table { border-color: #ddd; }
  .article-content th, .article-content td { border-color: #ddd; }
  .code-block-wrapper { border: 1px solid #ddd; }
  .code-header { border-bottom: 1px solid #ddd; }
  header { border-bottom: 2px solid #000; position: static; background: #fff; }
  .cat-tabs { display: none; }
}

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