/**
 * Someh Heading Links
 *
 * A chain icon at the end of a content heading, with a tooltip, revealed on
 * hover. Only the icon ever fades — the heading text is untouched, so nothing
 * here can hide content from a reader or a crawler.
 */

.someh-has-hlink {
  position: relative;
}

.someh-hlink {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: .92em;
  height: .92em;
  margin-inline-start: .42em;
  vertical-align: middle;
  color: currentColor;
  opacity: 0;
  text-decoration: none !important;
  border: 0 !important;
  box-shadow: none !important;
  background: none !important;
  transition: opacity .18s ease, color .18s ease, transform .18s ease;
}

.someh-hlink svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Revealed by hovering anywhere on the heading, not just the icon itself. */
.someh-has-hlink:hover .someh-hlink,
.someh-has-hlink:focus-within .someh-hlink {
  opacity: .45;
}

.someh-has-hlink .someh-hlink:hover,
.someh-has-hlink .someh-hlink:focus-visible {
  opacity: 1;
  transform: translateY(-1px);
}

.someh-hlink:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ *
 * Tooltip
 * ------------------------------------------------------------------ *
 * Positioned with physical left/transform so it centres identically in
 * right-to-left and left-to-right text.
 */
.someh-hlink::after,
.someh-hlink::before {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
}

.someh-hlink::after {
  content: attr(data-tip);
  transform: translateX(-50%) translateY(4px);
  padding: 5px 10px;
  border-radius: 7px;
  background: #33363b;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
  z-index: 20;
}

/* The little pointer under the bubble. */
.someh-hlink::before {
  content: "";
  bottom: calc(100% + 4px);
  transform: translateX(-50%) translateY(4px);
  border: 5px solid transparent;
  border-top-color: #33363b;
  z-index: 20;
}

.someh-hlink:hover::after,
.someh-hlink:hover::before,
.someh-hlink:focus-visible::after,
.someh-hlink:focus-visible::before,
.someh-hlink.is-copied::after,
.someh-hlink.is-copied::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Confirmation state */
.someh-hlink.is-copied {
  opacity: 1;
  color: #17976a;
}

.someh-hlink.is-copied::after {
  background: #17976a;
}

.someh-hlink.is-copied::before {
  border-top-color: #17976a;
}

/* ------------------------------------------------------------------ *
 * Touch, motion, print
 * ------------------------------------------------------------------ */

/* No hover to reveal it, so keep it gently visible. */
@media (hover: none) {
  .someh-has-hlink .someh-hlink {
    opacity: .38;
  }
}

@media (prefers-reduced-motion: reduce) {
  .someh-hlink,
  .someh-hlink::after,
  .someh-hlink::before {
    transition: none;
  }

  .someh-has-hlink .someh-hlink:hover {
    transform: none;
  }
}

@media print {
  .someh-hlink {
    display: none !important;
  }
}

/* ------------------------------------------------------------------ *
 * Night skin
 * ------------------------------------------------------------------ */
html.dark-mode .someh-hlink::after,
html.dark-skin .someh-hlink::after,
html[data-theme="dark"] .someh-hlink::after,
body.dark-skin .someh-hlink::after {
  background: #f1f3f5;
  color: #1b1e23;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}

html.dark-mode .someh-hlink::before,
html.dark-skin .someh-hlink::before,
html[data-theme="dark"] .someh-hlink::before,
body.dark-skin .someh-hlink::before {
  border-top-color: #f1f3f5;
}

html.dark-mode .someh-hlink.is-copied::after,
html.dark-skin .someh-hlink.is-copied::after,
html[data-theme="dark"] .someh-hlink.is-copied::after,
body.dark-skin .someh-hlink.is-copied::after {
  background: #3ddc9a;
  color: #05301f;
}

html.dark-mode .someh-hlink.is-copied::before,
html.dark-skin .someh-hlink.is-copied::before,
html[data-theme="dark"] .someh-hlink.is-copied::before,
body.dark-skin .someh-hlink.is-copied::before {
  border-top-color: #3ddc9a;
}

html.dark-mode .someh-hlink.is-copied,
html.dark-skin .someh-hlink.is-copied,
html[data-theme="dark"] .someh-hlink.is-copied,
body.dark-skin .someh-hlink.is-copied {
  color: #3ddc9a;
}
