/* =========================================================
   MoroHeritage — Editorial single post
   Loaded only on is_single() && 'post' === get_post_type()
   ========================================================= */

.moroheritage-post-page {
  --mh-container: 1180px;        /* editorial container: hero, layout, related */
  --mh-gutter: 40px;             /* desktop side gutter */
  --mh-sidebar-width: 290px;
  --mh-layout-gap: 52px;         /* main column ends up around 838px */
  --mh-post-measure: 780px;      /* reading width when there is no sidebar */
  background: var(--mh-cream, #fbf8f2);
}

/* Neutralise the parent theme container constraints for this template only. */
.moroheritage-post-page .mh-post-main {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0 0 96px;
  color: var(--mh-text, #241a15);
  font-family: var(--mh-font-sans);
}

/*
 * One editorial container for every top-level block. The hero and the featured
 * image are NOT inside the content column any more, so they use the full
 * 1180px width.
 */
.mh-single-hero,
.mh-single-layout,
.moroheritage-post-page .mh-related,
.mh-comments {
  width: min(calc(100% - (var(--mh-gutter) * 2)), var(--mh-container));
  margin-inline: auto;
}

/* -------------------------------------------------- Hero (full width) */

.mh-single-hero__content {
  width: 100%;
  max-width: none;
  padding-block: 48px 34px;
}

.mh-single-title {
  max-width: 1000px;
  margin: 0;
  font-family: var(--mh-font-serif);
  font-weight: 500;
  font-size: clamp(2.7rem, 5vw, 5.4rem);
  line-height: 1.02;
  letter-spacing: -0.028em;
  color: var(--mh-green-deep, #0f2620);
  overflow-wrap: anywhere;
  text-wrap: balance;
}

/* -------------------------------------------------- Featured image */

.mh-single-featured {
  width: 100%;
  max-width: none;
  margin: 0;
  overflow: hidden;
  border-radius: 18px;
  background: #eee7dc;
}

.mh-single-featured img,
.mh-single-featured__img {
  display: block;
  width: 100%;
  height: clamp(420px, 52vw, 650px);
  object-fit: cover;
}

.mh-single-featured figcaption {
  padding: 12px 18px 14px;
  font-size: 0.8125rem;
  line-height: 1.6;
  font-style: italic;
  color: var(--mh-muted, #6f6459);
  background: #fff;
}

/* -------------------------------------------------- Two-column layout */

.mh-single-layout {
  /* Clear breathing room between the image and both columns. */
  margin-top: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--mh-sidebar-width);
  gap: var(--mh-layout-gap);
  align-items: start;
}

/* Nothing to show in the sidebar: one centred editorial column. */
.mh-single-layout.no-sidebar {
  display: block;
  width: min(calc(100% - (var(--mh-gutter) * 2)), var(--mh-post-measure));
}

.mh-single-main {
  width: 100%;
  min-width: 0;
}

.mh-single-main > * {
  max-width: 100%;
}

/*
 * The column itself defines the measure (~824px). Any inner max-width left over
 * from the no-sidebar layout would narrow the text a second time.
 */
.mh-single-layout.has-sidebar .mh-post-body,
.mh-single-layout.has-sidebar .mh-post-content,
.mh-single-layout.has-sidebar .mh-single__content,
.mh-single-layout.has-sidebar .entry-content {
  width: 100%;
  max-width: none;
  margin-inline: 0;
}

/*
 * Sidebar column. The widget design itself lives in
 * assets/css/journal-sidebar.css, shared with the Journal and the archives, so
 * the widgets look identical everywhere.
 *
 * align-self: stretch is what makes the sticky work: with the grid's
 * align-items: start the aside collapses to the height of its widgets, leaving
 * position: sticky no distance to travel.
 */

/* -------------------------------------------------- Breadcrumb */

.mh-post-breadcrumb {
  padding: 30px 0 24px;
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
  color: var(--mh-muted, #6f6459);
}

.mh-post-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mh-post-breadcrumb li + li::before {
  content: "/";
  margin-right: 6px;
  color: var(--mh-gold, #c99a55);
}

.mh-post-breadcrumb a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.mh-post-breadcrumb a:hover,
.mh-post-breadcrumb a:focus-visible {
  color: var(--mh-green, #17372f);
  border-bottom-color: var(--mh-gold, #c99a55);
}

/* -------------------------------------------------- Hero pieces */

.mh-post-eyebrow {
  display: inline-block;
  margin-bottom: 20px;
  padding: 7px 14px;
  border: 1px solid var(--mh-gold, #c99a55);
  border-radius: 999px;
  color: var(--mh-brown, #825137);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.mh-post-eyebrow:hover,
.mh-post-eyebrow:focus-visible {
  background: var(--mh-green, #17372f);
  border-color: var(--mh-green, #17372f);
  color: var(--mh-cream, #fbf8f2);
}

.mh-post-standfirst {
  max-width: 62ch;
  margin: 20px 0 0;
  font-family: var(--mh-font-serif);
  font-size: clamp(1.075rem, 1rem + 0.4vw, 1.3rem);
  line-height: 1.6;
  font-style: italic;
  color: var(--mh-brown, #825137);
}

.mh-post-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--mh-border, #e7ddd0);
}

.mh-post-meta__avatar {
  border-radius: 50%;
  flex: 0 0 auto;
}

.mh-post-meta__text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.mh-post-meta__author {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--mh-green, #17372f);
}

.mh-post-meta__line {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 0.8125rem;
  color: var(--mh-muted, #6f6459);
}

/* -------------------------------------------------- Body */

.mh-post-body {
  max-width: none;
  padding-top: 0;
  font-size: 1.125rem;
  line-height: 1.75;
  color: #33291f;
}

.mh-post-body > * {
  margin-top: 1.5em;
  margin-bottom: 0;
}

.mh-post-body > *:first-child {
  margin-top: 0;
}

.mh-post-body p {
  margin: 1.5em 0 0;
}

.mh-post-body h2,
.mh-post-body h3,
.mh-post-body h4 {
  font-family: var(--mh-font-serif);
  font-weight: 500;
  color: var(--mh-green-deep, #0f2620);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.mh-post-body h2 {
  margin-top: 2.1em;
  font-size: clamp(1.6rem, 1.35rem + 1vw, 2.1rem);
  line-height: 1.22;
}

.mh-post-body h2::after {
  content: "";
  display: block;
  width: 54px;
  height: 2px;
  margin-top: 14px;
  background: var(--mh-gold, #c99a55);
}

.mh-post-body h3 {
  margin-top: 1.9em;
  font-size: clamp(1.3rem, 1.15rem + 0.6vw, 1.6rem);
  line-height: 1.3;
}

.mh-post-body h4 {
  margin-top: 1.7em;
  font-size: 1.15rem;
}

.mh-post-body a {
  color: var(--mh-brown-deep, #5d3826);
  text-decoration: none;
  background-image: linear-gradient(var(--mh-gold, #c99a55), var(--mh-gold, #c99a55));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
  transition: background-size 0.2s ease, color 0.2s ease;
}

.mh-post-body a:hover,
.mh-post-body a:focus-visible {
  color: var(--mh-green, #17372f);
  background-size: 100% 2px;
}

.mh-post-body strong { font-weight: 700; color: #2a2018; }

.mh-post-body ul,
.mh-post-body ol {
  padding-left: 1.35em;
}

.mh-post-body li {
  margin-top: 0.55em;
}

.mh-post-body ul li::marker { color: var(--mh-gold, #c99a55); }
.mh-post-body ol li::marker { color: var(--mh-brown, #825137); font-weight: 700; }

.mh-post-body blockquote {
  margin: 2.2em 0 0;
  padding: 4px 0 4px 26px;
  border-left: 3px solid var(--mh-gold, #c99a55);
  font-family: var(--mh-font-serif);
  font-size: 1.28rem;
  line-height: 1.6;
  font-style: italic;
  color: var(--mh-green, #17372f);
}

.mh-post-body blockquote p { margin: 0.6em 0 0; }
.mh-post-body blockquote p:first-child { margin-top: 0; }

.mh-post-body blockquote cite {
  display: block;
  margin-top: 12px;
  font-family: var(--mh-font-sans);
  font-size: 0.8125rem;
  font-style: normal;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--mh-muted, #6f6459);
}

.mh-post-body :where(img, video, iframe) {
  max-width: 100%;
  height: auto;
  border-radius: var(--mh-radius, 14px);
}

.mh-post-body figure {
  margin: 2.2em 0 0;
}

.mh-post-body figcaption,
.mh-post-body .wp-caption-text {
  margin-top: 10px;
  font-size: 0.8125rem;
  line-height: 1.6;
  font-style: italic;
  color: var(--mh-muted, #6f6459);
}

.mh-post-body hr,
.mh-post-body .wp-block-separator {
  width: 70px;
  height: 1px;
  margin: 2.6em auto;
  border: 0;
  background: var(--mh-gold, #c99a55);
}

.mh-post-body table {
  width: 100%;
  margin-top: 2em;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.mh-post-body th,
.mh-post-body td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--mh-border, #e7ddd0);
  text-align: left;
  vertical-align: top;
}

.mh-post-body thead th {
  background: var(--mh-cream-warm, #f5efe4);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mh-green, #17372f);
}

.mh-post-body :where(pre, .wp-block-code) {
  margin-top: 2em;
  padding: 18px 20px;
  overflow-x: auto;
  border-radius: var(--mh-radius, 14px);
  background: var(--mh-green-deep, #0f2620);
  color: #eadfcd;
  font-size: 0.875rem;
  line-height: 1.7;
}

.mh-post-body :not(pre) > code {
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--mh-cream-warm, #f5efe4);
  font-size: 0.9em;
}

/* Gutenberg alignments inside the reading column. */
.mh-post-body .alignwide {
  width: 100%;
}

.mh-single-layout.no-sidebar .mh-post-body .alignwide {
  width: min(100vw - (var(--mh-gutter) * 2), var(--mh-container));
  margin-inline: calc(50% - min(50vw - var(--mh-gutter), var(--mh-container) / 2));
}

.mh-post-body .alignfull {
  width: 100vw;
  margin-inline: calc(50% - 50vw);
  border-radius: 0;
}

.mh-post-body .alignfull :where(img) { border-radius: 0; }

.mh-post-body .alignleft {
  float: left;
  margin: 0.4em 1.6em 1.2em 0;
  max-width: 50%;
}

.mh-post-body .alignright {
  float: right;
  margin: 0.4em 0 1.2em 1.6em;
  max-width: 50%;
}

.mh-post-body .aligncenter { margin-inline: auto; text-align: center; }

.mh-post-body .wp-block-image,
.mh-post-body .wp-block-gallery,
.mh-post-body .wp-block-embed { margin-top: 2.2em; }

.mh-post-body .wp-block-pullquote {
  margin-top: 2.4em;
  padding: 28px 24px;
  border-top: 2px solid var(--mh-gold, #c99a55);
  border-bottom: 2px solid var(--mh-gold, #c99a55);
  text-align: center;
  font-family: var(--mh-font-serif);
  font-size: 1.35rem;
  font-style: italic;
  color: var(--mh-green, #17372f);
}

.mh-post-body .wp-block-button__link {
  display: inline-block;
  padding: 13px 22px;
  border-radius: 8px;
  background: var(--mh-green, #17372f);
  color: var(--mh-cream, #fbf8f2);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  background-image: none;
}

.mh-post-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2.4em;
  font-size: 0.875rem;
  color: var(--mh-muted, #6f6459);
}

/* -------------------------------------------------- Tags */

.mh-post-tags {
  margin-top: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mh-post-tags a {
  display: inline-block;
  padding: 6px 13px;
  border: 1px solid var(--mh-border, #e7ddd0);
  border-radius: 999px;
  background: #fff;
  color: var(--mh-brown, #825137);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.mh-post-tags a:hover,
.mh-post-tags a:focus-visible {
  border-color: var(--mh-gold, #c99a55);
  color: var(--mh-green, #17372f);
}

/* -------------------------------------------------- Share bar */

.mh-post-share {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 44px;
  padding: 18px 0;
  border-top: 1px solid var(--mh-border, #e7ddd0);
  border-bottom: 1px solid var(--mh-border, #e7ddd0);
}

.mh-post-share__label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mh-muted, #6f6459);
}

.mh-post-share ul {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mh-post-share li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mh-share-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--mh-border, #e7ddd0);
  border-radius: 50%;
  background: #fff;
  color: var(--mh-green, #17372f);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.mh-share-btn:hover,
.mh-share-btn:focus-visible {
  background: var(--mh-green, #17372f);
  border-color: var(--mh-green, #17372f);
  color: var(--mh-cream, #fbf8f2);
}

.mh-share-feedback {
  font-size: 0.75rem;
  color: var(--mh-brown, #825137);
}

/* -------------------------------------------------- Author card */

.mh-post-footer { margin-top: 48px; }

.mh-author-card {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--mh-border, #e7ddd0);
  border-radius: var(--mh-radius-lg, 20px);
  background: var(--mh-cream-warm, #f5efe4);
}

.mh-author-card__avatar {
  flex: 0 0 auto;
  border-radius: 50%;
}

.mh-author-card__body { min-width: 0; }

.mh-author-card__eyebrow {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mh-brown, #825137);
}

.mh-author-card__name {
  margin: 6px 0 0;
  font-family: var(--mh-font-serif);
  font-size: 1.375rem;
  font-weight: 500;
  color: var(--mh-green-deep, #0f2620);
}

.mh-author-card__bio {
  margin: 10px 0 0;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: #55483d;
}

.mh-author-card__link {
  display: inline-block;
  margin-top: 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--mh-brown-deep, #5d3826);
  text-decoration: none;
  border-bottom: 1px solid var(--mh-gold, #c99a55);
}

.mh-author-card__link:hover,
.mh-author-card__link:focus-visible { color: var(--mh-green, #17372f); }

/* -------------------------------------------------- Prev / next */

.mh-post-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 44px;
}

.mh-post-nav__item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 22px;
  border: 1px solid var(--mh-border, #e7ddd0);
  border-radius: var(--mh-radius, 14px);
  background: #fff;
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.mh-post-nav__item--empty { border-style: dashed; background: transparent; }

.mh-post-nav__item--next { text-align: right; }

a.mh-post-nav__item:hover,
a.mh-post-nav__item:focus-visible {
  border-color: var(--mh-gold, #c99a55);
  transform: translateY(-2px);
}

.mh-post-nav__label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mh-brown, #825137);
}

.mh-post-nav__item--next .mh-post-nav__label { justify-content: flex-end; }

.mh-post-nav__title {
  font-family: var(--mh-font-serif);
  font-size: 1.0625rem;
  line-height: 1.4;
  color: var(--mh-green-deep, #0f2620);
}

/* -------------------------------------------------- Related stories */

.moroheritage-post-page .mh-related {
  margin-top: 72px;
  padding-top: 48px;
  border-top: 1px solid var(--mh-border, #e7ddd0);
}

.mh-related__title {
  margin: 0 0 28px;
  font-family: var(--mh-font-serif);
  font-size: clamp(1.5rem, 1.3rem + 0.9vw, 2rem);
  font-weight: 500;
  color: var(--mh-green-deep, #0f2620);
}

/* Cards themselves are styled by assets/css/cards.css. */
.mh-related__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

/* -------------------------------------------------- Comments */

.mh-comments,
.mh-post-comments {
  margin-top: 64px;
}

/*
 * Previous / Next now sits inside the article column. Related Stories and the
 * comments sit OUTSIDE .mh-single-layout and use the editorial container, so no
 * widget can ever wrap them.
 */
.moroheritage-post-page .mh-post-nav {
  width: 100%;
}

.mh-post-comments .comments-title,
.mh-post-comments .comment-reply-title {
  font-family: var(--mh-font-serif);
  font-weight: 500;
  color: var(--mh-green-deep, #0f2620);
}

.mh-post-comments .comment-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mh-post-comments .comment-body {
  padding: 20px 0;
  border-bottom: 1px solid var(--mh-border, #e7ddd0);
}

.mh-post-comments input[type="text"],
.mh-post-comments input[type="email"],
.mh-post-comments input[type="url"],
.mh-post-comments textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--mh-border, #e7ddd0);
  border-radius: 9px;
  background: #fff;
  font-family: inherit;
  font-size: 0.9375rem;
}

.mh-post-comments .submit {
  padding: 12px 22px;
  border: 0;
  border-radius: 9px;
  background: var(--mh-green, #17372f);
  color: var(--mh-cream, #fbf8f2);
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

/* -------------------------------------------------- Focus & motion */

.moroheritage-post-page a:focus-visible,
.moroheritage-post-page button:focus-visible {
  outline: 2px solid var(--mh-brown, #825137);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .moroheritage-post-page *,
  .moroheritage-post-page *::before,
  .moroheritage-post-page *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  a.mh-post-nav__item:hover { transform: none; }
}

/* -------------------------------------------------- Responsive */

@media (max-width: 1200px) {
  .moroheritage-post-page {
    --mh-gutter: 28px;
    --mh-sidebar-width: 280px;
    --mh-layout-gap: 44px;
  }
}

/* Below 900px the sidebar drops under the article and stops being sticky. */
@media (max-width: 900px) {
  .moroheritage-post-page { --mh-gutter: 20px; }

  /* No fixed 280px column any more. */
  .mh-single-layout,
  .mh-single-layout.has-sidebar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 44px;
    margin-top: 44px;
  }

  .mh-single-hero__content { padding-block: 34px 26px; }

  .mh-single-title { font-size: clamp(2.1rem, 4.6vw, 3.1rem); }

  .mh-related__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mh-related__grid > *:nth-child(3) { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .moroheritage-post-page { --mh-gutter: 14px; }

  .moroheritage-post-page .mh-post-main { padding-bottom: 64px; }

  .mh-post-breadcrumb { padding: 22px 0 18px; }

  .mh-single-hero__content { padding-block: 24px 22px; }

  .mh-single-title { font-size: clamp(1.85rem, 7.6vw, 2.5rem); line-height: 1.1; }

  .mh-single-featured { border-radius: 14px; }

  /* Never let the hero image swallow a phone screen. */
  .mh-single-featured img,
  .mh-single-featured__img {
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
  }

  .mh-single-layout,
  .mh-single-layout.has-sidebar {
    margin-top: 36px;
    gap: 36px;
  }

  .mh-post-body {
    padding-top: 0;
    font-size: 1.0625rem;
    line-height: 1.75;
  }

  .mh-post-body .alignleft,
  .mh-post-body .alignright {
    float: none;
    max-width: 100%;
    margin: 2em 0 0;
  }

  .mh-author-card {
    flex-direction: column;
    gap: 14px;
    padding: 22px;
  }

  .mh-post-nav { grid-template-columns: 1fr; }
  .mh-post-nav__item--empty { display: none; }
  .mh-post-nav__item--next { text-align: left; }
  .mh-post-nav__item--next .mh-post-nav__label { justify-content: flex-start; }

  .mh-related__grid { grid-template-columns: 1fr; }
  .mh-related__grid > *:nth-child(3) { grid-column: auto; }
}
