/* Long-form reader for the project's Markdown documents. Depends on site.css. */

.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: 2px;
  pointer-events: none;
}

.read-progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--warm), var(--warm-strong));
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.reader-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 720px);
  justify-content: center;
  gap: clamp(28px, 5vw, 72px);
  width: min(var(--page-max), 100% - 2 * var(--gutter));
  margin: 0 auto;
  padding-block: clamp(32px, 6vw, 72px) 24px;
}

.reader-aside {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow: auto;
  scrollbar-width: thin;
}

.reader-toc,
.reader-docs {
  display: grid;
  gap: 2px;
  margin-bottom: 26px;
}

.reader-toc a,
.reader-docs a {
  padding: 6px 10px;
  border-left: 2px solid var(--hairline);
  color: var(--text-3);
  font-size: 0.86rem;
  line-height: 1.35;
  text-decoration: none;
}

.reader-toc a.toc-sub {
  padding-left: 22px;
  font-size: 0.8rem;
}

.reader-toc a:hover,
.reader-docs a:hover {
  color: var(--text-1);
}

.reader-toc a.is-active {
  border-left-color: var(--warm);
  color: var(--warm-strong);
}

.reader-docs a[aria-current="page"] {
  border-left-color: var(--text-2);
  color: var(--text-1);
}

.reader-docs-label {
  margin-top: 8px;
}

/* ---------- Article typography ---------- */

.reader-article {
  min-width: 0;
  color: var(--text-2);
  font-size: 1.08rem;
  line-height: 1.78;
}

.reader-article h1,
.reader-article h2,
.reader-article h3,
.reader-article h4 {
  color: var(--text-1);
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: -0.015em;
}

.reader-article h1 {
  margin: 0 0 28px;
  font-size: clamp(2.3rem, 5.4vw, 3.6rem);
  line-height: 1.04;
}

.reader-article h2 {
  margin: 56px 0 14px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  line-height: 1.15;
}

.reader-article h3 {
  margin: 36px 0 10px;
  font-size: 1.35rem;
  line-height: 1.25;
}

.reader-article p,
.reader-article ul,
.reader-article ol {
  margin: 0 0 18px;
}

.reader-article li + li {
  margin-top: 6px;
}

.reader-article strong {
  color: var(--text-1);
  font-weight: 600;
}

.reader-article a {
  color: var(--warm-strong);
  text-decoration: underline;
  text-decoration-color: rgba(242, 184, 114, 0.4);
  text-underline-offset: 3px;
}

.reader-article a:hover {
  text-decoration-color: var(--warm);
}

.reader-article blockquote {
  margin: 24px 0;
  padding: 4px 0 4px 20px;
  border-left: 2px solid var(--warm);
  color: var(--text-1);
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-style: italic;
}

.reader-article code {
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.reader-article pre {
  overflow-x: auto;
  margin: 22px 0;
  padding: 18px 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-m);
  background: var(--ink-1);
  line-height: 1.6;
}

.reader-article pre code {
  padding: 0;
  background: none;
  font-size: 0.88rem;
}

.table-wrap {
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-m);
}

.reader-article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  line-height: 1.5;
}

.reader-article th,
.reader-article td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
}

.reader-article th {
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.reader-article tr:last-child td {
  border-bottom: 0;
}

.reader-article figure {
  margin: 28px 0;
}

.reader-article figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-m);
  background: #fff;
}

.reader-article figcaption {
  margin-top: 10px;
  color: var(--text-3);
  font-size: 0.86rem;
}

.reader-article hr {
  margin: 40px 0;
  border: 0;
  border-top: 1px solid var(--hairline);
}

.reader-status {
  color: var(--text-3);
}

.reader-source {
  margin-top: 48px !important;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
  color: var(--text-3);
  font-size: 0.86rem;
}

/* ---------- Phones ---------- */

@media (max-width: 900px) {
  .reader-shell {
    grid-template-columns: 1fr;
  }

  .reader-aside {
    position: static;
    max-height: none;
    padding: 16px 18px 4px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-m);
    background: var(--ink-1);
  }

  .reader-toc {
    display: none;
  }

  .reader-aside > .eyebrow-mono:first-child {
    display: none;
  }

  .reader-docs-label {
    margin-top: 0;
  }
}
