/* =============================================================================
   SINGLE — single post/recipe/guide component styles
   Conditionally loaded on is_singular() via inc/setup.php
   All values reference tokens from style.css :root
   ============================================================================= */


/* =============================================================================
   READING PROGRESS BAR
   ============================================================================= */

.mfc-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--mfc-electric);
  z-index: 200;
  transition: width 0.1s linear;
  pointer-events: none;
}


/* =============================================================================
   SINGLE HERO — split layout: image left, text right
   ============================================================================= */

.single-hero {
  background: var(--mfc-bg-secondary);
  border-bottom: 1px solid var(--mfc-border);
}

/* Image left (order 1), text right (order 2) on desktop */
.single-hero__inner {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--mfc-space-10);
  align-items: center;
  padding-top: var(--mfc-space-8);
  padding-bottom: var(--mfc-space-8);
}

.single-hero__text {
  min-width: 0;
  order: 2;
}

.single-hero__thumb {
  order: 1;
}

.single-hero--no-image .single-hero__inner {
  grid-template-columns: 1fr;
}

/* Category pill badge */
.single-hero__cat-pill {
  display: inline-flex;
  align-items: center;
  font-size: var(--mfc-text-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--mfc-forest);
  background: var(--mfc-electric-surface, rgba(107,158,120,0.12));
  border: 1px solid var(--mfc-border);
  border-radius: var(--mfc-radius-full);
  padding: 4px 12px;
  text-decoration: none;
  margin-bottom: var(--mfc-space-3);
  transition: background var(--mfc-transition);
}

.single-hero__cat-pill:hover {
  background: var(--mfc-border);
}

/* H1 */
.single-hero__title {
  font-size: clamp(1.75rem, 3.5vw, 2.6rem);
  font-weight: 800;
  color: var(--mfc-text);
  line-height: 1.25;
  letter-spacing: -0.03em;
  margin: 0 0 var(--mfc-space-4);
}

.hero-mark {
  background: var(--mfc-electric);
  color: var(--mfc-deep);
  padding: 0.01em 0.14em;
  border-radius: 4px;
}

/* Meta row: author · date · time · rating */
.single-hero__meta {
  display: flex;
  align-items: center;
  gap: var(--mfc-space-3);
  font-size: var(--mfc-text-sm);
  color: var(--mfc-text-muted);
  flex-wrap: wrap;
}

.single-hero__meta b {
  color: var(--mfc-text-secondary);
  font-weight: 600;
}

.single-hero__meta-dot {
  opacity: 0.4;
}

.single-hero__rating {
  font-weight: 700;
  color: var(--mfc-electric-dark);
}

.single-hero__rating em {
  font-style: normal;
  font-weight: 400;
  color: var(--mfc-text-muted);
}

/* Image: rounded app-card, fills its grid column */
.single-hero__thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  border-radius: var(--mfc-radius-xl);
  overflow: hidden;
  border: 1px solid var(--mfc-border);
  box-shadow: 0 12px 32px rgba(28, 43, 30, 0.14);
}

/* Real <img> replaces the former CSS background — cover-crop to the box */
.single-hero__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Hero actions: Jump CTA under the dashboard */
.hero-actions {
  display: flex;
  align-items: center;
  gap: var(--mfc-space-3);
  margin-top: var(--mfc-space-5);
}


/* =============================================================================
   MACRO VIZ — calorie ring + macro bars
   Rendered by mfc_macro_viz() in inc/recipe-meta.php.
   Used in the single hero dashboard and the recipe card Nutrition tab.
   JS (main.js) adds .will-animate on init and .is-inview on scroll; the
   .is-inview rules are ordered after .will-animate so they win when both
   classes are present. Without JS the base state shows the finished viz.
   ============================================================================= */

.mfc-macro-viz {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--mfc-space-4) var(--mfc-space-6);
  margin-top: var(--mfc-space-5);
}

/* Card treatment (hero dashboard) — elevated widget on the tinted hero bg */
.mfc-macro-viz--card {
  background: var(--mfc-bg);
  border: 1px solid var(--mfc-border);
  border-radius: var(--mfc-radius-lg);
  padding: var(--mfc-space-5);
  box-shadow: 0 2px 12px rgba(28, 43, 30, 0.06);
}

/* ── Calorie ring ── */

.mfc-macro-viz__ring {
  position: relative;
  width: 128px;
  height: 128px;
  flex-shrink: 0;
}

.mfc-macro-ring {
  width: 100%;
  height: 100%;
}

.mfc-macro-ring__track {
  fill: none;
  stroke: var(--mfc-macro-track);
  stroke-width: 13;
}

/* Segment geometry comes from inline --mfc-len/--mfc-start set in PHP;
   326.73 = circumference of the r=52 circle in the 120 viewBox */
.mfc-macro-ring__seg {
  fill: none;
  stroke-width: 13;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
  stroke-dasharray: var(--mfc-len) calc(326.73 - var(--mfc-len));
  stroke-dashoffset: calc(-1 * var(--mfc-start));
}

.mfc-macro-ring__seg--protein { stroke: var(--mfc-macro-protein); }
.mfc-macro-ring__seg--carbs   { stroke: var(--mfc-macro-carbs); }
.mfc-macro-ring__seg--fat     { stroke: var(--mfc-macro-fat); }

.mfc-macro-viz__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Ring-less fallback (partial nutrition data): kcal flows inline */
.mfc-macro-viz__center--plain {
  position: static;
  flex-direction: row;
  align-items: baseline;
  gap: var(--mfc-space-1);
}

.mfc-macro-viz__kcal {
  font-size: var(--mfc-text-3xl);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--mfc-text);
  font-variant-numeric: tabular-nums;
}

.mfc-macro-viz__kcal-label {
  font-size: var(--mfc-text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mfc-text-tertiary);
  margin-top: 2px;
}

/* Composition-first center: the label ("Balanced" / "Protein-forward") is the
   primary read; kcal drops to a small secondary line beneath it. Used
   wherever the viz is ambient (hero summary, compact card) — see 'emphasis'
   arg on mfc_macro_viz(). The Nutrition-tab panel keeps kcal primary instead
   and never renders this element. */
.mfc-macro-viz__label {
  max-width: 90px;
  font-size: var(--mfc-text-lg);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--mfc-text);
  text-align: center;
  overflow-wrap: break-word;
}

.mfc-macro-viz__kcal--secondary {
  font-size: var(--mfc-text-xs);
  font-weight: 700;
  letter-spacing: normal;
  color: var(--mfc-text-muted);
  margin-top: var(--mfc-space-1);
}

/* ── Macro bars ── */

.mfc-macro-viz__bars {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: var(--mfc-space-3);
}

.mfc-macro-row {
  display: grid;
  grid-template-columns: 100px 1fr 44px;
  align-items: center;
  gap: var(--mfc-space-3);
}

.mfc-macro-row__label {
  font-size: var(--mfc-text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mfc-text-secondary);
  white-space: nowrap;
}

.mfc-macro-row__pct {
  font-style: normal;
  font-weight: 500;
  color: var(--mfc-text-muted);
  margin-left: 2px;
}

.mfc-macro-row__track {
  display: block;
  height: 8px;
  border-radius: var(--mfc-radius-full);
  background: var(--mfc-macro-track);
  overflow: hidden;
}

.mfc-macro-row__fill {
  display: block;
  height: 100%;
  width: var(--mfc-pct);
  border-radius: var(--mfc-radius-full);
}

.mfc-macro-row--protein .mfc-macro-row__fill { background: var(--mfc-macro-protein); }
.mfc-macro-row--carbs   .mfc-macro-row__fill { background: var(--mfc-macro-carbs); }
.mfc-macro-row--fat     .mfc-macro-row__fill { background: var(--mfc-macro-fat); }

.mfc-macro-row__val {
  font-size: var(--mfc-text-sm);
  font-weight: 800;
  color: var(--mfc-text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mfc-macro-viz__note {
  width: 100%;
  margin: 0;
  font-size: var(--mfc-text-xs);
  color: var(--mfc-text-muted);
}

/* ── Draw-in animation (classes added by main.js) ── */

.mfc-macro-viz.will-animate .mfc-macro-ring__seg { stroke-dasharray: 0 326.73; }
.mfc-macro-viz.will-animate .mfc-macro-row__fill { width: 0; }

.mfc-macro-viz.is-inview .mfc-macro-ring__seg {
  stroke-dasharray: var(--mfc-len) calc(326.73 - var(--mfc-len));
  transition: stroke-dasharray 900ms cubic-bezier(0.22, 1, 0.36, 1);
}

.mfc-macro-viz.is-inview .mfc-macro-ring__seg--carbs { transition-delay: 120ms; }
.mfc-macro-viz.is-inview .mfc-macro-ring__seg--fat   { transition-delay: 240ms; }

.mfc-macro-viz.is-inview .mfc-macro-row__fill {
  width: var(--mfc-pct);
  transition: width 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.mfc-macro-viz.is-inview .mfc-macro-row--carbs .mfc-macro-row__fill { transition-delay: 100ms; }
.mfc-macro-viz.is-inview .mfc-macro-row--fat   .mfc-macro-row__fill { transition-delay: 200ms; }

@media (prefers-reduced-motion: reduce) {
  .mfc-macro-viz .mfc-macro-ring__seg,
  .mfc-macro-viz .mfc-macro-row__fill {
    transition: none;
  }
}


/* Anchor targets (Jump to Recipe, no-JS tab links) must land below the
   sticky header + fixed jump bar instead of being covered by them.
   .wprm-recipe-container is WPRM's own anchor (id="wprm-recipe-container-{id}")
   that the hero + jump-bar buttons target. */
#recipe-card,
.wprm-recipe-container,
.mfc-tab-panel {
  scroll-margin-top: calc(64px + 56px);
}


/* =============================================================================
   JUMP BAR — sticky "Jump to Recipe" strip (recipe pages only)
   ============================================================================= */

.jump-bar {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  z-index: 99;
  background: var(--mfc-deep);
  border-bottom: 0.5px solid var(--mfc-border-dark);
  padding: var(--mfc-space-3) 0;
  opacity: 0;
  transform: translateY(-100%);
  transition:
    opacity var(--mfc-transition-slow),
    transform var(--mfc-transition-slow);
  pointer-events: none;
}

.jump-bar--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.jump-bar__inner {
  display: flex;
  align-items: center;
  gap: var(--mfc-space-4);
}

.jump-bar__title {
  font-size: var(--mfc-text-sm);
  font-weight: 600;
  color: var(--mfc-text-inverse);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.jump-bar__time {
  font-size: var(--mfc-text-xs);
  font-weight: 700;
  color: rgba(245, 249, 246, 0.55);
  white-space: nowrap;
  flex-shrink: 0;
}


/* =============================================================================
   FTC DISCLOSURE — affiliate note above the recipe story
   (markup: template-parts/single/recipe-content.php)
   ============================================================================= */

.ftc-disclosure {
  background: var(--mfc-bg-tertiary);
  border: 1px solid var(--mfc-border);
  border-radius: var(--mfc-radius-md);
  padding: var(--mfc-space-3) var(--mfc-space-5);
  font-size: var(--mfc-text-sm);
  color: var(--mfc-text-secondary);
  margin-bottom: var(--mfc-space-6);
}

.ftc-disclosure p {
  margin: 0;
}


/* =============================================================================
   GUIDE — callout, macro widget, sources
   ============================================================================= */

.guide-callout {
  background: var(--mfc-electric-surface);
  border-left: 3px solid var(--mfc-electric);
  border-radius: var(--mfc-radius-md);
  padding: var(--mfc-space-5) var(--mfc-space-6);
  margin-bottom: var(--mfc-space-8);
}

.guide-callout__title {
  font-size: var(--mfc-text-xs);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--mfc-forest);
  margin-bottom: var(--mfc-space-3);
}

.guide-callout__list {
  list-style: disc;
  padding-left: var(--mfc-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--mfc-space-2);
  color: var(--mfc-text);
  font-size: var(--mfc-text-base);
}

.macro-widget {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--mfc-border);
  border: 1px solid var(--mfc-border);
  border-radius: var(--mfc-radius-lg);
  overflow: hidden;
  margin-bottom: var(--mfc-space-8);
}

.macro-widget__stat {
  background: var(--mfc-bg-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--mfc-space-1);
  padding: var(--mfc-space-5) var(--mfc-space-4);
  text-align: center;
}

.macro-widget__value {
  font-size: var(--mfc-text-2xl);
  font-weight: 800;
  color: var(--mfc-deep);
  letter-spacing: -0.02em;
  line-height: 1;
}

.macro-widget__label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--mfc-text-tertiary);
}

.sources-list {
  margin-top: var(--mfc-space-10);
  padding-top: var(--mfc-space-6);
  border-top: 0.5px solid var(--mfc-border);
}

.sources-list__title {
  font-size: var(--mfc-text-xs);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--mfc-text-tertiary);
  margin-bottom: var(--mfc-space-4);
}

.sources-list__list {
  list-style: decimal;
  padding-left: var(--mfc-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--mfc-space-2);
  font-size: var(--mfc-text-sm);
  color: var(--mfc-text-tertiary);
}

.sources-list__list a {
  color: var(--mfc-forest);
  word-break: break-all;
}


/* =============================================================================
   NEWSLETTER STRIP — compact dark CTA on single pages
   (Author bio styles live further down — single source, matches
   template-parts/single/author-bio.php markup.)
   ============================================================================= */

.newsletter-strip .newsletter-strip__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--mfc-space-8);
  flex-wrap: wrap;
}

.newsletter-strip__text {
  display: flex;
  flex-direction: column;
  gap: var(--mfc-space-1);
}

.newsletter-strip__headline {
  font-size: var(--mfc-text-2xl);
  font-weight: 800;
  color: var(--mfc-text-inverse);
  letter-spacing: -0.02em;
  display: block;
}

.newsletter-strip__subtitle {
  color: rgba(245, 249, 246, 0.65);
  font-size: var(--mfc-text-base);
  margin: 0;
}

.newsletter-strip__form {
  flex-shrink: 0;
  max-width: 380px;
  width: 100%;
}

.newsletter-strip__form .form-inline {
  flex-wrap: nowrap;
}


/* =============================================================================
   COMMENTS — all comment styles live in assets/css/comments.css (enqueued
   under the same condition comments_template() renders). comments.php emits
   .mfc-* markup; the legacy .comments-area/.comment-form overrides that used
   to live here matched nothing and fought comments.css on shared classes.
   ============================================================================= */


/* =============================================================================
   POST CONTENT — wider reading column, no sidebar
   ============================================================================= */

.post-body {
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--mfc-padding-x);
  padding-right: var(--mfc-padding-x);
}

/* Prose defaults */
.prose {
  font-size: var(--mfc-text-base);
  line-height: 1.75;
  color: var(--mfc-text);
}

.prose h2 {
  font-size: clamp(1.25rem, 2.5vw, 1.6rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--mfc-text);
  margin-top: var(--mfc-space-10);
  margin-bottom: var(--mfc-space-4);
  padding-bottom: var(--mfc-space-3);
  border-bottom: 2px solid var(--mfc-border);
}

.prose h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--mfc-text);
  margin-top: var(--mfc-space-8);
  margin-bottom: var(--mfc-space-3);
}

.prose p {
  margin-bottom: var(--mfc-space-5);
}

.prose ul,
.prose ol {
  padding-left: var(--mfc-space-6);
  margin-bottom: var(--mfc-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--mfc-space-2);
}

.prose a {
  color: var(--mfc-forest);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose a:hover {
  color: var(--mfc-text);
}

/* Callout / tip block */
.prose blockquote,
.prose .wp-block-pullquote blockquote,
.callout {
  background: var(--mfc-bg-secondary);
  border-left: 3px solid var(--mfc-electric);
  border-radius: 0 var(--mfc-radius-md) var(--mfc-radius-md) 0;
  padding: var(--mfc-space-4) var(--mfc-space-5);
  margin: var(--mfc-space-6) 0;
  font-style: normal;
}

.prose blockquote p,
.prose .wp-block-pullquote p,
.callout p {
  font-size: var(--mfc-text-base);
  font-weight: 500;
  color: var(--mfc-text);
  margin: 0;
}

.prose .wp-block-pullquote {
  border: none;
  padding: 0;
  margin: 0;
}


/* =============================================================================
   AUTHOR BIO — athlete profile card
   ============================================================================= */

.author-bio {
  display: flex;
  align-items: center;
  gap: var(--mfc-space-5);
  padding: var(--mfc-space-6);
  background: var(--mfc-bg-secondary);
  border-radius: var(--mfc-radius-lg);
  border: 1px solid var(--mfc-border);
}

.author-bio__avatar {
  width: 72px;
  height: 72px;
  border-radius: var(--mfc-radius-full);
  border: 2.5px solid var(--mfc-electric);
  flex-shrink: 0;
  object-fit: cover;
}

.author-bio__body {
  display: flex;
  flex-direction: column;
  gap: var(--mfc-space-1);
}

.author-bio__label {
  font-size: var(--mfc-text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mfc-forest);
}

.author-bio__name {
  font-size: var(--mfc-text-lg);
  font-weight: 800;
  color: var(--mfc-text);
  letter-spacing: -0.015em;
  display: block;
}

.author-bio__desc {
  font-size: var(--mfc-text-sm);
  color: var(--mfc-text-secondary);
  line-height: 1.6;
  margin: var(--mfc-space-1) 0 0;
}


/* =============================================================================
   RELATED POSTS — 2-column grid
   ============================================================================= */

.related-posts__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--mfc-space-5);
}


/* =============================================================================
   RESPONSIVE
   ============================================================================= */

/* Admin bar offset — WP bar is 32px (>782px) / 46px (≤782px);
   theme header is 64px (>768px) / 56px (≤768px) */
body.admin-bar .jump-bar {
  top: calc(64px + 32px);
}

@media screen and (max-width: 782px) {
  body.admin-bar .jump-bar {
    top: calc(64px + 46px);
  }
}

@media screen and (max-width: 768px) {
  body.admin-bar .jump-bar {
    top: calc(56px + 46px);
  }
}

@media (max-width: 768px) {
  /* Header is 56px on mobile (64px desktop) — keep the bar flush against it */
  .jump-bar {
    top: 56px;
  }

  /* Hero: image on top, text below */
  .single-hero__inner {
    grid-template-columns: 1fr;
    padding-top: 0;
    padding-bottom: var(--mfc-space-6);
  }

  .single-hero__thumb {
    order: -1; /* image before text in the DOM visual order */
    /* Square corners only work edge-to-edge: bleed through the container's
       horizontal padding instead of showing a squared box inside it */
    width: calc(100% + var(--mfc-padding-x) * 2);
    margin-left: calc(-1 * var(--mfc-padding-x));
    margin-right: calc(-1 * var(--mfc-padding-x));
    height: 220px;
    aspect-ratio: auto;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  .single-hero__text {
    order: 2;
  }

  /* Dashboard: ring above bars, centred */
  .mfc-macro-viz--card {
    justify-content: center;
    padding: var(--mfc-space-4);
  }

  .jump-bar__title {
    display: none;
  }

  .macro-widget {
    grid-template-columns: repeat(2, 1fr);
  }

  .author-bio {
    flex-direction: column;
    text-align: center;
  }

  .author-bio__label,
  .author-bio__name,
  .author-bio__desc {
    text-align: center;
  }

  .related-posts__grid {
    grid-template-columns: 1fr;
  }

  .newsletter-strip .newsletter-strip__inner {
    flex-direction: column;
    text-align: center;
  }

  .newsletter-strip__form {
    max-width: 100%;
  }

  .newsletter-strip__form .form-inline {
    flex-direction: column;
  }
}

@media (max-width: 540px) {
  .single-hero__thumb {
    height: 200px;
  }
}
