/* Single blog post — reading layout transplanted from the helloagain blog
   research, adapted to Sunrise tokens.

   Layout model:
   - Outer article shell = min(1280px, 100% - 48px) (same band as .sun-blog__inner)
   - Header rows (eyebrow, H1, byline) + featured hero sit at the FULL outer width
   - Prose is a centred 65ch column (NN/g 50–75 zone; resolves against the
     16px body font on the wrapper, so every child shares one measure)
   - Image "Breakout" block styles (registered in functions.php) let images
     exceed the prose column toward the outer container edges via
     custom-property-driven negative margins; ≤900px they collapse back
     to the prose column. */

:root {
  --sun-post-outer: 1280px;   /* outer article shell (matches .sun-blog__inner) */
  --sun-post-pad: 48px;       /* 2 × 24px viewport gutter */
  --sun-prose-max: 65ch;      /* text measure — resolves on .sun-post__prose @16px */
}

.sun-post {
  padding: clamp(48px, 6vw, 96px) 0 0;
}

/* Breadcrumbs sit above the eyebrow in the post header. Kill the standalone
   component's padding here — .sun-post (top) and .sun-post__inner (gutters)
   already position it, so the component's own header-clearance + horizontal pad
   would only double-indent it past the title and inflate the row height. */
.sun-post__hero .sun-breadcrumbs { margin: 0 0 20px; padding: 0; }

/* "Aktualisiert am" reads a touch quieter than the publish date. */
.sun-post__updated { color: var(--sun-muted); }

/* ── Reading-progress bar — fixed under the sticky header ──────────── */
.sun-post__progress {
  position: fixed;
  top: 0;                                            /* JS pins it under the header */
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 90;
  pointer-events: none;
}
.sun-post__progress-fill {
  width: 100%;
  height: 100%;
  background: var(--sun-primary);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 60ms linear;
}
@media (prefers-reduced-motion: reduce) {
  .sun-post__progress-fill { transition: none; }     /* jump, no animation */
}

.sun-post__inner {
  box-sizing: border-box;
  width: min(var(--sun-post-outer), 100% - var(--sun-post-pad));
  margin-inline: auto;
}

/* ── Article header — full container width (helloagain pattern) ────── */
.sun-post__eyebrow {
  margin: 0 0 16px;
  font-family: var(--wp--preset--font-family--brand);
  font-weight: 500;
  font-size: var(--wp--preset--font-size--sm);
  line-height: 1.4286;
  color: var(--sun-bluegrey);
}

.sun-post__cat {
  color: var(--sun-primary);                        /* orange lead-in (.sun-blog__cat idiom) */
  font-weight: 500;
  text-decoration: none;
}
.sun-post__cat:hover { text-decoration: underline; }

.sun-post__sep { margin: 0 8px; color: var(--sun-muted); }

.sun-post__title {
  margin: 0 0 16px;
  font-family: var(--wp--preset--font-family--brand);
  font-weight: 500;
  font-size: var(--wp--preset--font-size--display-xl); /* H1 · 56 fluid */
  line-height: 1.15;
  letter-spacing: -0.56px;
  color: var(--sun-secondary);
  max-width: 24ch;                                   /* readable title line-length */
  overflow-wrap: break-word;
  hyphens: auto;
}

.sun-post__byline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-family: var(--wp--preset--font-family--brand);
  font-size: var(--wp--preset--font-size--sm);
  line-height: 1.4286;
  color: var(--sun-bluegrey);
}
.sun-post__byline .sun-post__sep { margin: 0; }
.sun-post__avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
}
.sun-post__author { color: var(--sun-secondary); font-weight: 500; }

/* ── Featured hero — wide, below the header rows ───────────────────── */
.sun-post__hero-image {
  margin: 32px 0 0;
}
.sun-post__hero-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 520px;
  aspect-ratio: 160 / 76;                            /* wide editorial crop */
  object-fit: cover;
  object-position: 50% 35%;
  border-radius: 4px;
}

/* Contain-mode hero — set by the template for small (<900px) or ultra-wide
 * (ar > 2.6) featured images (migrated news logos/banners): no blur-upscale,
 * no crop. Image sits near natural size on a neutral surface band. */
.sun-post__hero-image--contain {
  display: grid;
  place-items: center;
  padding: clamp(24px, 4vw, 48px);
  background: var(--sun-surface);
  border-radius: 4px;
}
.sun-post__hero-image--contain .sun-post__hero-img {
  width: auto;
  max-width: min(480px, 100%);
  height: auto;
  max-height: 280px;
  aspect-ratio: auto;
  object-fit: contain;
  border-radius: 0;
}

/* ── Body / prose — centred 65ch reading column ────────────────────── */
.sun-post__body {
  padding: clamp(32px, 5vw, 64px) 0 0;
}

.sun-post__prose {
  max-width: min(var(--sun-prose-max), 100%);
  margin-inline: auto;
  font-family: var(--wp--preset--font-family--brand);
  font-size: var(--wp--preset--font-size--md);       /* 16px */
  line-height: 1.5;                                  /* 24/16 (textmedia copy) */
  color: var(--sun-bluegrey);
}

/* Vertical rhythm */
.sun-post__prose > * { margin-block: 0; }
.sun-post__prose > * + * { margin-block-start: 20px; }

/* Lead / deck — the first paragraph (imports keep summaries bold there)
 * reads slightly larger, like an editorial standfirst. */
.sun-post__prose > p:first-child {
  font-size: var(--wp--preset--font-size--lg);       /* 18 */
  line-height: 1.5;
}

.sun-post__prose > h2,
.sun-post__prose > h3,
.sun-post__prose > h4,
.sun-post__prose > h5,
.sun-post__prose > h6 {
  margin-block-start: 48px;
  font-family: var(--wp--preset--font-family--brand);
  font-weight: 500;
  color: var(--sun-secondary);
  scroll-margin-top: 112px;                          /* fixed header + progress bar */
}
.sun-post__prose > h2 + *,
.sun-post__prose > h3 + *,
.sun-post__prose > h4 + *,
.sun-post__prose > h5 + *,
.sun-post__prose > h6 + * { margin-block-start: 12px; }

.sun-post__prose > h2 {
  font-size: var(--wp--preset--font-size--display-sm); /* 32 (textmedia heading) */
  line-height: 1.25;                                   /* 40/32 */
  letter-spacing: -0.32px;
}
.sun-post__prose > h3 {
  font-size: var(--wp--preset--font-size--xl);         /* 24 (faq/textmedia item) */
  line-height: 1.3334;                                 /* 32/24 */
}
.sun-post__prose > h4,
.sun-post__prose > h5,
.sun-post__prose > h6 {
  font-size: var(--wp--preset--font-size--lg);         /* 18 */
  line-height: 1.3334;
}

/* Inline links */
.sun-post__prose a {
  color: var(--sun-link);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
  transition: color .15s ease;
}
.sun-post__prose a:hover { color: var(--sun-link-hover); }
.sun-post__prose a:focus-visible {
  outline: 2px solid var(--sun-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Lists */
.sun-post__prose ul,
.sun-post__prose ol { padding-inline-start: 24px; }
.sun-post__prose li { margin-block-start: 8px; }
.sun-post__prose li:first-child { margin-block-start: 0; }
.sun-post__prose ul > li::marker { color: var(--sun-primary); }

/* Quote */
.sun-post__prose blockquote {
  margin-inline: 0;
  padding: 4px 0 4px 20px;
  border-left: 2px solid var(--sun-primary);
  font-size: var(--wp--preset--font-size--lg);
  line-height: 1.5;
  color: var(--sun-secondary);
}
.sun-post__prose blockquote cite {
  display: block;
  margin-top: 8px;
  font-style: normal;
  font-size: var(--wp--preset--font-size--sm);
  color: var(--sun-bluegrey);
}

/* Strong lead paragraphs (import keeps summaries bold) */
.sun-post__prose strong { color: var(--sun-secondary); font-weight: 600; }

/* Images — constrained to the prose column by default */
.sun-post__prose img { max-width: 100%; height: auto; }
.sun-post__prose > .wp-block-image { margin-block: 32px; }
.sun-post__prose > .wp-block-image img {
  display: block;
  width: auto;                /* natural size — never blur-upscale small images */
  max-width: 100%;            /* …but large images fill the prose column */
  height: auto;
  margin-inline: auto;        /* centre narrower-than-column images */
  border-radius: 4px;
}
/* Breakout figures size themselves — their img must fill the figure. */
.sun-post__prose > .wp-block-image[class*="is-style-sun-breakout"] img {
  width: 100%;
}
.sun-post__prose .wp-block-image figcaption {
  margin-top: 8px;
  font-size: var(--wp--preset--font-size--sm);
  color: var(--sun-bluegrey);
  text-align: center;
}

/* Embeds (YouTube etc.) */
.sun-post__prose .wp-block-embed { margin-block: 32px; }
.sun-post__prose .wp-block-embed iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border-radius: 4px;
}

/* ── Breakout image styles (helloagain technique, Sunrise container) ──
 * The prose wrapper is the centred reading column; the outer article
 * shell is min(1280px, 100vw - 48px). The breakout distance is:
 *
 *   --_outer : the outer shell width (viewport-driven, like helloagain's
 *              --ha-bol-site math — converges toward the prose column as
 *              the viewport narrows, so the breakout glides to 0)
 *   --_shift : (outer - prose)/2 — how far each breakout edge reaches;
 *              max(0px, …) guarantees it never inverts.
 *
 * "Breakout"       — exceeds the prose column symmetrically to BOTH outer edges
 * "Breakout left"  — right edge pinned to the prose column, bleeds left
 * "Breakout right" — left edge pinned to the prose column, bleeds right */
.sun-post__prose > .wp-block-image.is-style-sun-breakout,
.sun-post__prose > .wp-block-image.is-style-sun-breakout-left,
.sun-post__prose > .wp-block-image.is-style-sun-breakout-right {
  --_outer: min(var(--sun-post-outer), 100vw - var(--sun-post-pad));
  --_shift: max(0px, calc((var(--_outer) - 100%) / 2));
  max-width: none;
}

.sun-post__prose > .wp-block-image.is-style-sun-breakout {
  margin-inline: calc(-1 * var(--_shift));
}
.sun-post__prose > .wp-block-image.is-style-sun-breakout-left {
  width: calc(100% + var(--_shift));
  margin-left: calc(-1 * var(--_shift));
  margin-right: 0;
}
.sun-post__prose > .wp-block-image.is-style-sun-breakout-right {
  width: calc(100% + var(--_shift));
  margin-left: 0;
  margin-right: calc(-1 * var(--_shift));
}

/* ≤900px: single narrow column — collapse breakouts to the prose column
 * so a wide image can never force horizontal scroll. */
@media (max-width: 900px) {
  .sun-post__prose > .wp-block-image.is-style-sun-breakout,
  .sun-post__prose > .wp-block-image.is-style-sun-breakout-left,
  .sun-post__prose > .wp-block-image.is-style-sun-breakout-right {
    width: auto;
    max-width: 100%;
    margin-inline: 0;
  }
}

/* ── Sidebar: TOC + share (helloagain pattern, Sunrise gutter) ────────
 * ≥1200px the prose is a centred 65ch column inside the 1280 shell —
 * the sidebar sits absolutely in the LEFT gutter, its content sticky.
 * <1200px it flows inline above the prose; the TOC becomes a collapsed
 * "Inhalt" <details> (JS syncs open state to the breakpoint). */
.sun-post__body-wrap { position: relative; }

.sun-post__sidebar {
  box-sizing: border-box;
  max-width: min(var(--sun-prose-max), 100%);
  margin-inline: auto;
  margin-bottom: 32px;
  font-family: var(--wp--preset--font-family--brand);
  font-size: var(--wp--preset--font-size--md);       /* ch parity with the prose */
}

@media (min-width: 1200px) {
  .sun-post__sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: calc((100% - min(var(--sun-prose-max), 100%)) / 2 - 40px);
    max-width: none;
    margin: 0;
    /* Align the rail's top with where the prose text begins: the sidebar
       is absolute at the body-wrap top, but .sun-post__body pushes the prose
       down by its top padding — without this the TOC/share floats above the
       first paragraph (glaring on short, TOC-less posts). */
    padding-top: clamp(32px, 5vw, 64px);
  }
  .sun-post__sidebar-sticky {
    position: sticky;
    top: 112px;                                      /* under header + progress bar */
    max-height: calc(100vh - 128px);
    overflow-y: auto;
    scrollbar-width: thin;
  }
}

/* TOC */
.sun-post__toc {
  margin: 0 0 24px;
  border: 1px solid var(--sun-border);
  border-radius: 4px;
  padding: 16px;
}
.sun-post__toc-title {
  cursor: pointer;
  list-style: none;
  font-size: var(--wp--preset--font-size--sm);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sun-bluegrey);
}
.sun-post__toc-title::-webkit-details-marker { display: none; }
.sun-post__toc-title::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform .15s ease;
}
.sun-post__toc[open] > .sun-post__toc-title::after { transform: rotate(225deg); }

.sun-post__toc-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  border-left: 2px solid var(--sun-border);
}
.sun-post__toc-item { margin: 0; }
.sun-post__toc-item--h3 a { padding-left: 28px; }
.sun-post__toc-list a {
  display: block;
  margin-left: -2px;
  padding: 6px 0 6px 14px;
  border-left: 2px solid transparent;
  font-size: var(--wp--preset--font-size--sm);
  line-height: 1.4286;
  color: var(--sun-bluegrey);
  text-decoration: none;
  transition: color .15s ease, border-color .15s ease;
}
.sun-post__toc-list a:hover { color: var(--sun-secondary); }
.sun-post__toc-list a[aria-current="true"] {
  color: var(--sun-primary);
  font-weight: 500;
  border-left-color: var(--sun-primary);
}
.sun-post__toc-list a:focus-visible {
  outline: 2px solid var(--sun-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (min-width: 1200px) {
  /* Sidebar rail look — drop the boxed mobile chrome, hide the toggle. */
  .sun-post__toc { border: 0; border-radius: 0; padding: 0; }
  .sun-post__toc-title { pointer-events: none; }
  .sun-post__toc-title::after { display: none; }

  /* Divider between TOC and share when both live in the sticky rail.
   * (TOC hidden on heading-light posts → share stands alone, no divider.) */
  .sun-post__toc + .sun-post__share {
    border-top: 1px solid var(--sun-border);
    padding-top: 24px;
  }
}

/* Share */
.sun-post__share-title {
  margin: 0 0 8px;
  font-size: var(--wp--preset--font-size--sm);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sun-bluegrey);
}
.sun-post__share-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sun-post__share-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--sun-surface);
  color: var(--sun-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease;
}
.sun-post__share-btn:hover {
  background: var(--sun-secondary);
  color: var(--sun-base);
}
.sun-post__share-btn:focus-visible {
  outline: 2px solid var(--sun-primary);
  outline-offset: 2px;
}
.sun-post__share-icon { width: 16px; height: 16px; }
.sun-post__share-copy.is-copied {
  background: var(--sun-primary);
  color: var(--sun-base);
}
.sun-post__share-feedback {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--wp--preset--font-size--xs);
  font-weight: 500;
  color: var(--sun-primary);
  white-space: nowrap;
}

@media (max-width: 1199.98px) {
  /* Inline sidebar above the prose: share row sits right under the TOC. */
  .sun-post__share {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .sun-post__share-title { margin: 0; }
}

/* ── TL;DR — "Das Wichtigste in Kürze" takeaways (top of the article) ──
 * Prose-column width so it aligns with the reading measure; brand accent rail
 * marks it as an editorial callout, not body copy. */
.sun-post__tldr {
  box-sizing: border-box;
  max-width: min(var(--sun-prose-max), 100%);
  margin: 0 auto clamp(28px, 4vw, 40px);
  padding: clamp(16px, 3vw, 24px) clamp(20px, 3vw, 28px);
  background: var(--sun-surface);
  border-left: 3px solid var(--sun-primary);
  border-radius: 4px;
  font-family: var(--wp--preset--font-family--brand);
}
.sun-post__tldr-title {
  margin: 0 0 12px;
  font-size: var(--wp--preset--font-size--sm);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sun-bluegrey);
}
.sun-post__tldr-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sun-post__tldr-item {
  position: relative;
  padding-left: 22px;
  font-size: var(--wp--preset--font-size--md);
  line-height: 1.5;
  color: var(--sun-secondary);
}
.sun-post__tldr-item::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sun-primary);
}

/* ── In-article demo CTA (after the prose, before the footer nav) ─────
 * Navy conversion band at the prose width; primary button carries the action. */
.sun-post__cta {
  box-sizing: border-box;
  max-width: min(var(--sun-prose-max), 100%);
  margin: clamp(40px, 5vw, 56px) auto 0;
  padding: clamp(24px, 4vw, 36px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--sun-secondary);
  border-radius: 8px;
  font-family: var(--wp--preset--font-family--brand);
}
.sun-post__cta-body { flex: 1 1 260px; min-width: 0; }
.sun-post__cta-heading {
  margin: 0 0 6px;
  font-size: var(--wp--preset--font-size--lg);
  font-weight: 500;
  line-height: 1.3334;
  color: var(--sun-base);
}
.sun-post__cta-text {
  margin: 0;
  font-size: var(--wp--preset--font-size--sm);
  line-height: 1.4286;
  color: var(--sun-muted);
}
.sun-post__cta-btn { flex: 0 0 auto; gap: 8px; }
.sun-post__cta-btn .sun-post__cta-btn-icon { width: 16px; height: 16px; }

/* ── Post footer — back link + prev/next nav ───────────────────────── */
.sun-post__footer {
  max-width: min(var(--sun-prose-max), 100%);
  margin-inline: auto;
  margin-top: clamp(40px, 5vw, 64px);
  padding-top: 32px;
  border-top: 1px solid var(--sun-border);
  font-family: var(--wp--preset--font-family--brand);
}

/* "Alle Beiträge" — the pager's centred axis (sits BELOW prev/next, not a boxed
   button). A bottom-of-article back-to-index affordance earns its keep most on
   mobile, where the breadcrumb is a long scroll away at the very top. */
.sun-post__back {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  min-height: 44px;                                  /* comfortable tap target */
  margin: 24px auto 0;
  padding: 0 12px;
  font-size: var(--wp--preset--font-size--sm);
  font-weight: 500;
  color: var(--sun-bluegrey);
  text-decoration: none;
  transition: color .18s ease;
}
.sun-post__back:hover { color: var(--sun-primary); }
.sun-post__back:focus-visible {
  outline: 2px solid var(--sun-primary);
  outline-offset: 2px;
  border-radius: 4px;
}
.sun-post__back .sun-post__back-icon {
  width: 16px;
  height: 16px;
  transform: scaleX(-1);                             /* arrow-right-bold → points back */
}

.sun-post__nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;                                         /* footer padding-top handles space above; no margin-top */
}

.sun-post__nav-link {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  border: 1px solid var(--sun-border);
  border-radius: 4px;
  text-decoration: none;
  transition: border-color .18s ease, background-color .18s ease;
}
.sun-post__nav-link--next { text-align: right; align-items: flex-end; grid-column: 2; }
.sun-post__nav-link:hover {
  border-color: var(--sun-muted);
  background: var(--sun-base);
}
.sun-post__nav-link:focus-visible {
  outline: 2px solid var(--sun-primary);
  outline-offset: 2px;
}

.sun-post__nav-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--wp--preset--font-size--xs);
  font-weight: 500;
  color: var(--sun-bluegrey);
}
.sun-post__nav-icon { width: 14px; height: 14px; color: var(--sun-primary); }
.sun-post__nav-icon--prev { transform: scaleX(-1); }

.sun-post__nav-title {
  font-size: var(--wp--preset--font-size--md);
  font-weight: 500;
  line-height: 1.5;
  color: var(--sun-secondary);
}

@media (max-width: 640px) {
  .sun-post__nav { grid-template-columns: 1fr; }
  .sun-post__nav-link--next { grid-column: auto; }
}

/* ── Related row — card design comes 1:1 from blog-teaser CSS ──────── */
.sun-blog--related { padding-bottom: clamp(48px, 6vw, 96px); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sun-post__prose a,
  .sun-post__nav-link { transition: none; }
}
