/* =============================================
   BLOG.CSS — в стиле xselid.ru
   ============================================= */

/* NAV */
.nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.burger-btn {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: #0f0f0f;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-direction: column;
  cursor: pointer;
  z-index: 121;
}

.burger-btn span {
  width: 16px;
  height: 1px;
  background: var(--text);
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.burger-btn.is-open span:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}
.burger-btn.is-open span:nth-child(2) {
  opacity: 0;
}
.burger-btn.is-open span:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}

.mobile-menu-backdrop {
  display: none;
}

.mobile-menu-close {
  display: none;
}

.nav a {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

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

.header-login-btn {
  border: 1px solid var(--border);
  padding: 8px 12px;
}

.header-user-block {
  display: inline-flex;
  align-items: stretch;
  border: 1px dashed var(--border); 
  background: #111;
  border-radius: 10px;
}

.header-user-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: none;
}

.header-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #2a2a2a;
}

.header-user-avatar-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.72rem;
  color: var(--text);
  background: #121212;
}

.header-user-meta {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.05;
}

.header-user-name {
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  color: #bdbdbd;
}

.header-user-balance {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.header-logout-form {
  margin: 0;
  border-left: 1px solid var(--border);
}

.header-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: #9a9a9a;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.header-logout-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.logo {
  text-decoration: none;
}

/* MAIN overrides for non-center pages */
.main--left {
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
  padding: 60px 40px;
}

/* BTN BLOG */
.btn-blog {
  display: inline-block;
  margin-top: 8px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  border: 1px solid var(--border);
  padding: 10px 20px;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.btn-blog:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* =============================================
   BLOG PAGE
   ============================================= */

.blog-header {
  margin-bottom: 56px;
  animation: fade-up 0.6s 0.1s ease both;
}

.blog-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.8rem, 5vw, 3.5rem);
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 12px;
}

.blog-subtitle {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.posts-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  background: transparent;
  border: none;
  animation: fade-up 0.6s 0.2s ease both;
}

.post-card {
  background: var(--bg);
  text-decoration: none;
  display: block;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
}

.post-card::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.post-card:hover {
  background: #0f0f0f;
  border-color: var(--accent);
  transform: translateY(-3px);
}

.post-card:hover::before {
  width: 100%;
}

.post-card-inner {
  padding: 30px 28px;
}

.post-date {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  display: block;
  margin-bottom: 14px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.post-card-title {
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.3;
  transition: color 0.2s;
}

.post-card:hover .post-card-title {
  color: var(--accent);
}

.post-card-excerpt {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #b0b0b0;
  line-height: 1.7;
  margin-bottom: 22px;
}

.post-read-more {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color 0.2s;
}

.post-card:hover .post-read-more {
  color: var(--accent);
}

.post-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.post-card:active {
  transform: translateY(-1px);
}

.empty-blog {
  text-align: center;
  padding: 80px 0;
  color: #2a2a2a;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  animation: fade-up 0.6s 0.2s ease both;
}

/* =============================================
   POST PAGE
   ============================================= */

.post-container {
  max-width: 680px;
  width: 100%;
  animation: fade-up 0.6s 0.1s ease both;
}

.back-link {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 48px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--accent);
}

.post-header {
  margin-bottom: 48px;
}

.post-date {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  display: block;
  margin-bottom: 16px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.post-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.post-excerpt {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: 28px;
}

.post-divider {
  height: 1px;
  background: var(--border);
  position: relative;
}

.post-divider::after {
  content: '';
  position: absolute;
  left: 0;
  top: -1px;
  width: 40px;
  height: 2px;
  background: var(--accent);
}

/* =============================================
   POST CONTENT
   ============================================= */

.post-content {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.95;
  color: #aaa;
  margin-top: 40px;
}

.post-content h1,
.post-content h2,
.post-content h3 {
  font-family: var(--font-display);
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 48px 0 16px;
  line-height: 1.3;
}

.post-content h1 { font-size: 1.6rem; }
.post-content h2 { font-size: 1.2rem; }
.post-content h3 {
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
}

.post-content p {
  margin-bottom: 20px;
}

.post-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.post-content a:hover {
  border-color: var(--accent);
}

.post-content strong {
  color: var(--text);
  font-weight: 700;
}

.post-content em {
  color: var(--muted);
}

.post-content code {
  background: #111;
  border: 1px solid var(--border);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  border-radius: 0;
}

.post-content pre {
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  padding: 24px;
  overflow-x: auto;
  margin: 24px 0;
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: #ccc;
  font-size: 0.78rem;
}

.post-content blockquote {
  border-left: 2px solid var(--accent);
  padding: 12px 20px;
  color: var(--muted);
  margin: 24px 0;
  background: #0d0d0d;
}

.post-content ul,
.post-content ol {
  padding-left: 0;
  margin-bottom: 24px;
  list-style: none;
}

.post-content ul li::before {
  content: '—';
  color: var(--accent);
  margin-right: 10px;
}

.post-content ol {
  counter-reset: list;
}

.post-content ol li {
  counter-increment: list;
}

.post-content ol li::before {
  content: counter(list, decimal-leading-zero) '.';
  color: var(--accent);
  margin-right: 10px;
  font-size: 0.7rem;
}

.post-content li {
  margin-bottom: 10px;
  padding-left: 4px;
}

.post-content img {
  max-width: 100%;
  border: 1px solid var(--border);
  display: block;
  margin: 24px 0;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

/* =============================================
   404
   ============================================= */

.error-page {
  text-align: center;
  padding: 80px 0;
  animation: fade-up 0.6s ease both;
}

.error-code {
  font-family: var(--font-display);
  font-size: clamp(80px, 18vw, 160px);
  font-weight: 700;
  color: #535353;
  margin-bottom: 16px;
  line-height: 1;
  letter-spacing: -0.04em;
}

.error-text {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 32px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 768px) {
  body.menu-open {
    overflow: hidden;
  }

  .header {
    position: relative;
    z-index: 1001;
  }

  .burger-btn {
    display: inline-flex;
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    z-index: 1002;
  }

  .mobile-menu-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.24);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 998;
  }

  .mobile-menu-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .nav {
    position: fixed;
    left: auto;
    top: 0;
    right: 0;
    bottom: auto;
    width: min(86vw, 360px);
    min-height: 100dvh;
    background:
      radial-gradient(circle at 15% 12%, rgba(255, 82, 82, 0.16), transparent 38%),
      linear-gradient(180deg, #121212 0%, #0f0f0f 100%);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 0 0 0 14px;
    padding: 86px 24px 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    transform: translateX(104%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.26s ease, opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1000;
    overflow-y: auto;
  }

  .nav::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 3px,
      rgba(0, 0, 0, 0.08) 3px,
      rgba(0, 0, 0, 0.08) 4px
    );
    opacity: 0.35;
  }

  .nav > * {
    position: relative;
    z-index: 1;
  }

  .nav.is-open {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
  }

  .nav a {
    font-size: 0.82rem;
    width: 100%;
    padding: 8px 0;
    border-bottom: 1px solid #1a1a1a;
  }

  .nav .header-user-block {
    order: -3;
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    border: 1px solid #232323;
    border-radius: 8px;
    overflow: hidden;
  }

  .nav .header-login-btn {
    order: -2;
  }

  .header-user-link {
    width: 100%;
    border: none;
    background: transparent;
    padding: 10px 12px;
    margin-top: 0;
    margin-bottom: 0;
    gap: 10px;
    min-height: 54px;
  }

  .nav a.header-user-link {
    padding: 10px 12px;
    border-bottom: none;
  }

  .header-login-btn {
    width: auto;
    text-align: center;
    align-self: flex-start;
    padding: 10px 14px;
    border-color: rgba(255, 82, 82, 0.5);
    color: var(--text);
    background: rgba(255, 82, 82, 0.08);
  }

  .header-login-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
  }

  .header-logout-form {
    width: auto;
    margin-top: 0;
    border-left: 1px solid #232323;
  }

  .header-logout-btn {
    width: 54px;
    height: 54px;
    padding: 0;
    background: transparent;
  }

  .main--left {
    padding: 40px 24px;
  }

  .posts-grid {
    grid-template-columns: 1fr;
  }

  .post-container {
    padding: 0;
  }

  .post-title {
    font-size: 1.6rem;
  }
}

@media (max-width: 480px) {
  .main--left {
    padding: 32px 18px;
  }

  .blog-title {
    font-size: 1.6rem;
  }
}