/**
 * Paragraph Anchors Styles
 * 
 * Styles for paragraph anchor links and copy buttons
 */

.paragraph-anchor {
    position: relative;
    scroll-margin-top: 100px; /* Account for fixed header */
}

.paragraph-anchor__button {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #9ca3af;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.paragraph-anchor__button--left {
    left: -36px;
    top: 5px;
    margin: auto;
}

.paragraph-anchor__button--right {
    right: -36px;
    top: 4px;
}

/* Show button on hover - specific selectors for article content */
.article-page__content p:hover .paragraph-anchor__button,
.article-page__content h1:hover .paragraph-anchor__button,
.article-page__content h2:hover .paragraph-anchor__button,
.article-page__content h3:hover .paragraph-anchor__button,
.article-page__content h4:hover .paragraph-anchor__button,
.article-page__content h5:hover .paragraph-anchor__button,
.article-page__content h6:hover .paragraph-anchor__button,
.prose p:hover .paragraph-anchor__button,
.prose h1:hover .paragraph-anchor__button,
.prose h2:hover .paragraph-anchor__button,
.prose h3:hover .paragraph-anchor__button,
.prose h4:hover .paragraph-anchor__button,
.prose h5:hover .paragraph-anchor__button,
.prose h6:hover .paragraph-anchor__button {
    opacity: 1;
}

.paragraph-anchor__button:hover {
    background: #f3f4f6;
    color: #3b82f6;
}

.paragraph-anchor__button:focus {
    opacity: 1;
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.paragraph-anchor__button--copied {
    color: #10b981;
}

.paragraph-anchor__button svg {
    width: 16px;
    height: 16px;
}

/* Highlight effect when navigating to paragraph */
.paragraph-anchor--highlighted {
    animation: highlight-fade 2s ease;
}

@keyframes highlight-fade {
    0% {
        background-color: rgba(59, 130, 246, 0.1);
    }
    100% {
        background-color: transparent;
    }
}

/* Toast notification */
.paragraph-anchor-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background: #1a1a1a;
    color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.paragraph-anchor-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Dark theme */
[data-theme="dark"] .paragraph-anchor__button {
    color: #6b7280;
}

[data-theme="dark"] .paragraph-anchor__button:hover {
    background: #374151;
    color: #60a5fa;
}

[data-theme="dark"] .paragraph-anchor-toast {
    background: #2a2a2a;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .paragraph-anchor__button {
        /* Always show on mobile since hover doesn't work well */
        opacity: 0.5;
    }
    
    .article-page__content p:hover .paragraph-anchor__button,
    .article-page__content h1:hover .paragraph-anchor__button,
    .article-page__content h2:hover .paragraph-anchor__button,
    .article-page__content h3:hover .paragraph-anchor__button,
    .article-page__content h4:hover .paragraph-anchor__button,
    .article-page__content h5:hover .paragraph-anchor__button,
    .article-page__content h6:hover .paragraph-anchor__button,
    .prose p:hover .paragraph-anchor__button,
    .prose h1:hover .paragraph-anchor__button,
    .prose h2:hover .paragraph-anchor__button,
    .prose h3:hover .paragraph-anchor__button,
    .prose h4:hover .paragraph-anchor__button,
    .prose h5:hover .paragraph-anchor__button,
    .prose h6:hover .paragraph-anchor__button,
    .paragraph-anchor__button:focus {
        opacity: 1;
    }
    
    .paragraph-anchor__button--left {
        left: -32px;
    }
    
    .paragraph-anchor__button--right {
        right: -32px;
    }
}

/* Very small screens - hide left positioned buttons */
@media (max-width: 640px) {
    .paragraph-anchor__button--left {
        display: none;
    }
    
    .paragraph-anchor__button--right {
        right: 0;
        top: 0;
        opacity: 0.3;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .paragraph-anchor__button--left {
        left: -32px;
    }
}

/* Touch devices - make buttons more visible */
@media (hover: none) and (pointer: coarse) {
    .paragraph-anchor__button {
        opacity: 0.4;
        width: 32px;
        height: 32px;
    }
    
    .article-page__content p:hover .paragraph-anchor__button,
    .article-page__content h1:hover .paragraph-anchor__button,
    .article-page__content h2:hover .paragraph-anchor__button,
    .article-page__content h3:hover .paragraph-anchor__button,
    .article-page__content h4:hover .paragraph-anchor__button,
    .article-page__content h5:hover .paragraph-anchor__button,
    .article-page__content h6:hover .paragraph-anchor__button,
    .prose p:hover .paragraph-anchor__button,
    .prose h1:hover .paragraph-anchor__button,
    .prose h2:hover .paragraph-anchor__button,
    .prose h3:hover .paragraph-anchor__button,
    .prose h4:hover .paragraph-anchor__button,
    .prose h5:hover .paragraph-anchor__button,
    .prose h6:hover .paragraph-anchor__button,
    .paragraph-anchor__button:focus {
        opacity: 1;
    }
}
