/* =============================================================
   css/single-post.css — Bluworks Blog Post
   Loaded only on is_single() && post_type === 'post'

   Uses design tokens from style.css:
     --blu-primary, --blu-dark, --blu-soft, --blu-soft-2
     --ink, --ink-soft, --ink-mid, --ink-muted
     --line, --line-soft, --bg, --surface
     --font-display, --font-arabic
     --s-1 … --s-10, --r-1 … --r-full
     --shadow-md, --shadow-lg
     --maxw (1240px), --gutter (24px)
     --dur, --ease
   ============================================================= */


/* ── Layout constants ─────────────────────────────────────── */
:root {
  /* Article reading width — shared by header, cover and body */
  --sp-content: 800px;
}


/* ── Reading progress bar ───────────────────────────────────── */
.sp-progress {
  position: fixed;
  top: 0; left: 0; z-index: 500;
  height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--blu-primary, #1E50E5), var(--accent-blue, #4895FF));
  transition: width 60ms linear;
  pointer-events: none;
}


/* ── Article header ─────────────────────────────────────────── */
.sp-header {
  background: linear-gradient(175deg, var(--blu-soft, #EEF3FF) 0%, var(--bg, #FAFBFD) 100%);
  padding: clamp(48px, 6vw, 72px) var(--gutter, 24px) clamp(40px, 5vw, 56px);
  border-bottom: 1px solid var(--line, #E4E8F3);
}

.sp-header-inner {
  max-width: var(--maxw, 1240px);
  margin: 0 auto;
  padding: 0 var(--gutter, 24px);
  box-sizing: border-box;
}

/* Breadcrumb */
.sp-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: 13px;
  color: var(--ink-muted, #6B7088);
  margin-bottom: var(--s-5, 20px);
}
.sp-breadcrumb a {
  color: var(--ink-mid, #4B5068);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--dur, 220ms) var(--ease);
}
.sp-breadcrumb a:hover { color: var(--blu-primary, #1E50E5); }
.sp-bc-sep { color: var(--line, #E4E8F3); }

/* Category pill — matches .po-pill from overview exactly */
.sp-cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg, #FAFBFD);
  border: 1px solid var(--line, #E4E8F3);
  border-radius: var(--r-full, 999px);
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-mid, #4B5068);
  line-height: 1;
  white-space: nowrap;
  margin-bottom: var(--s-4, 16px);
}

/* H1 — constrained to article column width (stops where TOC begins) */
.sp-title {
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: clamp(26px, 3.5vw, 42px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink, #0A0F1E);
  margin: 0 0 var(--s-5, 20px);
  max-width: calc(var(--maxw, 1240px) - var(--gutter, 24px) * 2 - 64px - 236px); /* 892px */
}

html[dir="rtl"] .sp-title {
  font-family: var(--font-arabic, 'Noto Sans Arabic', sans-serif);
  letter-spacing: 0;
  line-height: 1.25;
}

/* Meta row */
.sp-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: 14px;
  color: var(--ink-mid, #4B5068);
}
.sp-meta-dot { color: var(--line, #E4E8F3); }
.sp-author { display: flex; align-items: center; gap: 8px; }
.sp-author-avatar {
  width: 34px; height: 34px; border-radius: 50%; overflow: hidden;
  background: var(--blu-primary, #1E50E5);
  flex-shrink: 0;
}
.sp-author-avatar img,
.sp-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-author-name { font-weight: 600; color: var(--ink, #0A0F1E); }
.sp-read-time { display: flex; align-items: center; gap: 5px; }
.sp-read-time svg { width: 14px; height: 14px; flex-shrink: 0; }


/* ── Cover image ────────────────────────────────────────────── */
.sp-cover-wrap {
  max-width: var(--sp-content);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 40px) var(--gutter, 24px) 0;
}
.sp-cover {
  width: 100%; aspect-ratio: 16/9;
  border-radius: var(--r-4, 16px); overflow: hidden;
  border: 1px solid var(--line, #E4E8F3);
  background: var(--line-soft, #F0F3F9);
}
.sp-cover img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}


/* ── Page body — two-column grid ────────────────────────────── */
.sp-body {
  max-width: var(--maxw, 1240px);
  margin: 0 auto;
  padding: clamp(40px, 5vw, 64px) var(--gutter, 24px) clamp(64px, 8vw, 96px);
  display: grid;
  grid-template-columns: 1fr 236px;
  gap: 64px;
  align-items: start;
  box-sizing: border-box;
}


/* ── Sidebar — TOC only ─────────────────────────────────────── */
.sp-sidebar { position: sticky; top: 80px; }

.sp-toc {
  background: var(--bg, #FAFBFD);
  border: 1px solid var(--line, #E4E8F3);
  border-radius: var(--r-3, 12px);
  padding: var(--s-5, 20px);
}

.sp-toc-label {
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted, #6B7088);
  margin-bottom: 14px;
}

.sp-toc-items { display: flex; flex-direction: column; gap: 1px; }

/* TOC link — built by JS */
.sp-toc-a {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 7px 10px; border-radius: 8px;
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: 13px; font-weight: 500;
  color: var(--ink-mid, #4B5068);
  text-decoration: none; line-height: 1.4;
  transition: all var(--dur, 220ms) var(--ease);
}
.sp-toc-a:hover { background: rgba(0,0,0,.04); color: var(--ink, #0A0F1E); }
.sp-toc-a.on  { background: var(--blu-soft, #EEF3FF); color: var(--blu-primary, #1E50E5); font-weight: 600; }

/* Number label inside TOC link */
.sp-toc-n {
  font-size: 10px; font-weight: 700;
  color: rgba(0,0,0,.18); flex-shrink: 0; margin-top: 2px;
  min-width: 14px;
}
.sp-toc-a.on .sp-toc-n { color: rgba(30,80,229,.3); }


/* ── Article body typography ────────────────────────────────── */
.sp-entry {
  /* Reading width matches header */
  max-width: var(--sp-content);
  min-width: 0;
}

/* Lead paragraph */
.sp-entry .sp-lead,
.sp-entry > p:first-child:not(.wp-block-paragraph) {
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.65;
  color: var(--ink, #0A0F1E);
  padding-bottom: var(--s-7, 40px);
  margin-bottom: var(--s-7, 40px);
  border-bottom: 1px solid var(--line, #E4E8F3);
}

/* ── H2 — auto-numbered blue badges via CSS counters ─────────
   Writers add class "no-number" via Gutenberg > Advanced >
   Additional CSS Class to skip numbering (e.g. on FAQ headings).
   ──────────────────────────────────────────────────────────── */
.sp-entry {
  counter-reset: sp-h2-counter;
}

.sp-entry h2 {
  counter-increment: sp-h2-counter;
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: clamp(20px, 2.4vw, 26px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink, #0A0F1E);
  margin: clamp(40px, 5vw, 60px) 0 var(--s-4, 16px);
  scroll-margin-top: 88px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Blue number badge */
.sp-entry h2:not(.no-number)::before {
  content: counter(sp-h2-counter, decimal-leading-zero);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: var(--r-2, 8px);
  background: var(--blu-primary, #1E50E5);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 10px rgba(30, 80, 229, 0.28);
  font-style: normal;
}

/* Plain h2 (FAQ, Conclusion, etc.) — no counter, no badge */
.sp-entry h2.no-number {
  counter-increment: none;
  display: block;
}

/* H3 */
.sp-entry h3 {
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: var(--t-h3, 20px);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink, #0A0F1E);
  margin: var(--s-8, 56px) 0 var(--s-3, 12px);
  scroll-margin-top: 88px;
}

/* Paragraphs */
.sp-entry p {
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: var(--t-body, 16px);
  line-height: 1.8;
  color: var(--ink-soft, #2D3247);
  margin-bottom: var(--s-5, 20px);
}

/* Lists */
.sp-entry ul,
.sp-entry ol {
  margin: 0 0 var(--s-5, 20px);
  padding-left: 0;
  list-style: none;
}
.sp-entry li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: var(--t-body, 16px);
  line-height: 1.72;
  color: var(--ink-soft, #2D3247);
  margin-bottom: var(--s-2, 8px);
}
.sp-entry li::before {
  content: '';
  flex-shrink: 0;
  margin-top: 10px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--blu-primary, #1E50E5);
}
.sp-entry ol { counter-reset: ol-counter; }
.sp-entry ol li { counter-increment: ol-counter; }
.sp-entry ol li::before {
  content: counter(ol-counter) '.';
  background: none;
  width: auto; height: auto;
  border-radius: 0;
  font-weight: 700;
  color: var(--blu-primary, #1E50E5);
  font-size: 14px;
  margin-top: 0;
}

/* Strong / em */
.sp-entry strong { font-weight: 700; color: var(--ink, #0A0F1E); }
.sp-entry em { font-style: italic; }

/* Links */
.sp-entry a {
  color: var(--blu-primary, #1E50E5);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1.5px solid rgba(30, 80, 229, .25);
  transition: border-color var(--dur, 220ms) var(--ease);
}
.sp-entry a:hover { border-color: var(--blu-primary, #1E50E5); }

/* Images */
.sp-entry img,
.sp-entry figure img {
  border-radius: var(--r-3, 12px);
  border: 1px solid var(--line, #E4E8F3);
  max-width: 100%; height: auto;
}
.sp-entry figure { margin: var(--s-5, 20px) 0 var(--s-6, 28px); }
.sp-entry figcaption {
  font-size: 13px; color: var(--ink-muted, #6B7088);
  text-align: center; margin-top: var(--s-2, 8px);
}

/* RTL */
html[dir="rtl"] .sp-entry p,
html[dir="rtl"] .sp-entry li,
html[dir="rtl"] .sp-entry h2,
html[dir="rtl"] .sp-entry h3 {
  font-family: var(--font-arabic, 'Noto Sans Arabic', sans-serif);
}


/* ── Tags ───────────────────────────────────────────────────── */
.sp-tags {
  display: flex; flex-wrap: wrap; gap: var(--s-2, 8px);
  margin: clamp(32px, 4vw, 48px) 0 var(--s-6, 28px);
}
.sp-tag {
  display: inline-block;
  padding: 5px 13px;
  border-radius: var(--r-full, 999px);
  background: var(--blu-soft, #EEF3FF);
  border: 1px solid transparent;
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: 12px; font-weight: 600;
  color: var(--blu-primary, #1E50E5);
  text-decoration: none;
  transition: all var(--dur, 220ms) var(--ease);
}
.sp-tag:hover {
  background: var(--blu-primary, #1E50E5);
  border-color: var(--blu-primary, #1E50E5);
  color: #fff;
}


/* ── Share ──────────────────────────────────────────────────── */
.sp-share {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 14px;
  padding: var(--s-6, 28px) 0;
  border-top: 1px solid var(--line, #E4E8F3);
  margin-top: clamp(32px, 4vw, 48px);
}
.sp-share-label {
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-muted, #6B7088);
}
.sp-share-btns { display: flex; gap: var(--s-2, 8px); }
.sp-share-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--blu-soft, #EEF3FF);
  border: 1px solid transparent;
  color: var(--blu-primary, #1E50E5);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  transition: all var(--dur, 220ms) var(--ease);
}
.sp-share-btn:hover {
  background: var(--blu-primary, #1E50E5);
  border-color: var(--blu-primary, #1E50E5);
  color: #fff;
  transform: scale(1.1);
}
.sp-share-btn svg { width: 16px; height: 16px; flex-shrink: 0; }


/* ── Related posts ──────────────────────────────────────────── */
.sp-related {
  background: var(--bg, #FAFBFD);
  border-top: 1px solid var(--line, #E4E8F3);
  padding: clamp(56px, 7vw, 80px) var(--gutter, 24px);
}
.sp-related-inner {
  max-width: var(--maxw, 1240px);
  margin: 0 auto;
  box-sizing: border-box;
}
.sp-related-head {
  display: flex; align-items: baseline;
  justify-content: space-between; gap: 20px;
  margin-bottom: var(--s-7, 40px);
}
.sp-related-head h2 {
  /* Override the global h2 counter rule — related heading is standalone */
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink, #0A0F1E);
  counter-increment: none !important;
  display: block !important;
}
.sp-related-head h2::before { display: none !important; }

.sp-related-see {
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: 14px; font-weight: 600;
  color: var(--blu-primary, #1E50E5);
  text-decoration: none; white-space: nowrap;
  flex-shrink: 0;
}
.sp-related-see:hover { text-decoration: underline; }

.sp-related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-5, 20px);
}

/* Related card */
.sp-related-card {
  background: var(--surface, #FFFFFF);
  border: 1px solid var(--line, #E4E8F3);
  border-radius: var(--r-4, 16px);
  overflow: hidden;
  text-decoration: none;
  display: flex; flex-direction: column;
  transition: transform var(--dur, 220ms) var(--ease),
              box-shadow var(--dur, 220ms) var(--ease);
}
.sp-related-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md, 0 4px 14px rgba(10,15,30,.08));
}
.sp-rc-cover {
  aspect-ratio: 16/9; overflow: hidden;
  background: var(--line-soft, #F0F3F9);
  display: flex; align-items: center; justify-content: center;
}
.sp-rc-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-rc-placeholder { font-size: 28px; }
.sp-rc-body { padding: var(--s-5, 20px); flex: 1; display: flex; flex-direction: column; gap: var(--s-2, 8px); }
.sp-rc-cat {
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--blu-primary, #1E50E5);
}
.sp-rc-title {
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em; line-height: 1.3;
  color: var(--ink, #0A0F1E);
}
.sp-rc-excerpt {
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: 13px; line-height: 1.55;
  color: var(--ink-mid, #4B5068);
  flex: 1;
}
.sp-rc-meta {
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif);
  font-size: 12px; color: var(--ink-muted, #6B7088);
  margin-top: auto;
}


/* ── Kadence default content reset ─────────────────────────── */
.sp-entry .entry-content { all: unset; display: block; }


/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .sp-progress  { transition: none; }
  .sp-toc-a,
  .sp-share-btn,
  .sp-related-card,
  .sp-tag { transition: none; }
  .sp-related-card:hover { transform: none; }
  .sp-share-btn:hover   { transform: none; }
}


/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1020px) {
  .sp-body {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .sp-sidebar { display: none; }
  .sp-entry   { max-width: 100%; }
}

@media (max-width: 720px) {
  .sp-related-grid { grid-template-columns: 1fr; }
  .sp-title { font-size: clamp(22px, 6vw, 32px); }
}

@media (max-width: 480px) {
  .sp-related-grid { grid-template-columns: 1fr; }
  .sp-header { padding-left: 18px; padding-right: 18px; }
  .sp-cover-wrap { padding-left: 18px; padding-right: 18px; }
  .sp-body   { padding-left: 18px; padding-right: 18px; }
  .sp-related { padding-left: 18px; padding-right: 18px; }
}


/* ── FAQ Accordion ──────────────────────────────────────────── */
.sp-entry details.wp-block-details,
.sp-entry .sp-faq-item {
  border: 1px solid var(--line, #E4E8F3);
  border-radius: 10px;
  margin: 8px 0;
  overflow: hidden;
  background: var(--surface, #fff);
  transition: border-color var(--dur, 220ms) var(--ease);
}

.sp-entry details.wp-block-details[open],
.sp-entry .sp-faq-item[open] {
  border-color: rgba(30, 80, 229, 0.25);
}

/* Summary row */
.sp-entry details.wp-block-details summary,
.sp-entry .sp-faq-item summary {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
  padding: 18px 22px !important;
  font-family: var(--font-display, 'Neue Haas Grotesk Display', sans-serif) !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  line-height: 1.35 !important;
  color: var(--ink, #0A0F1E) !important;
  cursor: pointer !important;
  list-style: none !important;
  user-select: none;
  transition: background var(--dur, 220ms) var(--ease),
              color    var(--dur, 220ms) var(--ease);
}

/* Remove browser default triangle markers */
.sp-entry details summary::-webkit-details-marker { display: none !important; }
.sp-entry details summary::marker              { display: none !important; font-size: 0; }

/* Chevron icon via ::after */
.sp-entry details summary::after {
  content: '';
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%234B5068' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transition: transform var(--dur, 220ms) var(--ease);
}

.sp-entry details[open] summary::after {
  transform: rotate(180deg);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%231E50E5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.sp-entry details summary:hover {
  background: var(--blu-soft, #EEF3FF) !important;
  color: var(--blu-primary, #1E50E5) !important;
}

.sp-entry details[open] summary {
  color: var(--blu-primary, #1E50E5) !important;
}

/* Body wrapper — created + animated by JS */
.sp-faq-body {
  overflow: hidden;
  transition: height  300ms cubic-bezier(0.2, 0.8, 0.2, 1),
              opacity 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Content inside the body */
.sp-faq-body > *:first-child { margin-top: 0 !important; }
.sp-faq-body > *:last-child  { margin-bottom: 0 !important; }

.sp-entry details .sp-faq-body p,
.sp-entry details .sp-faq-body li,
.sp-entry details .sp-faq-body > * {
  padding-left: 22px;
  padding-right: 22px;
  padding-bottom: 18px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-mid, #4B5068);
}

.sp-entry details .sp-faq-body p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .sp-entry details.wp-block-details,
  .sp-entry .sp-faq-item,
  .sp-faq-body,
  .sp-entry details summary,
  .sp-entry details summary::after { transition: none !important; }
}
/* ── Arabic RTL font override (auto) ────────────────────────────── */
html[dir="rtl"] .sp-breadcrumb,
html[dir="rtl"] .sp-cat-pill,
html[dir="rtl"] .sp-meta,
html[dir="rtl"] .sp-toc-label,
html[dir="rtl"] .sp-toc-a,
html[dir="rtl"] .sp-entry .sp-lead,
html[dir="rtl"] .sp-entry > p:first-child:not(.wp-block-paragraph),
html[dir="rtl"] .sp-tag,
html[dir="rtl"] .sp-share-label,
html[dir="rtl"] .sp-related-head h2,
html[dir="rtl"] .sp-related-see,
html[dir="rtl"] .sp-rc-cat,
html[dir="rtl"] .sp-rc-title,
html[dir="rtl"] .sp-rc-excerpt,
html[dir="rtl"] .sp-rc-meta,
html[dir="rtl"] .sp-entry details.wp-block-details summary,
html[dir="rtl"] .sp-entry .sp-faq-item summary {
  font-family: 'Noto Sans Arabic', 'Segoe UI', sans-serif !important;
}