/* =====================================================
   cpp-depth — Industrial Terminal theme
   ===================================================== */

/* --- Variables --- */
:root {
  --bg:           #0b0d0f;
  --bg-surface:   #111518;
  --bg-elevated:  #171c20;
  --border:       #1e2730;
  --border-hover: #2e3d4a;
  --text:         #c4cdd6;
  --text-muted:   #5a6a78;
  --text-dim:     #3a4a58;
  --accent:       #f0a030;
  --accent-dim:   #7a5018;
  --blue:         #3a9fd8;
  --green:        #4caf7d;
  --red:          #e05c5c;
  --font-mono:    'JetBrains Mono', monospace;
  --font-sans:    'IBM Plex Sans', sans-serif;
  --font-serif:   'IBM Plex Serif', serif;
  --radius:       6px;
  --max-w:        1140px;
  --narrow-w:     720px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Dot-grid background */
  background-image: radial-gradient(circle, #1e2730 1px, transparent 1px);
  background-size: 28px 28px;
  background-attachment: fixed;
}

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

/* --- Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 13, 15, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 60px;
}
.site-logo {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.logo-bracket { color: var(--text-muted); }
.logo-text    { color: var(--text); }
.logo-accent  { color: var(--accent); }

.site-nav {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}
.site-nav a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
  letter-spacing: 0.02em;
}
.site-nav a:hover,
.site-nav a.active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(240,160,48,.06);
}

.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 1rem;
}
.lang-btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s, border-color .15s, background .15s;
  cursor: pointer;
}
.lang-btn:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(240,160,48,.06);
}
.lang-active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(240,160,48,.08);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}

/* --- Hero --- */
.hero {
  padding: 6rem 0 5rem;
  border-bottom: 1px solid var(--border);
}
.hero-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-bottom: 1.25rem;
  opacity: 0.8;
}
.hero-title {
  font-family: var(--font-mono);
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: #e0e8f0;
  margin-bottom: 1.25rem;
}
.hero-accent { color: var(--accent); }
.hero-sub {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 540px;
  line-height: 1.65;
}

.page-hero {
  padding: 3.5rem 0 2.5rem;
  border-bottom: 1px solid var(--border);
}
.page-title {
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #e0e8f0;
  margin-top: 0.75rem;
}
.page-desc {
  color: var(--text-muted);
  margin-top: 0.75rem;
  max-width: 540px;
}

/* --- Section headers --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 3.5rem 0 1.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.section-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  opacity: 0.7;
}
.section-more {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.section-more:hover { color: var(--accent); }

/* --- Article grid --- */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* --- Article card --- */
.article-card {
  background: var(--bg-surface);
  padding: 1.75rem;
  transition: background .15s;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.article-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .2s;
}
.article-card:hover {
  background: var(--bg-elevated);
}
.article-card:hover::before { opacity: 1; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.card-category {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 3px;
  text-decoration: none;
  border: 1px solid;
}
.cat-architecture { color: #3a9fd8; border-color: rgba(58,159,216,.3); background: rgba(58,159,216,.08); }
.cat-performance  { color: #f0a030; border-color: rgba(240,160,48,.3); background: rgba(240,160,48,.08); }
.cat-embedded     { color: #4caf7d; border-color: rgba(76,175,125,.3); background: rgba(76,175,125,.08); }
.cat-snippets     { color: #a07ad8; border-color: rgba(160,122,216,.3); background: rgba(160,122,216,.08); }

.card-date, .card-reading-time {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
}

.card-title {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.card-title a {
  color: #d8e4f0;
  text-decoration: none;
  transition: color .15s;
}
.card-title a:hover { color: var(--accent); }

.card-excerpt {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}
.tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  transition: color .15s, border-color .15s;
}
.tag:hover { color: var(--text-muted); border-color: var(--border-hover); }

/* --- Article two-column layout (article + ToC sidebar) --- */
.article-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 3.5rem;
  align-items: start;
  padding-top: 4rem;
  padding-bottom: 6rem;
}

/* --- Single article --- */
.single-article {
  min-width: 0;
  flex: 1;
}
.article-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.article-title {
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #e0e8f0;
  margin: 1rem 0 0.75rem;
  line-height: 1.2;
}
.article-lead {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.6;
  font-style: italic;
  font-family: var(--font-serif);
}
.article-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

/* --- Article body --- */
.article-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
}
.article-body h2 {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: #d8e4f0;
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.01em;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.article-body h2::before {
  content: '## ';
  color: var(--accent);
  opacity: 0.6;
}
.article-body h3 {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: #c8d8e8;
  margin: 2rem 0 0.75rem;
}
.article-body h3::before {
  content: '### ';
  color: var(--blue);
  opacity: 0.6;
}
.article-body p { margin-bottom: 1.25rem; }
.article-body a {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: rgba(58,159,216,.4);
  transition: color .15s;
}
.article-body a:hover { color: var(--accent); }

.article-body strong { color: #e0e8f0; font-weight: 500; }
.article-body em { font-style: italic; color: #a0b4c8; }

.article-body ul, .article-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}
.article-body li { margin-bottom: 0.4rem; }

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--bg-surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
  font-family: var(--font-serif);
  font-style: italic;
}

/* Inline code */
.article-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-elevated);
  color: var(--accent);
  padding: 0.15em 0.45em;
  border-radius: 3px;
  border: 1px solid var(--border);
}

/* Code blocks */
.article-body pre {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
  position: relative;
}
.article-body pre::before {
  content: attr(data-lang);
  position: absolute;
  top: 0; right: 0;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 0 var(--radius) 0 var(--radius);
}
.article-body pre code {
  background: none;
  border: none;
  padding: 1.25rem 1.5rem;
  display: block;
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--text);
}

/* Syntax highlight line numbers */
.article-body .lntable {
  border-spacing: 0;
  width: 100%;
}
.article-body .lnt {
  color: var(--text-dim);
  padding-right: 1.25rem;
  user-select: none;
  font-size: 0.8rem;
}

/* Tables */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1.5rem 0;
  font-family: var(--font-mono);
}
.article-body th {
  background: var(--bg-elevated);
  color: var(--accent);
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-align: left;
  padding: 0.6rem 1rem;
  border-bottom: 2px solid var(--accent-dim);
}
.article-body td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.article-body tr:hover td { background: var(--bg-surface); }

/* --- Article footer / nav --- */
.article-footer {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}
.article-nav__prev,
.article-nav__next {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.article-nav__next { text-align: right; }
.article-nav__prev:hover,
.article-nav__next:hover {
  border-color: var(--accent-dim);
  background: var(--bg-elevated);
}
.nav-dir {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  opacity: 0.7;
}
.nav-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 500;
}

/* --- Footer --- */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  background: var(--bg-surface);
}
.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-desc {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-left: 1rem;
}
.footer-right {
  display: flex;
  gap: 1.25rem;
}
.footer-link {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.footer-link:hover { color: var(--accent); }

/* --- Home / list content padding --- */
.home-content, .list-content { padding: 0 0 5rem; }

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 3rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
.pagination a, .pagination span {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  transition: border-color .15s, color .15s;
}
.pagination a:hover { border-color: var(--accent-dim); color: var(--accent); }
.pagination .active span { border-color: var(--accent-dim); color: var(--accent); background: rgba(240,160,48,.06); }

/* --- ToC sidebar --- */
.toc-sidebar {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.toc {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.toc-title {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.7;
  margin-bottom: 0.75rem;
}

.toc nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc nav ul ul {
  padding-left: 0.75rem;
}

.toc nav li { margin: 0; }

.toc nav a {
  display: block;
  padding: 0.22rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 3px 3px 0;
  transition: color .15s, border-color .15s, background .15s;
}

.toc nav a:hover {
  color: var(--text);
  border-left-color: var(--border-hover);
}

.toc nav a.toc-active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(240,160,48,.05);
}

/* --- Responsive --- */
@media (max-width: 1060px) {
  .article-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .toc-sidebar { display: none; }
}

@media (max-width: 768px) {
  .site-nav { display: none; }
  .site-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 60px; left: 0; right: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
  }
  .nav-toggle { display: flex; margin-left: auto; }
  .article-grid { grid-template-columns: 1fr; }
  .article-nav { grid-template-columns: 1fr; }
  .footer-desc { display: none; }
  .article-layout { padding-top: 2rem; padding-bottom: 3rem; }
}
