/* ============================================
   SKIP LINK — Accessibility
   ============================================ */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 9999;
  padding: 10px 20px;
  background: var(--navy);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: 0 0 6px 6px;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 0;
}

/* ============================================
   ARTICLE BODY — Markdown Content Styles
   ============================================ */

/* Article content container — narrow width for readability */
.article-container {
  max-width: 720px !important;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

/* Featured image */
.article-featured-image {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 36px;
  border: 1px solid var(--gray100);
}

/* Article body base */
.article-body {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-light);
  padding: 8px 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
  max-width: 100%;
  overflow-x: hidden;
}

/* Force all child elements to stay within container */
.article-body * {
  max-width: 100%;
  box-sizing: border-box;
}

/* Override any Substack inline width styles on wrapper divs */
.article-body > div {
  width: auto !important;
  max-width: 100% !important;
  min-width: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Headings */
.article-body h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  margin-top: 40px;
  margin-bottom: 16px;
  line-height: 1.3;
}

.article-body h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--navy);
  margin-top: 32px;
  margin-bottom: 12px;
  line-height: 1.35;
}

.article-body h4 {
  font-size: 17px;
  font-weight: 600;
  color: var(--navy);
  margin-top: 24px;
  margin-bottom: 10px;
}

/* Paragraphs */
.article-body p {
  margin-bottom: 18px;
}

/* Links */
.article-body a {
  color: var(--teal);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}
.article-body a:hover {
  color: var(--lime);
}

/* Lists */
.article-body ul,
.article-body ol {
  margin-bottom: 18px;
  padding-left: 24px;
}

.article-body li {
  margin-bottom: 8px;
  line-height: 1.7;
}

.article-body ul li::marker {
  color: var(--lime);
}

.article-body ol li::marker {
  color: var(--teal);
  font-weight: 600;
}

/* Blockquotes */
.article-body blockquote {
  border-left: 3px solid var(--teal);
  margin: 24px 0;
  padding: 16px 24px;
  background: var(--teal-muted);
  border-radius: 0 6px 6px 0;
  font-style: italic;
  color: var(--text);
}

.article-body blockquote p {
  margin-bottom: 0;
}

/* Code */
.article-body code {
  font-family: 'Roboto Mono', monospace;
  font-size: 14px;
  background: var(--gray50);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--purple);
}

.article-body pre {
  background: var(--navy);
  color: var(--text-bright);
  padding: 20px 24px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--navy-mid);
}

.article-body pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: 13.5px;
  line-height: 1.65;
}

/* Horizontal rule */
.article-body hr {
  border: none;
  height: 2px;
  background: linear-gradient(90deg, var(--teal), var(--lime), var(--purple-light), var(--teal));
  margin: 40px 0;
  border-radius: 2px;
}

/* Images inside articles */
.article-body img {
  max-width: 100%;
  border-radius: 8px;
  margin: 24px 0;
  border: 1px solid var(--gray100);
}

/* Tables */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14.5px;
}

.article-body th {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
}

.article-body td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray100);
  color: var(--text-light);
}

.article-body tr:hover td {
  background: var(--gray50);
}

/* Strong / Bold */
.article-body strong {
  color: var(--text);
  font-weight: 600;
}

/* ── Author byline + reading time ── */
.article-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--text-muted);
}
.article-meta__author {
  font-weight: 500;
  color: var(--text-light);
}
.article-meta__sep {
  color: var(--teal);
  font-weight: 700;
}
.article-meta__time {
  color: var(--text-muted);
}
.article-meta__tag {
  font-family: 'Roboto', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--teal);
  background: var(--teal-muted);
  padding: 2px 8px;
  border-radius: 3px;
}

/* ── Table of contents ── */
.article-toc {
  background: var(--off-white);
  border: 1px solid var(--gray100);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 32px;
}
.article-toc__title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-family: 'Roboto Mono', monospace;
}
.article-toc__list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.article-toc__item {
  margin-bottom: 4px;
}
.article-toc__item a {
  font-size: 14px;
  color: var(--text-light);
  text-decoration: none;
  transition: color 0.15s;
  line-height: 1.5;
}
.article-toc__item a:hover {
  color: var(--teal);
}
.article-toc__item--h3 {
  padding-left: 16px;
}

/* ── Related articles ── */
.article-related {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--gray100);
}
.article-related__title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.article-related__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.article-related__card {
  display: block;
  padding: 16px 18px;
  background: var(--off-white);
  border: 1px solid var(--gray100);
  border-radius: 8px;
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.article-related__card:hover {
  border-color: var(--teal);
  box-shadow: 0 2px 8px rgba(0,212,200,0.1);
}
.article-related__date {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.article-related__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.35;
}

/* ── Share buttons ── */
.article-share {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--gray100);
  display: flex;
  align-items: center;
  gap: 16px;
}
.article-share__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.article-share__buttons {
  display: flex;
  gap: 8px;
}
.article-share__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--gray100);
  color: var(--text-light);
  background: var(--gray50);
  transition: all 0.2s ease;
  text-decoration: none;
}
.article-share__btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-muted);
}
.article-share__btn--linkedin:hover { color: #0077b5; border-color: #0077b5; }
.article-share__btn--x:hover { color: var(--navy); border-color: var(--navy); }
.article-share__btn--email:hover { color: var(--purple); border-color: var(--purple); }

/* ── Back to top button ── */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--gray100);
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease;
  pointer-events: none;
  z-index: 90;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.back-to-top--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--teal);
}

@media (max-width: 600px) {
  .article-share {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .article-related__grid {
    grid-template-columns: 1fr;
  }
  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
  }
}

/* ── Substack content cleanup ── */

/* Ensure all Substack divs flow naturally and stay contained */
.article-body div {
  margin-bottom: 0;
  max-width: 100% !important;
  width: auto !important;
  overflow-wrap: break-word;
}

/* Kill Substack's pencraft utility classes that break layout */
.article-body [class*="pencraft"],
.article-body [class*="pc-display"],
.article-body [class*="pc-gap"],
.article-body [class*="pc-reset"] {
  display: block !important;
  width: auto !important;
  max-width: 100% !important;
}

/* Image containers */
.article-body .image-link { display: block; margin: 28px 0; }
.article-body .image-link img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--gray100); }
.article-body figure,
.article-body figure.article-figure { margin: 28px 0; }
.article-body figure img,
.article-body figure.article-figure img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--gray100); }
.article-body figcaption { font-size: 13px; color: var(--text-muted); text-align: center; margin-top: 10px; font-style: italic; }
.article-body .captioned-image-container { margin: 28px 0; max-width: 100% !important; overflow: hidden; }
.article-body .captioned-image-container img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--gray100); }
.article-body .image2 { display: block; }
.article-body .image2-inset { max-width: 100% !important; overflow: hidden; }
.article-body .image-link-expand { display: none !important; }

/* Override Substack image sizing — prevent sizes="100vw" from blowing out layout */
.article-body picture,
.article-body picture source,
.article-body picture img {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
}
.article-body img.sizing-normal,
.article-body img.sizing-full-width {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
}

/* Substack subscription widgets and CTAs — hide */
.article-body .subscription-widget-wrap,
.article-body .subscription-widget-wrap-editor,
.article-body .button-wrapper,
.article-body .subscribe-widget,
.article-body .footer { display: none !important; }

/* Substack pullquotes */
.article-body .pullquote {
  font-size: 20px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.5;
  border-left: 3px solid var(--lime);
  padding: 8px 0 8px 24px;
  margin: 32px 0;
}

/* Substack embedded content */
.article-body .embedded-post-wrap { margin: 24px 0; }
.article-body .tweet-wrap { margin: 24px 0; }

/* Ensure Substack's paragraph-like divs get spacing */
.article-body .body-markup > div + div,
.article-body .body > div + div { margin-top: 16px; }

/* ── Print stylesheet ── */
@media print {
  .nav, .footer, .back-to-top, .article-share, .skip-link,
  .article-related, .btn--ghost { display: none !important; }
  body { font-size: 12pt; color: #000; background: #fff; }
  .page-header { background: none !important; padding: 20px 0; }
  .page-header__title { color: #000; font-size: 24pt; }
  .page-header__subtitle { color: #333; }
  .article-body { font-size: 11pt; line-height: 1.6; color: #000; }
  .article-body a { color: #000; text-decoration: underline; }
  .article-body a::after { content: " (" attr(href) ")"; font-size: 9pt; color: #666; }
  .article-body img { max-width: 100%; page-break-inside: avoid; }
  .article-body h2, .article-body h3 { page-break-after: avoid; color: #000; }
  .article-body blockquote { border-left-color: #999; background: none; }
  .article-body table { border: 1px solid #ccc; }
  .article-body th { background: #eee; color: #000; }
  .article-body td { border-bottom: 1px solid #ccc; }
  .article-toc { border: 1px solid #ccc; background: #f5f5f5; }
  .section { padding: 20px 0; }
}

/* ── Newsletter bar ── */
.newsletter-bar {
  background: var(--off-white);
  border-top: 1px solid var(--gray100);
  border-bottom: 1px solid var(--gray100);
  padding: 32px 0;
}
.newsletter-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.newsletter-bar__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}
.newsletter-bar__subtitle {
  font-size: 14px;
  color: var(--text-light);
}
.newsletter-bar__btn {
  white-space: nowrap;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .newsletter-bar__inner {
    flex-direction: column;
    text-align: center;
  }
}

/* Footer email */
.footer-email {
  margin-top: 4px;
}
.footer-email a {
  font-size: 13px;
  color: var(--text-on-dark);
  text-decoration: none;
  transition: color 0.2s ease;
}
.footer-email a:hover {
  color: var(--teal);
}

/* Footer legal row */
.footer-legal {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  text-align: center;
}
.footer-legal__link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: color 0.2s ease;
}
.footer-legal__link:hover {
  color: var(--teal);
}
