/* elegance/blog-post.css — post detail page in the "elegance" design language.
   Big centered editorial hero, reading column with sticky TOC on the right and
   a share rail on the left. White surfaces, hairlines, almost no shadows. */

/* ---------------------------------------------------------------- hero */

.elg-post-hero {
  font-family: var(--elg-font);
  background: var(--elg-bg);
  text-align: center;
  padding: 3.25rem 1rem 1.5rem;
}

.elg-post-title {
  margin: 0 auto 1.1rem;
  max-width: 60rem;
  font-size: clamp(2.1rem, 5.2vw, 3.4rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.025em;
  color: var(--elg-ink);
  overflow-wrap: break-word;
}

.elg-post-subtitle {
  margin: 0 auto 1.75rem;
  max-width: 46rem;
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  line-height: 1.55;
  color: var(--elg-muted);
}

/* author row: avatar · name · date · read-time pill */
.elg-author-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin-bottom: 1.4rem;
  color: var(--elg-muted);
  font-size: 0.95rem;
}

.elg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.elg-author-name {
  color: var(--elg-ink);
  font-weight: 600;
}

.elg-meta-dot {
  color: var(--elg-line-strong);
  user-select: none;
}

.elg-read-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  border-radius: var(--elg-radius-pill);
  background: var(--elg-accent-soft);
  color: var(--elg-accent-ink);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.elg-read-pill i {
  font-size: 0.8em;
}

/* tag pills with colored dots; pastel palette cycles by position */
.elg-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 auto;
  max-width: 46rem;
  padding: 0;
  list-style: none;
}

.elg-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.85rem;
  border-radius: var(--elg-radius-pill);
  font-size: 0.83rem;
  font-weight: 600;
  text-decoration: none;
  background: var(--elg-tag-blue-bg);
  color: var(--elg-tag-blue-fg);
}

.elg-tag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.elg-tags > li:nth-child(5n + 2) .elg-tag {
  background: var(--elg-tag-sky-bg);
  color: var(--elg-tag-sky-fg);
}

.elg-tags > li:nth-child(5n + 3) .elg-tag {
  background: var(--elg-tag-indigo-bg);
  color: var(--elg-tag-indigo-fg);
}

.elg-tags > li:nth-child(5n + 4) .elg-tag {
  background: var(--elg-tag-green-bg);
  color: var(--elg-tag-green-fg);
}

.elg-tags > li:nth-child(5n) .elg-tag {
  background: var(--elg-tag-purple-bg);
  color: var(--elg-tag-purple-fg);
}

a.elg-tag:hover,
a.elg-tag:focus-visible {
  text-decoration: underline;
}

/* optional cover image below the hero */
.elg-post-cover-wrap {
  max-width: 62rem;
  margin: 1.9rem auto 0;
  padding: 0 1rem;
}

.elg-post-cover {
  width: 100%;
  border-radius: var(--elg-radius);
  border: 1px solid var(--elg-line);
  object-fit: cover;
}

/* ------------------------------------------------------------- layout */

.elg-post-layout {
  font-family: var(--elg-font);
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) 15rem;
  gap: 2.75rem;
  max-width: 75rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 3rem;
}

/* left share rail */
.elg-share-rail {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  position: sticky;
  top: 110px;
  align-self: start;
}

.elg-share-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--elg-faint);
  text-align: center;
  margin-bottom: 0.1rem;
}

.elg-share-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--elg-line-strong);
  background: var(--elg-bg);
  color: var(--elg-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.elg-share-btn:hover,
.elg-share-btn:focus-visible {
  color: var(--elg-accent-ink);
  border-color: var(--elg-accent);
}

/* right sticky table of contents */
.elg-toc-sidebar {
  position: sticky;
  top: 110px;
  align-self: start;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding-left: 0.25rem;
}

.elg-toc-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--elg-faint);
  margin-bottom: 0.85rem;
}

.elg-toc-head i {
  font-size: 0.8rem;
}

/* the server renders .toc > .toc-title + .toc-list; we supply our own head */
.elg-toc-sidebar .toc-title {
  display: none;
}

.elg-toc-sidebar .toc-list,
.elg-toc-sidebar .toc-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.elg-toc-sidebar .toc-list ul {
  margin-left: 0.85rem;
}

.elg-toc-sidebar .toc-list a {
  display: block;
  padding: 0.32rem 0 0.32rem 0.85rem;
  border-left: 2px solid transparent;
  color: var(--elg-muted);
  font-size: 0.88rem;
  line-height: 1.4;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.elg-toc-sidebar .toc-list a:hover,
.elg-toc-sidebar .toc-list a:focus-visible {
  color: var(--elg-ink);
}

.elg-toc-sidebar .toc-list a.toc-active {
  border-left-color: var(--elg-accent);
  color: var(--elg-ink);
  font-weight: 600;
}

/* ------------------------------------------------------- reading column */

.post-body {
  max-width: 44rem;               /* ≈70ch at 18px */
  margin: 0 auto;
  font-size: 1.155rem;            /* ~18.5px */
  line-height: 1.75;
  color: var(--elg-text);
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

.post-body > :first-child {
  margin-top: 0;
}

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4 {
  color: var(--elg-ink);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 2.2em 0 0.7em;
}

.post-body h1 { font-size: 1.9rem; }
.post-body h2 { font-size: 1.6rem; }
.post-body h3 { font-size: 1.3rem; }
.post-body h4 { font-size: 1.12rem; }

.post-body h2[id],
.post-body h3[id],
.post-body h4[id] {
  scroll-margin-top: 96px;
}

.post-body p {
  margin: 0 0 1.25em;
}

.post-body a {
  color: var(--elg-accent-ink);
  text-decoration: underline;
  text-decoration-color: rgba(37, 99, 235, 0.35);
  text-underline-offset: 3px;
}

.post-body a:hover {
  text-decoration-color: currentColor;
}

.post-body ul,
.post-body ol {
  margin: 0 0 1.25em;
  padding-left: 1.4em;
}

.post-body li {
  margin-bottom: 0.4em;
}

.post-body blockquote {
  margin: 1.75em 0;
  padding: 0.35em 0 0.35em 1.25em;
  border-left: 3px solid var(--elg-accent);
  color: var(--elg-muted);
  font-style: italic;
}

.post-body blockquote p:last-child {
  margin-bottom: 0;
}

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--elg-radius);
  border: 1px solid var(--elg-line);
  margin: 1.5em 0;
}

.post-body hr {
  border: 0;
  border-top: 1px solid var(--elg-line);
  margin: 2.5em 0;
}

/* code — Prism (tomorrow theme) recolors highlighted blocks; the base style
   below also covers markdown blocks whose language class was sanitized away */
.post-body pre {
  background: #2d2d2d; /* same ground as the Prism "tomorrow" theme */
  color: #ccc;
  padding: 1em 1.2em;
  border-radius: var(--elg-radius);
  margin: 1.6em 0;
  font-size: 0.9rem;
  line-height: 1.6;
  overflow-x: auto;
}

.post-body :not(pre) > code {
  background: var(--elg-bg-soft);
  border: 1px solid var(--elg-line);
  border-radius: 6px;
  padding: 0.12em 0.4em;
  font-size: 0.86em;
  color: #b03060;
  overflow-wrap: break-word;
}

/* tables scroll inside their own box, never the page */
.post-body table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: 0.95rem;
}

.post-body th,
.post-body td {
  border: 1px solid var(--elg-line);
  padding: 0.55em 0.8em;
  text-align: left;
}

.post-body th {
  background: var(--elg-bg-soft);
  color: var(--elg-ink);
  font-weight: 600;
}

/* ------------------------------------------------------------ quote */

.elg-quote-section {
  font-family: var(--elg-font);
  border: 1px solid var(--elg-line);
  border-radius: var(--elg-radius);
  background: var(--elg-bg-soft);
  padding: 2.5rem 1.5rem;
  max-width: 50rem;
  margin: 1.5rem auto 0;
}

.elg-quote-section .post-quote {
  max-width: 44rem;
  margin: 0 auto;
  text-align: center;
}

.elg-quote-section .post-quote-mark {
  display: block;
  font-size: 3rem;
  line-height: 1;
  color: var(--elg-accent);
  font-family: Georgia, "Times New Roman", serif;
}

.elg-quote-section .post-quote-text {
  margin: 0.5rem 0 1rem;
  font-size: 1.3rem;
  line-height: 1.55;
  font-style: italic;
  color: var(--elg-ink);
  border: 0;
  padding: 0;
}

.elg-quote-section .post-quote-author {
  color: var(--elg-muted);
  font-size: 0.95rem;
}

.elg-quote-section .post-quote-dash::before {
  content: "—";
  margin-right: 0.4rem;
  color: var(--elg-faint);
}

/* ------------------------------------------------------ related posts */

.elg-related {
  font-family: var(--elg-font);
  border-top: 1px solid var(--elg-line);
  background: var(--elg-bg);
  padding: 3rem 1rem 3.5rem;
}

.elg-related-inner {
  max-width: 44rem;
  margin: 0 auto;
}

.elg-related .related-posts-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--elg-ink);
  margin-bottom: 1.25rem;
}

.elg-related .related-item {
  border-bottom: 1px solid var(--elg-line);
}

.elg-related .related-item:last-child {
  border-bottom: 0;
}

.elg-related .related-item-link {
  display: block;
  padding: 1rem 0;
  text-decoration: none;
}

.elg-related .related-item-title {
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--elg-ink);
  margin: 0 0 0.3rem;
  transition: color 0.15s ease;
}

.elg-related .related-item-link:hover .related-item-title,
.elg-related .related-item-link:focus-visible .related-item-title {
  color: var(--elg-accent-ink);
}

.elg-related .related-item-meta {
  display: flex;
  gap: 0.5rem;
  color: var(--elg-muted);
  font-size: 0.88rem;
}

/* ad container aligns with reading column */
.elg-ad-wrap {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ---------------------------------------------------------- responsive */

@media (max-width: 991.98px) {
  .elg-post-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    padding-top: 1.75rem;
  }

  /* share rail flows horizontally above the article */
  .elg-share-rail {
    position: static;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    order: -1;
  }

  .elg-share-label {
    margin-bottom: 0;
  }

  /* the TOC column is hidden by the template's d-none d-lg-block */
}

@media (max-width: 575.98px) {
  .elg-post-hero {
    padding-top: 2.25rem;
  }

  .post-body {
    font-size: 1.08rem;
  }
}
