/* ===== Shared Article Content Styles (Blog + Help) ===== */

.article-content {
  background-color: var(--fte-surface-bg);
  padding: 2rem;
  border: var(--fte-table-border-width, 1px) solid var(--fte-grid-border, var(--bs-border-color));
  border-radius: 0.5rem;
  box-shadow: var(--fte-panel-shadow, none);
}

[data-bs-theme="dark"] .article-content.markdown-content {
  --markdown-primary-heading: var(--bs-emphasis-color);
}

@media (max-width: 767.98px) {
  .article-content {
    padding: 1.25rem;
  }
}

.calculation-example {
  margin: 1.25rem 0 1.5rem;
  border: var(--fte-table-border-width, 1px) solid var(--fte-grid-border, var(--bs-border-color));
  border-radius: 0.5rem;
  background: var(--fte-surface-bg);
  overflow: hidden;
}

.calculation-example-title {
  padding: 0.75rem 1rem;
  border-bottom: var(--fte-table-border-width, 1px) solid var(--fte-grid-border, var(--bs-border-color));
  background: var(--fte-surface-muted-bg);
  color: var(--bs-secondary-color);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
}

.calculation-row {
  display: grid;
  grid-template-columns: minmax(9rem, 0.8fr) minmax(0, 1.7fr);
  gap: 1.5rem;
  padding: 1rem;
  align-items: baseline;
}

.calculation-row + .calculation-row {
  border-top: var(--fte-table-border-width, 1px) solid var(--fte-grid-border, var(--bs-border-color));
}

.calculation-label {
  color: var(--bs-secondary-color);
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1.6;
}

.calculation-expression {
  color: var(--bs-body-color);
  font-family: var(--bs-body-font-family);
  font-size: 1.0625rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.calculation-expression strong {
  color: var(--bs-emphasis-color);
  font-weight: 700;
}

/* ===== Help Process Diagrams ===== */
.help-process {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2rem;
  padding: 1rem;
  border-radius: 0.75rem;
  background: var(--fte-surface-muted-bg);
  counter-reset: help-process-step;
  list-style: none;
}

.help-process--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.article-content .help-process-step {
  position: relative;
  min-width: 0;
  padding: 3.25rem 1rem 1rem;
  border: var(--fte-table-border-width, 1px) solid var(--fte-grid-border, var(--bs-border-color));
  border-radius: 0.625rem;
  background: var(--fte-surface-bg);
  color: var(--bs-body-color);
  counter-increment: help-process-step;
  line-height: 1.5;
}

.article-content .help-process-step::before {
  position: absolute;
  top: 0.75rem;
  left: 1rem;
  display: inline-flex;
  width: 1.75rem;
  height: 1.75rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--fte-accent-border);
  border-radius: 50%;
  background: var(--fte-accent-subtle);
  color: var(--bs-emphasis-color);
  content: counter(help-process-step);
  font-size: 0.8125rem;
  font-weight: 700;
}

.article-content .help-process-step:not(:last-child)::after {
  position: absolute;
  top: 1.625rem;
  left: 100%;
  width: 1rem;
  border-top: 1px solid var(--fte-accent-border);
  content: "";
}

.help-process-step strong,
.help-process-step span {
  display: block;
}

.help-process-step strong {
  margin-bottom: 0.4rem;
  color: var(--bs-emphasis-color);
  font-size: 0.9375rem;
  line-height: 1.35;
}

.help-process-step span {
  color: var(--bs-secondary-color);
  font-size: 0.875rem;
}

/* ===== Help Concept Maps ===== */
.help-concept-map {
  margin: 1.5rem 0 2rem;
  padding: 1.25rem;
  border: var(--fte-table-border-width, 1px) solid var(--fte-grid-border, var(--bs-border-color));
  border-radius: 0.75rem;
  background: var(--fte-surface-muted-bg);
}

.article-content .help-concept-map-caption {
  margin-bottom: 1rem;
  color: var(--bs-emphasis-color);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.help-concept-flow {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr) 2rem minmax(0, 1fr) 2rem minmax(0, 1fr) 2rem
    minmax(0, 1fr);
  align-items: stretch;
  gap: 0.25rem;
}

.help-concept-flow + .help-concept-flow {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: var(--fte-table-border-width, 1px) solid var(--fte-grid-border, var(--bs-border-color));
}

.article-content .help-concept-node {
  display: flex;
  min-width: 0;
  min-height: 7rem;
  justify-content: center;
  padding: 1rem;
  border: var(--fte-table-border-width, 1px) solid var(--fte-grid-border, var(--bs-border-color));
  border-radius: 0.625rem;
  background: var(--fte-surface-bg);
  color: var(--bs-body-color);
  flex-direction: column;
}

.article-content .help-concept-node--primary {
  border-color: var(--fte-accent-border);
  background: var(--fte-accent-subtle);
}

.help-concept-node strong,
.help-concept-node span {
  display: block;
}

.help-concept-node strong {
  margin-bottom: 0.4rem;
  color: var(--bs-emphasis-color);
  font-size: 0.9375rem;
  line-height: 1.35;
}

.help-concept-node span {
  color: var(--bs-secondary-color);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.help-concept-connector {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fte-accent);
  font-size: 1.25rem;
  font-weight: 700;
}

.help-concept-connector::before {
  content: "\2192";
}

.help-concept-connector--plus::before {
  content: "+";
}

.article-content .help-concept-note {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-left: 0.25rem solid var(--fte-accent-border);
  background: var(--fte-surface-bg);
  color: var(--bs-secondary-color);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* ===== Help Trees ===== */
.help-tree {
  max-width: 100%;
  margin: 1.5rem 0 2rem;
  padding: 1.25rem;
  overflow-x: auto;
  border: var(--fte-table-border-width, 1px) solid var(--fte-grid-border, var(--bs-border-color));
  border-radius: 0.75rem;
  background: var(--fte-surface-muted-bg);
}

.article-content .help-tree-caption {
  margin-bottom: 1.25rem;
  color: var(--bs-emphasis-color);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.help-tree ul {
  position: relative;
  display: flex;
  min-width: max-content;
  justify-content: center;
  margin: 0;
  padding: 1.25rem 0 0;
}

.help-tree > ul {
  padding-top: 0;
}

.article-content .help-tree li {
  position: relative;
  display: flex;
  min-width: 8rem;
  align-items: center;
  padding: 1.25rem 0.25rem 0;
  flex: 1 1 auto;
  flex-direction: column;
  list-style: none;
}

.article-content .help-tree > ul > li {
  padding-top: 0;
}

.help-tree li::before,
.help-tree li::after {
  position: absolute;
  top: 0;
  width: 50%;
  height: 1.25rem;
  border-top: 1px solid var(--fte-accent-border);
  content: "";
}

.help-tree li::before {
  right: 50%;
  border-right: 1px solid var(--fte-accent-border);
}

.help-tree li::after {
  left: 50%;
}

.help-tree li:first-child::before,
.help-tree li:last-child::after,
.help-tree > ul > li::before,
.help-tree > ul > li::after {
  border: 0;
}

.help-tree li:only-child::before,
.help-tree li:only-child::after {
  display: none;
}

.help-tree li > ul::before {
  position: absolute;
  top: 0;
  left: 50%;
  height: 1.25rem;
  border-left: 1px solid var(--fte-accent-border);
  content: "";
}

.article-content .help-tree-node {
  display: flex;
  min-width: 7.5rem;
  max-width: 11rem;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.75rem;
  border: var(--fte-table-border-width, 1px) solid var(--fte-grid-border, var(--bs-border-color));
  border-radius: 0.5rem;
  background: var(--fte-surface-bg);
  color: var(--bs-body-color);
  font-size: 0.875rem;
  font-weight: 650;
  line-height: 1.35;
  text-align: center;
}

.article-content .help-tree-node--root {
  border-color: var(--fte-accent-border);
  background: var(--fte-accent-subtle);
  color: var(--bs-emphasis-color);
}

/* ===== Table of Contents ===== */
.toc-container {
  background-color: var(--fte-surface-muted-bg);
  border: var(--fte-table-border-width, 1px) solid var(--fte-grid-border, var(--bs-border-color));
  border-radius: 0.5rem;
  padding: 1.25rem 1.5rem;
}

.toc-container h6 {
  margin-top: 0;
}

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

.toc-container li {
  margin-bottom: 0.15rem;
}

.toc-container a {
  display: block;
  padding: 0.1rem 0 0.1rem 0.75rem;
  text-decoration: none;
  color: var(--bs-secondary-color);
  font-size: 0.9rem;
  border-left: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.toc-container a:hover {
  color: var(--bs-success);
  border-left-color: var(--bs-success);
}

/* ===== Right-side Sticky TOC ===== */
.toc-sticky {
  position: sticky;
  top: calc(var(--fte-public-header-height) + 1rem);
  max-height: calc(100vh - var(--fte-public-header-height) - 2rem);
  max-height: calc(100dvh - var(--fte-public-header-height) - 2rem);
  overflow-y: auto;
  padding-right: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--bs-border-color) transparent;
}

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

.toc-sticky li {
  margin-bottom: 0;
}

.toc-sticky a {
  display: block;
  padding: 0.15rem 0 0.15rem 0.75rem;
  text-decoration: none;
  color: var(--bs-secondary-color);
  font-size: 0.8rem;
  border-left: 2px solid var(--bs-border-color);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.toc-sticky a:hover,
.toc-sticky a.active {
  color: var(--bs-success);
  border-left-color: var(--bs-success);
}

/* ===== Help Layout Override ===== */
/* Help articles now use the default .article-content card styling */

/* ===== Mobile ===== */
@media (max-width: 767.98px) {
  .help-process,
  .help-process--three {
    grid-template-columns: minmax(0, 1fr);
  }

  .article-content .help-process-step:not(:last-child)::after {
    top: 100%;
    left: 1.875rem;
    width: 0;
    height: 1rem;
    border-top: 0;
    border-left: 1px solid var(--fte-accent-border);
  }

  .help-concept-flow {
    grid-template-columns: minmax(0, 1fr);
  }

  .article-content .help-concept-node {
    min-height: 0;
  }

  .help-concept-connector {
    min-height: 1.5rem;
  }

  .help-concept-connector::before {
    content: "\2193";
  }

  .help-concept-connector--plus::before {
    content: "+";
  }

  .help-tree {
    padding: 1rem;
    overflow-x: visible;
  }

  .article-content .help-tree-caption {
    text-align: left;
  }

  .help-tree ul,
  .article-content .help-tree li {
    display: block;
    min-width: 0;
  }

  .help-tree ul {
    padding: 0;
  }

  .article-content .help-tree li,
  .article-content .help-tree > ul > li {
    padding: 0.75rem 0 0;
  }

  .article-content .help-tree > ul > li {
    padding-top: 0;
  }

  .help-tree li::before,
  .help-tree li::after,
  .help-tree li > ul::before {
    display: none;
  }

  .help-tree li > ul {
    margin: 0.25rem 0 0 1rem;
    padding-left: 1rem;
    border-left: 1px solid var(--fte-accent-border);
  }

  .article-content .help-tree-node {
    width: 100%;
    max-width: none;
    min-height: 0;
    justify-content: flex-start;
    text-align: left;
  }

  .calculation-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.35rem;
  }

  .article-content a {
    display: inline;
    padding: 4px 0;
    overflow-wrap: anywhere;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  .toc-container a,
  .toc-sticky a {
    transition: none;
  }
}
