/* Blog post layout: section cards and a contents sidebar.
   blog.js adds the structure. Typography and colours come from /george/assets/main.css. */

.wrapper.post-grid {
  max-width: none;
  display: grid;
  grid-template-columns: 15rem minmax(0, max(52rem, 55vw));
  justify-content: center;
  gap: 2.5rem;
  align-items: start;
}

/* ---- Contents sidebar ------------------------------------------------- */

.post-toc {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 1.5rem 0 2rem;
  border: 0;
  margin: 0;
  scrollbar-width: thin;
}

.post-toc > summary { display: none; }

.post-toc nav {
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--rule);
}

.post-toc nav a {
  color: var(--ink-muted);
  font-size: 0.85rem;
  line-height: 1.35;
  padding: 0.4rem 0.8rem;
  border-left: 2px solid transparent;
  margin-left: -2px;
}

.post-toc nav a.lvl3 { padding-left: 1.6rem; font-size: 0.8rem; }
.post-toc nav a:hover { color: var(--accent); border-left-color: var(--accent); text-decoration: none; }
.post-toc nav a.on { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

/* ---- Cards ------------------------------------------------------------ */

.post-card {
  position: relative;
  background-color: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1.6rem 2.2rem 0.6rem;
  margin-bottom: 1.8rem;
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.06);
}

.post-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 2.2rem;
  right: 2.2rem;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, transparent, var(--accent) 20%, var(--accent) 80%, transparent);
  opacity: 0.55;
}

.post-card > h2:first-child {
  margin-top: 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

.post-card h2, .post-card h3 { scroll-margin-top: 1.5rem; }

/* The card already uses the raised colour; code and tables go one step back. */
.post-card pre, .post-card code { background-color: var(--paper); }
.post-card pre > code { background: none; }
.post-card table { display: block; overflow-x: auto; }

/* ---- Narrow screens: contents fold above the post --------------------- */

@media screen and (max-width: 59.99rem) {
  .wrapper.post-grid { display: block; }
  .post-toc {
    position: sticky;
    z-index: 10;
    max-height: none;
    overflow: visible;
    padding: 0;
    margin: 0 0 1.5rem;
    background-color: var(--paper);
    border-bottom: 1px solid var(--rule);
  }
  .post-toc > summary { display: list-item; list-style-position: inside; padding: 0.6rem 0; }
  .post-toc[open] nav { max-height: 70vh; overflow-y: auto; padding-bottom: 0.8rem; }
  .post-card { padding: 1.2rem 1.1rem 0.4rem; }
  .post-card::before { left: 1.1rem; right: 1.1rem; }
  .post-card h2, .post-card h3 { scroll-margin-top: 3.5rem; }
}

@media print {
  .post-toc { display: none; }
  .wrapper.post-grid { display: block; }
  .post-card { border: 0; box-shadow: none; padding: 0; background: none; }
  .post-card::before { display: none; }
}
