/* Mục lục cho các trang part-N của loạt "code thực chiến". Xem part-toc.js. */

/* Header của site là position: sticky, cao 60px — thiếu dòng này thì nhảy tới
   một mục xong tiêu đề của nó bị header che mất. */
.article-body h2[id],
.article-body h3[id] {
  scroll-margin-top: 76px;
}

.ptoc-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  transition:
    background 0.15s,
    border-color 0.15s;
}

.ptoc-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

.ptoc-btn__icon {
  font-size: 1rem;
  line-height: 1;
}

.ptoc-btn__label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ptoc-panel {
  position: fixed;
  right: 20px;
  bottom: 74px;
  z-index: 91;
  display: flex;
  flex-direction: column;
  width: 340px;
  max-height: min(70vh, 560px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.ptoc-panel[hidden] {
  display: none;
}

/* blog.css dat mau cho <strong> theo than bai (giao dien sang) nen tieu de panel
   thua huong rgb(36,36,36) — gan nhu den tren nen navy. Phai chi ro. */
.ptoc-panel__head strong {
  color: var(--text);
  font-size: 0.9375rem;
}

.ptoc-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.ptoc-close {
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.ptoc-close:hover {
  color: var(--text);
}

.ptoc-list {
  margin: 0;
  padding: 8px 0;
  list-style: none;
  overflow-y: auto;
}

.ptoc-item a {
  display: block;
  padding: 7px 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1.4;
  border-left: 2px solid transparent;
}

.ptoc-item a:hover {
  color: var(--text);
  background: var(--bg-card-hover);
}

.ptoc-item--h3 a {
  padding-left: 34px;
  font-size: 0.8125rem;
}

.ptoc-item a.is-current {
  color: var(--accent);
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* Màn hình hẹp: panel thành một tấm chiếm cả chiều ngang, dễ bấm bằng ngón tay */
@media (max-width: 900px) {
  .ptoc-panel {
    right: 12px;
    left: 12px;
    bottom: 74px;
    width: auto;
    max-height: 60vh;
  }

  .ptoc-btn {
    right: 12px;
    bottom: 12px;
  }

  .ptoc-item a {
    padding-top: 9px;
    padding-bottom: 9px;
  }
}

@media (max-width: 480px) {
  .ptoc-btn__label {
    display: none;
  }

  .ptoc-btn {
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ptoc-btn {
    transition: none;
  }
}
