/* Blog page — listing and cards */

.blog-page {
  padding-top: 64px;
  min-height: 100vh;
  padding-bottom: 48px;
}

.blog-header {
  text-align: center;
  padding: 48px 24px 40px;
  max-width: 640px;
  margin: 0 auto;
}

.blog-header h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.blog-header p {
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.5;
}

.blog-layout {
  display: flex;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

@media (max-width: 768px) {
  .blog-layout {
    flex-direction: column;
    gap: 32px;
  }

  .blog-sidebar {
    flex: none;
    position: static;
  }

  .blog-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .blog-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1025px) {
  .blog-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Sidebar */
.blog-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 0 0 250px;
  position: sticky;
  top: 80px;
  align-self: flex-start;
}

.blog-sidebar__section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.blog-sidebar__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.blog-categories {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.blog-category-btn {
  padding: 10px 14px;
  text-align: left;
  font-size: 14px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.blog-category-btn:hover {
  color: var(--text-primary);
  background: var(--gray-900);
}

.blog-category-btn--active {
  color: var(--accent);
  background: rgba(201, 168, 76, 0.1);
  border-color: rgba(201, 168, 76, 0.3);
}

.blog-search {
  width: 100%;
}

/* Feed */
.blog-feed {
  flex: 1;
  min-width: 0;
}

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.blog-card {
  background: var(--gray-900);
  border: 1px solid var(--gray-800);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.blog-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.blog-card__image {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--gray-800) 0%, var(--gray-900) 100%);
  overflow: hidden;
}

.blog-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.blog-card__category {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--accent);
  color: var(--black);
  border-radius: var(--radius-pill);
}

.blog-card__body {
  padding: 20px;
}

.blog-card__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  line-height: 1.3;
}

.blog-card__excerpt {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.blog-card__meta .avatar {
  flex-shrink: 0;
}

.blog-card__date {
  color: var(--text-secondary);
}

.blog-card__read-time {
  color: var(--text-secondary);
}

.avatar-xs {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

/* Pagination */
.blog-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 40px;
  flex-wrap: wrap;
}

.blog-pagination__btn {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--gray-900);
  border: 1px solid var(--gray-800);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.blog-pagination__btn:hover {
  border-color: var(--accent);
  background: rgba(201, 168, 76, 0.1);
}

.blog-pagination__btn--active {
  border-color: var(--accent);
  background: rgba(201, 168, 76, 0.15);
  color: var(--accent);
}

.blog-pagination__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Loading */
.blog-loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
  font-size: 17px;
}

/* Empty state */
.blog-empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-secondary);
  font-size: 17px;
}

/* ================================================================
   Blog post page
   ================================================================ */

.blog-post-page {
  padding-top: 64px;
  min-height: 100vh;
  padding-bottom: 48px;
}

.post-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 40vh;
  color: var(--text-secondary);
}

.post-loading .spinner {
  width: 32px;
  height: 32px;
  border-width: 3px;
  color: var(--accent);
}

.post-article {
  max-width: 800px;
  margin: 0 auto;
}

.post-hero {
  width: 100%;
  max-height: 500px;
  aspect-ratio: 21 / 9;
  background: linear-gradient(135deg, var(--gray-800) 0%, var(--gray-900) 100%);
  overflow: hidden;
}

.post-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-container {
  padding: 0 24px 48px;
}

.post-header {
  margin-top: 32px;
  margin-bottom: 32px;
}

.post-category {
  display: inline-block;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(201, 168, 76, 0.15);
  color: var(--accent);
  border-radius: var(--radius-pill);
  margin-bottom: 16px;
  text-decoration: none;
  transition: background var(--transition-fast);
}

.post-category:hover {
  background: rgba(201, 168, 76, 0.25);
}

.post-category .post-category-link {
  color: inherit;
  text-decoration: none;
}

.post-category .post-category-link:hover {
  text-decoration: underline;
}

.post-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 20px;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.post-author {
  display: flex;
  align-items: center;
  gap: 12px;
}

.post-author .avatar {
  flex-shrink: 0;
}

.post-author > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.post-author-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 15px;
}

.post-date {
  font-size: 14px;
  color: var(--text-secondary);
}

.post-stats {
  display: flex;
  gap: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.post-actions {
  margin-top: 16px;
}

/* Table of contents */
.post-toc {
  margin-bottom: 32px;
  padding: 20px 24px;
  background: var(--gray-900);
  border: 1px solid var(--gray-800);
  border-radius: var(--radius-md);
}

.post-toc h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.post-toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-toc li {
  margin-bottom: 8px;
}

.post-toc li.toc-h3 {
  padding-left: 16px;
}

.post-toc a {
  font-size: 14px;
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.post-toc a:hover {
  color: var(--accent);
}

/* Post body prose */
.post-body.prose {
  font-size: 17px;
  line-height: 1.75;
  max-width: 70ch;
  color: var(--text-primary);
}

.post-body.prose h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  margin-top: 2em;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-800);
  color: var(--text-primary);
}

.post-body.prose h3 {
  font-size: 20px;
  font-weight: 600;
  margin-top: 1.5em;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.post-body.prose p {
  margin-bottom: 1.25em;
}

.post-body.prose ul,
.post-body.prose ol {
  margin-bottom: 20px;
  padding-left: 24px;
}

.post-body.prose li {
  margin-bottom: 8px;
}

.post-body.prose blockquote {
  margin: 24px 0;
  padding-left: 20px;
  border-left: 4px solid var(--accent);
  color: var(--text-secondary);
  font-style: italic;
  background: rgba(201, 168, 76, 0.05);
}

.post-body.prose a {
  color: var(--accent);
  text-decoration: underline;
}

.post-body.prose a:hover {
  opacity: 0.9;
}

.post-body.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 20px 0;
}

.post-body.prose pre,
.post-body.prose code {
  font-family: ui-monospace, monospace;
  font-size: 14px;
}

.post-body.prose pre {
  background: var(--gray-900);
  border: 1px solid var(--gray-800);
  border-radius: var(--radius-md);
  padding: 16px;
  overflow-x: auto;
  margin: 20px 0;
}

.post-body.prose code {
  background: var(--gray-800);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

.post-body.prose pre code {
  padding: 0;
  background: none;
  display: block;
  overflow-x: auto;
}

/* Tags */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 32px;
  margin-bottom: 24px;
}

.post-tag {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--accent);
  background: rgba(201, 168, 76, 0.1);
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: var(--radius-pill);
  text-decoration: none;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.post-tag:hover {
  background: rgba(201, 168, 76, 0.2);
  border-color: var(--accent);
}

/* Share */
.post-share {
  display: flex;
  gap: 12px;
  margin-bottom: 48px;
}

/* Related posts */
.related-posts {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--gray-800);
}

.related-posts h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.related-card {
  display: block;
  background: var(--gray-900);
  border: 1px solid var(--gray-800);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.related-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.related-card__img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--gray-800);
}

.related-card__content {
  padding: 16px;
}

.related-card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.related-card__date {
  font-size: 13px;
  color: var(--text-secondary);
}

/* 404 state */
.post-not-found {
  text-align: center;
  padding: 80px 24px;
}

.post-not-found h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.post-not-found p {
  color: var(--text-secondary);
  font-size: 17px;
  margin-bottom: 24px;
}

/* ================================================================
   Blog editor page
   ================================================================ */

.editor-page {
  padding-top: 64px;
  min-height: 100vh;
  background: var(--black);
}

.editor-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 64px);
}

.editor-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 32px 40px 48px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.editor-title-input {
  width: 100%;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 12px 0 16px;
  margin-bottom: 16px;
  transition: border-color var(--transition-fast);
}

.editor-title-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

.editor-title-input:focus {
  outline: none;
  border-bottom-color: var(--gray-800);
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-800);
  margin-bottom: 16px;
  position: sticky;
  top: 64px;
  background: var(--black);
  z-index: 10;
}

.editor-toolbar button {
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.editor-toolbar button:hover {
  color: var(--text-primary);
  background: var(--gray-900);
  border-color: var(--gray-800);
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--gray-800);
  margin: 0 4px;
}

.editor-content {
  min-height: 500px;
  padding: 24px 0;
  outline: none;
  font-size: 17px;
  line-height: 1.75;
  color: var(--text-primary);
  background: var(--black);
}

.editor-content:focus {
  outline: none;
}

/* Prose styles inside editor (match post-body) */
.editor-content.prose,
.editor-content {
  font-size: 17px;
  line-height: 1.75;
}

.editor-content h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  margin-top: 2em;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-800);
}

.editor-content h3 {
  font-size: 20px;
  font-weight: 600;
  margin-top: 1.5em;
  margin-bottom: 12px;
}

.editor-content p {
  margin-bottom: 1.25em;
}

.editor-content ul,
.editor-content ol {
  margin-bottom: 1.25em;
  padding-left: 24px;
}

.editor-content blockquote {
  margin: 24px 0;
  padding-left: 20px;
  border-left: 4px solid var(--accent);
  color: var(--text-secondary);
  font-style: italic;
}

.editor-content a {
  color: var(--accent);
  text-decoration: underline;
}

.editor-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

.editor-content pre,
.editor-content code {
  font-family: ui-monospace, monospace;
  font-size: 14px;
}

.editor-content code {
  background: var(--gray-800);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
}

.editor-content hr {
  margin: 24px 0;
  border: none;
  border-top: 1px solid var(--gray-800);
}

/* Editor sidebar */
.editor-sidebar {
  flex: 0 0 320px;
  border-left: 1px solid var(--gray-800);
  padding: 24px;
  overflow-y: auto;
  max-height: calc(100vh - 64px);
  position: sticky;
  top: 64px;
  background: var(--black);
}

.editor-sidebar__section {
  margin-bottom: 20px;
}

.editor-sidebar__section label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.editor-sidebar__section input,
.editor-sidebar__section textarea,
.editor-sidebar__section select {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--gray-900);
  border: 1px solid var(--gray-800);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

.editor-sidebar__section input:focus,
.editor-sidebar__section textarea:focus,
.editor-sidebar__section select:focus {
  outline: none;
  border-color: var(--accent);
}

.editor-sidebar__section textarea {
  resize: vertical;
  min-height: 80px;
}

.editor-sidebar__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
  padding-top: 24px;
}

.editor-sidebar__actions .btn {
  width: 100%;
  justify-content: center;
}

.editor-status {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.editor-status:not(:empty) {
  opacity: 1;
}

.editor-status--success {
  color: var(--success);
}

.editor-status--error {
  color: var(--error);
}

/* Editor responsive */
@media (max-width: 1024px) {
  .editor-layout {
    flex-direction: column;
  }

  .editor-sidebar {
    flex: none;
    width: 100%;
    max-height: none;
    border-left: none;
    border-top: 1px solid var(--gray-800);
    position: static;
  }
}

@media (max-width: 768px) {
  .editor-main {
    padding: 24px 20px 32px;
  }

  .editor-title-input {
    font-size: 1.5rem;
  }

  .editor-sidebar {
    padding: 20px;
  }
}
