/* ==========================================================================
   Latx Technologies — Single article
   --------------------------------------------------------------------------
   The reading view: the sidebar layout, the table of contents, article body
   typography, the extractable key-points box, the author card and the source
   list. Loaded only on is_singular( 'post' ).

   Requires variables.css, reset.css, global.css, theme.css.
   ========================================================================== */

/* ==================================================== Article layout ====== */

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-x-large);
  align-items: start;
}

/* Grid items default to min-width:auto, so a wide child — a comparison table,
   a long link — sets a floor on the column and pushes it past the container.
   min-width:0 lets the column shrink and hands the overflow to the child's own
   scroll container instead. */
.article-layout > * {
  min-width: 0;
}

/* The table of contents becomes a sticky sidebar only when there is genuinely
   room for it; below that it sits inline above the article body. */
@media (width >= 64rem) {
  .article-layout {
    grid-template-columns: minmax(0, 16rem) minmax(0, 1fr);
    gap: var(--space-2x-large);
  }

  /* The sidebar must not stretch to the row height, or the sticky position has
     nothing to slide against. */
  .article-layout__aside {
    position: sticky;
    inset-block-start: calc(var(--header-height) + var(--space-medium));
    align-self: start;
  }
}

/* ================================================= Table of contents ====== */

.table-of-contents {
  padding: var(--space-medium);
  background-color: var(--color-background-raised);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-large);
}

.table-of-contents__heading {
  margin-block-end: var(--space-2x-small);
  font-family: var(--font-family-body);
  font-size: var(--font-size-overline);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-overline);
  text-transform: uppercase;
  color: var(--color-text-subtle);
}

.table-of-contents__list {
  display: grid;
  gap: 0.125rem;
}

.table-of-contents__link {
  display: block;
  padding: 0.4375rem 0;
  padding-inline-start: var(--space-2x-small);
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  text-decoration: none;
  border-inline-start: 2px solid transparent;
  transition:
    color var(--duration-fast) var(--easing-out),
    border-color var(--duration-fast) var(--easing-out);
}

.table-of-contents__link--child {
  padding-inline-start: var(--space-medium);
  font-size: 0.875rem;
}

.table-of-contents__link:hover {
  color: var(--color-text-strong);
  border-inline-start-color: var(--color-border-strong);
}

.table-of-contents__link.is-current {
  color: var(--color-accent-text);
  border-inline-start-color: var(--color-accent);
}

/* =========================================================== Article ====== */

.article__body {
  max-width: var(--max-text-width);
  font-size: var(--font-size-body-large);
  color: var(--color-text-muted);
}

.article__body > * + * {
  margin-block-start: var(--space-medium);
}

/* scroll-margin keeps a heading clear of the sticky header when the table of
   contents jumps to it. */
.article__body h2 {
  margin-block-start: var(--space-2x-large);
  color: var(--color-text-strong);
  scroll-margin-block-start: calc(var(--header-height) + var(--space-medium));
}

.article__body h3 {
  margin-block-start: var(--space-large);
  color: var(--color-text-strong);
  scroll-margin-block-start: calc(var(--header-height) + var(--space-medium));
}

.article__body ul,
.article__body ol {
  display: grid;
  gap: var(--space-2x-small);
  padding-inline-start: var(--space-medium);
}

.article__body ul {
  list-style: disc;
}

.article__body ol {
  list-style: decimal;
}

.article__body li::marker {
  color: var(--color-text-subtle);
}

.article__body strong {
  color: var(--color-text-strong);
}

.article__body blockquote {
  margin-inline: 0;
  padding-inline-start: var(--space-medium);
  font-size: var(--font-size-heading-4);
  color: var(--color-text-strong);
  border-inline-start: 3px solid var(--color-accent);
}

.article__body img,
.article__body figure img {
  border-radius: var(--radius-large);
}

.article__body figure {
  margin: 0;
}

.article__body figcaption {
  margin-block-start: var(--space-2x-small);
  font-size: var(--font-size-small);
  color: var(--color-text-subtle);
}

.article__body table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-body);
}

.article__body th,
.article__body td {
  padding: var(--space-x-small) var(--space-small);
  text-align: start;
  vertical-align: top;
  border-block-end: 1px solid var(--color-border-subtle);
}

.article__metadata {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2x-small) var(--space-medium);
  align-items: center;
  font-family: var(--font-family-monospace);
  font-size: var(--font-size-small);
  color: var(--color-text-subtle);
}

/* ======================================================== Key points ====== */

/* The extractable summary at the top of an article. Answer engines lift this,
   and readers in a hurry read only this. */
.key-points {
  padding: var(--space-medium);
  background-color: var(--color-background-accent-soft);
  border-radius: var(--radius-large);
  border-inline-start: 3px solid var(--color-accent);
}

.key-points__heading {
  margin-block-end: var(--space-2x-small);
  font-family: var(--font-family-display);
  font-size: var(--font-size-heading-4);
  color: var(--color-text-strong);
}

.key-points__list {
  display: grid;
  gap: var(--space-2x-small);
  padding-inline-start: var(--space-medium);
  font-size: var(--font-size-body);
  color: var(--color-slate-600);
  list-style: disc;
}

/* ======================================================= Author card ====== */

.author-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-medium);
  align-items: start;
  margin-block-start: var(--space-2x-large);
  padding: var(--space-medium);
  background-color: var(--color-background-raised);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-large);
}

.author-card__photograph {
  width: 3.5rem;
  height: 3.5rem;
  object-fit: cover;
  background-color: var(--color-slate-100);
  border-radius: 50%;
}

.author-card__name {
  font-family: var(--font-family-display);
  font-size: var(--font-size-heading-4);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-strong);
}

.author-card__role {
  font-family: var(--font-family-monospace);
  font-size: var(--font-size-small);
  color: var(--color-text-subtle);
}

.author-card__biography {
  margin-block-start: var(--space-2x-small);
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

/* =================================================== Sources listing ====== */

.source-list {
  display: grid;
  gap: var(--space-2x-small);
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
}

.source-list li {
  padding-block-start: var(--space-2x-small);
  border-block-start: 1px solid var(--color-border-subtle);
}

/* =================================================== Reading progress ===== */

/* A one-pixel bar under the sticky header. Decorative: it reports position, it
   does not control anything, so it is aria-hidden and never focusable. */
.reading-progress {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: calc(var(--z-index-header) + 1);
  height: 3px;
  background-image: var(--gradient-brand);
  transform: scaleX(var(--reading-progress, 0));
  transform-origin: 0 50%;
  pointer-events: none;
}
