/* Blog listing */
.blog-hero {
  background: #f0fdf4;
  color: var(--color-text);
  padding: var(--space-2xl) 0;
  text-align: center;
}
.blog-hero h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; margin-bottom: var(--space-sm); color: var(--color-primary-dark); }
.blog-hero p { color: var(--color-text-muted); max-width: 480px; margin: 0 auto; line-height: 1.6; }

.blog-listing { padding: 2rem 0 4rem; }

.blog-tags-filter {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-xl);
}

.blog-tag {
  display: inline-block;
  padding: 0.25em 0.75em;
  border-radius: 9999px;
  font-size: var(--text-sm);
  background: var(--color-border);
  color: var(--color-text);
  text-decoration: none;
  transition: background 0.15s;
}
.blog-tag:hover,
.blog-tag.active {
  background: var(--color-primary);
  color: white;
}

.blog-list {
  max-width: 720px;
  display: flex;
  flex-direction: column;
}

.blog-item {
  padding: var(--space-xl) 0;
  border-bottom: 1px solid var(--color-border);
}
.blog-item:first-child { padding-top: 0; }
.blog-item:last-child { border-bottom: none; }

.blog-item-meta {
  display: flex;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.blog-item h2 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-sm);
  line-height: 1.3;
}
.blog-item h2 a {
  color: var(--color-text);
  text-decoration: none;
}
.blog-item h2 a:hover { color: var(--color-primary); }

.blog-item-excerpt {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.blog-item .blog-tags { margin-top: var(--space-md); }

/* Blog post detail */
.blog-post {
  max-width: 720px;
  padding-top: 2.5rem;
  padding-bottom: 4rem;
}

.blog-post-header {
  margin-bottom: var(--space-xl);
}

.blog-post-meta {
  display: flex;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.blog-post-header h1 {
  font-size: 2.25rem;
  line-height: 1.2;
  margin-bottom: var(--space-md);
}

.blog-post-excerpt {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  line-height: 1.6;
}

.blog-post-cover {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-xl);
}

.blog-post-body {
  font-size: var(--text-lg);
  line-height: 1.8;
  color: var(--color-text);
}
.blog-post-body h2 { font-size: var(--text-2xl); margin: 2rem 0 0.75rem; }
.blog-post-body h3 { font-size: var(--text-xl); margin: 1.5rem 0 0.5rem; }
.blog-post-body p { margin-bottom: 1.25rem; }
.blog-post-body ul,
.blog-post-body ol { margin-bottom: 1.25rem; padding-left: 1.5rem; }
.blog-post-body li { margin-bottom: 0.4rem; }
.blog-post-body blockquote {
  border-left: 3px solid var(--color-primary);
  padding-left: var(--space-lg);
  margin: 1.5rem 0;
  color: var(--color-text-muted);
  font-style: italic;
}
.blog-post-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 1.5rem 0;
}
.blog-post-body figure.attachment {
  margin: 1.5rem 0;
  text-align: center;
}
.blog-post-body figure.attachment img { margin: 0; }
.blog-post-body figure.attachment .attachment__name,
.blog-post-body figure.attachment .attachment__size,
.blog-post-body figure.attachment .attachment__caption { display: none; }
.blog-post-body .video-embed,
trix-editor .video-embed {
  position: relative;
  width: 100%;
  max-width: 720px;
  min-height: 240px;
  aspect-ratio: 16 / 9;
  margin: 1.5rem auto;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
}
.blog-post-body .video-embed iframe,
trix-editor .video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Editor preview: clickable thumbnail placeholder (transformed to iframe on render) */
trix-editor .video-embed-placeholder,
.blog-post-body .video-embed-placeholder {
  position: relative;
  display: block;
  max-width: 720px;
  aspect-ratio: 16 / 9;
  margin: 1.5rem auto;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #111;
  cursor: pointer;
  text-decoration: none !important;
}
trix-editor .video-embed-placeholder .video-embed-thumb,
.blog-post-body .video-embed-placeholder .video-embed-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  color: #fff;
  text-align: center;
  line-height: 240px;
  font-weight: 600;
}
trix-editor .video-embed-placeholder::after,
.blog-post-body .video-embed-placeholder::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 68px;
  height: 48px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
  background-size: 28px;
  background-position: center;
  background-repeat: no-repeat;
}
.blog-post-body a { color: var(--color-primary); }
.blog-post-body a:hover { text-decoration: underline; }

.blog-post-footer {
  margin-top: 3rem;
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

/* Admin blog editor */
.blog-editor-form { max-width: 800px; }
.blog-editor-form .form-group { margin-bottom: var(--space-lg); }
.blog-editor-form label { display: block; font-weight: 600; margin-bottom: var(--space-xs); }
.blog-editor-form trix-editor {
  min-height: 300px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  background: var(--color-surface);
}

/* Trix editor live preview — mirror .trix-content styling for h1/quote/list/code */
trix-editor h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.2;
  margin: 1rem 0 0.5rem;
}
trix-editor blockquote {
  border-left: 3px solid var(--color-primary);
  padding-left: var(--space-lg);
  margin: 1rem 0;
  color: var(--color-text-muted);
  font-style: italic;
}
trix-editor ul,
trix-editor ol {
  padding-left: 1.5rem;
  margin: 0.75rem 0;
}
trix-editor li { margin: 0.25rem 0; }
trix-editor pre {
  background: var(--color-surface-muted, #f3f4f6);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 0.9em;
  white-space: pre-wrap;
  margin: 0.75rem 0;
}

.blog-tags-input {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  align-items: center;
}
.blog-tags-input .blog-tag {
  cursor: pointer;
}
.blog-tags-input .blog-tag.selected {
  background: var(--color-primary);
  color: white;
}

@media (max-width: 640px) {
  .blog-post-header h1 { font-size: var(--text-2xl); }
}
