/* The /blog/ section. It is a separate stylesheet because only the blog pages need it, and it
   leans on the variables and the page furniture already defined in styles.css. */

.blog-page .site-shell {
  overflow: visible;
}

/* ---- The list of posts ---------------------------------------------------------------- */

.blog-list .work-hero .lead {
  max-width: 44rem;
}

.blog-list-section {
  background: var(--modern-paper);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--modern-line);
  border-radius: 2rem;
  background: var(--modern-panel);
  color: var(--modern-ink-soft);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.02rem;
  text-decoration: none;
  transition: border-color 0.15s ease-out, color 0.15s ease-out, background 0.15s ease-out;
}

.tag-chip span {
  color: var(--modern-muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.tag-chip:hover,
.tag-chip:focus-visible {
  border-color: var(--modern-primary);
  color: var(--modern-primary-dark);
  text-decoration: none;
}

.tag-chip.is-active {
  border-color: var(--modern-primary);
  background: var(--modern-primary);
  color: #1b1703;
}

.tag-chip.is-active span {
  color: rgba(27, 23, 3, 0.65);
}

.post-year + .post-year {
  margin-top: 3rem;
}

.post-year-heading {
  margin: 0 0 1.25rem;
  color: var(--modern-muted);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.22rem;
  text-transform: uppercase;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 1.25rem;
}

.post-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--modern-line);
  border-radius: 1rem;
  background: var(--modern-panel);
  box-shadow: var(--modern-shadow);
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out, border-color 0.15s ease-out;
}

.post-card:hover,
.post-card:focus-within {
  transform: translateY(-3px);
  border-color: var(--modern-primary);
}

.post-card-link {
  flex: 1 1 auto;
  padding: 1.35rem 1.4rem 0.9rem;
  color: inherit;
  text-decoration: none;
}

.post-card-link:hover,
.post-card-link:focus-visible {
  color: inherit;
  text-decoration: none;
}

.post-card-link time {
  display: block;
  color: var(--modern-muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1rem;
}

.post-card-link h3 {
  margin: 0.45rem 0 0.6rem;
  font-size: 1.22rem;
  line-height: 1.3;
}

.post-card-link:hover h3 {
  color: var(--modern-primary-dark);
}

.post-card-link p {
  margin: 0;
  color: var(--modern-ink-soft);
  font-size: 0.92rem;
  line-height: 1.55;
}

.post-card footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem 1.1rem;
}

.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.post-card-tags a {
  padding: 0.2rem 0.55rem;
  border-radius: 0.4rem;
  background: rgba(31, 122, 103, 0.1);
  color: var(--modern-accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.03rem;
  text-decoration: none;
}

.post-card-tags a:hover,
.post-card-tags a:focus-visible {
  background: rgba(31, 122, 103, 0.2);
  color: var(--modern-accent);
  text-decoration: none;
}

.post-card-time {
  color: var(--modern-muted);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

/* ---- One post ----------------------------------------------------------------------- */

/* A post is an <article>, not a <section>, so the padding styles.css gives
   `.modern-site section.resume-section` do not reach it - it gets them here. */
.post-section {
  padding: 7.5rem 1.25rem 5rem;
  background: var(--modern-paper);
}

.post-content {
  width: min(48rem, 100%);
  margin: 0 auto;
}

.post-breadcrumb {
  margin-bottom: 1.5rem;
  color: var(--modern-muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04rem;
}

.post-breadcrumb a {
  color: var(--modern-accent);
}

.post-breadcrumb span:not([aria-hidden]) {
  color: var(--modern-muted);
}

.post-header h1 {
  margin: 0 0 0.85rem;
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  line-height: 1.12;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1rem;
  margin: 0 0 1.1rem;
  color: var(--modern-muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.post-meta time {
  color: var(--modern-ink-soft);
}

.post-updated {
  font-style: italic;
  font-weight: 400;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--modern-line);
}

.post-toc {
  margin: 2rem 0;
  padding: 1.1rem 1.4rem;
  border: 1px solid var(--modern-line);
  border-left: 3px solid var(--modern-primary);
  border-radius: 0.75rem;
  background: var(--modern-panel);
}

.post-toc h2 {
  margin: 0 0 0.6rem;
  color: var(--modern-muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.16rem;
  text-transform: uppercase;
}

.post-toc ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--modern-ink-soft);
}

.post-toc li + li {
  margin-top: 0.3rem;
}

/* ---- The body of a post ------------------------------------------------------------- */

.post-body {
  margin-top: 2rem;
  color: var(--modern-ink-soft);
  font-size: 1.03rem;
  line-height: 1.72;
  /* Several posts paste a bare URL into the text; on a phone it has to break somewhere. */
  overflow-wrap: break-word;
}

.post-body > * {
  margin-top: 0;
  margin-bottom: 1.25rem;
}

.post-body h2,
.post-body h3,
.post-body h4 {
  margin-top: 2.5rem;
  margin-bottom: 0.9rem;
  color: var(--modern-ink);
  line-height: 1.25;
  scroll-margin-top: 6rem;
}

.post-body h2 {
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--modern-line);
  font-size: 1.6rem;
}

.post-body h3 {
  font-size: 1.28rem;
}

.post-body h4 {
  font-size: 1.1rem;
}

.post-body a {
  color: var(--modern-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.post-body a:hover,
.post-body a:focus-visible {
  color: var(--modern-primary-dark);
}

.post-body ul,
.post-body ol {
  padding-left: 1.4rem;
}

.post-body li + li {
  margin-top: 0.4rem;
}

.post-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.75rem auto;
  border: 1px solid var(--modern-line);
  border-radius: 0.6rem;
  background: var(--modern-panel);
}

.post-body hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--modern-line);
}

.post-body kbd {
  display: inline-block;
  min-width: 1.6rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--modern-line);
  border-bottom-width: 2px;
  border-radius: 0.35rem;
  background: var(--modern-panel);
  color: var(--modern-ink);
  font-family: var(--font-family-monospace);
  font-size: 0.82rem;
  text-align: center;
}

/* An inline snippet, as opposed to a whole code block. */
.post-body :not(pre) > code {
  padding: 0.12rem 0.36rem;
  border: 1px solid var(--modern-line);
  border-radius: 0.35rem;
  background: rgba(21, 24, 22, 0.045);
  color: var(--modern-primary-dark);
  font-family: var(--font-family-monospace);
  font-size: 0.88em;
  overflow-wrap: break-word;
}

.post-body details {
  padding: 0.9rem 1.2rem;
  border: 1px solid var(--modern-line);
  border-radius: 0.6rem;
  background: var(--modern-panel);
}

.post-body summary {
  font-weight: 800;
  cursor: pointer;
}

/* A screenshot the old blog has lost. It is inline because the picture it replaces often sat
   inside a sentence. */
.post-media-lost {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  border: 1px dashed var(--modern-line);
  border-radius: 0.6rem;
  background: var(--modern-panel);
  color: var(--modern-muted);
  font-size: 0.88rem;
  font-style: italic;
}

/* ---- Tables ------------------------------------------------------------------------- */

.table-scroll {
  overflow-x: auto;
  margin: 1.75rem 0;
  border: 1px solid var(--modern-line);
  border-radius: 0.6rem;
  background: var(--modern-panel);
  -webkit-overflow-scrolling: touch;
}

.table-scroll table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.table-scroll th,
.table-scroll td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--modern-line);
  text-align: left;
  vertical-align: top;
}

.table-scroll th {
  background: rgba(21, 24, 22, 0.04);
  color: var(--modern-ink);
  font-weight: 800;
  white-space: nowrap;
}

.table-scroll tr:last-child td {
  border-bottom: 0;
}

/* ---- Code blocks -------------------------------------------------------------------- */

.code-block {
  margin: 1.75rem 0;
  overflow: hidden;
  border: 1px solid #2b322e;
  border-radius: 0.7rem;
  background: #181c1a;
}

.code-block figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0.5rem 0.45rem 0.95rem;
  border-bottom: 1px solid #2b322e;
  background: #131715;
}

.code-language {
  color: #8b968e;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14rem;
  text-transform: uppercase;
}

.code-copy {
  min-height: 1.9rem;
  padding: 0.15rem 0.7rem;
  border: 1px solid #343c37;
  border-radius: 0.4rem;
  background: transparent;
  color: #b7c0b8;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04rem;
  cursor: pointer;
  transition: border-color 0.15s ease-out, color 0.15s ease-out;
}

/* Without JavaScript the button would do nothing, so it is not shown. */
.code-copy {
  display: none;
}

.has-js .code-copy {
  display: inline-block;
}

.code-copy:hover,
.code-copy:focus-visible {
  border-color: var(--modern-primary);
  color: var(--modern-primary);
}

.code-copy.is-done {
  border-color: #3f8f6f;
  color: #7fd3ad;
}

.code-block pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  background: transparent;
  -webkit-overflow-scrolling: touch;
}

.code-block code {
  padding: 0;
  border: 0;
  background: none;
  color: #dfe5e0;
  font-family: var(--font-family-monospace);
  font-size: 0.86rem;
  line-height: 1.6;
  tab-size: 4;
  white-space: pre;
}

.hl-com { color: #7d8a80; font-style: italic; }
.hl-str { color: #c3d98d; }
.hl-num { color: #e2b35c; }
.hl-kw { color: #7fb6e8; font-weight: 700; }
.hl-fn { color: #ffd98a; }
.hl-var { color: #f0a989; }
.hl-attr { color: #9ed3c0; }
.hl-type { color: #8fd6ce; }
.hl-tag { color: #7fb6e8; }
.hl-op { color: #b9c4bc; }

/* ---- Newer / older ------------------------------------------------------------------ */

.post-neighbours {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--modern-line);
}

.post-neighbour {
  display: block;
  min-height: 2.5rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--modern-line);
  border-radius: 0.7rem;
  background: var(--modern-panel);
  color: var(--modern-ink);
  font-weight: 800;
  line-height: 1.35;
  text-decoration: none;
  transition: border-color 0.15s ease-out;
}

.post-neighbour:hover,
.post-neighbour:focus-visible {
  border-color: var(--modern-primary);
  color: var(--modern-primary-dark);
  text-decoration: none;
}

.post-neighbour span {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--modern-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14rem;
  text-transform: uppercase;
}

.post-neighbour.is-older {
  text-align: right;
}

/* ---- Phones ------------------------------------------------------------------------- */

@media (max-width: 575.98px) {
  .post-section {
    padding: 6.5rem 1rem 4rem;
  }

  .post-grid {
    grid-template-columns: 1fr;
  }

  .post-body {
    font-size: 1rem;
  }

  .post-body h2 {
    font-size: 1.35rem;
  }

  .code-block pre {
    padding: 0.85rem 0.9rem;
  }

  .code-block code {
    font-size: 0.8rem;
  }

  .post-neighbour.is-older {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .post-card,
  .post-neighbour,
  .tag-chip,
  .code-copy {
    transition: none;
  }

  .post-card:hover,
  .post-card:focus-within {
    transform: none;
  }
}
