/* ============================================================
   SINGLE BLOG POST — single.css
   Aesthetic: clean editorial, title-above-image, generous rhythm.
   Scoped to is_singular('post') via functions.php.
   Depends on: global.css (tokens, .card, .blog-card, .label, .section)
   ============================================================ */


/* ----------------------------------------------------------------
   Article header
   Back button → title → excerpt → meta row → contained image
   ---------------------------------------------------------------- */
.post-article-header {
  background-color: #0F172A; /* direct fallback — var below overrides if supported */
  background-color: var(--slate-deep);
  padding: 3rem 0 2.5rem; /* dark header ends cleanly after the meta row */
  border-bottom: none;
  position: relative;
  z-index: 1;
}

/* Constrain the header content to the 760px editorial column */
.post-article-header__inner {
  max-width: 760px;
}

/* Circular back button */
.post-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.375rem;
  height: 2.375rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  transition: border-color var(--ease), color var(--ease), background var(--ease);
  margin-bottom: 1.25rem;
  flex-shrink: 0;
}

.post-back-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: rgba(16, 185, 129, 0.1);
}

/* Post title */
.post-article-header__title {
  font-family: var(--font-display);
  font-size: clamp(1.875rem, 4.5vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--white);
  margin-bottom: 0.625rem;
}

/* Optional excerpt / subtitle */
.post-article-header__excerpt {
  font-size: 1.05rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.62);
  margin-bottom: 1.125rem;
}

/* Meta row: byline left, category badge right */
.post-article-header__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-bottom: 1.25rem;
}

.post-article-header__byline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.post-author-avatar {
  width: 28px !important;
  height: 28px !important;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.post-author-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--white);
}

.post-meta-sep {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.3);
}

.post-meta-date {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.52);
}

/* Category pill — ghost style: transparent, white border + text */
.post-cat-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.875rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: 2rem;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--white);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}

.post-cat-badge:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Featured image — now at the top of the white content area, full column width, no bleed */
.post-article-header__image {
  margin: 0 0 2.5rem;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.post-article-header__image img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-lg);
}


/* ----------------------------------------------------------------
   Post layout — two-column grid (prose + sticky TOC)
   ---------------------------------------------------------------- */
.post-layout {
  background: var(--white);
  padding-top: 2.5rem; /* image no longer bleeds — normal top spacing */
  padding-bottom: 4.5rem;
}

.post-layout__inner {
  display: grid;
  grid-template-columns: 1fr 252px;
  grid-template-areas: "content toc";
  gap: 3.5rem;
  align-items: start;
}

.post-content {
  grid-area: content;
  min-width: 0;
}

.post-toc {
  display: block;
  grid-area: toc;
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 116px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}


/* ----------------------------------------------------------------
   TOC
   ---------------------------------------------------------------- */
.post-toc details {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.125rem 1.25rem;
}

.post-toc summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 1rem;
  cursor: pointer;
  user-select: none;
}

.post-toc summary::-webkit-details-marker { display: none; }
.post-toc summary::marker { display: none; }

.post-toc__chevron {
  flex-shrink: 0;
  transition: transform var(--ease-md);
  color: var(--text-faint);
}

.post-toc details:not([open]) .post-toc__chevron { transform: rotate(-90deg); }

@media (min-width: 1024px) {
  .post-toc summary {
    cursor: default;
    pointer-events: none;
    margin-bottom: 0.875rem;
  }

  .post-toc__chevron { display: none; }
}

#toc-nav ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

#toc-nav li {
  border-left: 2px solid var(--border);
  transition: border-color var(--ease-md);
}

#toc-nav li.toc-h3 { margin-left: 0.875rem; }

#toc-nav li.toc-active { border-left-color: var(--teal); }

#toc-nav a {
  display: block;
  padding: 0.325rem 0.75rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--ease);
}

#toc-nav li.toc-h3 a {
  font-size: 0.76rem;
  color: var(--text-faint);
}

#toc-nav a:hover,
#toc-nav li.toc-active a { color: var(--teal); }


/* ----------------------------------------------------------------
   Prose — post body typography
   ---------------------------------------------------------------- */
.prose {
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.82;
  color: var(--text);
}

.prose > *:first-child { margin-top: 0 !important; }
.prose > *:last-child  { margin-bottom: 0 !important; }

/* --- Headings --- */
.prose h2,
.prose h3,
.prose h4 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text);
  line-height: 1.22;
  scroll-margin-top: 104px;
}

.prose h2 {
  font-size: 1.625rem;
  letter-spacing: -0.01em;
  margin-top: 3rem;
  margin-bottom: 0.875rem;
}

.prose h3 {
  font-size: 1.25rem;
  margin-top: 2.25rem;
  margin-bottom: 0.625rem;
}

.prose h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

/* --- Paragraphs --- */
.prose p { margin-bottom: 1.5rem; }

/* --- Links --- */
.prose a {
  color: var(--teal);
  text-decoration: underline;
  text-decoration-color: rgba(16, 185, 129, 0.3);
  text-underline-offset: 3px;
  transition: color var(--ease), text-decoration-color var(--ease);
}

.prose a:hover {
  color: var(--teal-dark);
  text-decoration-color: var(--teal-dark);
}

/* --- Lists --- */
.prose ul,
.prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }

.prose li {
  margin-bottom: 0.425rem;
  line-height: 1.7;
}

.prose li > ul,
.prose li > ol {
  margin-top: 0.4rem;
  margin-bottom: 0;
}

/* --- Blockquote --- */
.prose blockquote {
  margin: 2.5rem 0;
  padding: 1.25rem 1.625rem;
  border-left: 3px solid var(--teal);
  background: rgba(16, 185, 129, 0.035);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.prose blockquote p {
  margin-bottom: 0;
  font-size: 1.075rem;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.72;
}

.prose blockquote cite {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  font-style: normal;
  font-weight: 600;
  color: var(--text-faint);
}

/* --- Inline code --- */
.prose code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.875em;
  background: var(--bg-alt);
  color: var(--teal-dark);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border);
  white-space: nowrap;
}

/* --- Code block --- */
.prose pre {
  background: var(--slate);
  color: #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1.375rem 1.5rem;
  overflow-x: auto;
  margin: 2rem 0;
  font-size: 0.875rem;
  line-height: 1.65;
  -webkit-overflow-scrolling: touch;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
  white-space: pre;
  border-radius: 0;
}

/* --- Horizontal rule --- */
.prose hr {
  border: none;
  border-top: 0.5px solid var(--border);
  margin: 3rem 0;
}

/* --- Images within content --- */
.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  display: block;
  margin: 2rem auto;
}

/* --- Figure & caption --- */
.prose figure { margin: 2.25rem 0; }

.prose figcaption {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-top: 0.5rem;
  font-style: italic;
}

/* --- Tables --- */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.9rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.prose th,
.prose td {
  padding: 0.625rem 0.875rem;
  text-align: left;
  border: 0.5px solid var(--border);
}

.prose th {
  background: var(--bg-alt);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.prose tr:nth-child(even) td { background: rgba(241, 245, 249, 0.5); }

/* --- Misc inline --- */
.prose strong { font-weight: 700; }
.prose em     { font-style: italic; }

/* --- Multi-page pagination --- */
.post-pages {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 0.5px solid var(--border);
}

.post-pages a,
.post-pages span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.post-pages a:hover {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
}


/* ----------------------------------------------------------------
   Related posts
   ---------------------------------------------------------------- */
.post-related {
  background: var(--bg-alt);
  border-top: 0.5px solid var(--border);
}

.post-related__header { margin-bottom: 2.25rem; }

.post-related__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.25rem;
}

.post-related__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}


/* ----------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------- */

/* Below 1060px — single column, TOC stacks above content */
@media (max-width: 1060px) {
  .post-layout__inner {
    grid-template-columns: 1fr;
    grid-template-areas:
      "toc"
      "content";
    gap: 2rem;
  }

  .post-toc {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

/* Tablet */
@media (max-width: 860px) {
  .post-related__grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile */
@media (max-width: 640px) {
  .post-article-header { padding-top: 1.75rem; }

  .post-article-header__title { font-size: 1.625rem; }

  .post-article-header__excerpt { font-size: 1rem; }

  .post-article-header__meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .prose { font-size: 1rem; }

  .prose h2 {
    font-size: 1.375rem;
    margin-top: 2.25rem;
  }

  .prose h3 { font-size: 1.125rem; }

  .post-layout { padding-top: 3rem; padding-bottom: 3rem; }

  .post-related__grid { grid-template-columns: 1fr; }
}
