/* ==========================================================================
   PROSE MODERNIZATION
   Comprehensive typography & layout enhancements for content pages.
   Applies to all .prose content without requiring HTML changes.
   ========================================================================== */


/* ==========================================================================
   PAGE HEADER ENHANCEMENT
   ========================================================================== */
.page-header {
  padding: 4rem 1.5rem 2.5rem;
  position: relative;
}

@media (max-width: 700px) {
  .page-header {
    padding: 2.5rem 1rem 1.75rem;
  }
}

.page-header-inner {
  max-width: 860px;
  margin: 0 auto;
}

.breadcrumb {
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  margin-bottom: 1.5rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none !important;
  transition: color 0.15s;
}

.breadcrumb a:hover {
  color: var(--accent);
  background: transparent !important;
}

.breadcrumb-sep {
  color: var(--text-soft);
  font-weight: 400;
}

.breadcrumb > span:last-child {
  color: var(--text);
  font-weight: 600;
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.05;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}

.page-title em {
  font-style: italic;
  color: var(--accent);
  font-weight: 500;
}

/* Reading meta row (reading time, last updated) */
.page-meta {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.page-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.page-meta-item svg {
  width: 14px;
  height: 14px;
  opacity: 0.8;
}


/* ==========================================================================
   PROSE — core typography
   ========================================================================== */
.prose {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text);
  max-width: 760px !important;  /* optimal reading width */
}

/* Slight padding on smaller screens */
@media (max-width: 700px) {
  .prose { font-size: 1rem; line-height: 1.65; }
}

/* ---------- Lead paragraph (first para after page header) ---------- */
.prose > p:first-child,
.prose > p.lead {
  font-size: 1.2rem;
  line-height: 1.55;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--text);
}

/* If first element is a banner/callout, the next paragraph becomes lead */
.prose > .dld-banner + p,
.prose > .callout + p {
  font-size: 1.15rem;
  line-height: 1.6;
  font-weight: 500;
  margin-bottom: 1.75rem;
}


/* ---------- Headings ---------- */
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text);
}

/* H2 — major section with accent bar */
.prose h2 {
  font-size: clamp(1.5rem, 3.2vw, 2rem);
  margin-top: 3.25rem;
  margin-bottom: 1rem;
  padding-top: 0.5rem;
  position: relative;
  font-weight: 500;
}

.prose h2::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
  margin-bottom: 1rem;
}

.prose h2 em {
  color: var(--accent);
  font-weight: 500;
}

/* First H2 closer to top */
.prose > h2:first-of-type,
.prose > .dld-banner + h2,
.prose > p:first-child + h2 {
  margin-top: 2rem;
}

/* H3 — sub-section */
.prose h3 {
  font-size: clamp(1.2rem, 2.4vw, 1.4rem);
  margin-top: 2.25rem;
  margin-bottom: 0.6rem;
  color: var(--text);
  font-weight: 600;
}

/* H4 — minor heading */
.prose h4 {
  font-size: 1.1rem;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-family: var(--font-sans);
  letter-spacing: 0;
}

/* H5 / H6 — eyebrow style */
.prose h5,
.prose h6 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  font-family: var(--font-sans);
}


/* ---------- Paragraphs ---------- */
.prose p {
  margin: 0 0 1.15em;
}

.prose p:last-child { margin-bottom: 0; }


/* ---------- Inline emphasis ---------- */
.prose strong {
  font-weight: 700;
  color: var(--text);
}

.prose em {
  font-style: italic;
  font-family: var(--font-display);
}


/* ---------- Links ---------- */
.prose a:not(.btn):not(.link-arrow):not(.nav-link) {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  font-weight: 600;
  transition: background 0.12s, color 0.12s;
  padding: 0 2px;
  border-radius: 2px;
}

.prose a:not(.btn):not(.link-arrow):not(.nav-link):hover {
  background: var(--teal);
  color: var(--text);
}


/* ---------- Lists ---------- */
.prose ul,
.prose ol {
  margin: 1em 0 1.5em;
  padding-left: 0;
  list-style: none;
}

.prose li {
  position: relative;
  padding-left: 2rem;
  margin-bottom: 0.75em;
  line-height: 1.65;
}

/* Custom bullet for ul */
.prose ul > li::before {
  content: '';
  position: absolute;
  left: 0.3rem;
  top: 0.65rem;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 2px;
}

/* Numbered for ol */
.prose ol {
  counter-reset: prose-counter;
}

.prose ol > li {
  counter-increment: prose-counter;
}

.prose ol > li::before {
  content: counter(prose-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--accent);
  line-height: 1.5;
}

/* Nested lists smaller */
.prose ul ul,
.prose ol ol,
.prose ul ol,
.prose ol ul {
  margin: 0.5em 0;
}

.prose ul ul > li::before {
  width: 6px;
  height: 6px;
  top: 0.7rem;
  background: var(--text-muted);
}


/* ---------- Blockquote ---------- */
.prose blockquote {
  margin: 2rem 0;
  padding: 1rem 0 1rem 1.5rem;
  border-left: 4px solid var(--accent);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.45;
  color: var(--text);
}

.prose blockquote p {
  margin: 0;
}

.prose blockquote cite {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.88rem;
  font-style: normal;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--text-muted);
}


/* ---------- Hr — section divider ---------- */
.prose hr {
  border: none;
  border-top: 2px solid var(--text);
  margin: 3rem auto;
  max-width: 80px;
  position: relative;
}


/* ---------- Tables ---------- */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  border: 2px solid var(--text);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 4px 4px 0 0 var(--text);
}

.prose th,
.prose td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--text);
}

.prose th {
  background: var(--accent);
  color: var(--text);
  font-weight: 700;
  border-bottom: 2px solid var(--text);
}

.prose tr:last-child td {
  border-bottom: none;
}

.prose tr:nth-child(even) td {
  background: var(--bg-soft);
}


/* ---------- Definition list ---------- */
.prose dl {
  margin: 1.5rem 0;
}

.prose dt {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.prose dd {
  margin-left: 0;
  margin-bottom: 1rem;
  color: var(--text-muted);
}


/* ---------- Inline code ---------- */
.prose code {
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  border: 1px solid var(--text);
}

.prose pre {
  background: var(--text);
  color: var(--bg);
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  border: 2px solid var(--text);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 1.5rem 0;
}

.prose pre code {
  background: transparent;
  padding: 0;
  border: none;
  color: inherit;
}


/* ---------- Images ---------- */
.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 2px solid var(--text);
  margin: 1.5rem 0;
  display: block;
}


/* ==========================================================================
   CALLOUT BOXES
   For .dld-banner-like patterns, plus structured note boxes
   ========================================================================== */
.callout {
  margin: 1.5rem 0;
  padding: 1.25rem 1.5rem;
  border: 2px solid var(--text);
  border-radius: 14px;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 1rem;
  align-items: start;
}

.callout-info { background: var(--accent); }
.callout-tip { background: var(--teal); }
.callout-warning { background: var(--bg-card); border-color: var(--text); }

.callout-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.callout-body {
  font-size: 0.95rem;
  line-height: 1.55;
}

.callout-body p:last-child { margin-bottom: 0; }
.callout-body strong { display: block; margin-bottom: 0.25rem; font-size: 1rem; }


/* ==========================================================================
   STEPS — numbered card sequence
   ========================================================================== */
.steps {
  margin: 1.5rem 0;
  display: grid;
  gap: 1rem;
}

.step {
  padding: 1.5rem 1.5rem 1.5rem 4.5rem;
  background: var(--bg-card);
  border: 2px solid var(--text);
  border-radius: 14px;
  position: relative;
  box-shadow: 4px 4px 0 0 var(--text);
}

.step::before {
  content: attr(data-step);
  position: absolute;
  left: 1.25rem;
  top: 1.25rem;
  width: 2.25rem;
  height: 2.25rem;
  background: var(--accent);
  color: var(--text);
  border: 2px solid var(--text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
}

.step h4 {
  margin: 0 0 0.5rem !important;
  font-family: var(--font-display) !important;
  font-size: 1.15rem !important;
  font-weight: 600;
  letter-spacing: -0.01em !important;
}

.step p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}


/* ==========================================================================
   END-OF-ARTICLE ACTIONS
   ========================================================================== */
.article-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 3rem 0 1rem;
  padding-top: 2rem;
  border-top: 2px solid var(--text);
}

.article-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  background: var(--bg-card);
  border: 2px solid var(--text);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none !important;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.article-action:hover {
  background: var(--teal);
  transform: translateY(-1px);
}

.article-action svg {
  width: 14px;
  height: 14px;
}


/* ==========================================================================
   BACK-TO-TOP FLOATING BUTTON
   ========================================================================== */
.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: var(--text);
  border: 2px solid var(--text);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 3px 3px 0 0 var(--text);
  transition: all 0.18s;
  z-index: 998;
}

.back-to-top.is-visible {
  display: flex;
}

.back-to-top:hover {
  background: var(--teal);
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 0 var(--text);
}

.back-to-top svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 600px) {
  .back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
  }
}


/* ==========================================================================
   "WAS THIS USEFUL?" feedback section enhancement
   ========================================================================== */
.feedback-widget {
  margin-top: 3rem;
  text-align: left;
}


/* ==========================================================================
   ANCHOR LINKS for headings (when hovered show #)
   ========================================================================== */
.prose h2[id],
.prose h3[id] {
  scroll-margin-top: 100px;
}


/* ==========================================================================
   PRINT improvements
   ========================================================================== */
@media print {
  .back-to-top,
  .article-actions,
  .ig-feed,
  .related-section {
    display: none !important;
  }

  .prose h2::before {
    background: #000 !important;
  }

  .prose a:not(.btn) {
    color: #000;
  }

  .callout, .step {
    border-color: #000 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }
}
