/* assets/css/blog-detail.css - article page (blog-detail.php). Uses variables from index.css. */

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.bd-article a:focus-visible, .bd-aside a:focus-visible, .bd-header a:focus-visible,
.bd-pager a:focus-visible, .bd-related a:focus-visible, .bd-share-btn:focus-visible,
.bd-top:focus-visible, .bd-toc summary:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ── READING PROGRESS ── */
.bd-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 400; background: transparent; pointer-events: none; }
.bd-progress span { display: block; height: 100%; width: 100%; background: var(--primary-color); transform: scaleX(0); transform-origin: 0 50%; transition: transform 0.1s linear; }

/* ── HEADER ── */
.bd-header {
  background: var(--bg-light);
  padding: 2.5rem 24px 4.5rem;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}
.bd-header-inner { max-width: 820px; margin: 0 auto; }
.breadcrumbs ol {
  list-style: none; margin: 0 0 1.5rem; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem;
  font-size: 13px; color: var(--text-muted);
}
.breadcrumbs li + li::before { content: "›"; margin-right: 0.4rem; }
.breadcrumbs a { color: var(--text-light); text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary-color); text-decoration: underline; }
.bd-category {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--primary-color); background: var(--primary-light);
  padding: 6px 14px; border-radius: 20px; margin-bottom: 1.25rem;
  border: 1px solid var(--primary-border); text-decoration: none;
}
.bd-category:hover { background: var(--primary-color); color: #fff; }
.bd-title {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 700; line-height: 1.25;
  color: var(--dark-color);
  margin: 0 0 1.5rem;
}
.bd-meta {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 0.6rem 1rem; font-size: 13.5px; color: var(--text-muted);
}
.bd-author { display: inline-flex; align-items: center; gap: 10px; color: var(--dark-color); font-weight: 600; }
.bd-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #d4956a, var(--primary-color));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
}

/* ── FEATURE IMAGE ── */
.bd-feature { max-width: 1000px; margin: -3rem auto 3rem; padding: 0 24px; position: relative; }
.bd-feature img {
  display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; object-fit: cover;
  border-radius: 14px; box-shadow: 0 15px 35px rgba(0,0,0,0.1); background: #f9f5f2;
}

/* ── LAYOUT ── */
.bd-layout {
  max-width: 1140px; margin: 0 auto; padding: 0 24px 3rem;
  display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 4rem; align-items: start;
}
.bd-layout.no-toc .bd-aside { /* still shows the CTA */ }
.bd-header + .bd-layout { padding-top: 3rem; }

/* ── ARTICLE BODY ── */
.bd-article { max-width: 760px; font-size: 17px; line-height: 1.9; color: var(--text-light); }
.bd-lead { font-size: 1.2rem; line-height: 1.7; color: var(--dark-color); font-weight: 600; margin: 0 0 2rem; }
.bd-content p { margin: 0 0 1.75rem; }
.bd-content h2 {
  font-family: var(--font-heading); font-size: 1.8rem; line-height: 1.3;
  color: var(--dark-color); margin: 2.5rem 0 1rem; scroll-margin-top: 100px;
}
.bd-content h3 {
  font-family: var(--font-heading); font-size: 1.4rem; line-height: 1.35;
  color: var(--dark-color); margin: 2rem 0 0.75rem; scroll-margin-top: 100px;
}
.bd-content h4 { font-size: 1.1rem; color: var(--dark-color); margin: 1.5rem 0 0.5rem; }
.bd-content ul, .bd-content ol { margin: 0 0 1.75rem; padding-left: 1.5rem; }
.bd-content li { margin-bottom: 0.5rem; }
.bd-content a { color: var(--primary-color); text-decoration: underline; text-underline-offset: 2px; }
.bd-content a:hover { color: var(--primary-hover); }
.bd-content img { max-width: 100%; height: auto; border-radius: 10px; display: block; margin: 1.5rem auto; }
.bd-content figure { margin: 2rem 0; }
.bd-content figcaption { font-size: 13px; color: var(--text-muted); text-align: center; margin-top: 0.5rem; }
.bd-content blockquote {
  border-left: 4px solid var(--primary-color); background: var(--bg-light);
  padding: 1.25rem 1.5rem; margin: 2rem 0; border-radius: 0 8px 8px 0;
  font-style: italic; color: var(--dark-color); font-size: 1.1rem;
}
.bd-content blockquote p:last-child { margin-bottom: 0; }
.bd-content table { display: block; overflow-x: auto; border-collapse: collapse; margin: 0 0 1.75rem; font-size: 15px; }
.bd-content th, .bd-content td { border: 1px solid var(--border-color); padding: 0.6rem 0.9rem; text-align: left; }
.bd-content th { background: var(--bg-light); color: var(--dark-color); }
.bd-content hr { border: 0; border-top: 1px solid var(--border-color); margin: 2.5rem 0; }

/* ── SHARE / BACK ── */
.bd-actions {
  display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color);
  padding: 1.5rem 0; margin-top: 3rem; font-size: 14px;
}
.bd-back { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--primary-color); text-decoration: none; transition: transform 0.2s; }
.bd-back:hover { transform: translateX(-3px); }
.bd-share { display: flex; align-items: center; gap: 10px; }
.bd-share-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.bd-share-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border-color);
  background: #fff; color: var(--dark-color); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s; text-decoration: none; font-size: 14px; padding: 0;
}
.bd-share-btn:hover { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.bd-share-btn[hidden] { display: none; }

/* ── SOURCES ── */
.bd-sources { margin-top: 2.5rem; font-size: 14px; line-height: 1.7; }
.bd-sources h2 { font-family: var(--font-heading); font-size: 1.2rem; color: var(--dark-color); margin: 0 0 0.75rem; }
.bd-sources ol { margin: 0; padding-left: 1.25rem; }
.bd-sources li { margin-bottom: 0.4rem; overflow-wrap: anywhere; }
.bd-sources cite { font-style: normal; font-weight: 700; }
.bd-sources a { color: var(--primary-color); text-decoration: underline; text-underline-offset: 2px; }
.bd-source-host { color: var(--text-muted); font-size: 13px; margin-left: 0.4rem; }

/* ── ASIDE: TOC + CTA ── */
.bd-aside { position: sticky; top: 100px; display: flex; flex-direction: column; gap: 1.5rem; }
.bd-toc { border: 1px solid var(--border-color); border-radius: 12px; padding: 1rem 1.25rem; background: #fff; }
.bd-toc summary {
  cursor: pointer; font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-muted); list-style: none;
}
.bd-toc summary::-webkit-details-marker { display: none; }
.bd-toc summary::after { content: "+"; float: right; font-size: 16px; line-height: 1; }
.bd-toc[open] summary::after { content: "–"; }
.bd-toc ol { list-style: none; margin: 0.9rem 0 0; padding: 0; max-height: 55vh; overflow-y: auto; }
.bd-toc li { margin: 0; }
.bd-toc li.lvl-3 { padding-left: 0.9rem; }
.bd-toc a {
  display: block; padding: 0.4rem 0 0.4rem 0.75rem; border-left: 2px solid var(--border-color);
  font-size: 13.5px; line-height: 1.4; color: var(--text-light); text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}
.bd-toc a:hover { color: var(--primary-color); }
.bd-toc a[aria-current="true"] { color: var(--primary-color); border-left-color: var(--primary-color); font-weight: 700; }

.bd-cta { background: var(--dark-color); color: #fff; border-radius: 12px; padding: 1.5rem; }
.bd-cta-title { font-family: var(--font-heading); font-size: 1.2rem; font-style: italic; margin: 0 0 0.4rem; }
.bd-cta p { font-size: 13px; line-height: 1.6; color: rgba(255,255,255,0.7); margin: 0 0 1rem; }
.bd-cta .bd-cta-title { color: #fff; }
.bd-cta-btn {
  display: inline-block; background: var(--primary-color); color: #fff; text-decoration: none;
  font-size: 13px; font-weight: 700; padding: 0.7rem 1.2rem; border-radius: 8px; transition: background 0.2s;
}
.bd-cta-btn:hover { background: var(--primary-hover); }

/* ── PREV / NEXT ── */
.bd-pager {
  max-width: 1140px; margin: 0 auto 3rem; padding: 0 24px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
.bd-pager-link {
  display: block; border: 1px solid var(--border-color); border-radius: 12px; padding: 1.1rem 1.3rem;
  text-decoration: none; color: var(--dark-color); font-family: var(--font-heading); font-weight: 700; line-height: 1.35;
  transition: border-color 0.2s, transform 0.2s;
}
.bd-pager-link span {
  display: block; font-family: var(--font-primary); font-size: 11px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 0.35rem;
}
.bd-pager-link.next { text-align: right; grid-column: 2; }
.bd-pager-link:hover { border-color: var(--primary-color); color: var(--primary-color); transform: translateY(-2px); }

/* ── RELATED ── */
.bd-related { background: var(--bg-light); border-top: 1px solid var(--border-color); padding: 3.5rem 24px 4rem; }
.bd-related h2 { max-width: 1140px; margin: 0 auto 1.75rem; font-family: var(--font-heading); font-size: 1.7rem; color: var(--dark-color); }
.bd-related-grid { max-width: 1140px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.75rem; }
.bd-card { background: #fff; border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; }
.bd-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.bd-card-img { display: block; aspect-ratio: 4 / 3; background: #f9f5f2; overflow: hidden; }
.bd-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.5s ease; }
.bd-card:hover .bd-card-img img { transform: scale(1.05); }
.bd-card-body { padding: 1.1rem 1.25rem 1.3rem; }
.bd-card-cat { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--primary-color); margin-bottom: 0.4rem; }
.bd-card h3 { font-family: var(--font-heading); font-size: 1.1rem; line-height: 1.35; margin: 0 0 0.5rem; }
.bd-card h3 a { color: var(--dark-color); text-decoration: none; }
.bd-card h3 a:hover { color: var(--primary-color); }
.bd-card time { font-size: 12px; color: var(--text-muted); }

/* ── FLOATING UI ── */
.bd-top {
  position: fixed; right: 22px; bottom: 24px; z-index: 900; width: 44px; height: 44px; border-radius: 50%;
  border: none; background: var(--primary-color); color: #fff; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  display: flex; align-items: center; justify-content: center; transition: background 0.2s, transform 0.2s;
}
.bd-top[hidden] { display: none; }
.bd-top:hover { background: var(--primary-hover); transform: translateY(-2px); }
.bd-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); z-index: 1100;
  background: var(--dark-color); color: #fff; font-size: 13px; padding: 0.7rem 1.2rem; border-radius: 24px;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
}
.bd-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── ERROR STATE ── */
.bd-error { max-width: 600px; margin: 0 auto; padding: 6rem 24px; text-align: center; }
.bd-error h1 { font-family: var(--font-heading); font-size: 2rem; color: var(--dark-color); margin: 0 0 0.75rem; }
.bd-error p { color: var(--text-light); margin: 0 0 1.5rem; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .bd-header { padding: 2rem 20px 4rem; }
  .bd-layout { grid-template-columns: minmax(0, 1fr); gap: 2rem; padding: 0 20px 2rem; }
  .bd-aside { position: static; order: -1; }          /* TOC above the article on mobile */
  .bd-layout.no-toc .bd-aside { order: 2; }           /* CTA only: put it after the article */
  .bd-feature { padding: 0 16px; }
  .bd-article { font-size: 16px; }
  .bd-related-grid { grid-template-columns: 1fr; }
  .bd-pager { grid-template-columns: 1fr; }
  .bd-pager-link.next { grid-column: auto; }
  .bd-actions { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .bd-progress span, .bd-card, .bd-card-img img, .bd-back, .bd-pager-link, .bd-toast { transition: none; }
}