/* ==========================================================================
   Adamic Blog - Main Stylesheet
   Common styles shared across all pages
   ========================================================================== */

/* ==========================================================================
   CSS Variables - Default light theme, overridden by data-theme attribute
   ========================================================================== */

html {
    --primary-color: #1e40af; /* Darkened to Blue-800 for strong contrast (7.5:1 with white) */
    --text-color: #1f2937;
    --text-muted: #4b5563; /* Darkened from #6b7280 for better contrast */
    --border-color: #e5e7eb;
    --background: #ffffff;
    --background-alt: #f9fafb;
    --btn-text-color: #ffffff;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    line-height: 1.6;
    scroll-behavior: smooth !important;
}

body {
    font-family: 'system-fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--background);
    text-rendering: optimizeSpeed;
    padding-top: 120px !important;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
    color: var(--text-color);
    min-height: 2.4rem;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 1.125rem;
    margin-bottom: 1rem;
    line-height: 1.6;
    min-height: 1.8rem;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.header {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    background: var(--background);
    contain: layout style;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    backdrop-filter: blur(10px) !important;
    background: rgba(255, 255, 255, 0.95) !important;
    border-bottom: 1px solid rgba(229, 231, 235, 0.8) !important;
    will-change: transform !important;
    transform: translateZ(0) !important;
    transition: all 0.3s ease !important;
}

.site-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    background: var(--background) !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    backdrop-filter: blur(10px);
    will-change: transform !important;
    transform: translateZ(0) !important;
    transition: all 0.3s ease, background-color 0.3s ease, border-color 0.3s ease !important;
}

.header.scrolled,
.site-header.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
}

/* Light mode scrolled background */
[data-theme="light"] .header.scrolled,
[data-theme="light"] .site-header.scrolled {
    background: rgba(255, 255, 255, 0.98) !important;
}

/* Explicitly set header background for dark theme */
[data-theme="dark"] .header,
[data-theme="dark"] .site-header,
[data-theme="dark"] .header.scrolled,
[data-theme="dark"] .site-header.scrolled {
    background: rgba(17, 24, 39, 0.98) !important;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 88px;
}

.logo-link {
    display: inline-block;
    text-decoration: none;
}

.logo {
    height: 58px;
    width: 58px;
    image-rendering: crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    display: block;
    object-fit: contain;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    text-decoration: none;
    line-height: 1.2;
}

.main-nav {
    display: flex;
    align-items: center;
    margin-left: 0.5rem;
    gap: 0.4rem;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: var(--background-alt);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: 0;
}

.nav-text {
    display: inline;
}

.nav-icon {
    display: none;
}

.nav-link:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.site-tagline {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-left: auto;
    line-height: 1.2;
    white-space: nowrap !important;
}

/* ==========================================================================
   Theme Toggle Button
   ========================================================================== */

#theme-toggle,
#theme-toggle-mobile {
    min-width: 50px;
    padding: 0.75rem 0.75rem;
    cursor: pointer;
}

#theme-toggle:hover,
#theme-toggle-mobile:hover {
    background: var(--primary-color);
    color: var(--btn-text-color);
    border-color: var(--primary-color);
}

#theme-icon,
#theme-icon-mobile {
    font-size: 1.1rem;
    line-height: 1;
}

/* ==========================================================================
   Active Navigation State
   ========================================================================== */

/* Active navigation state - applies to current page link */
.nav-link.active {
    background: var(--primary-color);
    color: var(--btn-text-color);
    font-weight: 600;
    border-color: var(--primary-color);
}

/* Navigation link min-widths for consistent button sizes */
.nav-link[href="/"],
.nav-link[href="/"][title="Home"] {
    min-width: 79px;
}

.nav-link[href="/articles/"],
.nav-link[href="/articles/"][title="Articles"] {
    min-width: 88px;
}

.nav-link[href*="search.adamic.tech"],
.nav-link[title="AI Search"] {
    min-width: 100px;
}

.nav-link[href="/faq.html"],
.nav-link[href="/faq.html"][title="FAQ"] {
    min-width: 67px;
}

.nav-link[href="/contact.html"],
.nav-link[href="/contact.html"][title="Contact"] {
    min-width: 90px;
}

/* SVG icons in navigation - both desktop and mobile */
.nav-link svg,
.mobile-nav-links svg {
    display: inline-block;
    vertical-align: middle;
    padding: 4px 0;
}

/* ==========================================================================
   Page-Specific Active Navigation States
   ========================================================================== */

/* Home page active navigation */
body.page-home .nav-link[href="/"],
body.page-home .nav-link[title="Home"] {
    background: var(--primary-color);
    color: var(--btn-text-color);
    font-weight: 600;
    border-color: var(--primary-color);
}

/* Articles page active navigation */
body.articles-page .nav-link[href="/articles/"],
body.articles-page .nav-link[title="Articles"] {
    background: var(--primary-color);
    color: var(--btn-text-color);
    font-weight: 600;
}

/* FAQ page active navigation */
body.faq-page .nav-link[href="/faq.html"],
body.faq-page .nav-link[href="../faq.html"],
body.faq-page .nav-link[title="FAQ"] {
    background: var(--primary-color);
    color: var(--btn-text-color);
    font-weight: 600;
}

/* Contact page active navigation */
body.contact-page .nav-link[href="/contact.html"],
body.contact-page .nav-link[href="../contact.html"],
body.contact-page .nav-link[title="Contact"] {
    background: var(--primary-color);
    color: var(--btn-text-color);
    font-weight: 600;
}

/* ==========================================================================
   Hamburger Menu & Mobile Navigation
   ========================================================================== */

.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 0.5rem;
    border: none;
    background: none;
    margin-left: 0.5rem;
}

.hamburger span {
    width: 24px;
    height: 2px;
    background: var(--text-color);
    margin: 3px 0;
    transition: 0.3s;
    border-radius: 2px;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(-45deg) translate(-5px, 6px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(45deg) translate(-5px, -6px);
}

.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.mobile-nav {
    display: block;
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100vh;
    background: var(--background);
    border-left: 1px solid var(--border-color);
    z-index: 1000;
    transition: right 0.3s ease;
    padding: 2rem 1rem;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    text-align: left;
}

.mobile-nav.active {
    right: 0;
}

.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.mobile-nav-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
    padding: 0.5rem;
}

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: left;
}

.mobile-nav-links .nav-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--background-alt);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.mobile-nav-links .nav-link:hover,
.mobile-nav-links .nav-link.active {
    background: var(--primary-color);
    color: var(--btn-text-color);
    border-color: var(--primary-color);
}

.mobile-nav-links .nav-link .nav-text {
    display: inline;
}

.mobile-nav-links .nav-link .nav-icon {
    display: inline;
}

/* ==========================================================================
   Main Content
   ========================================================================== */

.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    font-size: 1rem;
    font-weight: 400;
    contain: layout style;
    min-height: 800px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ==========================================================================
   Back to Top Button
   ========================================================================== */

.back-to-top {
    position: fixed;
    top: min(50%, calc(100vh - 422px));
    left: 10%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: var(--btn-text-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.15);
    transition: all 0.3s ease;
    opacity: 1;
    visibility: visible;
    z-index: 1000;
    font-weight: bold;
}

.back-to-top:hover {
    background: var(--text-color);
    transform: translateY(-50%) translateX(2px);
    box-shadow: 0 6px 16px rgb(0 0 0 / 0.2);
}

.back-to-top:active {
    transform: translateY(-50%) translateX(0);
}

.back-to-top:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ==========================================================================
   Social Sharing Styles
   ========================================================================== */

.social-share {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--background-alt);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    contain: layout style;
}

.social-share-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.social-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 1.1rem;
    border: 1px solid var(--border-color);
    background: var(--background);
}

.social-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px -2px rgb(0 0 0 / 0.1);
}

.social-btn.twitter {
    color: #1da1f2;
}

.social-btn.twitter:hover {
    background: #1da1f2;
    color: white;
    border-color: #1da1f2;
}

.social-btn.linkedin {
    color: #0077b5;
}

.social-btn.linkedin:hover {
    background: #0077b5;
    color: white;
    border-color: #0077b5;
}

.social-btn.reddit {
    color: #FF4500;
}

.social-btn.reddit:hover {
    background: #FF4500;
    color: white;
    border-color: #FF4500;
}

.social-btn.discord {
    color: #5865F2;
}

.social-btn.discord:hover {
    background: #5865F2;
    color: white;
    border-color: #5865F2;
}

.social-btn.copy {
    color: var(--text-muted);
}

.social-btn.copy:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.social-btn.copied {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.share-success {
    font-size: 0.75rem;
    color: #10b981;
    margin-left: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.share-success.show {
    opacity: 1;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
    background: var(--background-alt);
    border-top: 1px solid var(--border-color);
    margin-top: 3rem;
    padding: 2rem 0 1rem;
    contain: layout style paint;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.footer-section h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 1rem;
}

.footer-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-section li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.footer-section a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.footer-bottom {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem 0;
    border-top: 1px solid var(--border-color);
    margin-top: 1.5rem;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer-bottom p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0;
}

.footer-bottom a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
}

.footer-bottom a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* ==========================================================================
   Theme System - Light Theme
   ========================================================================== */

html[data-theme="light"] {
    --primary-color: #1e40af; /* WCAG AA compliant for light theme (Darkened to Blue-800) */
    --text-color: #1f2937;
    --text-muted: #4b5563; /* Darkened from #6b7280 for better contrast */
    --border-color: #e5e7eb;
    --background: #ffffff;
    --background-alt: #f9fafb;
    --btn-text-color: #ffffff;
}

[data-theme="light"] body {
    background: var(--background);
    color: var(--text-color);
}

[data-theme="light"] .header {
    background: var(--background);
    border-bottom-color: var(--border-color);
}

[data-theme="light"] .header.header {
    background: rgba(255, 255, 255, 0.95) !important;
    border-bottom-color: rgba(229, 231, 235, 0.8) !important;
}

[data-theme="light"] .header.header.scrolled {
    background: rgba(255, 255, 255, 0.98) !important;
}

[data-theme="light"] .site-header {
    background: var(--background) !important;
    border-bottom-color: var(--border-color);
}

/* ==========================================================================
   Theme System - Dark Theme
   ========================================================================== */

html[data-theme="dark"] {
    --primary-color: #60a5fa; /* Already WCAG AA compliant for dark backgrounds */
    --text-color: #f9fafb;
    --text-muted: #d1d5db; /* Lightened from #9ca3af for better contrast on dark backgrounds */
    --border-color: #374151;
    --background: #111827;
    --background-alt: #1f2937;
    --btn-text-color: #111827;
}

[data-theme="dark"] body {
    background: var(--background);
    color: var(--text-color);
}

[data-theme="dark"] .header {
    background: var(--background);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .site-header {
    background: var(--background) !important;
    border-bottom-color: var(--border-color);
}

/* Fix dark mode scrolled state for site-header */
[data-theme="dark"] .site-header.scrolled {
    background: rgba(17, 24, 39, 0.98) !important;
}

[data-theme="dark"] .social-btn {
    background: var(--background-alt);
    border-color: var(--border-color);
}

[data-theme="dark"] .social-btn.reddit {
    color: #FF7B54;
    border-color: #FF7B54;
}

[data-theme="dark"] .social-btn.discord {
    color: #7289DA;
    border-color: #7289DA;
}

[data-theme="dark"] .social-btn.copied {
    background: #4caf50;
    border-color: #4caf50;
}

[data-theme="dark"] .share-success {
    color: #4caf50;
}

/* ==========================================================================
   System Dark Mode Preference (fallback when no explicit theme set)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #60a5fa; /* WCAG AA compliant for dark backgrounds */
        --text-color: #f9fafb;
        --text-muted: #d1d5db; /* Lightened from #9ca3af for better contrast on dark backgrounds */
        --border-color: #374151;
        --background: #111827;
        --background-alt: #1f2937;
        --btn-text-color: #111827;
    }

    body {
        background: var(--background);
        color: var(--text-color);
    }

    .header {
        background: var(--background);
        border-bottom-color: var(--border-color);
    }

    .header.header {
        background: rgba(17, 24, 39, 0.95) !important;
        border-bottom-color: rgba(55, 65, 81, 0.8) !important;
    }

    .header.header.scrolled {
        background: rgba(17, 24, 39, 0.98) !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
    }

    .social-btn {
        background: var(--background-alt);
        border-color: var(--border-color);
    }

    .social-btn.reddit {
        color: #FF7B54;
        border-color: #FF7B54;
    }

    .social-btn.discord {
        color: #7289DA;
        border-color: #7289DA;
    }
}

/* ==========================================================================
   Mobile Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    body {
        padding-top: 100px !important;
    }

    h1 {
        margin-top: 20px !important;
    }

    /* Fix dark mode scrolled header background on mobile */
    [data-theme="dark"] .header.scrolled,
    [data-theme="dark"] .site-header.scrolled {
        background: rgba(17, 24, 39, 0.98) !important;
    }

    .header-content {
        padding: 0 1rem;
        flex-wrap: nowrap;
        align-items: center;
    }

    .hamburger {
        display: flex;
        order: 3;
    }

    .main-nav {
        display: none;
    }

    .main-nav .nav-text {
        display: none;
    }

    .nav-icon {
        display: inline;
    }

    .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    #theme-toggle .nav-text {
        display: none;
    }

    .main {
        padding: 1rem;
        min-height: 900px;
    }

    .site-tagline {
        display: none;
    }

    .social-share {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .social-share-label {
        width: 100%;
        margin-bottom: 0.25rem;
        margin-right: 0;
    }

    .footer {
        padding: 1.5rem 0 1rem;
    }

    .footer-content {
        padding: 0 1rem;
        grid-template-columns: 1fr;
        gap: 1rem;
        text-align: center;
    }

    .footer-bottom {
        padding: 1rem 1rem 0;
        flex-direction: column;
        gap: 0.5rem;
    }

    .footer-section h2 {
        font-size: 1rem;
    }

    .footer-section a {
        font-size: 0.875rem;
    }

    .footer-section ul {
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
        justify-content: center;
    }

    .footer-section li {
        margin-bottom: 0.5rem;
        display: inline-block;
    }

    .back-to-top {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .main {
        min-height: 800px;
    }

    .header-content {
        height: 88px;
    }
}

/* ==========================================================================
   Documentation Refactoring Styles (Feature Grid & Install Snippets)
   ========================================================================== */

.quick-install {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--background-alt);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.quick-install pre {
    margin: 0;
    overflow-x: auto;
}

.quick-install code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.875rem;
    color: var(--primary-color);
}

[data-theme="dark"] .quick-install code {
    color: #93c5fd;
}

.visual-asset-placeholder {
    margin: 1.5rem 0;
    padding: 3rem 1rem;
    background: var(--background-alt);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    text-align: center;
    color: var(--text-muted);
    font-weight: 500;
}

.visual-asset {
    margin: 1.5rem 0;
    text-align: center;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
}

.feature-grid li {
    background: var(--background);
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.feature-grid li strong {
    display: block;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

