/*
  TextBases Core Template System V1
  File: /assets/css/textbases-article.css

  Purpose:
  - Shared article page layout
  - Keeps TOC, lists, examples, troubleshooting, tables, and related sections consistent
*/

.tb-article-hero {
  border-radius: var(--tb-radius-hero);
  padding: 36px;
}

.tb-article-hero .tb-hero-inner {
  max-width: 940px;
}

.tb-article-hero h1 {
  font-size: clamp(34px, 5.6vw, 64px);
}

.tb-article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(290px, 0.92fr);
  gap: 16px;
  margin-top: 18px;
}

.tb-article-body {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.tb-article-section {
  padding: 30px;
}

.tb-article-section h3 {
  margin: 24px 0 8px;
  color: var(--tb-heading);
  font-size: 19px;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.tb-article-section p {
  max-width: 980px;
}

.tb-tool-cta-card {
  margin-top: 18px;
  padding: 22px;
  border-color: var(--tb-border-blue);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.tb-tool-cta-card strong {
  display: block;
  color: var(--tb-heading);
  font-size: 20px;
  margin-bottom: 6px;
}

.tb-tool-cta-card p {
  margin: 0;
  color: #bfdbfe;
  font-size: 14px;
  line-height: 1.65;
}

.tb-tool-cta-card a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid rgba(37, 99, 235, 0.96);
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  text-decoration: none;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 18px 42px rgba(37, 99, 235, 0.26);
  transition: 0.22s ease;
}

.tb-tool-cta-card a:hover {
  transform: translateY(-2px);
}

@media (max-width: 900px) {
  .tb-article-hero,
  .tb-article-section {
    padding: 20px;
    border-radius: 24px;
  }

  .tb-article-layout,
  .tb-tool-cta-card {
    grid-template-columns: 1fr;
  }

  .tb-tool-cta-card a {
    width: 100%;
  }
}


/* =========================================================
   TextBases Article Mobile Overflow Fix V1
   Prevent article cards, examples, TOC, FAQ, and code blocks
   from escaping the viewport on small screens.
   ========================================================= */

.tb-article-page,
.tb-article-page *,
.tb-content,
.tb-content *,
.tb-article-section,
.tb-article-section *,
.tb-card,
.tb-card *,
.tb-callout,
.tb-callout *,
.tb-faq,
.tb-faq *,
.tb-faq-item,
.tb-faq-item *,
.tb-tool-cta-card,
.tb-tool-cta-card *,
.tb-toc,
.tb-toc *,
.tb-related-card,
.tb-related-card * {
  box-sizing: border-box;
  min-width: 0;
}

.tb-article-page {
  width: 100%;
  max-width: 100vw;
  overflow-x: clip;
}

.tb-article-layout,
.tb-article-body,
.tb-content,
.tb-section,
.tb-article-section,
.tb-card,
.tb-callout,
.tb-faq-item,
.tb-tool-cta-card,
.tb-related-grid,
.tb-related-card {
  max-width: 100%;
}

.tb-content p,
.tb-content li,
.tb-content a,
.tb-content strong,
.tb-content span,
.tb-content h1,
.tb-content h2,
.tb-content h3,
.tb-article-section p,
.tb-article-section li,
.tb-article-section a,
.tb-article-section strong,
.tb-article-section h2,
.tb-article-section h3,
.tb-faq-item p,
.tb-faq-item h3,
.tb-callout p,
.tb-callout strong {
  overflow-wrap: anywhere;
  word-break: normal;
}

.tb-code-sample,
.tb-content pre,
.tb-content code,
.tb-article-section pre,
.tb-article-section code {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.tb-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.tb-table {
  width: 100%;
  min-width: 640px;
}

@media (max-width: 768px) {
  .tb-article-page {
    padding-left: 14px;
    padding-right: 14px;
  }

  .tb-article-layout,
  .tb-grid-2,
  .tb-grid-3,
  .tb-related-grid {
    display: grid;
    grid-template-columns: 1fr !important;
    width: 100%;
    max-width: 100%;
  }

  .tb-article-section,
  .tb-section,
  .tb-card,
  .tb-callout,
  .tb-faq-item,
  .tb-tool-cta-card {
    width: 100%;
    max-width: 100%;
    padding-left: 20px;
    padding-right: 20px;
    overflow: hidden;
  }

  .tb-code-sample,
  .tb-content pre {
    width: 100%;
    max-width: 100%;
    padding: 16px;
    overflow-x: auto;
    white-space: pre-wrap;
  }

  .tb-toc ol,
  .tb-content ol,
  .tb-content ul {
    padding-left: 1.25rem;
    margin-left: 0;
  }

  .tb-tool-cta-card {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .tb-tool-cta-card a {
    width: 100%;
    max-width: 100%;
    text-align: center;
  }
}

@media (max-width: 420px) {
  .tb-article-page {
    padding-left: 10px;
    padding-right: 10px;
  }

  .tb-article-section,
  .tb-section,
  .tb-card,
  .tb-callout,
  .tb-faq-item,
  .tb-tool-cta-card {
    padding-left: 16px;
    padding-right: 16px;
    border-radius: 20px;
  }

  .tb-article-section h2,
  .tb-section h2 {
    font-size: clamp(1.35rem, 7vw, 1.75rem);
    line-height: 1.16;
  }

  .tb-content p,
  .tb-content li {
    font-size: 0.98rem;
    line-height: 1.75;
  }
}


/* =========================================================
   TextBases Article Mobile Overflow HARD Fix V2
   Strong override for mobile article overflow caused by parent
   width, pre/code/table, grids, long links, and nested cards.
   ========================================================= */

html,
body {
  max-width: 100%;
  overflow-x: hidden !important;
}

.tb-page,
.tb-article-page,
.tb-article-layout,
.tb-article-body,
.tb-content,
.tb-section,
.tb-card,
.tb-article-section,
.tb-callout,
.tb-mini-card,
.tb-faq,
.tb-faq-item,
.tb-tool-cta-card,
.tb-related-title,
.tb-related-grid,
.tb-related-card,
.tb-table-wrap {
  box-sizing: border-box !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

.tb-content *,
.tb-section *,
.tb-article-section *,
.tb-callout *,
.tb-faq-item *,
.tb-tool-cta-card *,
.tb-related-card * {
  box-sizing: border-box !important;
  min-width: 0 !important;
}

.tb-content p,
.tb-content li,
.tb-content a,
.tb-content strong,
.tb-content span,
.tb-content h1,
.tb-content h2,
.tb-content h3,
.tb-section p,
.tb-section li,
.tb-section a,
.tb-section strong,
.tb-section h2,
.tb-section h3,
.tb-article-section p,
.tb-article-section li,
.tb-article-section a,
.tb-article-section strong,
.tb-article-section h2,
.tb-article-section h3 {
  max-width: 100% !important;
  overflow-wrap: anywhere !important;
  word-wrap: break-word !important;
}

.tb-code-sample,
.tb-content pre,
.tb-content code,
.tb-article-section pre,
.tb-article-section code,
pre,
code {
  max-width: 100% !important;
  overflow-x: auto !important;
  white-space: pre-wrap !important;
  word-break: break-word !important;
}

.tb-table-wrap {
  width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

.tb-table {
  width: 100% !important;
  min-width: 0 !important;
}

@media (max-width: 900px) {
  html,
  body {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  .tb-page,
  .tb-article-page {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .tb-hero,
  .tb-section,
  .tb-card,
  .tb-article-section,
  .tb-callout,
  .tb-mini-card,
  .tb-faq-item,
  .tb-tool-cta-card,
  .tb-related-title,
  .tb-related-card {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 18px !important;
    padding-right: 18px !important;
    overflow: hidden !important;
  }

  .tb-article-layout,
  .tb-article-body,
  .tb-grid-2,
  .tb-grid-3,
  .tb-related-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 14px !important;
  }

  .tb-tool-cta-card {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .tb-tool-cta-card a {
    width: 100% !important;
    max-width: 100% !important;
    white-space: normal !important;
    text-align: center !important;
  }

  .tb-content ol,
  .tb-content ul,
  .tb-section ol,
  .tb-section ul,
  .tb-toc ol {
    padding-left: 1.15rem !important;
    margin-left: 0 !important;
  }

  .tb-content li,
  .tb-section li {
    padding-left: 0.25rem !important;
  }

  .tb-code-sample,
  .tb-content pre,
  .tb-article-section pre {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 14px !important;
    overflow-x: auto !important;
    white-space: pre-wrap !important;
  }
}

@media (max-width: 420px) {
  .tb-page,
  .tb-article-page {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .tb-hero,
  .tb-section,
  .tb-card,
  .tb-article-section,
  .tb-callout,
  .tb-mini-card,
  .tb-faq-item,
  .tb-tool-cta-card,
  .tb-related-card {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
}


/* =========================================================
   TextBases Article Mobile Balanced Fix V3
   Restores comfortable article width/padding after the V2 hard
   overflow fix while keeping cards/code/examples inside screen.
   ========================================================= */

.tb-article-page {
  width: min(100%, 1180px) !important;
  max-width: 1180px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  overflow-x: visible !important;
}

.tb-article-body,
.tb-article-layout,
.tb-article-page .tb-hero,
.tb-article-page .tb-section,
.tb-article-page .tb-related-title,
.tb-article-page .tb-related-grid {
  width: 100% !important;
  max-width: 100% !important;
}

.tb-article-section,
.tb-article-page .tb-card,
.tb-article-page .tb-callout,
.tb-article-page .tb-faq-item,
.tb-article-page .tb-tool-cta-card,
.tb-article-page .tb-related-card {
  overflow: hidden !important;
}

.tb-article-page .tb-code-sample,
.tb-article-page pre,
.tb-article-page code {
  max-width: 100% !important;
}

@media (min-width: 901px) {
  .tb-article-page {
    padding-left: 32px !important;
    padding-right: 32px !important;
  }
}

@media (max-width: 900px) {
  html,
  body {
    overflow-x: hidden !important;
  }

  .tb-article-page {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: clamp(16px, 4.5vw, 28px) !important;
    padding-right: clamp(16px, 4.5vw, 28px) !important;
    overflow-x: hidden !important;
  }

  .tb-article-page .tb-hero,
  .tb-article-page .tb-section,
  .tb-article-page .tb-card,
  .tb-article-page .tb-article-section,
  .tb-article-page .tb-callout,
  .tb-article-page .tb-mini-card,
  .tb-article-page .tb-faq-item,
  .tb-article-page .tb-tool-cta-card,
  .tb-article-page .tb-related-title,
  .tb-article-page .tb-related-card {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: clamp(18px, 5vw, 24px) !important;
    padding-right: clamp(18px, 5vw, 24px) !important;
  }

  .tb-article-page .tb-article-layout,
  .tb-article-page .tb-article-body,
  .tb-article-page .tb-grid-2,
  .tb-article-page .tb-grid-3,
  .tb-article-page .tb-related-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .tb-article-page .tb-code-sample,
  .tb-article-page pre {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    white-space: pre-wrap !important;
  }
}

@media (max-width: 420px) {
  .tb-article-page {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .tb-article-page .tb-hero,
  .tb-article-page .tb-section,
  .tb-article-page .tb-card,
  .tb-article-page .tb-article-section,
  .tb-article-page .tb-callout,
  .tb-article-page .tb-mini-card,
  .tb-article-page .tb-faq-item,
  .tb-article-page .tb-tool-cta-card,
  .tb-article-page .tb-related-card {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }
}

@media (max-width: 360px) {
  .tb-article-page {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .tb-article-page .tb-hero,
  .tb-article-page .tb-section,
  .tb-article-page .tb-card,
  .tb-article-page .tb-article-section,
  .tb-article-page .tb-callout,
  .tb-article-page .tb-mini-card,
  .tb-article-page .tb-faq-item,
  .tb-article-page .tb-tool-cta-card,
  .tb-article-page .tb-related-card {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
}
