/* ===== 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);
}

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

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

[data-bs-theme="dark"] .article-content p,
[data-bs-theme="dark"] .article-content li {
  color: var(--bs-body-color);
}

/* ===== Article Images ===== */
.article-content img {
  max-width: 100%;
  display: block;
  margin: 0 auto;
  padding: 16px 0;
  border-radius: 0.375rem;
}

/* ===== Inline Values and Worked Calculations ===== */
.article-content :not(pre) > code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.article-content a > code {
  color: inherit;
}

.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;
}

/* ===== Organization Membership Diagram ===== */
.organization-access-diagram {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 9rem minmax(0, 1fr);
  align-items: center;
  margin: 2rem 0;
  padding: 2rem 1.5rem;
  border-radius: 0.75rem;
  background: var(--fte-surface-muted-bg);
}

.organization-access-card {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 9.5rem;
  padding: 1.5rem;
  border: var(--fte-table-border-width, 1px) solid var(--fte-grid-border, var(--bs-border-color));
  border-radius: 0.75rem;
  background: var(--fte-surface-bg);
}

.organization-access-card-heading {
  margin-bottom: 1.25rem;
  color: var(--bs-emphasis-color);
  font-size: 0.9375rem;
  font-weight: 650;
  text-align: center;
}

.organization-access-members {
  display: flex;
  gap: 2rem;
  justify-content: center;
}

.organization-access-member {
  display: flex;
  align-items: center;
  min-width: 3.5rem;
  color: var(--bs-secondary-color);
  font-size: 0.8125rem;
  font-weight: 500;
  flex-direction: column;
  gap: 0.45rem;
  text-align: center;
}

.organization-access-member::before {
  width: 2.25rem;
  height: 2.25rem;
  border: var(--fte-table-border-width, 1px) solid var(--fte-accent-border);
  border-radius: 50%;
  background: var(--fte-accent-subtle);
  content: "";
}

.organization-access-bridge {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
}

.organization-access-bridge::before {
  position: absolute;
  top: 50%;
  right: -1.5rem;
  left: -1.5rem;
  z-index: -1;
  border-top: var(--fte-table-border-width, 1px) solid var(--fte-accent-border);
  content: "";
}

.organization-access-shared-user {
  display: flex;
  width: 7rem;
  aspect-ratio: 1;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  border: 2px solid var(--fte-accent);
  border-radius: 50%;
  background: var(--fte-accent-subtle);
  box-shadow: 0 0 0 0.5rem var(--fte-surface-muted-bg);
  flex-direction: column;
  text-align: center;
}

.organization-access-shared-detail {
  color: var(--bs-secondary-color);
  font-size: 0.6875rem;
  line-height: 1.35;
}

.organization-access-shared-name {
  margin-bottom: 0.25rem;
  color: var(--bs-emphasis-color);
  font-size: 1rem;
  font-weight: 650;
}

/* ===== Article Content Typography ===== */
.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
  margin-bottom: 0.75rem;
  margin-top: 1.75rem;
}

.article-content h1:first-child,
.article-content h2:first-child,
.article-content h3:first-child {
  margin-top: 0;
}

.article-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--bs-primary-text-emphasis);
  letter-spacing: 0;
  margin-top: 2.5rem;
}

.article-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--bs-body-color);
}

.article-content h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--bs-body-color);
  font-style: italic;
}

.article-content p {
  margin-left: 0;
  line-height: 1.8;
  color: var(--bs-body-color);
}

.article-content li {
  line-height: 1.8;
  color: var(--bs-body-color);
}

.article-content blockquote {
  margin: 1.25rem 0;
  padding: 0.875rem 1rem;
  border-left: 4px solid var(--bs-success);
  background-color: var(--fte-surface-muted-bg);
  color: var(--bs-body-color);
}

.article-content blockquote p:last-child {
  margin-bottom: 0;
}

/* Inline long-form content links should not rely on color alone. */
.article-body a,
.blog-article-body a {
  color: var(--bs-link-color);
  text-decoration-line: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
  text-decoration-skip-ink: auto;
}

.article-body a:hover,
.article-body a:focus-visible,
.blog-article-body a:hover,
.blog-article-body a:focus-visible {
  color: var(--bs-link-hover-color);
  text-decoration-thickness: 0.12em;
}

.article-content .table-responsive {
  margin: 1rem 0 1.25rem;
  border: var(--fte-table-border-width, 1px) solid var(--fte-grid-border, var(--bs-border-color));
  border-radius: var(--fte-table-radius, 0.5rem);
  background: var(--fte-surface-bg, var(--bs-body-bg));
}

.article-content table {
  width: 100%;
  min-width: 36rem;
  margin-bottom: 0;
  border: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.article-content table th,
.article-content table td {
  padding: 0.25rem 0.5rem;
  border: 0;
  border-left: 1px solid var(--fte-grid-border, var(--bs-border-color));
  border-top: 1px solid var(--fte-grid-border, var(--bs-border-color));
  vertical-align: top;
}

.article-content table thead:first-child tr:first-child > *,
.article-content table tbody:first-child tr:first-child > * {
  border-top: 0;
}

.article-content table tr > :first-child {
  border-left: 0;
}

.article-content table thead th {
  background-color: var(--fte-table-header-bg, var(--bs-tertiary-bg));
  color: var(--fte-table-header-color, var(--bs-secondary-text-emphasis));
  font-size: var(--fte-table-header-font-size, 0.8125rem);
  font-weight: var(--fte-table-header-font-weight, 650);
  text-transform: var(--fte-table-header-text-transform, none);
}

.article-content table tbody tr:hover {
  background-color: var(--fte-table-hover-bg, var(--fte-surface-hover-bg));
}

/* ===== 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: 1rem;
  max-height: calc(100vh - 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) {
  .article-content img {
    padding: 8px 0;
  }

  .organization-access-diagram {
    grid-template-columns: minmax(0, 1fr);
    padding: 1.5rem 1rem;
  }

  .organization-access-bridge {
    min-height: 8.5rem;
    align-items: center;
  }

  .organization-access-bridge::before {
    top: -0.75rem;
    right: auto;
    bottom: -0.75rem;
    left: 50%;
    border-top: 0;
    border-left: var(--fte-table-border-width, 1px) solid var(--fte-accent-border);
  }

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

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

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