/* ==========================================================================
   Component: Single post — header, featured image, table of contents,
   article typography, tables, quote, share bar and author box.
   JS: assets/js/components/toc.js
   ========================================================================== */

/* ---------- Header ---------- */
.post-header { padding-top: 8px; }

.post-header__title {
  margin: 0 0 16px;
  font-size: 2.6rem;
  line-height: 1.3;
}

.post-header .post-meta { margin-bottom: 24px; font-size: .82rem; }

/* Centered post top: breadcrumb, title, meta and featured image */
.post-top .breadcrumb { justify-content: center; }
.post-top .breadcrumb-item.active { flex: 0 1 auto; }
.post-header--center { text-align: center; }
.post-header--center .post-header__title { max-width: 920px; margin-left: auto; margin-right: auto; }
.post-header--center .post-meta { justify-content: center; }

/* ---------- Featured image ---------- */
.post-featured {
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
}
.post-featured img { display: block; width: 100%; height: auto; }
.post-featured figcaption {
  padding: 10px 2px 0;
  font-size: .78rem;
  color: var(--muted);
}

/* ---------- Table of contents ---------- */
.toc { padding: 20px; }

@media (min-width: 992px) {
  .toc {
    position: sticky;
    top: calc(var(--header-h) + 22px);
  }
}

.toc__title {
  margin: 0 0 14px;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.toc__list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.toc__list li { border-left: 2px solid var(--line); }

.toc__link {
  display: block;
  margin-left: -2px;
  padding: 6px 0 6px 14px;
  border-left: 2px solid transparent;
  font-size: .8rem;
  font-weight: 500;
  color: var(--muted);
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.toc__link:hover { color: var(--brand); }
.toc__link.is-active {
  border-left-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}

/* Mobile: TOC collapses into a native <details> */
.toc__toggle { list-style: none; cursor: pointer; }
.toc__toggle::-webkit-details-marker { display: none; }
.toc__toggle .toc__title { margin: 0; }
.toc details[open] .toc__toggle .toc__title { margin-bottom: 14px; }

@media (max-width: 991.98px) {
  .toc__toggle {
    position: relative;
    padding-right: 28px;
  }
  .toc__toggle::after {
    content: "";
    position: absolute;
    right: 4px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
    transform: translateY(-70%) rotate(45deg);
    transition: transform .25s var(--ease);
  }
  .toc details[open] .toc__toggle::after { transform: translateY(-30%) rotate(-135deg); }
}

@media (min-width: 992px) {
  .toc__toggle { pointer-events: none; }
}

/* ---------- Article body ---------- */
.post-content {
  font-size: 1.125rem;
  line-height: 1.85;
  color: var(--sub);
}
.post-content > section { scroll-margin-top: calc(var(--header-h) + 24px); }

.post-content h2 {
  position: relative;
  margin: 36px 0 14px;
  padding-left: 14px;
  font-size: 1.8rem;
  color: var(--ink);
}
.post-content h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 4px;
  height: 1.1em;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--brand), var(--c-ent));
  transform: translateY(-50%);
}
.post-content h3 { margin: 28px 0 10px; font-size: 1.5rem; color: var(--ink); }
.post-content p { margin: 0 0 16px; }
.post-content ul,
.post-content ol { margin: 0 0 18px; padding-left: 20px; }
.post-content li { margin-bottom: 8px; }
/* List bullets / numbers in the theme (category) colour */
.post-content li::marker { color: var(--c, var(--brand)); font-weight: 700; }
.post-content strong { color: var(--ink); }
.post-content a:not([class]) { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }

.post-highlight {
  margin: 0 0 20px;
  padding: 16px 20px;
  border-left: 4px solid var(--brand);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: color-mix(in srgb, var(--brand) 7%, transparent);
}

/* ---------- Tables ---------- */
.post-table-wrap {
  margin: 20px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.post-table {
  width: 100%;
  min-width: 560px;
  margin: 0;
  border-collapse: collapse;
  font-size: .86rem;
}
.post-table th {
  padding: 12px 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.post-table td {
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.post-table td:first-child { font-weight: 600; color: var(--ink); }
.post-table tr:nth-child(even) td { background: var(--mist); }

/* ---------- Quote ---------- */
.post-quote {
  margin: 20px 0;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--c-ent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-style: italic;
}
.post-quote p { margin: 0; }
.post-quote footer {
  margin-top: 10px;
  font-size: .8rem;
  font-style: normal;
  font-weight: 600;
  color: var(--ink);
}

/* ---------- Share bar ---------- */
.post-share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.post-share__label { margin-right: 4px; font-size: .82rem; font-weight: 600; color: var(--ink); }
.post-share a {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--mist);
  transition: background-color .25s var(--ease), border-color .25s var(--ease);
}
.post-share img { width: 15px; height: 15px; }
.post-share a:hover { border-color: var(--brand); background: var(--brand); }
.post-share a:hover img { filter: brightness(0) invert(1); }
:root[data-theme="dark"] .post-share img[src*="/x.svg"] { filter: invert(1); }

/* ---------- Author box ---------- */
.author-box {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-top: 28px;
  padding: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
  isolation: isolate;
}

/* Same doodle pattern as the footer, drawn in the text colour so it works in light + dark */
.author-box::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-color: var(--ink);
  -webkit-mask: url("../../images/footer-doodles.webp") center / 1200px auto repeat;
  mask: url("../../images/footer-doodles.webp") center / 1200px auto repeat;
  opacity: .07;
  pointer-events: none;
}

.author-box__avatar {
  flex: none;
  width: 90px;
  height: 90px;
  overflow: hidden;
  border: 3px solid color-mix(in srgb, var(--brand) 20%, transparent);
  border-radius: 50%;
}
.author-box__avatar img { display: block; width: 100%; height: 100%; }

.author-box__label {
  display: inline-block;
  margin-bottom: 4px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--brand);
}
.post-content .author-box__name { margin: 0 0 2px; padding-left: 0; font-size: 1.15rem; }
.post-content .author-box__name::before { display: none; }
.post-content .author-box__name a { color: var(--ink); text-decoration: none; }
.post-content .author-box__name a:hover { color: var(--brand); }
.author-box__role { margin: 0 0 10px; font-size: .8rem; font-weight: 600; color: var(--brand); }
.author-box__bio { margin: 0 0 14px; font-size: .86rem; line-height: 1.7; color: var(--sub); }

.author-box__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.author-box__actions .btn-pill { padding: 8px 18px; font-size: .82rem; }
.author-box .social-links a { width: 32px; height: 32px; background: var(--brand); }
.author-box .social-links .icon { width: 14px; height: 14px; }

@media (max-width: 575.98px) {
  .author-box { flex-direction: column; align-items: center; padding: 22px; text-align: center; }
  .author-box__actions { justify-content: center; }
}

/* Article list spacing must not leak into the author box */
.post-content .author-box ul { margin: 0; padding: 0; }
.post-content .author-box li { margin: 0; }

/* Post headings on phones: same hierarchy, scaled so long titles don't break awkwardly */
@media (max-width: 575.98px) {
  .post-header__title { font-size: 2rem; }
  .post-content h2 { font-size: 1.5rem; }
  .post-content h3 { font-size: 1.3rem; }
}
