/*
 * Body Journey — Pillar Page ("The Index" editorial long-read)
 * Loaded only on pillar pages (see bodyjourney_enqueue_assets()).
 *
 * Design rules:
 *  - Rationed ink: headings stay white; orange appears ONLY as the eyebrow
 *    rule, one gradient-clipped H1 keyword, Part eyebrows, drop-cap,
 *    pull-quote bar, active TOC tick, progress gauge, and cluster accents.
 *  - Motion animates transform/opacity only (CLS-safe, composited).
 *  - Content is visible by default; the start-hidden reveal state only
 *    applies when JS is on (html.bj-pillar-js) AND motion is allowed.
 */

/* ------------------------------------------------------------------ *
 * Layout shell
 * ------------------------------------------------------------------ */
.bj-pillar {
  position: relative;
}

.bj-pillar-layout {
  display: grid;
  /* Size columns to the reading measure + TOC and center the pair, so the TOC
     sits next to the prose instead of being pushed to the far right. */
  grid-template-columns: minmax(0, 720px) minmax(0, 280px);
  gap: 56px;
  justify-content: center;
  align-items: start;
  padding: 8px 0 24px;
}

.bj-pillar-main {
  min-width: 0;
}

.bj-pillar-article {
  max-width: 720px;
}

/* ------------------------------------------------------------------ *
 * Hero — asymmetric editorial split with a static warm wash
 * ------------------------------------------------------------------ */
.bj-pillar-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 48px;
  align-items: center;
  padding: 36px 0 44px;
  background: radial-gradient(115% 90% at 92% -10%, rgba(255, 138, 0, 0.13), transparent 55%);
}

.bj-pillar--no-cover .bj-pillar-hero {
  grid-template-columns: 1fr;
  max-width: 840px;
}

.bj-pillar-hero__text {
  min-width: 0;
}

.bj-pillar-hero__eyebrow {
  display: inline-block;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--bj-border);
  font-family: Rubik, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--bj-primary);
}

.bj-pillar-hero__title {
  margin: 0;
  font-family: Rubik, system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1.0;
  letter-spacing: -0.02em;
  color: var(--bj-text);
}

/* One gradient-clipped keyword, with a solid fallback for old engines. */
.bj-pillar-hero__hl {
  color: var(--bj-primary);
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .bj-pillar-hero__hl {
    background: linear-gradient(90deg, var(--bj-primary), var(--bj-primary-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }
}

.bj-pillar-hero__deck {
  margin: 18px 0 0;
  max-width: 60ch;
  font-family: Nunito, system-ui, sans-serif;
  font-size: clamp(18px, 2.2vw, 21px);
  line-height: 1.5;
  color: var(--bj-muted);
}

.bj-pillar-hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 22px 0 0;
  font-size: 14px;
  color: var(--bj-muted);
}

.bj-pillar-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.bj-pillar-stat__num {
  display: inline-block;
  min-width: 2ch;
  font-weight: 700;
  color: var(--bj-text);
  font-variant-numeric: tabular-nums;
}

.bj-pillar-meta-sep {
  color: var(--bj-border);
}

.bj-pillar-hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 26px;
}

/* Cover panel (the LCP element lives inside, space reserved via aspect-ratio) */
.bj-pillar-hero__cover {
  position: relative;
  margin: 0;
  aspect-ratio: 4 / 5;
  border: 1px solid var(--bj-border);
  border-radius: var(--bj-radius-lg);
  overflow: hidden;
  line-height: 0;
}

.bj-pillar-hero__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bj-pillar-hero__cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 42%, rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.bj-pillar-hero__cover-chip {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 1;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.42);
  font-family: Rubik, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1;
}

/* ------------------------------------------------------------------ *
 * TL;DR / Key takeaways (answer-first AEO block)
 * ------------------------------------------------------------------ */
.bj-pillar-tldr {
  max-width: 720px;
  margin: 0 0 40px;
  padding: 22px 26px;
  background: var(--bj-surface);
  border: 1px solid var(--bj-border);
  border-radius: var(--bj-radius-lg);
}

.bj-pillar-tldr__heading {
  margin: 0 0 14px;
  font-family: Rubik, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bj-primary);
}

.bj-pillar-tldr__list {
  margin: 0;
  padding-left: 20px;
}

.bj-pillar-tldr__list li {
  margin-bottom: 8px;
  color: var(--bj-text);
  line-height: 1.55;
}

.bj-pillar-tldr__list li:last-child {
  margin-bottom: 0;
}

/* ------------------------------------------------------------------ *
 * Prose — numbered "Parts", drop-cap, pull quotes (scoped to the hub)
 * ------------------------------------------------------------------ */
.bj-pillar-prose {
  counter-reset: bj-part;
}

.bj-pillar-prose h2 {
  counter-increment: bj-part;
  position: relative;
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--bj-border);
}

.bj-pillar-prose h2::before {
  content: "Part " counter(bj-part, decimal-leading-zero);
  display: block;
  margin-bottom: 10px;
  font-family: Rubik, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bj-primary);
  font-variant-numeric: tabular-nums;
}

.bj-pillar-prose > p:first-of-type::first-letter {
  float: left;
  margin: 8px 12px 0 0;
  font-family: Rubik, system-ui, sans-serif;
  font-weight: 800;
  font-size: 3.4em;
  line-height: 0.78;
  color: var(--bj-primary);
}

.bj-pillar-prose blockquote {
  margin: 32px 0;
  padding: 4px 0 4px 24px;
  border-left: 3px solid var(--bj-primary);
  font-family: Rubik, system-ui, sans-serif;
  font-size: clamp(20px, 2.4vw, 24px);
  font-weight: 500;
  line-height: 1.4;
  color: var(--bj-text);
}

.bj-pillar-prose blockquote p:last-child {
  margin-bottom: 0;
}

/* ------------------------------------------------------------------ *
 * Sticky TOC + reading-progress gauge + active tick
 * ------------------------------------------------------------------ */
.bj-pillar-progress {
  position: relative;
  height: 3px;
  margin-bottom: 16px;
  border-radius: 2px;
  background: var(--bj-border);
  overflow: hidden;
}

.bj-pillar-progress__fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(var(--bj-progress, 0));
  background: linear-gradient(90deg, var(--bj-primary), var(--bj-primary-2));
}

.bj-pillar-toc .toc-link {
  position: relative;
  padding-left: 16px;
}

.bj-pillar-toc .toc-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 2px;
  height: 14px;
  border-radius: 2px;
  background: var(--bj-primary);
  transform: translateY(-50%) scaleY(0);
  transform-origin: center;
  transition: transform 0.2s ease;
}

.bj-pillar-toc .toc-link.active {
  color: var(--bj-text);
  font-weight: 600;
}

.bj-pillar-toc .toc-link.active::before {
  transform: translateY(-50%) scaleY(1);
}

/* ------------------------------------------------------------------ *
 * Cluster grid — lead story + numbered index
 * ------------------------------------------------------------------ */
.bj-pillar-cluster {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--bj-border);
  content-visibility: auto;
  contain-intrinsic-size: auto 600px;
}

.bj-pillar-cluster__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.bj-pillar-cluster__heading {
  margin: 0;
  font-family: Rubik, system-ui, sans-serif;
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 700;
  color: var(--bj-text);
}

.bj-pillar-cluster__count {
  margin: 0;
  flex: none;
  font-size: 14px;
  color: var(--bj-muted);
  font-variant-numeric: tabular-nums;
}

.bj-pillar-cluster__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.bj-pillar-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 0;
  transition: transform 0.2s ease;
}

.bj-pillar-card::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--bj-primary), var(--bj-primary-2));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.25s ease;
}

.bj-pillar-card:hover {
  transform: translateY(-2px);
}

.bj-pillar-card:hover::after,
.bj-pillar-card:focus-within::after {
  transform: scaleX(1);
}

.bj-pillar-card__index {
  display: block;
  margin-bottom: 8px;
  font-family: Rubik, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--bj-muted);
  font-variant-numeric: tabular-nums;
}

.bj-pillar-card__more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  font-family: Rubik, system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--bj-primary);
}

.bj-pillar-card__arrow {
  transition: transform 0.2s ease;
}

.bj-pillar-card:hover .bj-pillar-card__arrow {
  transform: translateX(4px);
}

/* Lead story spans the row and goes image-left on wider viewports. */
.bj-pillar-card--lead {
  grid-column: 1 / -1;
}

@media (min-width: 760px) {
  .bj-pillar-card--lead {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    align-items: stretch;
  }

  .bj-pillar-card--lead .bj-pillar-card__thumb {
    height: 100%;
  }

  .bj-pillar-card--lead .bj-pillar-card__thumb img {
    height: 100%;
    object-fit: cover;
  }

  .bj-pillar-card--lead .bj-pillar-card__body {
    align-self: center;
  }

  .bj-pillar-card--lead .bj-pillar-card__title {
    font-size: clamp(22px, 2.4vw, 28px);
  }
}

/* ------------------------------------------------------------------ *
 * Reveal animations — visible by default; hidden start only with JS+motion
 * ------------------------------------------------------------------ */
.bj-reveal {
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  html.bj-pillar-js .bj-reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.55s ease, transform 0.55s ease;
  }

  html.bj-pillar-js .bj-reveal.is-in {
    opacity: 1;
    transform: none;
  }

  /* Hero entrance stagger */
  html.bj-pillar-js .bj-pillar-hero .bj-reveal[data-reveal="0"] { transition-delay: 0ms; }
  html.bj-pillar-js .bj-pillar-hero .bj-reveal[data-reveal="1"] { transition-delay: 70ms; }
  html.bj-pillar-js .bj-pillar-hero .bj-reveal[data-reveal="2"] { transition-delay: 140ms; }
  html.bj-pillar-js .bj-pillar-hero .bj-reveal[data-reveal="3"] { transition-delay: 210ms; }
  html.bj-pillar-js .bj-pillar-hero .bj-reveal[data-reveal="4"] { transition-delay: 280ms; }

  /* Cover panel scales in rather than translating */
  html.bj-pillar-js .bj-pillar-hero__cover.bj-reveal {
    transform: scale(1.03);
    transition: opacity 0.7s ease, transform 0.7s ease;
  }

  html.bj-pillar-js .bj-pillar-hero__cover.bj-reveal.is-in {
    transform: none;
  }

  /* Cluster card stagger (small, capped) */
  html.bj-pillar-js .bj-pillar-card:nth-child(1) { transition-delay: 0ms; }
  html.bj-pillar-js .bj-pillar-card:nth-child(2) { transition-delay: 60ms; }
  html.bj-pillar-js .bj-pillar-card:nth-child(3) { transition-delay: 120ms; }
  html.bj-pillar-js .bj-pillar-card:nth-child(4) { transition-delay: 180ms; }
  html.bj-pillar-js .bj-pillar-card:nth-child(5) { transition-delay: 240ms; }
  html.bj-pillar-js .bj-pillar-card:nth-child(n+6) { transition-delay: 300ms; }
}

@media (prefers-reduced-motion: reduce) {
  .bj-pillar-card,
  .bj-pillar-card::after,
  .bj-pillar-card__arrow,
  .bj-pillar-toc .toc-link::before {
    transition: none;
  }

  .bj-pillar-card:hover {
    transform: none;
  }
}

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */
@media (max-width: 1100px) {
  .bj-pillar-hero {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: 32px;
  }
}

@media (max-width: 900px) {
  .bj-pillar-layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  /* TOC becomes a static "jump to section" box above the article */
  .bj-pillar-toc {
    order: -1;
    position: static;
    max-height: none;
  }

  .bj-pillar-progress {
    display: none;
  }

  .bj-pillar-hero {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 24px 0 32px;
  }

  /* On mobile the title leads; the cover drops below the copy */
  .bj-pillar-hero__cover {
    order: 2;
    aspect-ratio: 16 / 10;
    max-height: 320px;
  }

  .bj-pillar-article,
  .bj-pillar-tldr {
    max-width: none;
  }
}

@media (max-width: 600px) {
  .bj-pillar-prose h2 {
    margin-top: 44px;
  }

  .bj-pillar-cluster__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .bj-pillar-hero__title {
    font-size: clamp(34px, 9vw, 46px);
  }
}
