/* ─── Hero ───────────────────────────────────────────────────────────────── */

.post-hero { padding: 64px 0 56px; }

.post-hero-grid {
  max-width: 1200px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  align-items: center;
  gap: 56px;
}

/* Single column: the image sits right under the title, before the lead. */
@media (max-width: 960px) {
  .post-hero { padding: 48px 0 40px; }
  .post-hero-grid { grid-template-columns: 1fr; gap: 0; }
  .post-hero-text { display: contents; }
  .post-hero-cat { order: 1; justify-self: start; }
  .post-title { order: 2; }
  .post-hero-media { order: 3; margin-bottom: 24px; }
  .post-lead { order: 4; }
  .post-meta { order: 5; }
}

.post-hero-cat {
  display: inline-block;
  margin-bottom: 18px;
  padding: 4px 9px;
  border-radius: 5px;
  /* Same tint as the related-post category labels. */
  background: color-mix(in oklch, var(--accent) 9%, transparent);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  transition: background .15s ease;
}

.post-hero-cat:hover { background: color-mix(in oklch, var(--accent) 16%, transparent); }

.post-title {
  font-size: clamp(32px, 4.2vw, 48px);
  line-height: 1.12;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
  overflow-wrap: break-word;
}

.post-lead {
  font-size: 17px;
  line-height: 1.65;
  color: var(--fg-dim);
  margin-bottom: 24px;
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 24px;
  font-size: 14px;
  color: var(--fg-mute);
}

.post-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.post-meta-item svg { width: 15px; height: 15px; flex-shrink: 0; }

.post-meta-author img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: block;
}

.post-hero-media {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.post-hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-hero-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(60% 70% at 75% 25%, var(--accent-glow), transparent 70%),
    radial-gradient(50% 60% at 20% 85%, oklch(0.58 0.2 290 / 0.14), transparent 70%),
    var(--surface-2);
}

.post-hero-placeholder-mark {
  display: inline-flex;
  padding: 22px 30px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .06);
}

.post-hero-placeholder-mark svg,
.post-hero-placeholder-mark img { height: 28px; width: auto; display: block; }

/* ─── Content + sidebar layout ───────────────────────────────────────────── */

.post-layout {
  max-width: 1200px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: 64px;
  padding-top: 48px;
  padding-bottom: 72px;
  border-top: 1px solid var(--border);
}

.post-sidebar {
  position: sticky;
  /* --sidebar-top is set by post-toc.js so a sidebar taller than the viewport
     scrolls until its bottom is visible, then sticks. */
  top: var(--sidebar-top, 96px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (max-width: 1080px) {
  .post-layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; }
}

/* Single column: TOC → article → CTA card → related posts. */
@media (max-width: 900px) {
  .post-layout { grid-template-columns: minmax(0, 1fr); gap: 32px; padding-top: 32px; padding-bottom: 64px; }
  .post-main,
  .post-sidebar { display: contents; }
  .post-toc { order: -1; }
  .post-cta-card { order: 1; }
}

/* ─── Content ────────────────────────────────────────────────────────────── */

.post-content {
  max-width: 760px;
  color: var(--fg-dim);
  font-size: 16px;
  line-height: 1.7;
  counter-reset: post-section;
}

.post-content > * + * { margin-top: 18px; }

.post-content p { font-size: inherit; }

.post-content h2,
.post-content h3,
.post-content h4 {
  color: var(--fg);
  letter-spacing: -0.02em;
  /* Adds to html scroll-padding-top (sticky nav) for a bit of breathing room. */
  scroll-margin-top: 16px;
}

.post-content h2 { font-size: 28px; line-height: 1.25; margin-top: 48px; }
.post-content h3 { font-size: 22px; line-height: 1.3; margin-top: 40px; }
.post-content h4 { font-size: 18px; line-height: 1.35; margin-top: 32px; }

.post-content > :first-child { margin-top: 0; }

/* Section numbers ("1. …") on the headings the TOC is built from. */
.post-content.has-numbered-sections[data-section-level="2"] > h2,
.post-content.has-numbered-sections[data-section-level="3"] > h3 {
  counter-increment: post-section;
}

.post-content.has-numbered-sections[data-section-level="2"] > h2::before,
.post-content.has-numbered-sections[data-section-level="3"] > h3::before {
  content: counter(post-section) ". ";
}

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-glow);
  text-underline-offset: 3px;
  transition: text-decoration-color .15s ease;
}

.post-content a:hover { text-decoration-color: currentColor; }

.post-content strong { color: var(--fg); font-weight: 700; }

/* Bulleted lists render as a checklist, matching the design. */
.post-content ul {
  list-style: none;
  padding-left: 0;
}

.post-content ul > li {
  position: relative;
  padding-left: 32px;
}

.post-content ul > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.2em;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: oklch(0.62 0.15 155) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / 12px no-repeat;
}

/* Nested lists fall back to a simple dash. */
.post-content li ul { margin-top: 8px; }

.post-content li ul > li { padding-left: 18px; }

.post-content li ul > li::before {
  content: "–";
  top: 0;
  width: auto;
  height: auto;
  border-radius: 0;
  background: none;
  color: var(--fg-mute);
}

.post-content ol { padding-left: 22px; }
.post-content ol > li { padding-left: 4px; }
.post-content ol > li::marker { color: var(--fg); font-weight: 600; }

.post-content li + li { margin-top: 10px; }
.post-content li p { margin: 0; }

.post-content blockquote {
  margin: 0;
  padding: 4px 24px;
  border-left: 3px solid var(--accent);
  color: var(--fg);
  font-size: 18px;
  font-style: italic;
}

.post-content blockquote p:first-child { margin-top: 0; }

.post-content pre {
  background: var(--fg);
  color: #f4f4f2;
  padding: 20px 22px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
}

.post-content code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--fg);
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
}

.post-content figure { margin: 0; }

.post-content figcaption {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg-mute);
  text-align: center;
  margin-top: 10px;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.post-content th,
.post-content td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}

.post-content th {
  background: var(--surface-2);
  color: var(--fg);
  font-weight: 600;
}

.post-content .wph-post-callout { margin-top: 28px; margin-bottom: 8px; }

/* ─── In-article banner ──────────────────────────────────────────────────── */

.post-content .post-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 36px 0 8px;
  padding: 24px 28px;
  border: 1px solid color-mix(in oklch, var(--accent) 16%, var(--border));
  border-radius: var(--radius-lg);
  background: color-mix(in oklch, var(--accent) 5%, var(--surface));
}

.post-banner-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
}

.post-banner-icon svg { width: 24px; height: 24px; }

.post-banner-body { flex: 1; min-width: 0; }

.post-content .post-banner-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.35;
}

.post-content .post-banner-text {
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg-dim);
}

.post-content .post-banner-btn {
  flex-shrink: 0;
  color: #fff;
  text-decoration: none;
}

.post-banner-btn svg { width: 14px; height: 14px; }

@media (max-width: 600px) {
  .post-content .post-banner { flex-wrap: wrap; padding: 20px; }
  .post-banner-body { flex-basis: calc(100% - 68px); }
  .post-content .post-banner-btn { width: 100%; justify-content: center; }
}

/* ─── Sidebar: table of contents ─────────────────────────────────────────── */

.post-toc {
  padding: 22px 22px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.post-toc-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
}

.post-toc-title svg { width: 16px; height: 16px; }

.post-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: toc;
}

.post-toc-list > li { counter-increment: toc; }

.post-toc-list a {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 7px 0 7px 14px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--fg-mute);
  transition: color .15s ease;
}

.post-toc-row > a::before {
  content: counter(toc) ".";
  flex-shrink: 0;
  min-width: 16px;
}

.post-toc-list a::after {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background .15s ease;
}

.post-toc-list a:hover { color: var(--fg); }

.post-toc-list a.is-active { color: var(--accent); }
.post-toc-list a.is-active::after { background: var(--accent); }

.post-toc-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.post-toc-row > a { flex: 1; min-width: 0; }

/* Chevron: expands/collapses a section's sub-items without scrolling to it. */
.post-toc-toggle {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  margin-top: 5px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--fg-mute);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.post-toc-toggle:hover { background: var(--surface-2); color: var(--fg); }

.post-toc-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.post-toc-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform .2s ease;
}

.post-toc-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

/* Sub-items (next heading level): collapsed until toggled with the chevron. */
.post-toc-sub {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .25s ease;
}

.post-toc-list > li.is-open > .post-toc-sub { grid-template-rows: 1fr; }
.post-toc-list > li.is-open > .post-toc-sub > ul { visibility: visible; transition-delay: 0s; }

.post-toc-sub > ul {
  min-height: 0;
  overflow: hidden;
  /* Keeps collapsed links out of the tab order; delayed so the collapse animates. */
  visibility: hidden;
  transition: visibility 0s .25s;
  list-style: none;
  margin: 0;
  padding: 0 0 0 26px;
}

.post-toc-sub a {
  padding: 5px 0 5px 14px;
  font-size: 13px;
}

.post-toc-sub a::after { display: none; }
.post-toc-sub a.is-active { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .post-toc-sub,
  .post-toc-toggle svg { transition: none; }
}

/* Single column: the TOC isn't sticky there, so show every sub-item. */
@media (max-width: 900px) {
  .post-toc-sub { grid-template-rows: 1fr; }
  .post-toc-sub > ul { visibility: visible; }
  .post-toc-toggle { display: none; }
}

/* ─── Sidebar: CTA card ──────────────────────────────────────────────────── */

.post-cta-card {
  padding: 28px 24px 26px;
  border: 1px solid color-mix(in oklch, var(--accent) 14%, var(--border));
  border-radius: var(--radius-lg);
  background:
    radial-gradient(80% 90% at 100% 0%, var(--accent-glow), transparent 65%),
    color-mix(in oklch, var(--accent) 4%, var(--surface));
}

.post-cta-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  margin-bottom: 18px;
  color: var(--accent);
}

.post-cta-icon svg { width: 100%; height: 100%; }

.post-cta-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--fg);
  margin-bottom: 8px;
}

.post-cta-text {
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 20px;
}

.post-cta-card .btn svg { width: 14px; height: 14px; }

/* ─── Related posts (full width, below content + sidebar) ────────────────── */

.post-main { min-width: 0; max-width: 760px; }

.post-related { padding: 0 0 88px; }

.post-related > .container {
  max-width: 1200px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
}

.post-related-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.post-related-title {
  font-size: clamp(22px, 2.4vw, 28px);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.post-related-all {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.post-related-all svg { width: 14px; height: 14px; transition: transform .2s ease; }
.post-related-all:hover svg { transform: translateX(3px); }

.post-related-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.post-related-list > li { display: flex; }

.post-related-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color .25s ease, box-shadow .25s ease, transform .25s ease;
}

.post-related-item:hover {
  border-color: color-mix(in oklch, var(--accent) 30%, var(--border));
  box-shadow: 0 18px 40px -12px color-mix(in oklch, var(--accent) 28%, transparent);
  transform: translateY(-4px);
}

.post-related-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Cover: featured image, or a generated gradient (hue varies per post). */
.post-related-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-2);
}

.post-related-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .5s cubic-bezier(.2, .8, .2, 1);
}

.post-related-item:hover .post-related-thumb img { transform: scale(1.05); }

.post-related-thumb.is-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.post-related-logo {
  display: inline-flex;
  opacity: .22;
  filter: grayscale(1);
  transition: opacity .25s ease;
}

.post-related-logo svg,
.post-related-logo img { height: 22px; width: auto; display: block; }

.post-related-item:hover .post-related-logo { opacity: .35; }

.post-related-read {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: oklch(1 0 0 / .82);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-dim);
}

.post-related-read svg { width: 11px; height: 11px; }

.post-related-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px 16px;
}

.post-related-cat {
  align-self: flex-start;
  padding: 2px 7px;
  border-radius: 4px;
  background: color-mix(in oklch, var(--accent) 9%, transparent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.post-related-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--fg);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color .15s ease;
}

.post-related-item:hover .post-related-name { color: var(--accent); }

.post-related-excerpt {
  font-size: 13px;
  line-height: 1.55;
  color: var(--fg-mute);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-related-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--fg-mute);
}

.post-related-arrow {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  color: var(--fg-dim);
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.post-related-arrow svg { width: 13px; height: 13px; transition: transform .2s ease; }

.post-related-item:hover .post-related-arrow {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.post-related-item:hover .post-related-arrow svg { transform: translateX(2px); }

@media (prefers-reduced-motion: reduce) {
  .post-related-item,
  .post-related-thumb img,
  .post-related-arrow svg { transition: none; }
  .post-related-item:hover { transform: none; }
}

@media (max-width: 720px) {
  .post-related { padding-bottom: 64px; }
  .post-related > .container { padding-top: 32px; }
}

/* Phones: compact horizontal rows. */
@media (max-width: 680px) {
  .post-related-list { grid-template-columns: 1fr; gap: 12px; }
  .post-related-item { flex-direction: row; }
  .post-related-thumb { flex-shrink: 0; width: 120px; aspect-ratio: auto; }
  .post-related-read { display: none; }
  .post-related-body { padding: 12px 14px; gap: 6px; }
  .post-related-excerpt { display: none; }
  .post-related-footer { padding-top: 8px; }
}

/* Core button blocks inside articles: match the theme's .btn styles (beats .post-content a). */
.post-content .wp-block-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 28px 0 0; }
.post-content .wp-block-button__link { display: inline-flex; align-items: center; padding: 12px 18px; border-radius: 8px; border: 1px solid transparent; font-size: 16px; font-weight: 600; text-decoration: none; background: linear-gradient(180deg, var(--accent), var(--accent-dim)); color: #fff; transition: filter .15s, transform .15s; }
.post-content .wp-block-button__link:hover { filter: brightness(1.08); transform: translateY(-1px); color: #fff; }
.post-content .is-style-outline .wp-block-button__link { background: transparent; color: var(--fg); border-color: var(--border-2); }
.post-content .is-style-outline .wp-block-button__link:hover { filter: none; border-color: var(--fg-mute); color: var(--fg); }

/* Wide tables scroll inside their own box instead of widening the whole post column. */
.post-content .wp-block-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 24px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.04);
}
/* Card-style table: no outer/vertical borders, soft header, row dividers only (overrides core block styles). */
.post-content .wp-block-table table { border: 0; margin: 0; }
.post-content .wp-block-table thead { border-bottom: 0; }
.post-content .wp-block-table th,
.post-content .wp-block-table td { border: 0; border-bottom: 1px solid var(--border); padding: 14px 18px; }
.post-content .wp-block-table th { background: var(--surface-2); font-size: 14px; }
.post-content .wp-block-table tbody tr:last-child td { border-bottom: 0; }
.post-content .wp-block-table td:first-child { color: var(--fg); font-weight: 600; }
@media (max-width: 600px) {
  .post-content table { font-size: 14px; }
  .post-content th, .post-content td, .post-content .wp-block-table th, .post-content .wp-block-table td { padding: 10px 12px; }
}
