/* Blog — editorial layer on top of app theme tokens */
html[data-surface="app"]:has(.blog-body) {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

@media (prefers-reduced-motion: reduce) {
  html[data-surface="app"]:has(.blog-body) {
    scroll-behavior: auto;
  }
}

html[data-surface="app"] .blog-body {
  scroll-behavior: smooth;
}

html[data-surface="app"] {
  --blog-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --blog-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  --blog-ink: #0a0a0a;
  --blog-ink-body: #1c1c1c;
  --blog-ink-soft: #5a5a5a;
  --blog-ink-faint: #8a8a8a;
  --blog-surface: var(--app-card);
  --blog-accent: var(--app-primary-ink, var(--app-primary));
}

html[data-surface="app"] .blog-body {
  font-family: var(--blog-sans);
  color: var(--blog-ink-body);
  -webkit-font-smoothing: antialiased;
}

html[data-surface="app"] .blog-serif {
  font-family: var(--blog-serif);
}

/* ── H1 ── */
.blog-body .blog-index-title,
.blog-body .blog-post-title {
  font-family: var(--blog-serif);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.06;
  color: var(--blog-ink);
  text-wrap: balance;
}

.blog-body .blog-index-title {
  font-size: clamp(2.6rem, 7vw, 3.75rem);
}

.blog-body .blog-post-title {
  font-size: clamp(2.15rem, 5.5vw, 3.1rem);
}

/* ── H2 ── */
.blog-body .blog-post-content h2,
.blog-body .blog-faq h2,
.blog-body .blog-card--featured .blog-card-title {
  font-family: var(--blog-serif);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.18;
  color: var(--blog-ink);
}

.blog-body .blog-post-content h2 {
  font-size: clamp(1.55rem, 3.2vw, 1.9rem);
  margin-top: 2.75em;
  margin-bottom: 0.7em;
}

.blog-body .blog-post-content h2:first-child {
  margin-top: 0;
}

.blog-body .blog-faq h2 {
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

/* ── H3 ── */
.blog-body .blog-post-content h3,
.blog-body .blog-faq-item h3 {
  font-family: var(--blog-sans);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.35;
  color: var(--blog-ink);
}

.blog-body .blog-post-content h3 {
  font-size: 1.15rem;
  margin-top: 2em;
  margin-bottom: 0.55em;
}

.blog-body .blog-faq-item h3 {
  font-size: 1rem;
}

/* ── Card titles (h2 in list) ── */
.blog-body .blog-card-title {
  font-family: var(--blog-serif);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.22;
  color: var(--blog-ink);
}

.blog-body .blog-card--featured .blog-card-title {
  font-size: clamp(1.85rem, 4vw, 2.55rem);
  line-height: 1.1;
}

/* ── Body copy ── */
.blog-body .blog-post-content p,
.blog-body .blog-index-lede,
.blog-body .blog-post-dek {
  font-family: var(--blog-sans);
  font-size: 1.125rem;
  line-height: 1.82;
}

.blog-body .blog-post-content p {
  color: var(--blog-ink-body);
  margin-bottom: 1.35em;
}

.blog-body .blog-index-lede,
.blog-body .blog-post-dek {
  color: var(--blog-ink-soft);
  line-height: 1.65;
  max-width: 40ch;
}

.blog-body .blog-post-dek {
  margin-top: 1rem;
  margin-left: auto;
  margin-right: auto;
}

.blog-body .blog-index-lede {
  margin-top: 1.1rem;
}

.blog-body .blog-card-desc,
.blog-body .blog-faq-item p,
.blog-body .blog-post-bio,
.blog-body .blog-post-cta {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--blog-ink-soft);
}

.blog-body .blog-card-desc {
  font-size: 0.92rem;
  line-height: 1.6;
}

/* ── Span / meta ── */
.blog-body .blog-index-kicker,
.blog-body .blog-post-kicker,
.blog-body .blog-related-title,
.blog-body .blog-toc-label {
  font-family: var(--blog-sans);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blog-ink-faint);
}

.blog-body .blog-card-meta,
.blog-body .blog-post-byline {
  font-family: var(--blog-sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--blog-ink-faint);
}

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

.blog-body .blog-card-app {
  color: var(--blog-ink);
  font-weight: 700;
}

/* ── Links ── */
.blog-body .blog-post-content a,
.blog-body .blog-post-cta a,
.blog-body .blog-toc-list a {
  font-family: var(--blog-sans);
  color: var(--blog-ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--blog-ink) 28%, transparent);
  transition: text-decoration-color 0.15s, color 0.15s;
}

.blog-body .blog-post-content a:hover,
.blog-body .blog-post-cta a:hover,
.blog-body .blog-toc-list a:hover {
  text-decoration-color: var(--blog-ink);
  color: var(--blog-ink);
}

.blog-body .blog-toc-list a {
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--blog-ink-soft);
  text-decoration: none;
}

.blog-body .blog-toc-list a:hover {
  color: var(--blog-ink);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--blog-ink) 35%, transparent);
}

.blog-body .blog-card-link:hover .blog-card-title {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--blog-ink) 30%, transparent);
  text-underline-offset: 3px;
}

/* ── Emphasis in prose ── */
.blog-body .blog-post-content strong {
  font-weight: 700;
  color: var(--blog-ink);
}

.blog-body .blog-post-content em {
  font-style: italic;
  color: var(--blog-ink-body);
}

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

.blog-body .blog-post-content ul,
.blog-body .blog-post-content ol {
  font-size: 1.1rem;
  line-height: 1.75;
  color: var(--blog-ink-body);
  margin: 0 0 1.35em 1.35em;
}

.blog-body .blog-post-content li {
  margin-bottom: 0.45em;
}

.blog-body .blog-post-content blockquote {
  font-family: var(--blog-serif);
  font-size: 1.2rem;
  font-style: italic;
  font-weight: 500;
  line-height: 1.55;
  color: var(--blog-ink);
}

html[data-surface="app"] .blog-image-figure {
  margin: 0;
}

/* Post cover — must be global: img lives in BlogImage child (Astro scope misses it) */
html[data-surface="app"] .blog-post .blog-image-figure {
  margin: 0 0 2rem;
  overflow: hidden;
  border-radius: 0;
  width: 100%;
}

html[data-surface="app"] .blog-post .blog-post-cover {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  display: block;
}

html[data-surface="app"] .blog-post-content img {
  width: 100%;
  height: auto;
  max-height: min(52vh, 420px);
  object-fit: cover;
  object-position: center;
  display: block;
  margin: 1.5em 0;
  border-radius: 12px;
}

@media (max-width: 640px) {
  html[data-surface="app"] .blog-post .blog-image-figure {
    margin: 0 0 1.25rem;
  }

  html[data-surface="app"] .blog-post .blog-post-cover {
    aspect-ratio: 4 / 3;
    max-height: 42vh;
  }

  html[data-surface="app"] .blog-post-content img {
    max-height: 40vh;
    margin: 1.15em 0;
    border-radius: 10px;
  }
}

@media (min-width: 901px) {
  html[data-surface="app"] .blog-post .blog-post-cover {
    aspect-ratio: 21 / 9;
    max-height: none;
  }
}

/* Reading progress — positioned via .app-top-chrome in scroll-header.css */
.blog-progress-bar {
  display: block;
  height: 100%;
  width: 0;
  background: #111;
  transition: width 0.12s ease-out;
  will-change: width;
}

/* Blog card thumbnails — global so child components inherit sizing */
.blog-card-media {
  width: 120px;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  flex-shrink: 0;
}

.blog-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .blog-progress-bar {
    transition: none;
  }
}

/* Scroll reveal — blog sections */
html[data-surface="app"] .blog-reveal {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1) var(--d, 0s),
    transform 0.75s cubic-bezier(0.22, 1, 0.36, 1) var(--d, 0s);
}

html[data-surface="app"] .blog-reveal-stagger .blog-reveal-child {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--i, 0) * 0.07s + var(--sd, 0ms)),
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--i, 0) * 0.07s + var(--sd, 0ms));
}

html[data-surface="app"] .blog-reveal.on,
html[data-surface="app"] .blog-reveal-stagger.on .blog-reveal-child {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html[data-surface="app"] .blog-reveal,
  html[data-surface="app"] .blog-reveal-stagger .blog-reveal-child {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
