/* ==========================================================================
   RailsPress Documentation - Utilities
   ==========================================================================
   Prose typography for long-form content, table of contents, and heading
   anchors. Loaded after all other CSS files.
   All values reference --rp-* variables from variables.css.
   ========================================================================== */


/* -----------------------------------------------------------------------
   1. Prose Typography
   -----------------------------------------------------------------------
   Wraps all Guide and Docs long-form content. Sets max line length,
   heading hierarchy, body text rhythm, links, inline code, code blocks,
   and tables.
   ----------------------------------------------------------------------- */

.prose {
  max-width: 75ch;
}

/* ---- Headings ---- */

.prose h1 {
  font-size: 2.25rem;
  font-family: var(--rp-font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: var(--rp-space-md);
}

.prose .lead {
  font-size: 1.125rem;
  color: var(--rp-text-muted);
  margin-bottom: var(--rp-space-2xl);
  line-height: 1.6;
}

.prose h2 {
  font-size: 1.5rem;
  font-family: var(--rp-font-display);
  font-weight: 600;
  margin-top: var(--rp-space-3xl);
  margin-bottom: var(--rp-space-lg);
  padding-bottom: var(--rp-space-sm);
  border-bottom: 1px solid var(--rp-border);
}

.prose h2:first-of-type {
  margin-top: var(--rp-space-xl);
}

.prose h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: var(--rp-space-2xl);
  margin-bottom: var(--rp-space-md);
}

.prose h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: var(--rp-space-xl);
  margin-bottom: var(--rp-space-sm);
}

/* ---- Body Text ---- */

.prose p,
.prose ul,
.prose ol {
  margin-bottom: var(--rp-space-lg);
  line-height: 1.7;
  color: var(--rp-text);
}

.prose ul,
.prose ol {
  padding-left: var(--rp-space-xl);
}

.prose li {
  margin-bottom: var(--rp-space-sm);
}

.prose li::marker {
  color: var(--rp-text-muted);
}

.prose strong {
  font-weight: 600;
  color: var(--rp-text);
}

/* ---- Links ---- */

.prose a {
  color: var(--rp-primary);
  text-decoration: underline;
  text-decoration-color: rgba(61, 90, 128, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color var(--rp-transition-fast);
}

.prose a:hover {
  text-decoration-color: var(--rp-primary);
}

/* ---- Inline Code (not inside pre) ---- */

.prose code:not(pre code) {
  background: var(--rp-bg-subtle);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.875em;
  font-family: var(--rp-font-mono);
}

/* ---- Code Blocks in Prose ---- */

.prose .code-block {
  margin-bottom: var(--rp-space-xl);
}

/* ---- Tables ---- */

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--rp-space-xl);
  font-size: 0.875rem;
}

.prose th,
.prose td {
  padding: var(--rp-space-sm) var(--rp-space-md);
  border: 1px solid var(--rp-border);
  text-align: left;
}

.prose th {
  background: var(--rp-bg-subtle);
  font-weight: 600;
}

.prose td {
  color: var(--rp-text-muted);
}

.prose td code {
  font-size: 0.8125rem;
}


/* -----------------------------------------------------------------------
   2. Table of Contents
   -----------------------------------------------------------------------
   In-page navigation block placed at the top of long-form pages.
   ----------------------------------------------------------------------- */

.toc {
  background: var(--rp-bg-subtle);
  border: 1px solid var(--rp-border);
  border-radius: 8px;
  padding: var(--rp-space-lg);
  margin-bottom: var(--rp-space-2xl);
}

.toc h2 {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0 0 var(--rp-space-md) 0;
  padding: 0;
  border: none;
}

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

.toc li {
  margin-bottom: var(--rp-space-xs);
}

.toc a {
  color: var(--rp-text-muted);
  font-size: 0.875rem;
  text-decoration: none;
  transition: color var(--rp-transition-fast);
}

.toc a:hover {
  color: var(--rp-primary);
}

/* Nested TOC items */

.toc ul ul {
  margin-left: var(--rp-space-md);
  margin-top: var(--rp-space-xs);
}

.toc ul ul a {
  font-size: 0.8125rem;
}


/* -----------------------------------------------------------------------
   3. Heading Anchors
   -----------------------------------------------------------------------
   Permalink icons for headings with [id] attributes. Hidden by default,
   revealed on heading hover.
   ----------------------------------------------------------------------- */

.prose h2[id],
.prose h3[id],
.prose h4[id] {
  position: relative;
}

.anchor-link {
  position: absolute;
  left: -1.5rem;
  color: var(--rp-text-light);
  text-decoration: none;
  opacity: 0;
  font-weight: 400;
  transition: opacity var(--rp-transition-fast), color var(--rp-transition-fast);
}

.anchor-link:hover {
  color: var(--rp-primary);
}

.prose h2[id]:hover .anchor-link,
.prose h3[id]:hover .anchor-link,
.prose h4[id]:hover .anchor-link {
  opacity: 1;
}
