/* Wings Universal Anchor System - Frontend Styles */

/* Anchor copy button styling */
.wings-anchor-copy {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8em;
  opacity: 0;
  transition:
    opacity 0.3s ease,
    background-color 0.2s ease,
    transform 0.2s ease;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  vertical-align: middle;
  color: #666;
  text-decoration: none;
}

.wings-anchor-copy:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.1);
  transform: scale(1.1);
  color: #333;
}

.wings-anchor-copy.copied {
  background-color: #4caf50;
  color: white;
  opacity: 1;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Table of Contents styling */
.wings-toc {
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 1em;
  margin: 1em 0;
}

.wings-toc h3 {
  margin-top: 0;
  margin-bottom: 0.5em;
  color: #333;
  font-size: 1.2em;
}

.wings-toc ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.wings-toc li {
  margin: 0.25em 0;
  line-height: 1.4;
}

.wings-toc a {
  text-decoration: none;
  color: #333;
  transition: color 0.2s ease;
  display: block;
  padding: 0.2em 0;
}

.wings-toc a:hover {
  color: #0073aa;
  text-decoration: underline;
}

.wings-toc-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.wings-toc-list ul {
  padding-left: 1.5em;
  margin-top: 0.25em;
}

.wings-toc-list li {
  margin: 0.25em 0;
  line-height: 1.4;
}

.wings-toc-list a {
  text-decoration: none;
  color: #333;
  transition: color 0.2s ease;
}

.wings-toc-list a:hover {
  color: #0073aa;
}

/* Heading positioning - anchor buttons positioned to the right without affecting alignment */
h1,
h2,
h3,
h4,
h5,
h6 {
  position: relative;
}

/* Wrap heading content so the button can be positioned outside the text flow.
   This prevents centered headings (e.g. CTA titles) from being visually shifted. */
.wings-anchor-heading {
  position: relative;
  display: inline-block;
}

.wings-anchor-heading .wings-anchor-copy {
  position: absolute;
  left: 100%;
  top: 50%;
  /* Keep the icon vertically centered on the text.
     Note: this must win over the generic `.wings-anchor-copy { transform: ... }` rules below. */
  transform: translate(0, -50%) translateY(-1px) !important;
  margin-left: 0.4em;
}

/* Heading hover states - anchor buttons only visible on hover */
h1:hover .wings-anchor-copy,
h2:hover .wings-anchor-copy,
h3:hover .wings-anchor-copy,
h4:hover .wings-anchor-copy,
h5:hover .wings-anchor-copy,
h6:hover .wings-anchor-copy {
  opacity: 0.8;
}

/* Block anchor button styling */
.wings-block-anchor {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  opacity: 0;
  transition:
    opacity 0.3s ease,
    transform 0.2s ease;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Wings block hover states for anchor buttons - only visible on hover */
.wings-cta:hover .wings-block-anchor,
.wings-faq:hover .wings-block-anchor,
.wings-image:hover .wings-block-anchor,
.wings-blockquote:hover .wings-block-anchor,
.wings-callout:hover .wings-block-anchor,
.wings-single-node:hover .wings-block-anchor,
.wings-file-download:hover .wings-block-anchor,
.wings-nodes-grid:hover .wings-block-anchor,
.wings-people-organizations-grid:hover .wings-block-anchor {
  opacity: 0.8;
  transform: scale(1.05);
}

/* Make Wings blocks position relative for absolute positioning of anchor buttons */
.wings-cta,
.wings-faq,
.wings-image,
.wings-blockquote,
.wings-callout,
.wings-single-node,
.wings-file-download,
.wings-nodes-grid,
.wings-people-organizations-grid {
  position: relative;
}

/* Ensure anchor buttons are hidden by default for all elements */
.wings-anchor-copy {
  opacity: 0 !important;
  transform: translateY(-1px);
}

/* Show anchor buttons only on hover */
h1:hover .wings-anchor-copy,
h2:hover .wings-anchor-copy,
h3:hover .wings-anchor-copy,
h4:hover .wings-anchor-copy,
h5:hover .wings-anchor-copy,
h6:hover .wings-anchor-copy {
  opacity: 0.8 !important;
  transform: translateY(0);
}

/* When hovering headings, don't break the vertical centering of the button wrapper. */
h1:hover .wings-anchor-heading .wings-anchor-copy,
h2:hover .wings-anchor-heading .wings-anchor-copy,
h3:hover .wings-anchor-heading .wings-anchor-copy,
h4:hover .wings-anchor-heading .wings-anchor-copy,
h5:hover .wings-anchor-heading .wings-anchor-copy,
h6:hover .wings-anchor-heading .wings-anchor-copy {
  transform: translate(0, -50%) translateY(0) !important;
}

.wings-cta:hover .wings-block-anchor,
.wings-faq:hover .wings-block-anchor,
.wings-image:hover .wings-block-anchor,
.wings-blockquote:hover .wings-block-anchor,
.wings-callout:hover .wings-block-anchor,
.wings-single-node:hover .wings-block-anchor,
.wings-file-download:hover .wings-block-anchor,
.wings-nodes-grid:hover .wings-block-anchor,
.wings-people-organizations-grid:hover .wings-block-anchor {
  opacity: 0.8 !important;
  transform: scale(1.05);
}

/* Keep copied state visible */
.wings-anchor-copy.copied {
  opacity: 1 !important;
}

/* Hover active state for better UX */
.wings-anchor-copy.hover-active {
  opacity: 0.8 !important;
  transform: translateY(0);
}

/* Hover-active on headings should also preserve vertical centering. */
h1 .wings-anchor-heading .wings-anchor-copy.hover-active,
h2 .wings-anchor-heading .wings-anchor-copy.hover-active,
h3 .wings-anchor-heading .wings-anchor-copy.hover-active,
h4 .wings-anchor-heading .wings-anchor-copy.hover-active,
h5 .wings-anchor-heading .wings-anchor-copy.hover-active,
h6 .wings-anchor-heading .wings-anchor-copy.hover-active {
  transform: translate(0, -50%) translateY(0) !important;
}

/* Special handling for heading anchor buttons */
h1 .wings-anchor-copy.hover-active,
h2 .wings-anchor-copy.hover-active,
h3 .wings-anchor-copy.hover-active,
h4 .wings-anchor-copy.hover-active,
h5 .wings-anchor-copy.hover-active,
h6 .wings-anchor-copy.hover-active {
  transform: translateY(0);
}

/* Responsive design */
@media (max-width: 768px) {
  .wings-anchor-copy {
    font-size: 0.7em;
    padding: 0.15em 0.3em;
  }

  .wings-toc {
    padding: 0.75em;
    margin: 0.75em 0;
  }

  .wings-toc h3 {
    font-size: 1.1em;
  }
}

/* Accessibility improvements */
.wings-anchor-copy:focus {
  outline: 2px solid #0073aa;
  outline-offset: 2px;
  opacity: 1 !important;
  background-color: rgba(0, 115, 170, 0.1);
}

.wings-anchor-copy:focus:hover {
  background-color: rgba(0, 115, 170, 0.2);
}

.wings-toc a:focus {
  outline: 2px solid #0073aa;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .wings-anchor-copy {
    display: none;
  }

  .wings-toc {
    background: none;
    border: none;
    padding: 0;
    margin: 1em 0;
  }
}
