/**
 * Base styles for Programmatic SEO Hub.
 * Complements Tailwind with custom utilities and component styles.
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
    --transition-fast: 150ms;
    --transition-base: 200ms;
    --transition-slow: 300ms;
}

/* ==========================================================================
   Base Element Styles
   ========================================================================== */

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem; /* Account for sticky nav */
}

/* Selection styling */
::selection {
    background-color: rgba(34, 197, 94, 0.3);
    color: #fafafa;
}

/* Focus styles for accessibility */
:focus-visible {
    outline: 2px solid #22c55e;
    outline-offset: 2px;
}

/* Remove default focus for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}

/* ==========================================================================
   Typography
   ========================================================================== */

/* Prose styling for article content */
.prose {
    color: #a1a1aa;
    line-height: 1.75;
}

/* Ensure .not-prose elements don't inherit prose color/line-height */
.prose .not-prose {
    color: initial;
    line-height: normal;
}

.prose h2:where(:not(.not-prose, .not-prose *)) {
    font-family: 'Instrument Serif', Georgia, serif;
    font-size: 1.75rem;
    color: #fafafa;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    scroll-margin-top: 5rem;
}

.prose h3:where(:not(.not-prose, .not-prose *)) {
    font-family: 'Instrument Serif', Georgia, serif;
    font-size: 1.375rem;
    color: #f4f4f5;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    scroll-margin-top: 5rem;
}

.prose h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #e4e4e7;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.prose p:where(:not(.not-prose, .not-prose *)) {
    margin-bottom: 1.25rem;
}

.prose a:where(:not(.not-prose, .not-prose *)) {
    color: #4ade80;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--transition-fast);
}

.prose a:where(:not(.not-prose, .not-prose *)):hover {
    color: #22c55e;
}

.prose strong {
    color: #f4f4f5;
    font-weight: 600;
}

.prose ul,
.prose ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.prose ul {
    list-style-type: disc;
}

.prose ol {
    list-style-type: decimal;
}

.prose li {
    margin-bottom: 0.5rem;
}

.prose blockquote {
    border-left: 3px solid #22c55e;
    padding-left: 1rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: #d4d4d8;
}

.prose code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875em;
    background-color: #27272a;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    color: #fb923c;
}

.prose pre {
    background-color: #18181b;
    border: 1px solid #27272a;
    border-radius: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.prose pre code {
    background: none;
    padding: 0;
    color: #e4e4e7;
}

.prose img {
    border-radius: 0.75rem;
    margin: 1.5rem 0;
}

.prose hr {
    border: none;
    border-top: 1px solid #27272a;
    margin: 2rem 0;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

.prose th,
.prose td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #27272a;
}

.prose th {
    color: #fafafa;
    font-weight: 600;
}

/* ==========================================================================
   Navigation Styles
   ========================================================================== */

.nav-link {
    padding: 0.5rem 0.75rem;
    color: #a1a1aa;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all var(--transition-fast);
}

.nav-link:hover {
    color: #fafafa;
    background-color: rgba(39, 39, 42, 0.5);
}

.nav-link.active {
    color: #22c55e;
    background-color: rgba(34, 197, 94, 0.1);
}

.mobile-nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: #a1a1aa;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all var(--transition-fast);
}

.mobile-nav-link:hover {
    color: #fafafa;
    background-color: rgba(39, 39, 42, 0.5);
}

/* ==========================================================================
   Footer Styles
   ========================================================================== */

.footer-link {
    color: #71717a;
    font-size: 0.875rem;
    transition: color var(--transition-fast);
}

.footer-link:hover {
    color: #4ade80;
}

/* ==========================================================================
   Table of Contents
   ========================================================================== */

.toc-link.active {
    color: #4ade80;
    border-left-color: #4ade80;
}

/* ==========================================================================
   Animations
   ========================================================================== */

/* Fade in animation for page loads */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Stagger animation delays */
.animate-delay-100 { animation-delay: 100ms; }
.animate-delay-200 { animation-delay: 200ms; }
.animate-delay-300 { animation-delay: 300ms; }
.animate-delay-400 { animation-delay: 400ms; }

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Line clamp utilities (supplement Tailwind) */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==========================================================================
   Form Styles (for Admin)
   ========================================================================== */

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: #18181b;
    border: 1px solid #27272a;
    border-radius: 0.5rem;
    color: #fafafa;
    font-size: 0.875rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.form-input::placeholder {
    color: #52525b;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #e4e4e7;
}

.form-textarea {
    min-height: 10rem;
    resize: vertical;
}

/* ==========================================================================
   Button Styles
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.5rem;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.btn-primary {
    background-color: #22c55e;
    color: #09090b;
}

.btn-primary:hover {
    background-color: #16a34a;
}

.btn-secondary {
    background-color: #27272a;
    color: #fafafa;
    border: 1px solid #3f3f46;
}

.btn-secondary:hover {
    background-color: #3f3f46;
}

.btn-ghost {
    background-color: transparent;
    color: #a1a1aa;
}

.btn-ghost:hover {
    background-color: rgba(39, 39, 42, 0.5);
    color: #fafafa;
}

/* ==========================================================================
   Citation Tooltip Component
   ========================================================================== */

.citation-ref {
    cursor: pointer;
    position: relative;
}

.citation-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #27272a;
    border: 1px solid #3f3f46;
    border-radius: 0.5rem;
    padding: 12px;
    min-width: 280px;
    max-width: 360px;
    box-sizing: border-box;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.4);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
    margin-bottom: 0.5rem;
}

.citation-tooltip.active {
    opacity: 1;
    visibility: visible;
}

/* Arrow pointing down from tooltip */
.citation-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #3f3f46;
}

.citation-tooltip-title {
    font-size: 0.8rem;
    color: #a1a1aa;
    margin-bottom: 0.375rem;
    line-height: 1.4;
}

.citation-tooltip-link {
    font-size: 0.75rem;
    color: #4ade80;
    text-decoration: underline;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.citation-tooltip-link:hover {
    color: #86efac;
}

/* ==========================================================================
   Inline CTA Component
   ========================================================================== */

/* Shimmer animation for inline CTA */
@keyframes ctaShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.inline-cta::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: ctaShimmer 8s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

