/* ==========================================================================
   Blog post reading layout (single.php), Oct 2026 design pass.
   Loaded only on single posts, after main.css (inc/template-functions.php).

   Why: header and body now share one left edge and one ~66-character column
   (37rem at 19px Switzer measures about 66-68 characters),
   the header is light (BRAND.md: light by default), the heading scale sits
   well below the title, captions read as sentences, and the end of the post
   has one related module. Research and sources: memory
   wp-blog-post-design-research (25-blog benchmark + Bringhurst, Butterick,
   NN/g, Muller-Brockmann).

   Plain CSS on purpose. Prod's compiled main.css can lag the repo, so this
   file never relies on new Tailwind utilities. The theme imports Tailwind
   with `important`, so prose overrides sit inside @layer utilities, where a
   class selector beats the typography plugin's :where() rules. Elements
   styled here carry no competing utility classes.
   ========================================================================== */

:root {
  --ms-ink: var(--color-ink, #0A1628);
  --ms-ink-85: rgba(10, 22, 40, 0.85);
  --ms-ink-70: rgba(10, 22, 40, 0.70);
  --ms-ink-68: rgba(10, 22, 40, 0.68);
  --ms-stone: var(--color-stone, #E8E4DF);
  --ms-emerald-strong: var(--color-emerald-strong, #00674F);
  --ms-caption: var(--color-slate-strong, #4a5263);
}

/* One column for header, body, author card and post navigation. */
.ms-article-col {
  max-width: 37rem;
  margin-left: auto;
  margin-right: auto;
}

/* ---- Header ---------------------------------------------------------- */
.ms-post-header {
  padding-top: 3rem;
}
@media (min-width: 768px) {
  .ms-post-header { padding-top: 5rem; }
}

.ms-pill {
  display: inline-block;
  margin-bottom: 1.5rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--ms-stone);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ms-emerald-strong);
  text-decoration: none;
  position: relative;
  transition: background-color 0.15s ease;
}
.ms-pill:hover { background-color: rgba(0, 103, 79, 0.06); }

.ms-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2.125rem, 1.35rem + 2.6vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ms-ink);
  text-wrap: balance;
}

.ms-dek {
  margin: 1.25rem 0 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.4;
  color: var(--ms-ink-70);
  text-wrap: pretty;
}
@media (min-width: 768px) {
  .ms-dek { font-size: 1.375rem; }
}

.ms-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.875rem;
  margin-top: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--ms-stone);
  font-size: 0.875rem;
  color: var(--ms-ink-68);
}
.ms-author { display: flex; align-items: center; gap: 0.625rem; }
.ms-author-name { color: var(--ms-ink); font-weight: 500; }
.ms-sep { color: rgba(10, 22, 40, 0.35); }
/* Author on its own line, then the date group, so a wrapped row never starts
   or ends with a stray separator (the column is too narrow for both anyway). */
.ms-author { flex-basis: 100%; }
.ms-sep-author { display: none; }
.ms-when { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.625rem; }
/* Phones: "Updated ..." gets its own line under the date and read time. */
@media (max-width: 639px) {
  .ms-updated { order: 3; flex-basis: 100%; }
  .ms-sep-updated { display: none; }
}

.ms-era {
  margin: 1.5rem 0 0;
  padding-left: 0.875rem;
  border-left: 2px solid var(--ms-stone);
  font-size: 0.9375rem;
  line-height: 1.5;
  font-style: italic;
  color: var(--ms-ink-68);
}

.ms-keypoints {
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--ms-stone);
  border-radius: 0.75rem;
  background-color: rgba(232, 228, 223, 0.25);
}
.ms-keypoints-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ms-emerald-strong);
}
.ms-keypoints ul {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  list-style: disc;
}
.ms-keypoints li {
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--ms-ink-85);
}
.ms-keypoints li + li { margin-top: 0.4rem; }
.ms-keypoints li::marker { color: rgba(10, 22, 40, 0.4); }

/* Phones: tighter header rhythm so the first paragraph stays near the top
   even when every reading extra is filled in. */
@media (max-width: 639px) {
  .ms-post-header { padding-top: 2.25rem; }
  .ms-pill { margin-bottom: 1rem; }
  .ms-dek { margin-top: 0.875rem; font-size: 1.125rem; }
  .ms-meta { margin-top: 1.25rem; padding-bottom: 1.25rem; }
  .ms-era { margin-top: 1rem; }
  .ms-keypoints { margin-top: 1.25rem; padding: 1rem 1.125rem; }
  .ms-article-body { padding-top: 1.75rem; }
}

/* ---- Body ------------------------------------------------------------- */
.ms-article-body {
  padding-top: 2.5rem;
  padding-bottom: 4rem;
}
@media (min-width: 768px) {
  .ms-article-body { padding-top: 3rem; padding-bottom: 5rem; }
}

@layer utilities {
  .prose.ms-article {
    max-width: none !important;
    font-size: 1.125rem !important;
    line-height: 1.65 !important;
  }
  @media (min-width: 768px) {
    .prose.ms-article { font-size: 1.1875rem !important; }
  }

  .prose.ms-article :is(h1, h2, h3):not(.not-prose *) { color: var(--ms-ink) !important; }

  /* Sizes apply to every heading in the post body. */
  .prose.ms-article h2:not(.not-prose *) {
    font-size: 1.625rem !important;
    line-height: 1.2 !important;
    margin-bottom: 0.875rem !important;
  }
  .prose.ms-article h3:not(.not-prose *) {
    font-size: 1.3125rem !important;
    line-height: 1.25 !important;
    margin-top: 2.25rem !important;
    margin-bottom: 0.5rem !important;
  }
  @media (min-width: 768px) {
    .prose.ms-article h2:not(.not-prose *) { font-size: 2rem !important; }
    .prose.ms-article h3:not(.not-prose *) { font-size: 1.4375rem !important; }
  }

  /* The section break (stone rule + space) only on top-level headings, so
     headings inside old boxed content don't get a divider. */
  .prose.ms-article > h2 {
    margin-top: 3.25rem !important;
    padding-top: 2rem !important;
    border-top: 1px solid var(--ms-stone) !important;
  }
  /* Older posts use H3 as their top level. With no top-level H2, top-level
     H3s take the section-break role. */
  .prose.ms-article:not(:has(> h2)) > h3 {
    font-size: 1.625rem !important;
    margin-top: 3.25rem !important;
    margin-bottom: 0.875rem !important;
    padding-top: 2rem !important;
    border-top: 1px solid var(--ms-stone) !important;
  }
  @media (min-width: 768px) {
    .prose.ms-article:not(:has(> h2)) > h3 { font-size: 2rem !important; }
  }

  /* A heading that opens the post gets no rule or extra space. */
  .prose.ms-article > :is(h2, h3):first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: 0 !important;
  }

  .prose.ms-article li:not(.not-prose *)::marker { color: rgba(10, 22, 40, 0.4) !important; }

  /* A caption sits right under its image: the prose default puts ~2em
     under every img, which left a gap between picture and caption. */
  .prose.ms-article figure:not(.not-prose *),
  .prose.ms-article .wp-caption:not(.not-prose *) {
    margin-top: 2.25rem !important;
    margin-bottom: 2.25rem !important;
  }
  .prose.ms-article figure:not(.not-prose *) img,
  .prose.ms-article .wp-caption:not(.not-prose *) img {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
  }

  /* Captions read as sentences, not spaced mono caps. */
  .prose.ms-article .wp-caption-text:not(.not-prose *),
  .prose.ms-article figcaption:not(.not-prose *) {
    font-family: var(--font-sans) !important;
    font-size: 0.9375rem !important;
    line-height: 1.5 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    color: var(--ms-caption) !important;
    margin-top: 0.625rem !important;
  }
  /* Every caption sits on the column's left edge. */
  .prose.ms-article figcaption:not(.not-prose *),
  .prose.ms-article .wp-caption-text:not(.not-prose *) {
    text-align: left !important;
  }

  /* Legacy screenshots: real-size files fill the column (many are 1024px
     files that the old markup squeezed to width="400"); genuinely small
     images sit at natural size on a stone plate. Classes come from
     mindshift_post_media_classes() in template-functions.php. */
  .prose.ms-article img.ms-img-fill {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
  }
  .prose.ms-article figure:has(img.ms-img-small),
  .prose.ms-article p:has(> img.ms-img-small:only-child),
  .prose.ms-article p:has(> a:only-child > img.ms-img-small) {
    padding: 1.5rem !important;
    border: 1px solid var(--ms-stone) !important;
    border-radius: 0.75rem !important;
    background-color: rgba(232, 228, 223, 0.45) !important;
    text-align: center !important;
  }
  .prose.ms-article img.ms-img-small {
    display: inline-block !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 auto !important;
  }
  .prose.ms-article figure:has(img.ms-img-small) figcaption {
    text-align: left !important;
    margin-top: 1rem !important;
  }

  /* Long H4s (a name plus a sentence) read as subheads, not 12px caps. */
  .prose.ms-article h4.ms-h4-long {
    font-family: var(--font-sans) !important;
    font-size: 1.1875rem !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    color: var(--ms-ink) !important;
    margin-top: 2rem !important;
    margin-bottom: 0.5rem !important;
  }

  /* Lists read as lists: tight items, the usual space around the list. */
  .prose.ms-article li:not(.not-prose *) {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
  }
  .prose.ms-article li:not(.not-prose *) + li {
    margin-top: 0.5rem !important;
  }

  /* Lighter links: body weight, a thin tinted underline that darkens on hover. */
  .prose.ms-article a:not(.not-prose *) {
    font-weight: inherit !important;
    text-decoration-line: underline !important;
    text-decoration-thickness: 1px !important;
    text-underline-offset: 0.2em !important;
    text-decoration-color: rgba(0, 103, 79, 0.45) !important;
  }
  .prose.ms-article a:not(.not-prose *):hover,
  .prose.ms-article a:not(.not-prose *):focus-visible {
    text-decoration-color: currentColor !important;
  }

  /* Diagrams (SVG) break out wider on desktop so their labels stay legible. */
  @media (min-width: 960px) {
    .prose.ms-article figure:has(> img[src$=".svg"]),
    .prose.ms-article figure:has(> a > img[src$=".svg"]),
    .prose.ms-article > p:has(> img[src$=".svg"]:only-child),
    .prose.ms-article > p:has(> a:only-child > img[src$=".svg"]) {
      width: 48rem !important;
      max-width: 48rem !important;
      margin-left: calc((100% - 48rem) / 2) !important;
      margin-right: 0 !important;
    }
    /* The caption stays on the text column's edge under a wide diagram. */
    .prose.ms-article figure:has(> img[src$=".svg"]) figcaption,
    .prose.ms-article figure:has(> a > img[src$=".svg"]) figcaption {
      max-width: 37rem;
      margin-left: 5.5rem !important;
    }
  }
  /* Phones: block-editor diagrams scroll sideways instead of shrinking
     their labels to a few pixels. */
  @media (max-width: 639px) {
    .prose.ms-article figure.wp-block-image:has(> img[src$=".svg"]) {
      overflow-x: auto !important;
    }
    .prose.ms-article figure.wp-block-image > img[src$=".svg"] {
      min-width: 40rem !important;
      max-width: none !important;
    }
  }

  /* The topic-matched offer card (inc/blog-cta.php) carries max-w-[68ch];
     inside the post column it should share the column edge. */
  .ms-article-body aside.max-w-\[68ch\] {
    max-width: none !important;
  }

  /* A named person's words: a cite line under the quote. */
  .prose.ms-article blockquote:not(.not-prose *) cite {
    display: block;
    margin-top: 0.75rem;
    font-family: var(--font-mono) !important;
    font-style: normal !important;
    font-size: 0.75rem !important;
    letter-spacing: 0.08em !important;
    color: var(--ms-ink-68) !important;
  }
}

/* ---- End of post ------------------------------------------------------ */
/* Author card first, right after the last paragraph. */
.ms-author-card { margin-top: 3.5rem; }
@media (max-width: 639px) {
  .ms-author-card > div { flex-direction: column; }
}

/* Tags left, share right, under one stone rule. */
.ms-endrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--ms-stone);
}
.ms-endrow .ms-tags { flex: 1 1 0; min-width: 0; margin: 0; padding: 0; border: 0; }
.ms-endrow .ms-share { flex: 0 0 auto; }

.ms-share { display: flex; align-items: center; gap: 0.5rem; }
.ms-share-label {
  margin-right: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ms-ink-68);
}
.ms-share-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background-color: rgba(232, 228, 223, 0.6);
  color: var(--ms-ink);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.ms-share-btn:hover { background-color: var(--ms-emerald-strong); color: #F7F5F2; }
.ms-share-btn:focus-visible, .ms-pill:focus-visible, .ms-tag:focus-visible {
  outline: 2px solid var(--ms-emerald-strong);
  outline-offset: 2px;
}
.ms-copy-status {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translate(-50%, 0.35rem);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  white-space: nowrap;
  color: var(--ms-emerald-strong);
}
.ms-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--ms-stone);
}
.ms-tag {
  position: relative;
  border: 1px solid transparent; /* keeps the pill shape in forced-colors mode */
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background-color: rgba(232, 228, 223, 0.6);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ms-ink);
  text-decoration: none;
  transition: background-color 0.15s ease;
}
.ms-tag:hover { background-color: var(--ms-stone); }
/* 44px touch targets on phones without changing the look. */
@media (max-width: 639px) {
  .ms-pill::after, .ms-tag::after { content: ""; position: absolute; inset: -8px 0; }
}

.ms-related {
  padding: 4rem 0;
  background-color: rgba(232, 228, 223, 0.35);
  border-top: 1px solid var(--ms-stone);
}
@media (min-width: 768px) {
  .ms-related { padding: 6rem 0; }
}
