/* Base styles for all heading anchors */
.heading-anchor {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5em;
  opacity: 0;
  color: #a00;
  text-decoration: none;
  transition: opacity 0.2s ease-in-out;
  font-size: 0.8em;
  vertical-align: middle;
  user-select: none;
}

/* Show on hover */
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
  opacity: 1;
}

/* Also show when focusing the anchor link itself */
.heading-anchor:focus,
.heading-anchor:hover {
  opacity: 1;
  outline: none;
}

/* Symbol styling */
.heading-anchor-symbol {
  display: inline-block;
  font-weight: normal;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .heading-anchor {
    color: gold;
  }
}

/* Override for forced dark mode (your site uses mode="dark") */
body.dark-mode .heading-anchor,
body.dark .heading-anchor {
  color: gold;
}

/* Mobile: always visible on touch devices */
@media (hover: none) and (pointer: coarse) {
  .heading-anchor {
    opacity: 0.6;
  }
}

/* Add padding to headings to make clickable area larger */
h1, h2, h3, h4, h5, h6 {
  scroll-margin-top: 2rem; /* Better scroll position */
}
