/* ==========================================================================
   Single blog post
   --------------------------------------------------------------------------
   Loaded only on single posts (see wpat_assets()), for the same reason
   product.css and downloads.css are gated: this file styles one template
   family and would be dead weight everywhere else.

   Layout is a two-column CSS grid rather than core's columns block. The page
   needs the wide 1240px container for the hero, related posts and navigation,
   while the article itself has to stay at a comfortable 820px reading measure —
   two different widths that a single constrained layout cannot express.

   Every value below comes from the tokens already defined in base.css. No new
   colours, radii, shadows or font families are introduced.
   ========================================================================== */

/* --- Reading progress ---------------------------------------------------- */

.post-progress {
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  background: transparent;
  z-index: 95;
  pointer-events: none;
}

.post-progress__bar {
  display: block;
  height: 100%;
  width: 0;
  background: var(--color-accent);
  transition: width 80ms linear;
}

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

.post-hero {
  margin-block: var(--space-6) var(--space-8);
}

.post-crumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-5);
  padding: 0;
  list-style: none;
  font-size: var(--fs-sm);
  color: var(--color-ink-faint);
}

.post-crumbs li + li::before {
  content: "/";
  margin-right: var(--space-2);
  color: var(--color-border);
}

.post-crumbs a {
  color: var(--color-ink-soft);
}

.post-crumbs a:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

.post-crumbs [aria-current="page"] {
  color: var(--color-ink-faint);
}

.post-hero__inner {
  max-width: 880px;
}

.post-eyebrow {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.post-eyebrow a:hover {
  text-decoration: underline;
}

.post-hero__title {
  margin: 0 0 var(--space-5);
  font-size: clamp(2rem, 1.35rem + 2.6vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--color-primary);
}

/* --- Hero meta ----------------------------------------------------------- */

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  margin-bottom: var(--space-6);
  font-size: var(--fs-sm);
  color: var(--color-ink-soft);
}

.post-meta__author {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.post-meta__avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: block;
}

.post-meta__by a {
  font-weight: 700;
  color: var(--color-primary);
}

.post-meta__by a:hover {
  color: var(--color-accent);
}

.post-meta__facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--color-ink-faint);
}

.post-meta__facts li + li::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: var(--color-border);
  margin-right: var(--space-4);
  vertical-align: middle;
}

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

/* No forced aspect ratio: the image keeps its own proportions, so nothing is
   cropped. WordPress emits width/height on the img, which is what actually
   prevents layout shift.

   Capped short of the 1240px container on purpose — a 16:9 image at full
   container width stands ~700px tall and buries the opening paragraph below
   the fold. Narrowing the frame shortens it without cropping anything. */
.post-hero__media {
  margin: 0 auto;
  max-width: 1040px;
}

.post-hero__media img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  background: var(--color-surface-alt);
}

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

.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 820px) 300px;
  column-gap: var(--space-10);
  justify-content: center;
  align-items: start;
}

/* Short posts render no contents list, leaving the sidebar empty. Give the
   column back so the article stays centred instead of sitting off to one side. */
.post-layout:not(:has(.post-toc)) {
  grid-template-columns: minmax(0, 820px);
}

.post-layout__main {
  min-width: 0;
}

.post-layout__aside {
  position: sticky;
  top: var(--space-6);
}

/* --- Article body -------------------------------------------------------- */

.post-body {
  font-size: var(--fs-md);
  line-height: 1.75;
  color: var(--color-ink-soft);
}

/* Drop the browser defaults first so the rhythm rule below is the only source
   of vertical spacing; headings then opt into a larger gap. */
.post-body > * {
  margin-top: 0;
  margin-bottom: 0;
}

.post-body > * + * {
  margin-top: var(--space-5);
}

.post-body h2,
.post-body h3,
.post-body h4 {
  color: var(--color-primary);
  scroll-margin-top: var(--space-8);
}

.post-body > h2 {
  margin-top: var(--space-10);
  margin-bottom: var(--space-4);
  font-size: clamp(1.6rem, 1.3rem + 1vw, 2rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.post-body > h3 {
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
  font-size: clamp(1.2rem, 1.08rem + 0.5vw, 1.375rem);
  line-height: 1.35;
}

.post-body > h2:first-child,
.post-body > h3:first-child {
  margin-top: 0;
}

.post-body a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--color-ink-faint);
  transition: color var(--transition), text-decoration-color var(--transition);
}

.post-body a:hover {
  color: var(--color-accent);
  text-decoration-color: currentColor;
}

.post-body strong {
  color: var(--color-ink);
  font-weight: 700;
}

/* base.css strips list markers site-wide for the navigation and card lists.
   Editorial content needs them back. */
/* No margin reset here: that would outrank the rhythm rule above and collapse
   the gap between a list and the paragraph before it. */
.post-body ul,
.post-body ol {
  padding-left: var(--space-5);
}

.post-body ul {
  list-style: disc;
}

.post-body ol {
  list-style: decimal;
}

.post-body li {
  margin-bottom: var(--space-2);
  padding-left: var(--space-1);
}

.post-body li::marker {
  color: var(--color-accent);
}

.post-body li > ul,
.post-body li > ol {
  margin-top: var(--space-2);
  margin-bottom: 0;
}

.post-body blockquote {
  padding: var(--space-4) var(--space-5);
  border-left: 3px solid var(--color-accent);
  background: var(--color-surface-alt);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--fs-lg);
  line-height: 1.55;
  color: var(--color-ink);
}

.post-body blockquote p:last-child {
  margin-bottom: 0;
}

.post-body blockquote cite {
  display: block;
  margin-top: var(--space-3);
  font-size: var(--fs-sm);
  font-style: normal;
  color: var(--color-ink-faint);
}

.post-body figure {
  margin-inline: 0;
}

.post-body img {
  height: auto;
  border-radius: var(--radius-md);
}

.post-body figcaption {
  margin-top: var(--space-3);
  font-size: var(--fs-sm);
  color: var(--color-ink-faint);
  text-align: center;
}

/* Tables scroll rather than forcing the whole page sideways on a phone. */
.post-body .wp-block-table,
.post-body figure.wp-block-table {
  overflow-x: auto;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.post-body th,
.post-body td {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.post-body thead th {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 700;
}

.post-body tbody tr:nth-child(even) {
  background: var(--color-surface-alt);
}

.post-body code {
  padding: 0.15em 0.4em;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

.post-body pre {
  overflow-x: auto;
  padding: var(--space-4);
  background: var(--color-surface-dark);
  color: #e2e8f0;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  line-height: 1.6;
}

.post-body pre code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
}

.post-body hr {
  margin-block: var(--space-8);
  border: 0;
  border-top: 1px solid var(--color-border);
}

.post-body iframe,
.post-body video {
  max-width: 100%;
  border-radius: var(--radius-md);
}

/* --- Table of contents --------------------------------------------------- */

.post-toc {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-alt);
  padding: var(--space-4) var(--space-5);
}

.post-toc__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  /* The label is only ~16px tall; on mobile this is the control that opens the
     whole list, so it needs a finger-sized target. */
  min-height: 44px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  color: var(--color-primary);
}

.post-toc__heading {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink-faint);
}

/* The chevron is only meaningful once JS has made the panel collapsible. */
.post-toc__chevron {
  display: none;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--color-ink-faint);
  border-bottom: 2px solid var(--color-ink-faint);
  transform: rotate(45deg);
  transition: transform var(--transition);
  flex: none;
}

.post-toc.is-enhanced .post-toc__chevron {
  display: block;
}

.post-toc.is-enhanced[data-open="true"] .post-toc__chevron {
  transform: rotate(-135deg);
}

.post-toc__list {
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
  max-height: min(60vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Without JavaScript the list simply stays open. */
.post-toc.is-enhanced .post-toc__list {
  display: none;
}

.post-toc.is-enhanced[data-open="true"] .post-toc__list {
  display: block;
}

.post-toc__item a {
  display: block;
  padding: var(--space-2) 0 var(--space-2) var(--space-3);
  border-left: 2px solid var(--color-border);
  font-size: var(--fs-sm);
  line-height: 1.4;
  color: var(--color-ink-soft);
  transition: color var(--transition), border-color var(--transition);
}

.post-toc__item--h3 a {
  padding-left: var(--space-5);
  font-size: var(--fs-xs);
  color: var(--color-ink-faint);
}

.post-toc__item a:hover {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
}

.post-toc__item.is-current a {
  color: var(--color-primary);
  border-left-color: var(--color-accent);
  font-weight: 700;
}

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

.post-tags {
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}

.post-tags__label,
.post-share__label {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink-faint);
}

.post-tags ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-tags a {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: var(--fs-sm);
  color: var(--color-ink-soft);
  background: var(--color-surface);
  transition: background var(--transition), color var(--transition),
    border-color var(--transition);
}

.post-tags a:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary-light);
  color: var(--color-primary);
}

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

.post-share {
  margin-top: var(--space-6);
}

.post-share ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-share__link {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  color: var(--color-ink-soft);
  background: var(--color-surface);
  transition: background var(--transition), color var(--transition),
    border-color var(--transition), transform var(--transition);
}

.post-share__link:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  transform: translateY(-2px);
}

/* --- Author box ---------------------------------------------------------- */

.post-author {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
  margin-top: var(--space-8);
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-alt);
}

.post-author__avatar {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  flex: none;
  display: block;
}

.post-author__body {
  min-width: 0;
}

.post-author__kicker {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink-faint);
}

.post-author__name {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-md);
}

.post-author__name a {
  color: var(--color-primary);
}

.post-author__name a:hover {
  color: var(--color-accent);
}

.post-author__bio {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-sm);
  line-height: 1.65;
  color: var(--color-ink-soft);
}

.post-author__more {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-accent);
}

.post-author__more:hover {
  text-decoration: underline;
}

.post-author__count {
  color: var(--color-ink-faint);
  font-weight: 400;
}

/* --- Article CTA --------------------------------------------------------- */

.post-cta {
  margin-top: var(--space-8);
  padding: var(--space-8) var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--color-primary);
  text-align: center;
}

.post-cta__eyebrow {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.post-cta__title {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-xl);
  color: #fff;
}

.post-cta__text {
  margin: 0 auto var(--space-5);
  max-width: 46ch;
  color: #cbd5e1;
}

.post-cta__btn {
  display: inline-block;
  padding: var(--space-3) var(--space-6);
  border-radius: 999px;
  background: var(--color-accent);
  color: #fff;
  font-weight: 700;
  transition: transform var(--transition), background var(--transition);
}

.post-cta__btn:hover {
  transform: translateY(-2px);
  background: #ff7d1f;
  color: #fff;
}

/* --- Previous / next ----------------------------------------------------- */

.post-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-8);
}

.post-nav__link {
  display: block;
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  transition: border-color var(--transition), background var(--transition);
}

.post-nav__link:hover {
  border-color: var(--color-primary-light);
  background: var(--color-surface-alt);
}

.post-nav__link--next {
  text-align: right;
}

/* The block prints "Previous article" / "Next article" as a bare label node
   before the linked title. */
.post-nav__link .post-navigation-link__label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-ink-faint);
}

.post-nav__link a {
  color: var(--color-primary);
  font-weight: 600;
  line-height: 1.4;
}

.post-nav__link a:hover {
  color: var(--color-accent);
}

/* --- Related posts ------------------------------------------------------- */

.post-related {
  margin-block: var(--space-12) var(--space-10);
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-border);
}

.post-related__title {
  margin: 0 0 var(--space-6);
  font-size: var(--fs-xl);
  color: var(--color-primary);
}

.post-related__grid {
  gap: var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-related__grid > li {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition),
    border-color var(--transition);
}

.post-related__grid > li:hover,
.post-related__grid > li:focus-within {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: transparent;
}

.related-card__media {
  background: var(--color-surface-alt);
}

.related-card__media img {
  width: 100%;
  display: block;
  object-fit: cover;
}

.related-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  flex: 1;
}

.related-card__terms {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.3;
}

.related-card__terms a {
  color: var(--color-accent);
}

.related-card__terms a:hover {
  text-decoration: underline;
}

.related-card__title {
  margin: 0;
  font-size: var(--fs-md);
  line-height: 1.35;
}

.related-card__title a {
  color: var(--color-primary);
}

.related-card__title a:hover {
  color: var(--color-accent);
}

.related-card__date {
  margin: auto 0 0;
  padding-top: var(--space-3);
  font-size: var(--fs-xs);
  color: var(--color-ink-faint);
}

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

.post-layout__main .wp-block-comments {
  margin-top: var(--space-10);
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-border);
}

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

/* A 300px sidebar plus the gutter costs ~364px, so below this width the
   reading column would drop under its 760px minimum. The contents list moves
   above the article and becomes a collapsible panel instead. */
@media (max-width: 1179px) {
  /* Still capped: a single column left free to fill a 1100px viewport would run
     well over 100 characters a line. */
  .post-layout {
    grid-template-columns: minmax(0, 820px);
  }

  .post-layout__aside {
    position: static;
    order: -1;
    margin-bottom: var(--space-6);
  }

  .post-toc__list {
    max-height: 45vh;
  }
}

@media (max-width: 782px) {
  .post-hero {
    margin-block: var(--space-5) var(--space-6);
  }

  .post-body {
    font-size: var(--fs-base);
    line-height: 1.7;
  }

  .post-nav {
    grid-template-columns: minmax(0, 1fr);
  }

  .post-nav__link--next {
    text-align: left;
  }

  .post-related {
    margin-block: var(--space-8);
  }

  /* The block's own grid style is a single class, so match it and win on order. */
  .post-related .post-related__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .post-related .post-related__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .post-hero__media img {
    border-radius: var(--radius-md);
  }

  .post-meta {
    gap: var(--space-3);
  }

  /* The facts wrap onto two lines at this width, which strands a separator dot
     at the start of a line. The gap alone reads clearly enough. */
  .post-meta__facts li + li::before {
    display: none;
  }

  .post-author {
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-5);
  }

  .post-cta {
    padding: var(--space-6) var(--space-5);
  }

  .post-body ul,
  .post-body ol {
    padding-left: var(--space-4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .post-progress__bar,
  .post-share__link,
  .post-cta__btn,
  .post-related__grid > li {
    transition: none;
  }
}
