/* ==========================================================================
   Blog sidebar — blog-system global component.
   Used on /blog.html and /blog/post-xx.html only. Vertically stacked widgets:
   search, recent posts, categories, tags.
   ========================================================================== */

.blog-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-xxl);
}

/* Widget block: heading + content */
.blog-widget {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* Widget heading — display-md */
.blog-widget__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;      /* display-md */
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.3px;
  color: var(--c-text-primary);
}

/* Screen-reader-only label */
.blog-widget__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Search — text-input field with icon submit button
   -------------------------------------------------------------------------- */

.blog-search {
  display: flex;
  align-items: stretch;
  gap: var(--space-xs);
  padding: var(--space-xs);
  border: 1px solid var(--c-hairline);
  border-radius: var(--rounded-sm);
}

/* text-input-light: canvas surface */
[data-theme="light"] .blog-search {
  background-color: var(--light-canvas);
}

/* text-input-dark: canvas-soft surface */
[data-theme="dark"] .blog-search {
  background-color: var(--dark-canvas-soft);
}

.blog-search:focus-within {
  border-color: var(--c-accent);
}

.blog-search__input {
  flex: 1;
  min-width: 0;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-body);
  font-size: 16px;      /* body-md (prevents iOS zoom on focus) */
  font-weight: 360;
  line-height: 1.5;
  color: var(--c-text-primary);
  background: transparent;
  border: 0;
  outline: none;
}

.blog-search__input::placeholder {
  color: var(--c-text-muted);
}

/* Submit — accent square, 44px tap target */
.blog-search__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--space-xxl) + var(--space-md));
  min-height: calc(var(--space-xxl) + var(--space-md));
  padding: 0;
  color: var(--c-text-primary);
  background-color: var(--c-accent);
  border: 0;
  border-radius: var(--rounded-sm);
  cursor: pointer;
}

.blog-search__button:focus-visible {
  outline: 2px solid var(--c-accent-strong);
  outline-offset: var(--space-xxs);
}

.blog-search__button svg {
  width: var(--space-lg);
  height: var(--space-lg);
}

/* --------------------------------------------------------------------------
   Recent posts + categories — hairline-ruled lists
   -------------------------------------------------------------------------- */

.blog-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.blog-list > li {
  border-bottom: 1px solid var(--c-hairline);
}

.blog-list > li:last-child {
  border-bottom: 0;
}

/* Recent post row: title over date, whole row is the link */
.blog-recent__link {
  display: flex;
  flex-direction: column;
  gap: var(--space-xxs);
  padding: var(--space-md) 0;
  text-decoration: none;
}

.blog-recent__title {
  font-family: var(--font-body);
  font-size: 16px;      /* body-md */
  font-weight: 360;
  line-height: 1.5;
  color: var(--c-text-primary);
}

.blog-recent__date {
  font-family: var(--font-body);
  font-size: 14px;      /* body-sm */
  font-weight: 360;
  line-height: 1.45;
  color: var(--c-text-muted);
}

.blog-recent__link:hover .blog-recent__title,
.blog-recent__link:focus-visible .blog-recent__title {
  color: var(--c-accent-strong);
}

.blog-recent__link:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: var(--space-xxs);
}

/* Category row: name left, post count right */
.blog-category {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  font-family: var(--font-body);
  font-size: 16px;      /* body-md */
  font-weight: 360;
  line-height: 1.5;
  color: var(--c-text-secondary);
}

/* Category row as link → blog.html?category= */
a.blog-category {
  text-decoration: none;
}

a.blog-category:hover,
a.blog-category:focus-visible,
a.blog-category[aria-current="true"] {
  color: var(--c-accent-strong);
}

/* Active category — accent rule marks the selected row */
a.blog-category[aria-current="true"] {
  padding-left: var(--space-md);
  box-shadow: inset var(--space-xxs) 0 0 var(--c-accent);
}

a.blog-category:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: var(--space-xxs);
}

/* Count in code font */
.blog-category__count {
  font-family: var(--font-code);
  font-size: 15px;      /* code-sm */
  line-height: 1.45;
  color: var(--c-accent-strong);
}

/* --------------------------------------------------------------------------
   Tags — pill-accent shape, tinted accent surface (matches Lab/Projects pills)
   -------------------------------------------------------------------------- */

.blog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin: 0;
  padding: 0;
  list-style: none;
}

.blog-tags li {
  display: flex;
}

/* Tag pill link → blog.html?tag= */
.blog-tags a {
  position: relative;
  padding: var(--space-xxs) var(--space-sm);
  font-family: var(--font-body);
  font-size: 14px;      /* body-sm */
  font-weight: 360;
  line-height: 1.45;
  color: var(--c-text-primary);
  text-decoration: none;
  background-color: color-mix(in srgb, var(--c-accent) 18%, var(--c-canvas-soft));
  border-radius: var(--rounded-full);
}

/* Invisible hit area extends the pill toward a 44px tap target */
.blog-tags a::after {
  content: "";
  position: absolute;
  inset: calc(var(--space-sm) * -1) 0;
}

/* Hover / focus / active filter — full pill-accent surface */
.blog-tags a:hover,
.blog-tags a:focus-visible,
.blog-tags a[aria-current="true"] {
  background-color: var(--c-accent);
}

.blog-tags a:focus-visible {
  outline: 2px solid var(--c-accent-strong);
  outline-offset: var(--space-xxs);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

/* Mobile: tighter widget rhythm, smaller headings */
@media (max-width: 480px) {
  .blog-sidebar {
    gap: var(--space-xl);
  }

  .blog-widget {
    gap: var(--space-md);
  }

  .blog-widget__title {
    font-size: 18px;    /* display-sm */
    line-height: 1.3;
    letter-spacing: -0.2px;
  }

  /* Taller rows keep tag tap areas from overlapping */
  .blog-tags {
    row-gap: var(--space-md);
  }
}
