html {
  scroll-behavior: smooth;
}

/* =========================
   TOC Box (Aram Style)
========================= */
.custom-toc-box {
  position: relative;
  background: linear-gradient(180deg, var(--al-comment-surface-soft) 0%, var(--al-comment-bg-soft) 100%);
  border: 1px solid var(--al-comment-border);
  border-radius: var(--al-comment-radius-lg);
  padding: 18px 18px 16px;
  margin: 20px 0;
  box-shadow: var(--al-comment-shadow-sm);
  overflow: hidden;
}

/* خط بالای باکس حذف شده است */
.custom-toc-box::before {
  display: none !important;
}

/* =========================
   Toggle Header
========================= */
.custom-toc-toggle {
  width: 100%;
  background: transparent !important;
  border: none !important;
  padding: 0;
  margin: 0;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;

  text-align: right;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.5;
  color: var(--al-comment-text) !important;

  cursor: pointer;
  outline: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--al-comment-transition-fast);
}

.custom-toc-toggle:hover {
  color: var(--al-comment-accent-dark) !important;
}

.custom-toc-toggle-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.custom-toc-toggle-title::before {
  content: "≡";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--al-comment-radius-xs);
  background: var(--al-comment-accent-soft);
  color: var(--al-comment-accent-strong);
  font-size: 16px;
  font-weight: 700;
  flex: 0 0 28px;
  transition: transform var(--al-comment-transition-fast), background var(--al-comment-transition-fast);
}

.custom-toc-toggle:hover .custom-toc-toggle-title::before {
  background: var(--al-comment-accent);
  color: #ffffff;
}

.custom-toc-toggle-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  transition: transform var(--al-comment-transition), color var(--al-comment-transition-fast);
  color: var(--al-comment-accent);
  transform: rotate(0deg);
}

.custom-toc-toggle[aria-expanded="true"] .custom-toc-toggle-icon {
  transform: rotate(180deg);
}

/* =========================
   Content & List
========================= */
.custom-toc-content {
  overflow: hidden;
  height: auto;
  opacity: 1;
  margin-top: 16px;
  will-change: height, opacity;
  transition: opacity var(--al-comment-transition), margin-top var(--al-comment-transition);
}

.custom-toc-content.is-collapsed {
  opacity: 0;
  margin-top: 0;
}

.custom-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.custom-toc-list li {
  margin: 0 0 8px 0;
}

.custom-toc-list li:last-child {
  margin-bottom: 0;
}

/* =========================
   Link Items
========================= */
.custom-toc-list li a {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  column-gap: 10px;

  padding: 8px 12px 8px 10px;
  border-radius: var(--al-comment-radius-sm);

  text-decoration: none !important;
  color: var(--al-comment-text-soft) !important;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--al-comment-border-soft);
  box-shadow: var(--al-comment-shadow-xs);

  outline: none !important;
  -webkit-tap-highlight-color: transparent;

  line-height: 1.85;
  transition:
    background var(--al-comment-transition-fast),
    border-color var(--al-comment-transition-fast),
    transform var(--al-comment-transition-fast),
    box-shadow var(--al-comment-transition-fast),
    color var(--al-comment-transition-fast);
}

.custom-toc-list li a:hover {
  color: var(--al-comment-accent-dark) !important;
  background: var(--al-comment-surface);
  border-color: var(--al-comment-accent-soft);
  transform: translateX(-4px);
  box-shadow: var(--al-comment-shadow-sm);
}

/* =========================
   Numbers (بج‌های شماره‌گذاری)
========================= */
.toc-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: var(--al-comment-radius-pill);

  background: var(--al-comment-accent-soft);
  color: var(--al-comment-accent-strong);
  font-weight: 800;
  font-size: 13px;
  direction: ltr;
  text-align: center;
  line-height: 1;
  transition: background var(--al-comment-transition-fast), color var(--al-comment-transition-fast);
}

.custom-toc-list li a:hover .toc-number {
  background: var(--al-comment-accent);
  color: #ffffff;
}

.toc-text {
  color: var(--al-comment-text);
  line-height: 1.85;
  word-break: break-word;
}

/* =========================
   Main / Sub items
========================= */
.custom-toc-list .toc-main-item {
  font-size: 15.5px;
  font-weight: 700;
}

.custom-toc-list .toc-sub-item {
  font-size: 14.5px;
  font-weight: 400;
  padding-right: 20px;
}

.custom-toc-list .toc-sub-item a {
  background: rgba(255, 255, 255, 0.45);
  border-color: transparent;
}

.custom-toc-list .toc-sub-item a:hover {
  background: var(--al-comment-surface);
  border-color: var(--al-comment-border-soft);
}

.custom-toc-list .toc-sub-item .toc-number {
  background: var(--al-comment-bg-soft);
  color: var(--al-comment-text-muted);
  font-size: 12px;
  min-width: 26px;
  height: 26px;
}

.custom-toc-list .toc-sub-item a:hover .toc-number {
  background: var(--al-comment-accent-soft);
  color: var(--al-comment-accent-strong);
}

/* =========================
   Active / Focus state
========================= */
.custom-toc-list li a:focus-visible {
  border-color: var(--al-comment-accent);
  box-shadow: 0 0 0 3px var(--al-comment-accent-soft);
}

/* =========================
   Scroll Margin برای هدینگ‌ها
========================= */
.single-post h2,
.single-post h3,
.single-post h4,
.single-post h5,
.single-post h6 {
  scroll-margin-top: 35px;
}

/* =========================
   Mobile
========================= */
@media (max-width: 768px) {
  .custom-toc-box {
    border-radius: var(--al-comment-radius-md);
    padding: 14px 14px 12px;
    margin: 16px 0;
  }

  .custom-toc-toggle {
    font-size: 16px;
    gap: 8px;
  }

  .custom-toc-toggle-title::before {
    width: 26px;
    height: 26px;
    font-size: 14px;
    border-radius: 8px;
  }

  .custom-toc-content {
    margin-top: 12px;
  }

  .custom-toc-list li a {
    padding: 8px 10px 8px 8px;
    border-radius: var(--al-comment-radius-xs);
  }

  .custom-toc-list .toc-main-item {
    font-size: 15px;
  }

  .custom-toc-list .toc-sub-item {
    font-size: 14px;
    padding-right: 12px;
  }

  .toc-number {
    min-width: 26px;
    height: 26px;
    font-size: 12px;
    margin-left: 4px;
  }

  .single-post h2,
  .single-post h3,
  .single-post h4 {
    scroll-margin-top: 20px;
  }
}
