/**
 * Single blog post – light theme.
 * Light background, dark text, blue/teal accents.
 */

/* -------------------------------------------------------------------------
   Layout & scroll
   ------------------------------------------------------------------------- */
html,
body {
  height: auto;
  overflow-x: visible;
}

.site-wrap,
.page-wrapper,
body {
  overflow: visible !important;
  transform: none !important;
}

body.single {
  background: #f8fafc;
  min-height: 100vh;
}

body.single .aptly-header-site-header {
  background: #ffffff;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.single .aptly-header-site-header .aptly-header-nav a,
body.single .aptly-header-site-header .aptly-header-mobile-menu-button {
  color: #0f172a;
}

body.single .aptly-header-site-header .aptly-header-logo-default {
  display: none;
}

body.single .aptly-header-site-header .aptly-header-logo-scrolled {
  display: block;
}

body.single .aptly-header-site-header .aptly-header-cta-default {
  display: none;
}

body.single .aptly-header-site-header .aptly-header-cta-scrolled {
  display: block;
}

body.single .aptly-header-site-header.is-scrolled {
  background: #ffffff;
  border-bottom-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

body.single .aptly-header-site-header.is-scrolled .aptly-header-nav a,
body.single .aptly-header-site-header.is-scrolled .aptly-header-mobile-menu-button {
  color: #0f172a;
}

body.single::before {
  content: "";
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.06) 1.5px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0.6;
}

/* -------------------------------------------------------------------------
   Blog container – light theme
   ------------------------------------------------------------------------- */
.blog-container {
  --blog-text: #0f172a;
  --blog-text-muted: #64748b;
  --blog-border: rgba(0, 0, 0, 0.08);
  --blog-bg-muted: #f1f5f9;
  --blog-accent-gradient: linear-gradient(90deg, #486ad2, #08bbd2);

  --blog-accent: var(--color-secondary);
  --blog-accent-hover: var(--color-accent-hover);
  --blog-radius: var(--radius-md);
  --blog-radius-sm: 0.375rem;

  --blog-font-title: clamp(1.25rem, 2.2vw + 1rem, 2rem);
  --blog-font-body: clamp(0.875rem, 0.5rem + 0.8vw, 1rem);
  --blog-font-heading: clamp(1rem, 0.6rem + 0.8vw, 1.25rem);
  --blog-font-small: clamp(0.8125rem, 0.45rem + 0.6vw, 0.9375rem);
  --blog-font-caption: clamp(0.75rem, 0.45rem + 0.5vw, 0.8125rem);

  padding-top: calc(var(--header-height, 80px) + 2rem);
  padding-bottom: 2.5rem;
  overflow: visible;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  background: transparent;
  color: var(--blog-text);
  word-wrap: break-word;
}

.blog-container > * {
  position: relative;
  z-index: 1;
}

/* Title row: blog post title */
.blog-title-row {
  margin-bottom: 1rem;
}

.blog-title-row .blog-title {
  margin: 0;
}

.blog-title {
  font-size: var(--blog-font-title);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  color: var(--blog-text);
  margin: 0 0 1rem 0;
}

/* -------------------------------------------------------------------------
   Post meta (author, date, read time) – compact
   ------------------------------------------------------------------------- */
.post-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
}

.author-section {
  display: flex;
  gap: 0.625rem;
  align-items: center;
}

.author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.author-name {
  font-weight: 600;
  font-size: var(--blog-font-small);
  color: var(--blog-accent);
}

.author-role {
  font-size: var(--blog-font-small);
  color: var(--blog-text-muted);
  margin-top: 0.125rem;
}

.publish-date {
  font-size: var(--blog-font-small);
  color: var(--blog-text-muted);
}

.meta-item {
  font-size: var(--blog-font-small);
  color: var(--blog-text-muted);
}

.meta-item-read-time {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.meta-item-clock-icon {
  flex-shrink: 0;
  color: var(--blog-text-muted);
}

/* Post tags (ACF field "tags" or WordPress post tags) */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  margin-bottom: 1rem;
}

.post-tag-pill {
  display: inline-block;
  font-size: var(--blog-font-small);
  font-weight: 500;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: rgba(8, 187, 210, 0.12);
  color: var(--blog-accent);
  border: 1px solid rgba(8, 187, 210, 0.25);
}

/* -------------------------------------------------------------------------
   Blog hero – featured image with title overlayed
   ------------------------------------------------------------------------- */
.blog-hero {
  position: relative;
  width: 100%;
  min-height: 320px;
  max-height: 420px;
  margin-bottom: 1.5rem;
  border-radius: var(--blog-radius);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
}

.blog-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.35) 45%, rgba(0, 0, 0, 0.15) 100%);
}

.blog-hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 320px;
  padding: 1.5rem 0 1.25rem;
}

.blog-hero-title {
  margin: 0 0 0.5rem 0;
  font-size: var(--blog-font-title);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.blog-hero-meta {
  margin: 0;
  font-size: var(--blog-font-small);
  color: rgba(255, 255, 255, 0.9);
}

.blog-hero-meta .author-name {
  color: #ffffff;
  font-weight: 600;
}

.blog-hero-meta .meta-item-sep {
  opacity: 0.8;
  margin: 0 0.2rem;
}

/* -------------------------------------------------------------------------
   Featured image – compact (fallback when no hero)
   ------------------------------------------------------------------------- */
.blog-container .featured-image {
  width: 100%;
  height: auto;
  border-radius: var(--blog-radius);
  margin-bottom: 1.25rem;
  display: block;
  object-fit: cover;
  max-height: 360px;
  border: 1px solid var(--blog-border);
}

/* -------------------------------------------------------------------------
   Content wrapper (TOC | article | related)
   ------------------------------------------------------------------------- */
.content-wrapper {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  position: relative;
  overflow: visible;
}

@media (min-width: 1024px) {
  .content-wrapper {
    grid-template-columns: 260px minmax(0, 1fr) 300px;
  }
}

@media (min-width: 1024px) and (max-width: 1200px) {
  .content-wrapper {
    grid-template-columns: 1fr 300px;
  }

  .content-wrapper .toc-sidebar {
    display: none;
  }
}

@media (min-width: 1600px) {
  .blog-container {
    padding-top: calc(var(--header-height, 80px) + 2.5rem);
  }

  .content-wrapper {
    gap: 1.5rem;
  }

  .toc {
    padding: 1rem 1.25rem;
  }

  .toc h3 {
    margin-bottom: 0.75rem;
  }

  .toc a {
    padding: 0.4rem 0;
  }
}

/* -------------------------------------------------------------------------
   Table of contents
   ------------------------------------------------------------------------- */
.toc-sidebar {
  position: sticky;
  top: calc(var(--header-height, 80px) + 0.75rem);
  height: fit-content;
  z-index: 10;
}

.toc {
  background: var(--blog-bg-muted);
  padding: 0.875rem 1rem;
  border-radius: var(--blog-radius-sm);
  border: 1px solid var(--blog-border);
  border-left: 3px solid var(--blog-accent);
}

.toc h3 {
  font-size: var(--blog-font-caption);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--blog-text-muted);
  margin: 0 0 0.625rem;
  padding-left: 0;
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc li {
  margin: 0;
}

.toc a {
  display: block;
  padding: 0.35rem 0;
  font-size: var(--blog-font-small);
  line-height: 1.3;
  text-decoration: none;
  color: var(--blog-text);
  transition:
    color 0.12s ease,
    background 0.12s ease;
  border-radius: 3px;
  padding-left: 0.375rem;
  margin-left: -0.375rem;
}

.toc a:hover {
  color: var(--blog-accent);
  background: rgba(0, 0, 0, 0.04);
}

.toc a.is-active {
  color: var(--blog-accent);
  font-weight: 700;
}

/* -------------------------------------------------------------------------
   Main article content
   ------------------------------------------------------------------------- */
.main-content {
  min-width: 0;
  width: 100%;
}

.article-content {
  width: 100%;
  max-width: none;
}

/* Paragraphs & lists – fluid type */
.article-content p,
.article-content li {
  font-size: var(--blog-font-body);
  line-height: 1.65;
  color: var(--blog-text);
  margin: 0 0 0.75rem;
}

.article-content p:last-child,
.article-content li:last-child {
  margin-bottom: 0;
}

.article-content ul,
.article-content ol {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.article-content ul {
  list-style-type: disc;
}

.article-content ol {
  list-style-type: decimal;
}

.article-content li {
  margin-bottom: 0.25rem;
}

.article-content li::marker {
  color: var(--blog-text-muted);
}

/* Headings – fluid type */
.article-content h1 {
  font-size: var(--blog-font-heading);
  font-weight: 700;
  line-height: 1.25;
  color: var(--blog-text);
  margin: 1.5rem 0 0.5rem;
}

.article-content h1:first-child {
  margin-top: 0;
}

.article-content h2 {
  font-size: var(--blog-font-heading);
  font-weight: 700;
  line-height: 1.3;
  color: var(--blog-text);
  margin: 1.5rem 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--blog-border);
}

.article-content h3 {
  font-size: var(--blog-font-heading);
  font-weight: 700;
  line-height: 1.35;
  color: var(--blog-text);
  margin: 1.25rem 0 0.375rem;
}

.article-content h4,
.article-content h5,
.article-content h6 {
  font-size: var(--blog-font-body);
  font-weight: 700;
  margin: 1rem 0 0.375rem;
  color: var(--blog-text);
}

.article-content h5 {
  margin: 0.875rem 0 0.25rem;
}

.article-content h6 {
  margin: 0.75rem 0 0.25rem;
  color: var(--blog-text-muted);
}

/* Links – accent */
.article-content a {
  color: var(--blog-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}

.article-content a:hover {
  color: var(--blog-accent-hover);
}

/* Strong & emphasis */
.article-content strong {
  font-weight: 700;
  color: var(--blog-text);
}

/* Images inside content */
.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--blog-radius-sm);
  margin: 1rem 0;
  display: block;
}

.article-content img:first-child {
  margin-top: 0;
}

/* Blockquotes */
.article-content blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: var(--blog-bg-muted);
  border-radius: 0 var(--blog-radius-sm) var(--blog-radius-sm) 0;
  border: 1px solid var(--blog-border);
  border-left: 3px solid var(--blog-accent);
  font-style: italic;
  font-size: var(--blog-font-body);
  color: var(--blog-text-muted);
}

.article-content blockquote p:last-child {
  margin-bottom: 0;
}

/* Code */
.article-content code {
  font-size: 0.85em;
  padding: 0.15em 0.35em;
  background: var(--blog-bg-muted);
  border-radius: 3px;
  font-family: ui-monospace, monospace;
  color: var(--blog-text);
}

.article-content pre {
  margin: 1rem 0;
  padding: 0.875rem 1rem;
  background: var(--blog-bg-muted);
  border-radius: var(--blog-radius-sm);
  overflow-x: auto;
  border: 1px solid var(--blog-border);
}

.article-content pre code {
  padding: 0;
  background: none;
  font-size: var(--blog-font-caption);
  line-height: 1.45;
}

/* GitHub / embed containers */
.article-content div.github-container {
  margin: 1rem 0;
}

/* -------------------------------------------------------------------------
   Related posts (Keep Reading) – compact
   ------------------------------------------------------------------------- */
.related-posts-wrapper {
  position: sticky;
  top: calc(var(--header-height, 80px) + 0.75rem);
  height: fit-content;
  background: var(--blog-bg-muted);
  padding: 1rem;
  border-radius: var(--blog-radius-sm);
  border: 1px solid var(--blog-border);
}

.related-posts-wrapper h3 {
  font-size: var(--blog-font-caption);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--blog-text-muted);
  margin: 0 0 0.75rem;
}

.related-link {
  display: block;
  text-decoration: none;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--blog-border);
  transition: color 0.12s ease;
}

.related-link:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.related-link:hover {
  color: var(--blog-accent);
}

.related-link h4 {
  font-size: var(--blog-font-body);
  font-weight: 600;
  line-height: 1.3;
  color: var(--blog-text);
  margin: 0 0 0.125rem;
}

.related-link .cta {
  font-size: var(--blog-font-small);
  color: var(--blog-text-muted);
  font-weight: 500;
}

.related-link:hover .cta {
  color: var(--blog-accent);
}

/* -------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------- */
@media (max-width: 1023px) {
  .blog-container {
    padding-top: calc(var(--header-height, 80px) + 1.5rem);
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .content-wrapper {
    grid-template-columns: 1fr;
  }

  .toc-sidebar {
    display: none;
  }

  .related-posts-wrapper {
    position: static;
    width: 100%;
  }

  .article-content {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .blog-container {
    padding: calc(var(--header-height, 80px) + 1.25rem) 0.75rem 2rem;
  }

  .blog-title {
    margin-bottom: 0.375rem;
  }

  .post-meta-row {
    flex-direction: column;
    align-items: flex-start;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
  }

  .blog-hero {
    min-height: 260px;
    max-height: 320px;
    margin-bottom: 1rem;
  }

  .blog-hero-inner {
    min-height: 260px;
    padding: 1rem 0 1rem;
  }

  .blog-container .featured-image {
    margin-bottom: 1rem;
    max-height: 240px;
  }

  .related-posts-wrapper {
    padding: 0.875rem;
  }

  .article-content h2 {
    margin-top: 1.25rem;
  }
}
