/* =========================================================
   Blog index (/blog/) — scoped to .blog-index
   Visual language borrowed from the homepage "Recent Work" list:
   square corners, brown rules, dark badge on the thumbnail,
   outline buttons. Sizes are fluid (clamp) and entries adapt to
   their column width via a container query.
   ========================================================= */

.blog-index {
  --bi-ink: #463935;
  --bi-trim: #120e0d;
  --bi-muted: rgba(70, 57, 53, 0.7);
  --bi-line: rgba(70, 57, 53, 0.3);
  --bi-gutter: clamp(0.9rem, 0.5rem + 2vw, 2.5rem);

  box-sizing: border-box;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(0.9rem, 0.6rem + 1.2vw, 1.75rem) var(--bi-gutter) 4rem;
  color: var(--bi-ink);
}

.blog-index *,
.blog-index *::before,
.blog-index *::after {
  box-sizing: inherit;
}

.blog-index a {
  text-decoration: none !important;
}

/* ---------- Banner ---------- */
.bi-hero {
  position: relative;
  overflow: hidden;
  background: #0b1c26 url("/assets/img/banner.jpeg") center / cover no-repeat;
  padding: clamp(1.25rem, 0.7rem + 2.6vw, 2.5rem) 1rem;
  text-align: center;
}

.bi-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom right, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.45));
}

.bi-hero > * {
  position: relative;
}

.bi-hero-title {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.3em 0.55em;
  margin: 0 0 0.55rem;
  font-size: clamp(2rem, 1.3rem + 3vw, 3.2rem);
  font-weight: 400;
  line-height: 1;
  color: #fff !important;
}

.bi-hero-code {
  font-family: "Ubuntu Mono", "Courier New", monospace;
  padding: 0.18em 0.7em;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.5);
}

.bi-hero-subtitle {
  margin: 0;
  font-size: clamp(0.95rem, 0.85rem + 0.4vw, 1.05rem);
  font-style: italic;
  color: #f3f3f3;
}

/* ---------- Section headings (match homepage: text + 3px rule) ---------- */
.bi-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin: 0 0 1rem;
  padding-bottom: 0.3rem;
  border-bottom: 3px solid var(--bi-ink);
}

.bi-heading h2 {
  margin: 0 !important;
  font-size: clamp(1.35rem, 1.15rem + 0.8vw, 1.65rem) !important;
  font-weight: 600;
  line-height: 1.2;
  color: var(--bi-ink) !important;
}

.bi-heading-aside {
  font-size: 0.95rem;
  color: var(--bi-muted) !important;
  white-space: nowrap;
}

.bi-heading-aside:hover {
  color: var(--bi-ink) !important;
  text-decoration: underline !important;
}

/* ---------- Layout ---------- */
.bi-layout {
  display: grid;
  grid-template-columns: 13.5rem minmax(0, 1fr);
  gap: clamp(1.25rem, 0.8rem + 2vw, 2.75rem);
  margin-top: clamp(1.25rem, 0.9rem + 1.2vw, 2rem);
  align-items: start;
}

/* ---------- Categories ---------- */
.bi-categories {
  position: sticky;
  top: 6.5rem;
  align-self: start;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  scrollbar-width: thin;
}

.bi-categories .bi-heading {
  border-bottom-width: 2px;
  margin-bottom: 0.6rem;
}

.bi-categories .bi-heading h2 {
  font-size: 1.2rem !important;
}

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

.bi-cat-list li {
  margin: 0;
}

.bi-cat {
  display: block;
  padding: 0.22rem 0 0.22rem 0.6rem;
  border-left: 3px solid transparent;
  font-size: 1rem;
  line-height: 1.35;
  color: var(--bi-ink) !important;
}

.bi-cat:hover,
.bi-cat:focus-visible {
  border-left-color: var(--bi-line);
  outline: none;
}

.bi-cat.is-active {
  border-left-color: var(--bi-ink);
  font-weight: 600;
}

.bi-count {
  color: var(--bi-muted);
  font-weight: 400;
}

/* ---------- Feed ---------- */
.bi-feed {
  container-type: inline-size;
  min-width: 0;
}

.bi-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.bi-empty {
  margin: 0.5rem 0 0;
  color: var(--bi-muted);
  font-style: italic;
}

/* ---------- Entry ---------- */
.bi-entry {
  display: grid;
  grid-template-columns: clamp(7rem, 32%, 15rem) minmax(0, 1fr);
  background: #fff;
  border: 1px solid var(--bi-line);
  transition: border-color 120ms ease;
}

.bi-entry:hover {
  border-color: var(--bi-ink);
}

.bi-entry.no-thumb {
  grid-template-columns: minmax(0, 1fr);
}

.bi-thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.6rem 0.6rem 0.6rem;
  border-right: 1px solid var(--bi-line);
  background: #fff;
}

.bi-thumb img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1514 / 877;
  object-fit: contain;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* Dark label in the corner of the thumbnail — same idea as the "arxiv" badge */
.bi-badge {
  position: absolute;
  top: 0;
  left: 0;
  max-width: 100%;
  padding: 0.18rem 0.55rem;
  background: var(--bi-ink);
  color: #fff !important;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bi-body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.8rem 1rem 0.85rem;
  min-width: 0;
}

.bi-entry.no-thumb .bi-badge {
  position: static;
  align-self: flex-start;
  margin-bottom: 0.15rem;
}

.bi-title {
  margin: 0 !important;
  font-size: clamp(1.15rem, 1.05rem + 0.45vw, 1.35rem) !important;
  font-weight: 700;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.bi-title a {
  color: var(--bi-ink) !important;
}

.bi-title a:hover,
.bi-title a:focus-visible {
  text-decoration: underline !important;
  outline: none;
}

.bi-meta {
  margin: 0;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--bi-muted);
}

.bi-excerpt {
  margin: 0.1rem 0 0;
  font-size: 1rem;
  line-height: 1.45;
  color: #3a302d;
}

.bi-actions {
  margin-top: auto;
  padding-top: 0.35rem;
}

/* Outline button — same as the PDF / Code buttons on the homepage */
.bi-btn {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border: 1px solid var(--bi-ink);
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--bi-ink) !important;
  background: transparent;
  transition: background-color 120ms ease, color 120ms ease;
}

.bi-btn:hover,
.bi-btn:focus-visible {
  background: var(--bi-ink);
  color: #fdf6e3 !important;
  outline: none;
}

/* Narrow column: image becomes a short band above the text */
@container (max-width: 520px) {
  .bi-entry {
    grid-template-columns: minmax(0, 1fr);
  }

  .bi-thumb {
    padding: 1.5rem 0.75rem 0.5rem;
    border-right: 0;
    border-bottom: 1px solid var(--bi-line);
  }

  .bi-thumb img {
    width: auto;
    max-width: 100%;
    max-height: 10.5rem;
  }

  .bi-body {
    padding: 0.7rem 0.85rem 0.8rem;
    gap: 0.25rem;
  }
}

/* ---------- Narrow screens: categories become one inline line ---------- */
@media (max-width: 760px) {
  .bi-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.9rem;
  }

  .bi-categories {
    position: static;
    max-height: none;
    overflow: visible;
    padding-bottom: 0.7rem;
    border-bottom: 1px solid var(--bi-line);
  }

  .bi-categories .bi-heading {
    margin: 0 0 0.35rem;
    padding: 0;
    border: 0;
  }

  .bi-categories .bi-heading h2 {
    font-size: 1rem !important;
  }

  .bi-categories .bi-heading h2::after {
    content: ":";
  }

  .bi-cat-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.9rem;
  }

  .bi-cat {
    padding: 0;
    border-left: 0;
  }

  .bi-cat.is-active {
    font-weight: 700;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bi-entry,
  .bi-btn {
    transition: none;
  }
}
