/* ═══════════════════════════════════════════════
   MicroLab Blog — CSS v3
   Mobile-first, читаемый код, все категории
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  --green:      #198754;
  --green-l:    #d1e7dd;
  --green-d:    #0f5132;
  --code-bg:    #282c34;
  --code-bd:    #3e4451;
  --radius:     10px;
  --shadow:     0 1px 6px rgba(0,0,0,.08);
  --shadow-h:   0 4px 18px rgba(0,0,0,.13);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: #f3f5f7;
  color: #1a1d23;
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Navbar ── */
.navbar {
  border-bottom: 1px solid rgba(255,255,255,.07);
  padding-top: .5rem;
  padding-bottom: .5rem;
}
.navbar-brand { font-weight: 700; font-size: 1.05rem; letter-spacing: -.3px; white-space: nowrap; }
.navbar-nav .nav-link {
  font-size: .82rem;
  font-weight: 500;
  padding: .35rem .55rem;
  border-radius: 6px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active { color: #4ade80 !important; background: rgba(255,255,255,.08); }
.navbar .form-control {
  background: rgba(255,255,255,.1);
  border-color: transparent;
  color: #fff;
  font-size: .85rem;
}
.navbar .form-control::placeholder { color: rgba(255,255,255,.45); }
.navbar .form-control:focus { background: rgba(255,255,255,.15); border-color: #4ade80; color: #fff; box-shadow: none; }

/* ── Cards ── */
.card { border-radius: var(--radius) !important; box-shadow: var(--shadow); }
.article-card { transition: transform .18s, box-shadow .18s; }
.article-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-h) !important; }

/* ── Category badge ── */
.badge.bg-success-subtle { background: #d1e7dd !important; color: #0f5132 !important; font-weight: 500; font-size: .7rem; text-transform: uppercase; letter-spacing: .3px; }

/* ── Sidebar category links ── */
.cat-link { color: #343a40; transition: background .12s; }
.cat-link:hover { background: #f0faf4; color: var(--green); }

/* ═══════════════════════════════════════════════
   ARTICLE CONTENT
   ═══════════════════════════════════════════════ */
.article-content {
  font-size: 1.03rem;
  line-height: 1.85;
  color: #1a1d23;
  /* Предотвращает переполнение на мобильном */
  overflow-wrap: break-word;
  word-break: break-word;
}

.article-content h1 { font-size: clamp(1.4rem,4vw,1.9rem); font-weight: 700; margin: 2rem 0 .8rem; }
.article-content h2 {
  font-size: clamp(1.2rem,3.5vw,1.45rem);
  font-weight: 650;
  margin: 2.2rem 0 .75rem;
  padding-bottom: .45rem;
  border-bottom: 2px solid var(--green);
  color: #111;
}
.article-content h3 { font-size: clamp(1.05rem,3vw,1.2rem); font-weight: 600; margin: 1.8rem 0 .6rem; color: var(--green-d); }
.article-content h4 { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 .5rem; }
.article-content p  { margin-bottom: 1.1rem; }
.article-content ul, .article-content ol { padding-left: 1.5rem; margin-bottom: 1.1rem; }
.article-content li { margin-bottom: .4rem; }
.article-content hr { margin: 2rem 0; border-color: #dee2e6; }
.article-content a  { color: var(--green); }
.article-content a:hover { color: var(--green-d); }

/* ═══════════════════════════════════════════════
   КОД — главный фикс
   Принцип: atom-one-dark задаёт ВСЕ цвета сам.
   Мы только добавляем обёртку и шрифт.
   НЕ переопределяем цвет токенов — hljs сделает сам.
   ═══════════════════════════════════════════════ */

/* Обёртка блока кода */
.code-block {
  margin: 1.6rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--code-bd);
  box-shadow: 0 3px 14px rgba(0,0,0,.3);
  /* Горизонтальный скролл на мобильном */
  max-width: 100%;
}

/* Шапка */
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #21252b;
  padding: .4rem .9rem;
  border-bottom: 1px solid var(--code-bd);
  gap: .5rem;
}
.code-dots { display: flex; gap: 5px; flex-shrink: 0; }
.code-dots span { width: 11px; height: 11px; border-radius: 50%; }
.code-dots .d-red    { background: #ff5f57; }
.code-dots .d-yellow { background: #febc2e; }
.code-dots .d-green  { background: #28c840; }
.code-lang {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 500;
  color: #636d83;
  text-transform: uppercase;
  letter-spacing: .8px;
  flex: 1;
  text-align: center;
}
.copy-btn {
  flex-shrink: 0;
  background: #2c313a;
  color: #7a8394;
  border: 1px solid var(--code-bd);
  border-radius: 4px;
  padding: .15rem .5rem;
  font-size: .7rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.copy-btn:hover  { background: #3e4451; color: #abb2bf; }
.copy-btn.copied { color: #98c379 !important; border-color: #98c379 !important; }

/* <pre> — только геометрия, НЕ трогаем цвета hljs */
.code-block pre {
  margin: 0 !important;
  padding: 1rem 1.2rem !important;
  border-radius: 0 !important;
  border: none !important;
  overflow-x: auto;
  background: var(--code-bg) !important;
  /* Мобильный: горизонтальный скролл без переноса */
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

/* <code> — только шрифт */
.code-block pre code,
.code-block pre code.hljs {
  font-family: var(--font-mono) !important;
  font-size: .855rem !important;
  line-height: 1.7 !important;
  white-space: pre !important;
  /* НЕ задаём color — это делает atom-one-dark */
}

/* Скроллбар кода */
.code-block pre::-webkit-scrollbar { height: 4px; }
.code-block pre::-webkit-scrollbar-track { background: #21252b; }
.code-block pre::-webkit-scrollbar-thumb { background: #4b5263; border-radius: 2px; }

/* Инлайн-код */
.article-content :not(pre) > code {
  font-family: var(--font-mono);
  font-size: .875em;
  background: #eef7f0;
  color: #1a5e30;
  padding: .12em .42em;
  border-radius: 4px;
  border: 1px solid #c8e6d0;
  white-space: nowrap;
}

/* Blockquote */
.article-content blockquote {
  border-left: 4px solid var(--green);
  padding: .8rem 1.2rem;
  margin: 1.5rem 0;
  background: #f0faf4;
  border-radius: 0 6px 6px 0;
  color: #495057;
  font-style: italic;
}

/* Таблицы */
.table-wrap { overflow-x: auto; margin: 1.5rem 0; border-radius: var(--radius); border: 1px solid #dee2e6; -webkit-overflow-scrolling: touch; }
.article-content table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: 0; min-width: 400px; }
.article-content th { background: var(--green); color: #fff; padding: .6rem .9rem; font-weight: 600; text-align: left; white-space: nowrap; }
.article-content td { padding: .5rem .9rem; border-bottom: 1px solid #dee2e6; }
.article-content tr:last-child td { border-bottom: none; }
.article-content tr:nth-child(even) td { background: #f8fffe; }

/* TOC */
.toc-block { border-left: 3px solid var(--green) !important; border-radius: var(--radius) !important; }
.toc-list a { color: #495057; text-decoration: none; display: block; padding: .1rem 0; transition: color .12s; }
.toc-list a:hover { color: var(--green); }
.toc-list li { padding: .1rem 0; }

/* Misc */
.breadcrumb { background: none; padding: 0; font-size: .85rem; }
.breadcrumb-item + .breadcrumb-item::before { content: "›"; color: #adb5bd; }
.breadcrumb-item a { color: var(--green); text-decoration: none; }
.page-link { color: var(--green); border-radius: 6px !important; }
.page-link:hover { color: var(--green-d); background: var(--green-l); }
.page-item.active .page-link { background: var(--green); border-color: var(--green); }
.last-no-border:last-child { border-bottom: none !important; }
.card .list-unstyled a { color: #343a40; text-decoration: none; }
.card .list-unstyled a:hover { color: var(--green); }
.blinking-cursor { animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ═══════════════════════════════════════════════
   ТЁМНАЯ ТЕМА
   ═══════════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
  body { background: #0d1117; color: #c9d1d9; }
  .article-content { color: #c9d1d9; }
  .article-content h2 { color: #e6edf3; border-color: #238636; }
  .article-content h3 { color: #3fb950; }
  .article-content a  { color: #3fb950; }
  .article-content a:hover { color: #2ea043; }
  .card { background: #161b22 !important; border-color: #30363d !important; color: #c9d1d9; }
  .card-footer { background: #161b22 !important; }
  .card-title { color: #e6edf3 !important; }
  .navbar.bg-dark { background: #010409 !important; }
  footer.bg-dark  { background: #010409 !important; }
  .article-content :not(pre) > code { background: #1b2a1e; color: #3fb950; border-color: #2d5a35; }
  .article-content blockquote { background: #161b22; border-color: #238636; color: #8b949e; }
  .article-content th { background: #238636; }
  .article-content td { border-color: #30363d; }
  .table-wrap { border-color: #30363d; }
  .article-content tr:nth-child(even) td { background: #1c2128; }
  .text-muted { color: #8b949e !important; }
  .text-body  { color: #c9d1d9 !important; }
  .border-bottom, .border-top { border-color: #30363d !important; }
  .badge.bg-success-subtle { background: #1b3a2d !important; color: #3fb950 !important; }
  .alert-secondary { background: #161b22; border-color: #30363d; color: #8b949e; }
  .toc-block { background: #161b22 !important; border-color: #238636 !important; }
  .toc-list a { color: #8b949e; }
  .toc-list a:hover { color: #3fb950; }
  .cat-link { color: #c9d1d9; }
  .cat-link:hover { background: #1b3a2d; color: #3fb950; }
  .page-link { color: #3fb950; }
  .page-link:hover { background: #1b3a2d; border-color: #2d5a35; }
  .page-item.active .page-link { background: #238636; border-color: #238636; }
  .card .list-unstyled a { color: #c9d1d9; }
  .card .list-unstyled a:hover { color: #3fb950; }
}

/* ═══════════════════════════════════════════════
   МОБИЛЬНЫЙ (главное)
   ═══════════════════════════════════════════════ */
@media (max-width: 767px) {
  body { font-size: .97rem; }
  .article-content { font-size: .97rem; line-height: 1.8; }
  .article-content h2 { font-size: 1.2rem; margin-top: 1.8rem; }
  .article-content h3 { font-size: 1.05rem; }

  /* Код на мобильном — чуть меньше шрифт, скролл */
  .code-block pre { padding: .75rem .85rem !important; }
  .code-block pre code.hljs { font-size: .78rem !important; }
  .code-dots { display: none; } /* убираем точки на мобильном — экономим место */
  .code-lang { text-align: left; }

  /* Инлайн-код на мобильном не переносится принудительно */
  .article-content :not(pre) > code { white-space: normal; }

  /* Таблицы */
  .article-content th, .article-content td { padding: .45rem .65rem; font-size: .85rem; }

  /* Карточки */
  .card-body { padding: .9rem; }

  /* Пагинация */
  .pagination { flex-wrap: wrap; gap: .25rem; }
}

@media (max-width: 400px) {
  .code-block pre code.hljs { font-size: .72rem !important; }
  .copy-btn { font-size: .65rem; padding: .12rem .4rem; }
}

/* ── Картинки в статье ── */
.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  margin: 1.4rem auto;
}
.article-content figure {
  margin: 1.6rem 0;
  text-align: center;
}
.article-content figure img {
  margin: 0 auto .6rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.article-content figcaption {
  font-size: .875rem;
  color: #6c757d;
  font-style: italic;
}
@media (prefers-color-scheme: dark) {
  .article-content figcaption { color: #8b949e; }
  .article-content figure img { box-shadow: 0 2px 12px rgba(0,0,0,.4); }
}
