/*
 * iLoveMarkdown blog — shared stylesheet for /blog, the author archive and
 * every plain-HTML post. Posts do NOT go through webpack, so this file lives at
 * a stable, un-hashed path and is fully self-contained (no dependency on
 * style.css or guides.css). Design tokens mirror the main site (assets/css/style.css).
 */

:root {
  /* One continuous white surface, matching the /guides/* pages
     (guides.css sets body background to --card). */
  --background: #ffffff;
  --foreground: #26231f;
  --card: #ffffff;
  --card-foreground: #3b3b3b;
  --primary: #15a536;
  --primary-dark: #0f7a28;
  --primary-foreground: #ffffff;
  --muted-foreground: #6b6660;
  --border-subtle: rgba(94, 90, 90, 0.16);
  --primary-tint-bg: rgba(21, 165, 54, 0.10);
  --primary-tint-faint: rgba(21, 165, 54, 0.05);
  --radius: 0.75rem;
  --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
  --card-shadow-lg: 0 10px 30px -12px rgb(0 0 0 / 0.15);
  --maxw: 1120px;
  --readw: 720px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--foreground);
  background: var(--background);
  line-height: 1.7;
  font-size: 1.0625rem;
  -webkit-font-smoothing: antialiased;
}

.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 1.25rem; }
.container-narrow { max-width: var(--readw); }

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* ---------- Header / nav ---------- */
.site-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; }
.logo { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.15rem; color: var(--foreground); }
.logo:hover { text-decoration: none; }
.site-logo { height: 25px; width: auto; display: block; }
.logo-sm .site-logo { height: 22px; }
.site-nav { display: flex; align-items: center; gap: 1.35rem; flex-wrap: wrap; }
.site-nav a { color: var(--card-foreground); font-weight: 500; font-size: 0.95rem; }
.site-nav a:hover { color: var(--primary-dark); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--primary); font-weight: 600; }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { font-size: 0.85rem; color: var(--muted-foreground); margin-bottom: 1rem; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.breadcrumbs a { color: var(--muted-foreground); }
.breadcrumbs a:hover { color: var(--primary-dark); }
.breadcrumbs span[aria-hidden] { opacity: 0.5; }

/* ---------- Article ---------- */
main { display: block; }
.blog-hero { padding: 3rem 0 1.5rem; }
.eyebrow { display: inline-block; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary); background: var(--primary-tint-bg); padding: 0.3rem 0.7rem; border-radius: 999px; margin-bottom: 0.9rem; }
.post-title, .blog-hero h1 { font-size: clamp(1.9rem, 4.5vw, 2.75rem); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 0.75rem; font-weight: 700; }
.text-green { color: var(--primary); }
.post-meta { color: var(--muted-foreground); font-size: 0.92rem; display: flex; flex-wrap: wrap; gap: 0.35rem 0.75rem; align-items: center; margin: 0 0 0.5rem; }
.post-meta a { color: var(--primary-dark); font-weight: 600; }
.post-meta .dot { opacity: 0.5; }

.post-body { padding-bottom: 2rem; }
.post-body h2 { font-size: clamp(1.4rem, 3vw, 1.85rem); line-height: 1.25; letter-spacing: -0.01em; margin: 2.5rem 0 0.85rem; font-weight: 700; }
.post-body h3 { font-size: 1.25rem; margin: 1.75rem 0 0.6rem; font-weight: 650; }
.post-body p { margin: 0 0 1.15rem; }
.post-body ul, .post-body ol { margin: 0 0 1.25rem; padding-left: 1.4rem; }
.post-body li { margin-bottom: 0.5rem; }
.post-body img { border-radius: var(--radius); box-shadow: var(--card-shadow); margin: 1.75rem 0; }
.post-body figure { margin: 1.75rem 0; }
.post-body figure img { margin: 0; width: 100%; }
.post-body figure.post-hero-image { margin: 0 0 2rem; }
.post-body hr { border: 0; border-top: 1px solid var(--border-subtle); margin: 2.5rem 0; }

.post-body blockquote {
  margin: 1.75rem 0;
  padding: 0.5rem 0 0.5rem 1.25rem;
  border-left: 4px solid var(--primary);
  color: var(--card-foreground);
  font-style: italic;
  font-size: 1.1rem;
}
.post-body blockquote cite { display: block; font-style: normal; font-size: 0.9rem; color: var(--muted-foreground); margin-top: 0.5rem; }

.post-body code {
  font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--primary-tint-faint);
  color: var(--primary-dark);
  padding: 0.15em 0.4em;
  border-radius: 6px;
}
.post-body pre {
  background: #1e1b17;
  color: #f4f2ef;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  line-height: 1.55;
}
.post-body pre code { background: none; color: inherit; padding: 0; }

.post-body table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.95rem; display: block; overflow-x: auto; }
.post-body th, .post-body td { border: 1px solid var(--border-subtle); padding: 0.6rem 0.85rem; text-align: left; }
.post-body th { background: var(--primary-tint-faint); font-weight: 600; }

/* Key takeaways — plain heading + list, no box/card styling */
.key-takeaways { margin: 1.5rem 0 2rem; }
.key-takeaways h2 { margin: 0 0 0.5rem; }
.key-takeaways ul { margin: 0; }

/* Direct-answer lead paragraph under each heading. Medium weight only, so it
   leads the section without competing with the h2/h3 titles above it. */
.answer { font-weight: 500; color: var(--foreground); }

.callout {
  display: flex;
  gap: 0.75rem;
  background: var(--primary-tint-faint);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.75rem 0;
}
.callout p { margin: 0; }

/* Inline table of contents inside a post (the no-JS / mobile fallback) */
.post-toc { background: var(--card); border: 1px solid var(--border-subtle); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 1.75rem 0; }
.post-toc strong { display: block; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-foreground); margin-bottom: 0.6rem; }
.post-toc ol { margin: 0; padding-left: 1.2rem; }
.post-toc li { margin-bottom: 0.3rem; }

/* ---------- Sticky sidebar table of contents ----------
   Built by blog.js from the post's headings as a progressive enhancement. The
   article keeps its 720px reading column; when the sidebar is live (.has-toc)
   it widens into a two-column grid on desktop. Offsets clear the sticky header. */
.post-body h2[id], .post-body h3[id] { scroll-margin-top: 88px; }

.toc-sidebar { display: none; }

.blog-post.has-toc { max-width: var(--maxw); }

@media (min-width: 960px) {
  .blog-post.has-toc {
    display: grid;
    grid-template-columns: minmax(0, var(--readw)) 15.5rem;
    justify-content: center;
    gap: 3.5rem;
    align-items: start;
  }
  .blog-post.has-toc .blog-post-content { min-width: 0; }
  /* The inline box is redundant once the sidebar is showing. */
  .blog-post.has-toc .post-toc { display: none; }

  .toc-sidebar {
    display: block;
    position: sticky;
    top: 88px;
    align-self: start;
    max-height: calc(100vh - 108px);
    overflow-y: auto;
  }
}

.toc-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted-foreground); font-weight: 600; margin: 0 0 0.85rem; }
.toc-nav ul { list-style: none; margin: 0; padding: 0; }
.toc-nav li { margin: 0; }
.toc-nav li a {
  display: block;
  padding: 0.35rem 0 0.35rem 1rem;
  border-left: 2px solid var(--border-subtle);
  color: var(--muted-foreground);
  font-size: 0.9rem;
  line-height: 1.35;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.toc-nav li a:hover { color: var(--primary-dark); text-decoration: none; border-left-color: var(--muted-foreground); }
.toc-nav li.toc-h3 a { padding-left: 2rem; font-size: 0.85rem; }
.toc-nav li.is-active > a { color: var(--primary-dark); font-weight: 600; border-left-color: var(--primary); }

/* FAQ */
.faqs { margin-top: 2.5rem; }
.faq-item { border-bottom: 1px solid var(--border-subtle); padding: 1rem 0; }
.faq-item h3 { margin: 0 0 0.4rem; font-size: 1.08rem; }
.faq-item p { margin: 0; color: var(--card-foreground); }

/* ---------- CTA ---------- */
.blog-cta {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 2rem;
  margin: 3rem 0 1rem;
  text-align: center;
  box-shadow: var(--card-shadow);
}
.blog-cta h2 { margin: 0 0 0.5rem; font-size: 1.5rem; }
.blog-cta p { margin: 0 auto 1.25rem; color: var(--muted-foreground); max-width: 46ch; }
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-weight: 600; font-size: 1rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: var(--primary-dark); }

/* ---------- Index / author listing ---------- */
.blog-index-hero { padding: 3.5rem 0 1rem; text-align: center; }
.blog-index-hero h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 0.75rem; letter-spacing: -0.02em; }
.blog-index-hero p { color: var(--muted-foreground); max-width: 60ch; margin: 0 auto; font-size: 1.1rem; }

.author-card { display: flex; gap: 1.25rem; align-items: center; background: var(--card); border: 1px solid var(--border-subtle); border-radius: var(--radius); padding: 1.5rem; margin: 2rem 0 1rem; box-shadow: var(--card-shadow); }
.author-avatar { flex: 0 0 auto; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-tint-bg); color: var(--primary); }
.author-avatar svg { width: 38px; height: 38px; }
.author-card h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.author-card p { margin: 0; color: var(--muted-foreground); }

.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem; padding: 2rem 0 1rem; }
.post-card {
  display: flex; flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.post-card:hover { transform: translateY(-3px); box-shadow: var(--card-shadow-lg); }
.post-card .eyebrow { align-self: flex-start; margin-bottom: 0.75rem; }
.post-card h2 { font-size: 1.3rem; line-height: 1.25; margin: 0 0 0.6rem; }
.post-card h2 a { color: var(--foreground); }
.post-card h2 a:hover { color: var(--primary-dark); text-decoration: none; }
.post-card p { color: var(--muted-foreground); margin: 0 0 1.1rem; flex-grow: 1; }
.post-card .card-meta { font-size: 0.85rem; color: var(--muted-foreground); display: flex; gap: 0.5rem; align-items: center; }
.post-card .read-more { font-weight: 600; color: var(--primary-dark); }

/* Listing-card thumbnail — full-bleed image on top of the card (Neil-Patel
   style). Negative margins pull it out to the card edges past the 1.5rem
   padding; a fixed 16:9 box + object-fit:cover keeps every card uniform
   regardless of whether the source was a post hero or its OG image. */
.post-card .card-thumb {
  display: block;
  margin: -1.5rem -1.5rem 1.25rem;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--primary-tint-faint);
}
.post-card .card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s ease; }
.post-card:hover .card-thumb img { transform: scale(1.035); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border-subtle); background: var(--card); margin-top: 3rem; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 2rem; padding-block: 2.5rem; }
.footer-brand .logo-sm { font-size: 1.05rem; }
.footer-copy { color: var(--muted-foreground); font-size: 0.9rem; margin: 0.75rem 0 0; }
.footer-col { display: flex; flex-direction: column; gap: 0.55rem; }
.footer-heading { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-foreground); font-weight: 600; margin-bottom: 0.25rem; }
.footer-col a { color: var(--card-foreground); font-size: 0.95rem; }
.footer-col a:hover { color: var(--primary-dark); }

@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
  .site-nav { gap: 0.9rem; font-size: 0.9rem; }
  .site-nav a { font-size: 0.9rem; }
}

@media (max-width: 520px) {
  .site-nav { display: none; }
}
