/**
 * Table of contents — RTL, Hamyar-adjacent.
 */

.hpq-toc {
  font-family: var(--hpq-font, "Vazirmatn", Tahoma, ui-sans-serif, system-ui, sans-serif);
}

.hpq-toc__box {
  margin: 0 0 1.35rem;
  padding: 0.9rem 1rem 1rem;
  background: var(--hpq-white, #fff);
  border: 1px solid var(--hpq-border, #e5e7eb);
  border-radius: var(--hpq-radius, 10px);
  box-shadow: 0 1px 2px rgba(47, 101, 98, 0.04);
}

.hpq-toc--sidebar .hpq-toc__box {
  margin: 0;
}

.hpq-toc__title {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--hpq-teal-deep, #2f6562);
  list-style: none;
  cursor: default;
}

.hpq-toc details.hpq-toc__box > summary.hpq-toc__title {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.hpq-toc details.hpq-toc__box > summary.hpq-toc__title::-webkit-details-marker {
  display: none;
}

.hpq-toc details.hpq-toc__box > summary.hpq-toc__title::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-inline-end: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex: 0 0 auto;
}

.hpq-toc details.hpq-toc__box[open] > summary.hpq-toc__title::after {
  transform: rotate(-135deg);
  margin-top: 0.25rem;
}

/* Peek (semi-open): show ~2 items until expanded. details stays open so list is visible. */
.hpq-toc details.hpq-toc__box[data-hpq-toc-peek]:not(.is-expanded) > summary.hpq-toc__title::after {
  transform: rotate(45deg);
  margin-top: 0;
}

.hpq-toc details.hpq-toc__box[data-hpq-toc-peek].is-expanded > summary.hpq-toc__title::after {
  transform: rotate(-135deg);
  margin-top: 0.25rem;
}

.hpq-toc details.hpq-toc__box[data-hpq-toc-peek]:not(.is-expanded) > .hpq-toc__list {
  max-height: 5.1rem;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
}

.hpq-toc details.hpq-toc__box[data-hpq-toc-peek].is-expanded > .hpq-toc__list,
.hpq-toc details.hpq-toc__box[data-hpq-toc-peek].hpq-toc__box--short > .hpq-toc__list {
  max-height: none;
  overflow: visible;
  -webkit-mask-image: none;
  mask-image: none;
}

.hpq-toc details.hpq-toc__box[data-hpq-toc-peek].hpq-toc__box--short > summary.hpq-toc__title {
  cursor: default;
  pointer-events: none;
}

.hpq-toc details.hpq-toc__box[data-hpq-toc-peek].hpq-toc__box--short > summary.hpq-toc__title::after {
  display: none;
}

.hpq-toc__list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: hpq-toc;
}

.hpq-toc__item {
  margin: 0;
  border-top: 1px solid var(--hpq-border, #e5e7eb);
}

.hpq-toc__item:first-child {
  border-top: 0;
}

.hpq-toc__item a {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.45rem 0.15rem;
  color: var(--hpq-ink, #1a1a1a);
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1.55;
  font-weight: 600;
}

.hpq-toc__item a::before {
  counter-increment: hpq-toc;
  content: counter(hpq-toc, decimal);
  flex: 0 0 1.35rem;
  color: var(--hpq-teal, #54a29e);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

.hpq-toc__item--h3 a {
  padding-right: 1.1rem;
  font-weight: 500;
  font-size: 0.8125rem;
  color: var(--hpq-muted, #525252);
}

.hpq-toc__item a:hover,
.hpq-toc__item a:focus-visible {
  color: var(--hpq-teal-deep, #2f6562);
}

.hpq-toc__item.is-active > a {
  color: var(--hpq-teal-deep, #2f6562);
}

.hpq-toc__item.is-active > a::before {
  color: var(--hpq-copper, #b87333);
}

.hpq-content-block h2[id],
.hpq-faq h2[id],
.hpq-news h2[id],
.hpq-calc h2[id],
.hpq-post-body h2[id],
.hpq-post-body h3[id],
.hpq-section h2[id] {
  scroll-margin-top: calc(var(--hh-bar-h, 4.25rem) + var(--hh-nav-h, 2.85rem) + 0.75rem);
}

.hpq-content-aside .hpq-toc--sidebar {
  position: sticky;
  top: calc(var(--hh-bar-h, 4.25rem) + var(--hh-nav-h, 2.85rem) + 0.5rem);
  z-index: 2;
}

.hpq-post-sidebar .hpq-toc--sidebar {
  position: sticky;
  top: calc(var(--hh-bar-h, 4.25rem) + var(--hh-nav-h, 2.85rem) + 0.5rem);
  z-index: 2;
  margin-bottom: 1rem;
}

@media (min-width: 901px) {
  .hpq-toc-pos--auto.hpq-toc--inline {
    display: none;
  }
}

@media (max-width: 900px) {
  .hpq-toc-pos--auto.hpq-toc--sidebar {
    display: none;
  }

  .hpq-content-aside .hpq-toc--sidebar,
  .hpq-post-sidebar .hpq-toc--sidebar {
    position: static;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hpq-toc details.hpq-toc__box > summary.hpq-toc__title::after {
    transition: none;
  }
}
