/* ------------------------------------------------------------------ *
 * custom.css — the only custom stylesheet. Pico v2 does the heavy
 * lifting; this file just constrains width, builds the top bar / footer
 * layout, the card grid, and a few responsive tweaks.
 * ------------------------------------------------------------------ */

/* Constrain content width to ~950px, centered (Pico's container varies
   by breakpoint, so we pin it). */
.container {
  max-width: 950px;
}

/* --- Top bar ------------------------------------------------------- */
.topbar {
  border-bottom: 1px solid var(--pico-muted-border-color);
  margin-bottom: 2rem;
}
.topbar nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--pico-color);
}
.logo strong { color: var(--pico-primary); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  list-style: none;
}
.nav-links li { margin: 0; }

.lang-switch a {
  font-size: 0.8rem;
  font-weight: bold;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  font-size: 1rem;
  width: auto;
}

/* Mobile menu controls — hidden on desktop. The extra `.topbar` qualifier
   raises specificity above Pico's `[type=checkbox]~label` rule. */
.topbar .nav-toggle { display: none; }
.topbar .nav-burger { display: none; cursor: pointer; font-size: 1.4rem; margin-bottom: 0; }

/* --- Hero / page heads -------------------------------------------- */
.hero, .page-head { margin-bottom: 1.5rem; }
.hero h1 { margin-bottom: 0.25rem; }

/* --- Article cards & grid ----------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}
.card { margin: 0; }
.card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--pico-border-radius);
}
.card-body h3 { margin: 0.6rem 0 0.2rem; font-size: 1.1rem; }
.meta { color: var(--pico-muted-color); font-size: 0.85rem; margin-bottom: 0.4rem; }

/* --- Single post -------------------------------------------------- */
.post .cover {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: var(--pico-border-radius);
  margin: 1rem 0 1.5rem;
}
.post-tags { margin-top: 2rem; }
.tag {
  display: inline-block;
  font-size: 0.85rem;
  margin-right: 0.3rem;
  text-decoration: none;
}

/* Images in content always scale to the container. */
.content img { max-width: 100%; height: auto; }

/* --- Code blocks: keep dark in BOTH light and dark site themes ----
   Chroma (github-dark, noClasses) emits inline dark colors on <pre>,
   so we only add spacing, rounding and horizontal scroll here. */
.highlight {
  margin: 1.25rem 0;
  border-radius: var(--pico-border-radius);
  overflow: hidden;
}
.highlight pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  background: #0d1117; /* matches github-dark, in case a block is empty */
}

/* --- Tables: horizontal scroll on small screens ------------------- */
.table-wrap { overflow-x: auto; margin: 1.25rem 0; }
.table-wrap table { margin: 0; }

/* --- Archives ----------------------------------------------------- */
.archive-list { padding: 0; }
.archive-list li { display: flex; gap: 1rem; list-style: none; }
.archive-list time { color: var(--pico-muted-color); min-width: 4rem; }

.term-list { padding: 0; }
.term-list li { list-style: none; }
.term-list .count { color: var(--pico-muted-color); font-size: 0.85rem; }

/* --- Footer ------------------------------------------------------- */
.site-footer {
  margin-top: 3rem;
  padding: 2rem 0 1rem;
  border-top: 1px solid var(--pico-muted-border-color);
}
.site-footer .grid { grid-template-columns: repeat(3, 1fr); }
.site-footer h4 { margin-bottom: 0.6rem; }
.site-footer ul { padding: 0; font-size: 0.9rem; }
/* Pico sets `ul li { list-style: square }` on the LI, so we clear it there. */
.site-footer li { list-style: none; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag-cloud li { margin: 0; }
.footer-bottom { margin-top: 1.5rem; color: var(--pico-muted-color); }

/* --- Responsive: collapse the top bar on small screens ------------ */
@media (max-width: 768px) {
  .card-grid { grid-template-columns: 1fr; }
  .site-footer .grid { grid-template-columns: 1fr; }

  .topbar .nav-burger { display: block; }
  .nav-links {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    margin-top: 0.5rem;
  }
  /* The hidden checkbox (#nav-toggle) reveals the menu — no JS needed. */
  .nav-toggle:checked ~ .nav-links { display: flex; }
  .topbar nav { flex-wrap: wrap; }
}
