html {
  scroll-behavior: smooth;
}

/* =========================
   TOC Box
========================= */
.custom-toc-box{
  position: relative;
  background: linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
  border: 1px solid rgba(37, 99, 235, 0.10);
  border-radius: 20px;
  padding: 18px 18px 16px;
  margin: 28px 0 30px;
  box-shadow:
    0 10px 30px rgba(15, 23, 42, 0.05),
    0 2px 8px rgba(37, 99, 235, 0.04);
  overflow: hidden;
}

.custom-toc-box::before{
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #2563eb, #60a5fa, #93c5fd);
  opacity: 0.95;
}

/* =========================
   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: 18px;
  font-weight: 800;
  line-height: 1.5;
  color: #0f172a !important;

  cursor: pointer;
  outline: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
}

.custom-toc-toggle:hover{
  color: #2563eb !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: 10px;
  background: rgba(37, 99, 235, 0.10);
  color: #2563eb;
  font-size: 16px;
  font-weight: 700;
  flex: 0 0 28px;
}

.custom-toc-toggle-icon{
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  transition: transform 0.28s ease, color 0.2s ease;
  color: #2563eb;
  transform: rotate(0deg);
}

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

/* =========================
   Content
========================= */
.custom-toc-content{
  overflow: hidden;
  height: auto;
  opacity: 1;
  margin-top: 16px;
  will-change: height, opacity;
  transition: opacity 0.25s ease, margin-top 0.25s ease;
}

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

/* =========================
   List
========================= */
.custom-toc-list{
  list-style: none;
  margin: 0;
  padding: 0;
}

.custom-toc-list li{
  margin: 0 0 10px 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: 10px 12px 10px 10px;
  border-radius: 14px;

  text-decoration: none !important;
  color: #0f172a !important;
  background: rgba(255, 255, 255, 0.60);
  border: 1px solid rgba(255,255,255,0.65);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55);

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

  line-height: 1.95;
  transition:
    background 0.25s ease,
    border-color 0.25s ease,
    transform 0.22s ease,
    box-shadow 0.25s ease;
}

.custom-toc-list li a:hover{
  color: #2563eb !important;
  background: #ffffff;
  border-color: rgba(37, 99, 235, 0.18);
  transform: translateX(-3px);
  box-shadow:
    0 8px 18px rgba(37, 99, 235, 0.08),
    0 2px 6px rgba(15, 23, 42, 0.04);
}

/* =========================
   Numbers
========================= */
.toc-number{
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  margin-left: 6px;
  border-radius: 999px;

  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1d4ed8;
  font-weight: 800;
  font-size: 13px;
  direction: ltr;
  text-align: center;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

.toc-text{
  color: #111827;
  line-height: 1.95;
  word-break: break-word;
}

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

.custom-toc-list .toc-sub-item{
  font-size: 15px;
  font-weight: 400;
  padding-right: 22px;
  opacity: 0.92;
}

.custom-toc-list .toc-sub-item a{
  background: rgba(255,255,255,0.38);
}

.custom-toc-list .toc-sub-item .toc-number{
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  color: #2563eb;
  font-size: 12px;
  min-width: 28px;
  height: 28px;
}

/* =========================
   Active / focus state
========================= */
.custom-toc-list li a:focus-visible{
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

/* =========================
   Mobile
========================= */
@media (max-width: 921px){
  .custom-toc-box{
    border-radius: 16px;
    padding: 15px 14px 14px;
    margin: 24px 0 26px;
  }

  .custom-toc-toggle{
    font-size: 17px;
    gap: 10px;
  }

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

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

  .custom-toc-list li a{
    padding: 9px 10px 9px 8px;
    border-radius: 12px;
  }

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

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

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

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

/* ایجاد فاصله مناسب هنگام اسکرول به هدینگ‌ها */
.single-post h2,
.single-post h3,
.single-post h4 {
  scroll-margin-top: 25px;
}
