/* ==========================================================================
   Blog styles — extends the existing design system (tokens.css + base.css)
   ========================================================================== */

/* ---------- Skeleton / loading shimmer ------------------------------------ */
.skel {
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--line) 50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--radius);
}
.skel--text { display: block; }
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Blog hero ------------------------------------------------------ */
.blog-hero {
  padding-block: clamp(2.5rem, 7vw, 5rem) clamp(1.5rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
}
.blog-hero__eyebrow {
  font-size: var(--step--1);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--defense);
  margin: 0 0 0.6rem;
  max-width: none;
}
.blog-hero h1 {
  margin-bottom: 0.75rem;
}
.blog-hero__lead {
  font-size: var(--step-1);
  color: var(--ink-2);
  max-width: 52ch;
  margin: 0;
}

/* ---------- Tag filter bar ------------------------------------------------- */
.blog-tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 2rem;
}
.blog-tag {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.3rem 0.85rem;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  transition: all 0.15s ease;
}
.blog-tag:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.blog-tag--active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

/* ---------- Post grid ------------------------------------------------------ */
.blog-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
  gap: 1.5rem;
}

/* ---------- Post card ------------------------------------------------------ */
.blog-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.blog-card:not(.blog-card--skeleton):hover {
  box-shadow: 0 8px 28px -4px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
  border-color: var(--ink-2);
}
.blog-card--skeleton {
  pointer-events: none;
}

.blog-card__img-wrap {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-2);
  flex-shrink: 0;
}
.blog-card__img-wrap.skel {
  border-radius: 0;
}
.blog-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}
.blog-card:hover .blog-card__img {
  transform: scale(1.04);
}

.blog-card__body {
  padding: 1.15rem 1.25rem 1.3rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.blog-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}
.blog-card__tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--defense);
  background: var(--defense-bg);
  padding: 0.1rem 0.5rem;
  border-radius: 99px;
  text-decoration: none;
}
.blog-card__title {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  text-decoration: none;
  margin: 0 0 0.5rem;
  display: block;
}
.blog-card__title:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.blog-card__excerpt {
  font-size: 0.9rem;
  color: var(--ink-2);
  line-height: 1.55;
  margin: 0 0 1rem;
  flex: 1;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
.blog-card__meta {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.8rem;
  color: var(--ink-2);
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
  margin-top: auto;
}
.blog-card__date { font-variant-numeric: tabular-nums; }
.blog-card__sep { opacity: 0.5; }

/* ---------- Empty state ---------------------------------------------------- */
.blog-empty {
  text-align: center;
  padding: 3rem 1rem;
}
.blog-empty__text {
  color: var(--ink-2);
  max-width: none;
}

/* ============================================================================
   Single post page
   ============================================================================ */

/* Loading wrapper */
.post-loading { padding-block: clamp(2rem, 5vw, 3.5rem); }
.post-cover-skel {
  width: 100%;
  aspect-ratio: 16 / 7;
  border-radius: calc(var(--radius) * 2);
}
.post-error-wrap { padding-block: 4rem; }

/* Post wrapper */
.post-wrap {
  width: min(100% - 2 * var(--gutter), 52rem);
  margin-inline: auto;
  padding-block: clamp(2rem, 5vw, 3.5rem) 4rem;
}

/* Back link */
.post-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--ink-2);
  text-decoration: none;
  margin-bottom: 2rem;
  transition: color 0.15s;
}
.post-back:hover { color: var(--ink); }

/* Header */
.post-header { margin-bottom: 2rem; }
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}
.post-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--defense);
  background: var(--defense-bg);
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  text-decoration: none;
}
.post-title {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.85rem;
}
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  color: var(--ink-2);
  font-size: 0.88rem;
}
.post-meta__date { font-variant-numeric: tabular-nums; }

/* Cover image */
.post-cover {
  width: 100%;
  aspect-ratio: 16 / 7;
  object-fit: cover;
  border-radius: calc(var(--radius) * 2);
  display: block;
  margin-bottom: 2.5rem;
}

/* Post body (rich text / markdown-rendered HTML) */
.post-body {
  font-size: var(--step-0);
  line-height: 1.75;
  color: var(--ink);
}
.post-body p { max-width: none; }
.post-body h2 {
  font-size: var(--step-2);
  margin: 2rem 0 0.65rem;
}
.post-body h3 {
  font-size: var(--step-1);
  margin: 1.5rem 0 0.5rem;
}
.post-body a { color: var(--defense); }
.post-body ul,
.post-body ol {
  padding-left: 1.4rem;
  margin: 0.5rem 0 1rem;
}
.post-body li { margin-bottom: 0.35rem; }
.post-body blockquote {
  border-left: 3px solid var(--line);
  padding: 0.2rem 0 0.2rem 1rem;
  margin: 1rem 0;
  color: var(--ink-2);
}
/* Code block container */
.code-block-wrap {
  margin: 1.5rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  overflow: hidden;
}
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.9rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.75rem;
}
.code-lang {
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.code-copy-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-2);
  font-size: 0.72rem;
  font-family: inherit;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.code-copy-btn:hover {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--ink-2);
}
.code-copy-btn--copied {
  color: var(--defense) !important;
  border-color: var(--defense) !important;
}
.post-body pre {
  background: transparent;
  padding: 1rem 1.2rem;
  margin: 0;
  overflow-x: auto;
  font-size: 0.88em;
  line-height: 1.55;
  font-family: var(--mono);
}
.post-body code:not(pre code) {
  background: var(--surface-2);
  color: var(--defense);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: var(--mono);
}

/* Figures & Images */
.post-figure {
  margin: 2rem 0;
  text-align: center;
}
.post-figure img {
  width: 100%;
  max-width: 100%;
  border-radius: calc(var(--radius) * 1.5);
  border: 1px solid var(--line);
  display: block;
}
.post-figcaption {
  margin-top: 0.65rem;
  font-size: var(--step--1);
  color: var(--ink-2);
  font-style: italic;
}
.post-body img:not(.post-figure img) {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 1rem 0;
}
.post-body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2.5rem 0;
}

/* GFM Tables */
.post-table-wrap {
  overflow-x: auto;
  margin: 2rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.post-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.92rem;
}
.post-table-wrap th {
  background: rgba(255, 255, 255, 0.03);
  padding: 0.85rem 1.1rem;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.post-table-wrap td {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--ink);
  vertical-align: top;
}
.post-table-wrap tr:last-child td {
  border-bottom: none;
}
.post-table-wrap tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ---------- Post footer actions (like) ------------------------------------ */
.post-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 2.5rem 0;
}
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.55rem 1.1rem;
  border-radius: 99px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  transition: all 0.2s ease;
}
.like-btn:hover {
  border-color: #e05a7a;
  color: #e05a7a;
  background: #fdf0f3;
}
.like-btn:hover,
.like-btn--liked {
  background: #2c1820;
  border-color: #e05a7a;
  color: #f08098;
}

:root[data-theme="light"] .like-btn:hover,
:root[data-theme="light"] .like-btn--liked {
  background: #fdf0f3;
  border-color: #e05a7a;
  color: #e05a7a;
}
.like-btn__icon { font-size: 1.05rem; line-height: 1; }
.like-btn__count { font-variant-numeric: tabular-nums; }

/* ---------- Comments ------------------------------------------------------- */
.comments-section { margin-top: 0; }
.comments-section h2 {
  font-size: var(--step-1);
  margin-bottom: 1.5rem;
}
.comment-list {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.comment {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.7rem;
  align-items: start;
}
.comment__avatar {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--line);
  flex-shrink: 0;
}
.comment__body {}
.comment__header {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  margin-bottom: 0.3rem;
}
.comment__author {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
}
.comment__date {
  font-size: 0.78rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.comment__text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  background: var(--surface);
  padding: 0.7rem 1rem;
  border-radius: 4px 12px 12px 12px;
  border: 1px solid var(--line);
}
.comment-empty {
  color: var(--ink-2);
  font-size: 0.92rem;
  padding: 1rem 0;
  margin: 0;
}

/* Comment form */
.comment-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 2);
  padding: 1.25rem 1.4rem;
  margin-top: 0.5rem;
}
.comment-form h3 {
  font-size: var(--step-0);
  font-weight: 700;
  margin: 0 0 1rem;
}
.comment-form .field + .field { margin-top: 0.85rem; }
.comment-form .field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--ink-2);
}
.comment-form input,
.comment-form textarea {
  background: var(--bg);
}
.comment-form textarea { min-height: 7rem; }
.comment-form__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.comment-form__note {
  font-size: 0.8rem;
  color: var(--ink-2);
  margin: 0;
}
.comment-form__success {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--defense);
  margin-top: 0.75rem;
}
