/* ==========================================================================
   Citgentic Blog layer
   Loads AFTER the static site's /styles.css and only adds what the blog needs:
   hero tweaks, search, category chips, post cards, article prose, related, CTA.
   Tokens come from /styles.css (:root). Spacing is on the 8px scale.
   ========================================================================== */

:root {
  --blog-radius: 16px;
  --blog-radius-sm: 8px;
  --blog-measure: 68ch;
  --blog-shadow: 0 24px 48px rgba(26, 26, 26, 0.08);
  --blog-amber: #8A6D00; /* accessible yellow on light backgrounds, same as .text-amber */
}

/* ---------- Hero (listing, archive, search, 404) ---------- */
.blog-hero { padding: 176px 0 96px; }
.blog-hero .page-hero-content { max-width: 760px; }
.blog-hero .body-large { margin-bottom: 32px; }

/* ---------- Search ---------- */
.blog-search { max-width: 520px; }
.blog-search-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: rgba(254, 253, 251, 0.7);
  margin-bottom: 8px;
}
.blog-search-row { display: flex; gap: 8px; }
.blog-search-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  color: var(--c-white);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 12px 16px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.blog-search-input:hover { border-color: rgba(255, 255, 255, 0.32); }
.blog-search-input:focus { outline: none; border-color: var(--c-yellow); background: rgba(255, 255, 255, 0.1); }
.blog-search-input::-webkit-search-cancel-button { filter: invert(1); }
.blog-search-btn { flex-shrink: 0; }

/* ---------- Listing ---------- */
.blog-listing { padding: 64px 0 96px; }
.blog-section-title { margin-bottom: 32px; }

.blog-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 48px;
}
.blog-chip {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--c-ink);
  background: var(--c-white);
  border: 1px solid var(--c-border-dark);
  border-radius: 999px;
  padding: 8px 16px;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.blog-chip:hover { border-color: var(--c-ink); }
.blog-chip:active { transform: scale(0.97); }
.blog-chip.is-active { background: var(--c-ink); color: var(--c-white); border-color: var(--c-ink); }

.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px;
}

/* ---------- Post card ---------- */
.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--c-white);
  border: 1px solid var(--c-border-dark);
  border-radius: var(--blog-radius);
  overflow: hidden;
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, border-color 0.2s ease-out;
}
.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--blog-shadow);
  border-color: rgba(255, 208, 44, 0.5);
}
.post-card:focus-within { border-color: var(--c-yellow); }

.post-card-media {
  display: block;
  aspect-ratio: 16 / 9;
  background: var(--c-ink);
  overflow: hidden;
}
.post-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease-out;
}
.post-card:hover .post-card-media img { transform: scale(1.03); }
.post-card-fallback {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 70% 30%, rgba(255, 208, 44, 0.22), transparent 60%),
    var(--c-ink);
}
.post-card-fallback img { width: 48px; height: 48px; object-fit: contain; }
.post-card:hover .post-card-fallback img { transform: none; }

.post-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  flex: 1;
}
.post-card-cat {
  position: relative;
  z-index: 2;
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--blog-amber);
}
.post-card-cat:hover { color: var(--c-ink); }
.post-card-title {
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
/* Whole card is clickable through the title link. */
.post-card-title a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.post-card-title a:focus-visible { outline: none; }
.post-card-excerpt {
  font-size: 15px;
  line-height: 1.55;
  color: var(--c-muted);
  flex: 1;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--c-muted);
  margin-top: 8px;
}

/* ---------- Pagination ---------- */
.blog-pagination { margin-top: 48px; }
.blog-pagination .nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.blog-pagination .page-numbers,
.blog-pagination .post-page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
  border: 1px solid var(--c-border-dark);
  background: var(--c-white);
  color: var(--c-ink);
}
.blog-pagination a.page-numbers:hover,
.blog-pagination a.post-page-numbers:hover { border-color: var(--c-ink); }
.blog-pagination .current { background: var(--c-ink); color: var(--c-white); border-color: var(--c-ink); }
.blog-pagination .dots { border: none; background: none; }
.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

/* ---------- Empty state ---------- */
.blog-empty {
  max-width: 640px;
  margin: 0 auto;
  padding: 64px 32px;
  text-align: center;
  background: var(--c-white);
  border: 1px dashed rgba(0, 0, 0, 0.16);
  border-radius: var(--blog-radius);
}
.blog-empty-mark {
  display: inline-flex;
  width: 72px; height: 72px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--c-soft-yellow);
  margin-bottom: 24px;
}
.blog-empty p { margin: 0 auto 32px; color: var(--c-muted); }
.blog-empty-actions,
.blog-404-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}
.blog-404-actions { margin-top: 48px; }

/* ---------- Single post ---------- */
.post-hero { padding: 176px 0 96px; }
.post-hero-content { max-width: 880px; }
.post-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(254, 253, 251, 0.5);
  margin-bottom: 24px;
}
.post-crumbs a { color: var(--c-yellow); }
.post-crumbs a:hover { color: var(--c-white); }
.post-title {
  font-size: clamp(36px, 5vw, 60px);
  line-height: 1.08;
  letter-spacing: -0.035em;
  margin-bottom: 24px;
}
.post-dek { color: rgba(254, 253, 251, 0.72) !important; margin-bottom: 32px; }
.post-meta-hero { color: rgba(254, 253, 251, 0.6); margin-top: 0; }
.post-author { color: var(--c-white); font-weight: 500; }

.post-figure-wrap { margin-top: -48px; position: relative; z-index: 2; }
.post-figure { max-width: 1040px; margin: 0 auto; }
.post-figure img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--blog-radius);
  box-shadow: var(--blog-shadow);
}
.post-figure figcaption,
.prose figcaption {
  font-size: 14px;
  color: var(--c-muted);
  text-align: center;
  margin-top: 8px;
}

/* ---------- Article prose ---------- */
.prose {
  max-width: var(--blog-measure);
  margin: 0 auto;
  padding: 64px 0 48px;
  font-size: 18px;
  line-height: 1.7;
  color: #2b2b2b;
}
.prose > * + * { margin-top: 24px; }
.prose p { max-width: none; line-height: 1.7; }
.prose h2,
.prose h3,
.prose h4 { color: var(--c-ink); line-height: 1.25; scroll-margin-top: 96px; }
.prose h2 { font-size: 30px; letter-spacing: -0.03em; margin-top: 48px; }
.prose h3 { font-size: 24px; letter-spacing: -0.02em; margin-top: 32px; }
.prose h4 { font-size: 20px; letter-spacing: -0.01em; margin-top: 32px; }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: 16px; }

.prose a {
  color: var(--c-ink);
  text-decoration: underline;
  text-decoration-color: var(--c-yellow);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
.prose a:hover { background: var(--c-soft-yellow); }

.prose strong { font-weight: 700; color: var(--c-ink); }

.prose ul,
.prose ol { padding-left: 24px; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li + li { margin-top: 8px; }
.prose li::marker { color: var(--blog-amber); font-weight: 700; }

.prose blockquote {
  border-left: 4px solid var(--c-yellow);
  padding: 8px 0 8px 24px;
  font-size: 20px;
  font-weight: 500;
  color: var(--c-ink);
}
.prose blockquote cite { display: block; font-size: 14px; font-style: normal; color: var(--c-muted); margin-top: 8px; }

.prose img,
.prose video { max-width: 100%; height: auto; border-radius: var(--blog-radius-sm); }
.prose figure { margin-left: 0; margin-right: 0; }
.prose .alignwide { max-width: 960px; margin-left: 50%; transform: translateX(-50%); width: min(960px, 100vw - 48px); }

.prose hr { border: none; border-top: 1px solid var(--c-border-dark); margin: 48px 0; }

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--c-cloud);
  border-radius: 4px;
  padding: 2px 4px;
}
.prose pre {
  background: var(--c-ink);
  color: var(--c-white);
  border-radius: var(--blog-radius-sm);
  padding: 24px;
  overflow-x: auto;
  font-size: 15px;
  line-height: 1.6;
}
.prose pre code { background: none; padding: 0; color: inherit; }

.prose table { width: 100%; border-collapse: collapse; font-size: 16px; }
.prose .wp-block-table { overflow-x: auto; margin-left: 0; margin-right: 0; }
.prose .wp-block-table table { border: 1px solid var(--c-border-dark); border-radius: var(--blog-radius-sm); }
/* Override WordPress's default boxed cell borders with clean row lines. */
.prose .wp-block-table thead { border-bottom: 2px solid var(--c-ink); }
.prose th,
.prose td,
.prose .wp-block-table th,
.prose .wp-block-table td {
  text-align: left;
  padding: 8px 16px;
  border: 0;
  border-bottom: 1px solid var(--c-border-dark);
}
.prose tbody tr:last-child td { border-bottom: 0; }
.prose th { font-weight: 700; color: var(--c-ink); background: var(--c-cloud); }
.prose .wp-block-table figcaption { text-align: left; }

.prose .wp-block-button__link {
  display: inline-flex;
  padding: 16px 24px;
  font-weight: 700;
  font-size: 15px;
  border-radius: 12px;
  background: var(--c-yellow);
  color: var(--c-ink);
  text-decoration: none;
}
.prose .wp-block-button__link:hover { background: var(--c-warm-yellow); }

.post-tags {
  max-width: var(--blog-measure);
  margin: 0 auto 64px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 24px;
  border-top: 1px solid var(--c-border-dark);
}

.blog-related { padding: 96px 0; }

/* ---------- Closing CTA ---------- */
.blog-cta-wrap { padding: 96px 0; background: var(--c-white); }
.blog-related + .blog-cta-wrap,
.blog-listing + .blog-cta-wrap { background: var(--c-cloud); padding-top: 0; }
.blog-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 48px;
  border-radius: 24px;
  position: relative;
  overflow: hidden;
}
.blog-cta::before {
  content: "";
  position: absolute;
  width: 480px; height: 480px;
  right: -160px; top: -240px;
  background: radial-gradient(circle, rgba(255, 208, 44, 0.18), transparent 65%);
  pointer-events: none;
}
.blog-cta-copy { position: relative; max-width: 560px; }
.blog-cta-copy .label-small { margin-bottom: 16px; }
.blog-cta-copy p { color: rgba(254, 253, 251, 0.72); }
.blog-cta-actions { position: relative; display: flex; flex-wrap: wrap; gap: 16px; flex-shrink: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
}
@media (max-width: 768px) {
  .blog-hero, .post-hero { padding: 128px 0 64px; }
  .blog-listing { padding: 48px 0 64px; }
  .blog-cats { margin-bottom: 32px; }
  .post-grid { grid-template-columns: 1fr; }
  .post-figure-wrap { margin-top: -32px; }
  .prose { padding: 48px 0 32px; font-size: 17px; }
  .prose h2 { font-size: 24px; margin-top: 32px; }
  .prose h3 { font-size: 20px; }
  .blog-related, .blog-cta-wrap { padding: 64px 0; }
  .blog-cta { flex-direction: column; align-items: flex-start; padding: 32px 24px; }
  .blog-cta-actions { width: 100%; }
  .blog-cta-actions .btn { flex: 1; }
  .blog-search-row { flex-direction: column; }
  .blog-search-btn { width: 100%; }
  .blog-empty { padding: 48px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .post-card, .post-card-media img, .blog-chip { transition: none; }
  .post-card:hover { transform: none; }
  .post-card:hover .post-card-media img { transform: none; }
}
