/* qwertmax.ru — blog styles. No external fonts, no JS. */
:root {
  --bg: #ffffff;
  --fg: #1d2127;
  --muted: #5b6472;
  --line: #e5e7eb;
  --surface: #ffffff;
  --soft: #f6f7f9;
  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-soft: #eef0ff;
  --code-bg: #f4f5f8;
  --code-fg: #1f2330;
  --header-bg: rgba(255, 255, 255, 0.78);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  --w: 720px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --fg: #e6e9ef;
    --muted: #9aa3b2;
    --line: #252b36;
    --surface: #141922;
    --soft: #171c25;
    --accent: #a5b4fc;
    --accent-hover: #c7d2fe;
    --accent-soft: #1f2442;
    --code-bg: #161b24;
    --code-fg: #e2e6ee;
    --header-bg: rgba(14, 17, 22, 0.72);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  }
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 80px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
a:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.wrap { width: 100%; max-width: calc(var(--w) + 48px); margin: 0 auto; padding: 0 24px; }

.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; padding: 8px 14px; background: var(--accent); color: #fff; border-radius: 8px; }
.skip:focus { left: 12px; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em; color: var(--fg); text-decoration: none; white-space: nowrap; }
.brand:hover { color: var(--accent); }
.site-nav ul { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.site-nav a { display: block; padding: 6px 12px; border-radius: 999px; font-size: 0.9rem; font-weight: 500; color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--fg); background: var(--soft); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

main.wrap { padding-top: 56px; padding-bottom: 72px; min-height: 60vh; }

/* Page heads (home, category, 404) */
.page-head { margin-bottom: 36px; }
.page-kicker { margin: 0 0 4px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.page-title { margin: 0; font-size: clamp(2rem, 1.5rem + 2vw, 2.75rem); line-height: 1.12; letter-spacing: -0.025em; font-weight: 800; }
.page-sub { margin: 10px 0 0; color: var(--muted); font-size: 1.05rem; }

/* Meta line + tags */
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: 0.875rem; line-height: 1.5; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tag {
  position: relative;
  z-index: 1;
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.6;
  text-decoration: none;
}
.tag:hover { background: var(--accent); color: var(--bg); }
.tags-inline { display: inline-flex; margin-left: 4px; }

/* Cards */
.cards { display: grid; gap: 18px; }
.card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); box-shadow: var(--shadow); transform: translateY(-1px); }
.card.has-thumb { grid-template-columns: minmax(0, 1fr) 136px; }
.card-body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.card-title { margin: 0; font-size: 1.3rem; line-height: 1.3; letter-spacing: -0.015em; font-weight: 750; }
.card-title a { color: var(--fg); text-decoration: none; overflow-wrap: anywhere; }
.card-title a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.card:hover .card-title a { color: var(--accent); }
.card-excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 0.97rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.card-body .tags { margin-top: 4px; }
.card-thumb { align-self: start; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; background: var(--soft); border: 1px solid var(--line); }
.card-thumb img { display: block; background: #fff; width: 100%; height: 100%; object-fit: cover; }

/* Buttons + pagination */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--bg); }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin-top: 40px; }
.pagination .nums { display: inline-flex; gap: 6px; }

/* Single entry */
.entry-header { margin-bottom: 36px; }
.entry-title { margin: 0 0 14px; font-size: clamp(2rem, 1.4rem + 2.6vw, 2.9rem); line-height: 1.12; letter-spacing: -0.028em; font-weight: 800; overflow-wrap: anywhere; }
.entry-meta { font-size: 0.92rem; }

.entry-content { overflow-wrap: break-word; hyphens: auto; }
.entry-content > * { margin-top: 0; margin-bottom: 1.25em; }
.entry-content h2, .entry-content h3, .entry-content h4 { line-height: 1.25; letter-spacing: -0.02em; font-weight: 750; margin-top: 2em; margin-bottom: 0.6em; }
.entry-content h2 { font-size: 1.6rem; }
.entry-content h3 { font-size: 1.3rem; }
.entry-content h4 { font-size: 1.1rem; }
.entry-content ul, .entry-content ol { padding-left: 1.4em; }
.entry-content li { margin: 0.3em 0; }
.entry-content li::marker { color: var(--muted); }
.entry-content hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.entry-content strong, .entry-content b { font-weight: 700; }

/* Large images fill the column; small originals stay sharp at natural size, centered. */
.entry-content img { display: block; width: auto; max-width: 100%; height: auto; margin-left: auto; margin-right: auto; border-radius: 12px; border: 1px solid var(--line); background: var(--soft); }
.entry-content p > img, .entry-content p > a > img { margin-top: 0.5em; margin-bottom: 0.5em; }
.entry-content figure { margin: 2em 0; }
.entry-content figure img { margin-top: 0; margin-bottom: 0; }
.entry-content figcaption { margin-top: 10px; color: var(--muted); font-size: 0.85rem; line-height: 1.5; text-align: center; }

.entry-content blockquote {
  margin: 1.8em 0;
  padding: 4px 0 4px 20px;
  border-left: 4px solid var(--accent);
  color: var(--fg);
  font-style: italic;
  overflow-wrap: anywhere;
}
.entry-content blockquote p:last-child { margin-bottom: 0; }

.entry-content code { font-family: var(--mono); font-size: 0.88em; background: var(--code-bg); color: var(--code-fg); padding: 0.15em 0.4em; border-radius: 6px; border: 1px solid var(--line); overflow-wrap: anywhere; }
.entry-content pre {
  margin: 1.6em 0;
  padding: 16px 18px;
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.6;
  tab-size: 4;
  hyphens: none;
}
.entry-content pre code { padding: 0; background: none; border: 0; font-size: inherit; overflow-wrap: normal; white-space: pre; }

.table-wrap { overflow-x: auto; }
.entry-content table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.entry-content th, .entry-content td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.entry-content iframe, .entry-content video { max-width: 100%; }

/* Prev / next */
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); }
.pn { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--fg); min-width: 0; }
.pn:hover { border-color: var(--accent); }
.pn-next { grid-column: 2; text-align: right; }
.pn-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.pn-title { font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.pn:hover .pn-title { color: var(--accent); }

/* 404 */
.notfound { text-align: center; padding: 40px 0 10px; }
.nf-code { margin: 0; font-size: clamp(4.5rem, 3rem + 8vw, 8rem); font-weight: 850; line-height: 1; letter-spacing: -0.05em; color: var(--accent); }
.notfound .page-title { margin-top: 12px; }
.notfound p { color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--soft); padding: 40px 0 32px; font-size: 0.92rem; }
.footer-recent h2 { margin: 0 0 12px; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.footer-recent ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.footer-recent a { color: var(--fg); text-decoration: none; overflow-wrap: anywhere; }
.footer-recent a:hover { color: var(--accent); text-decoration: underline; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); }
.footer-bottom a { color: var(--muted); }
.footer-bottom a:hover { color: var(--accent); }

/* Mobile */
@media (max-width: 640px) {
  body { font-size: 17px; }
  .wrap { padding: 0 18px; }
  .header-inner { min-height: 56px; padding-top: 6px; padding-bottom: 6px; gap: 4px 12px; }
  .site-nav { margin-left: -12px; }
  main.wrap { padding-top: 32px; padding-bottom: 48px; }
  .card { padding: 18px; }
  .card.has-thumb { grid-template-columns: minmax(0, 1fr) 84px; gap: 14px; }
  .card-title { font-size: 1.15rem; }
  .post-nav { grid-template-columns: 1fr; }
  .pn-next { grid-column: auto; }
  .pagination .btn { padding: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card:hover { transform: none; }
}

@media print {
  .site-header, .site-footer, .post-nav, .pagination { display: none; }
  body { font-size: 12pt; }
}
