/* Ссылка на раздел (бриф 051): значок «#» у заголовков и строк инструментов, отступ под
   липкую шапку и короткая подсветка цели. */

/* Отступ под липкую шапку здесь не задаётся — он один на сайт, в brand-docs.css. */

.anchor-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  width: 1.6em;
  height: 1.6em;
  margin-left: 0.3em;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #8a8f98;
  font: 600 0.85em/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.anchor-link::before { content: "#"; }
.anchor-host:hover .anchor-link,
.anchor-link:focus-visible,
.anchor-link.anchor-done { opacity: 1; }
.anchor-link:hover { color: #1b1b1f; background: rgba(0, 0, 0, 0.06); }
.anchor-link:focus-visible { outline: 2px solid #6b5cff; outline-offset: 1px; }

/* Подсказка «Ссылка скопирована» — из data-tip, тоже без текста в разметке. */
.anchor-link.anchor-done::after {
  content: attr(data-tip);
  position: absolute;
  /* Растёт влево от значка: вправо она могла бы раздвинуть узкую страницу. */
  right: 0;
  bottom: calc(100% + 6px);
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 6px;
  background: #1b1b1f;
  color: #fff;
  font: 500 12px/1.3 "Inter", ui-sans-serif, system-ui, sans-serif;
  pointer-events: none;
}
.anchor-link { position: relative; }

/* Без наведения (телефон) значок виден всегда, но приглушённо. */
@media (hover: none) {
  .anchor-link { opacity: 0.45; }
  .anchor-link.anchor-done { opacity: 1; }
}

/* Цель перехода по ссылке — короткая подсветка, гаснет за ~2 с. Якорь инструмента вне
   таблиц (бриф 052) — пустой <span id> перед его <code>: подсвечивается абзац, пункт
   списка или блок кода, в котором он стоит. */
h2:target, h3:target, tr:target, tr:has(> td span:target),
section:target > h2:first-of-type,
p:has(> span[id]:target), li:has(> span[id]:target), pre:has(> span[id]:target) {
  animation: anchor-flash 2s ease-out;
}
@keyframes anchor-flash {
  0%, 30% { background: #c1f526; }
  100% { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  h2:target, h3:target, tr:target, tr:has(> td span:target),
  section:target > h2:first-of-type,
  p:has(> span[id]:target), li:has(> span[id]:target), pre:has(> span[id]:target) {
    animation: none; background: rgba(193, 245, 38, 0.45);
  }
}
