/* Modern Documentation CSS inspired by Substack with Aynstyn branding */

/* Reset and base styles */
@layer legacy, tailwind, pencraft;

@layer legacy {
    :root {
        /* Aynstyn Brand Colors (from index.css) */
        --color-primary: hsl(207 90% 54%);
        --color-primary-foreground: hsl(211 100% 99%);
        --color-background: hsl(0 0% 100%);
        --color-foreground: hsl(20 14.3% 4.1%);
        --color-muted: hsl(60 4.8% 95.9%);
        --color-muted-foreground: hsl(25 5.3% 44.7%);
        --color-border: hsl(20 5.9% 90%);
        --color-accent: hsl(60 4.8% 95.9%);
        --color-accent-foreground: hsl(24 9.8% 10%);
        
        /* Typography */
        --font-family-text: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
        --font-family-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        
        /* Spacing */
        --space-xs: 0.25rem;
        --space-sm: 0.5rem;
        --space-md: 1rem;
        --space-lg: 1.5rem;
        --space-xl: 2rem;
        --space-2xl: 3rem;
        --space-3xl: 4rem;
        
        /* Shadows */
        --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
        
        /* Border radius */
        --radius-sm: 0.375rem;
        --radius-md: 0.5rem;
        --radius-lg: 0.75rem;
    }

    /* Dark mode support */
    .dark {
        --color-background: hsl(240 10% 3.9%);
        --color-foreground: hsl(0 0% 98%);
        --color-muted: hsl(240 3.7% 15.9%);
        --color-muted-foreground: hsl(240 5% 64.9%);
        --color-border: hsl(240 3.7% 15.9%);
        --color-accent: hsl(240 3.7% 15.9%);
        --color-accent-foreground: hsl(0 0% 98%);
    }

    /* Base styles */
    * {
        box-sizing: border-box;
    }

    html {
        scroll-behavior: smooth;
        scrollbar-gutter: stable;
    }

    body {
        font-family: var(--font-family-text);
        color: var(--color-foreground);
        background-color: var(--color-background);
        line-height: 1.7;
        margin: 0;
        padding: 0;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* Header Styles */
    .site-header {
        background: var(--color-background);
        border-bottom: 1px solid var(--color-border);
        position: sticky;
        top: 0;
        z-index: 50;
        backdrop-filter: blur(10px);
        background-color: rgba(255, 255, 255, 0.9);
    }

    .nav-container {
        max-width: 1280px;
        margin: 0 auto;
        padding: 0 var(--space-lg);
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 4rem;
    }

    .nav-brand {
        display: flex;
        align-items: center;
        gap: var(--space-md);
    }

    .logo {
        height: 2rem;
        width: auto;
    }

    .brand-text {
        display: flex;
        flex-direction: column;
    }

    .brand-name {
        font-weight: 700;
        font-size: 1.125rem;
        color: var(--color-primary);
    }

    .brand-tagline {
        font-size: 0.875rem;
        color: var(--color-muted-foreground);
        line-height: 1;
    }

    .nav-link {
        color: var(--color-muted-foreground);
        text-decoration: none;
        font-weight: 500;
        padding: var(--space-sm) var(--space-md);
        border-radius: var(--radius-md);
        transition: all 0.2s ease;
    }

    .nav-link:hover {
        color: var(--color-primary);
        background-color: var(--color-accent);
    }

    /* Main Layout */
    .docs-container {
        max-width: 1280px;
        margin: 0 auto;
        display: grid;
        grid-template-columns: 280px 1fr;
        gap: var(--space-3xl);
        padding: 0 var(--space-lg);
        min-height: calc(100vh - 4rem);
    }

    /* Sidebar Navigation */
    .docs-sidebar {
        border-right: 1px solid var(--color-border);
        padding: var(--space-2xl) 0;
        position: sticky;
        top: 5rem;
        height: fit-content;
        max-height: calc(100vh - 6rem);
        overflow-y: auto;
    }

    .sidebar-nav {
        padding-right: var(--space-xl);
    }

    .nav-section {
        margin-bottom: var(--space-2xl);
    }

    .nav-section h3 {
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--color-foreground);
        margin: 0 0 var(--space-md) 0;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .nav-section ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .nav-section li {
        margin-bottom: var(--space-xs);
    }

    .nav-item {
        display: block;
        color: var(--color-muted-foreground);
        text-decoration: none;
        padding: var(--space-sm) var(--space-md);
        border-radius: var(--radius-md);
        font-size: 0.925rem;
        transition: all 0.2s ease;
        border-left: 2px solid transparent;
    }

    .nav-item:hover {
        color: var(--color-primary);
        background-color: var(--color-accent);
    }

    .nav-item.active {
        color: var(--color-primary);
        background-color: var(--color-accent);
        border-left-color: var(--color-primary);
        font-weight: 500;
    }

    /* Main Content */
    .docs-content {
        padding: var(--space-2xl) 0;
        max-width: none;
    }

    /* Hero Section */
    .hero-section {
        margin-bottom: var(--space-3xl);
        padding-bottom: var(--space-2xl);
        border-bottom: 1px solid var(--color-border);
    }

    .docs-title {
        font-family: var(--font-family-heading);
        font-size: 3rem;
        font-weight: 700;
        line-height: 1.1;
        margin: 0 0 var(--space-lg) 0;
        color: var(--color-foreground);
        letter-spacing: -0.02em;
    }

    .docs-subtitle {
        font-size: 1.25rem;
        line-height: 1.6;
        color: var(--color-muted-foreground);
        margin: 0;
        max-width: 42rem;
    }

    /* Article Content */
    .docs-article {
        max-width: 48rem;
    }

    .content-section {
        margin-bottom: var(--space-3xl);
        scroll-margin-top: 5rem;
    }

    .content-section h2 {
        font-family: var(--font-family-heading);
        font-size: 2rem;
        font-weight: 600;
        line-height: 1.2;
        margin: 0 0 var(--space-lg) 0;
        color: var(--color-foreground);
        padding-bottom: var(--space-md);
        border-bottom: 2px solid var(--color-primary);
    }

    .content-section h3 {
        font-family: var(--font-family-heading);
        font-size: 1.5rem;
        font-weight: 600;
        line-height: 1.3;
        margin: var(--space-xl) 0 var(--space-md) 0;
        color: var(--color-foreground);
    }

    .content-section h4 {
        font-family: var(--font-family-heading);
        font-size: 1.125rem;
        font-weight: 600;
        line-height: 1.4;
        margin: var(--space-lg) 0 var(--space-sm) 0;
        color: var(--color-foreground);
    }

    .content-section p {
        margin: 0 0 var(--space-lg) 0;
        line-height: 1.7;
        color: var(--color-foreground);
    }

    .section-intro {
        font-size: 1.125rem;
        color: var(--color-muted-foreground);
        margin-bottom: var(--space-xl) !important;
    }

    .content-intro {
        margin-bottom: var(--space-2xl);
    }

    .content-intro p {
        font-size: 1.125rem;
        line-height: 1.7;
        color: var(--color-muted-foreground);
    }

    /* Lists */
    ul, ol {
        margin: 0 0 var(--space-lg) 0;
        padding-left: var(--space-lg);
    }

    li {
        margin-bottom: var(--space-sm);
        line-height: 1.7;
    }

    /* Links */
    a {
        color: var(--color-primary);
        text-decoration: none;
        font-weight: 500;
    }

    a:hover {
        text-decoration: underline;
    }

    /* Feature Grid */
    .feature-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: var(--space-xl);
        margin: var(--space-2xl) 0;
    }

    .feature-card {
        padding: var(--space-xl);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        background: var(--color-background);
        transition: all 0.2s ease;
    }

    .feature-card:hover {
        box-shadow: var(--shadow-md);
        border-color: var(--color-primary);
    }

    .feature-icon {
        font-size: 2rem;
        margin-bottom: var(--space-md);
        display: block;
    }

    .feature-card h3 {
        font-size: 1.25rem;
        font-weight: 600;
        margin: 0 0 var(--space-sm) 0;
        color: var(--color-foreground);
    }

    .feature-card p {
        margin: 0;
        color: var(--color-muted-foreground);
        line-height: 1.6;
    }

    /* Step Container */
    .step-container {
        margin: var(--space-2xl) 0;
    }

    .step-item {
        display: flex;
        gap: var(--space-lg);
        margin-bottom: var(--space-2xl);
        padding-bottom: var(--space-xl);
        border-bottom: 1px solid var(--color-border);
    }

    .step-item:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    .step-number {
        flex-shrink: 0;
        width: 2.5rem;
        height: 2.5rem;
        background: var(--color-primary);
        color: var(--color-primary-foreground);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        font-size: 1.125rem;
    }

    .step-content h3 {
        margin-top: 0;
        margin-bottom: var(--space-sm);
    }

    .step-content p {
        margin-bottom: 0;
    }

    /* Info Box */
    .info-box {
        background: var(--color-accent);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        padding: var(--space-xl);
        margin: var(--space-xl) 0;
    }

    .info-box h4 {
        margin-top: 0;
        margin-bottom: var(--space-md);
        color: var(--color-foreground);
    }

    /* Method and Component Grids */
    .method-grid,
    .result-components,
    .improvement-tips,
    .privacy-highlights,
    .support-options {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: var(--space-lg);
        margin: var(--space-xl) 0;
        max-width: 700px; /* Limit width for 2-column layout */
    }

    .method-card,
    .component,
    .tip,
    .highlight,
    .support-card {
        padding: var(--space-lg);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        background: var(--color-background);
    }

    .method-card h4,
    .component h4,
    .tip h4,
    .highlight h4,
    .support-card h4 {
        margin-top: 0;
        margin-bottom: var(--space-sm);
        color: var(--color-foreground);
    }

    .method-card p,
    .component p,
    .tip p,
    .highlight p,
    .support-card p {
        margin-bottom: 0;
        color: var(--color-muted-foreground);
    }

    /* Subject Categories */
    .subject-categories {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: var(--space-lg);
        margin: var(--space-xl) 0;
    }

    .category {
        text-align: center;
        padding: var(--space-xl);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        background: var(--color-background);
    }

    .category h4 {
        margin-top: 0;
        margin-bottom: var(--space-sm);
        color: var(--color-primary);
    }

    /* Scoring Criteria */
    .scoring-criteria ul {
        background: var(--color-accent);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        padding: var(--space-lg);
        margin: var(--space-xl) 0;
    }

    /* Support Link */
    .support-link {
        display: inline-block;
        margin-top: var(--space-sm);
        padding: var(--space-sm) var(--space-md);
        background: var(--color-primary);
        color: var(--color-primary-foreground) !important;
        border-radius: var(--radius-md);
        text-decoration: none;
        font-weight: 500;
        transition: all 0.2s ease;
    }

    .support-link:hover {
        background: hsl(207 90% 48%);
        text-decoration: none;
    }

    /* Footer (using existing Tailwind classes) */
    footer {
        margin-top: var(--space-3xl);
    }

    /* Tailwind utility classes */
    .bg-gray-800 { background-color: rgb(31 41 55); }
    .text-white { color: rgb(255 255 255); }
    .mt-12 { margin-top: 3rem; }
    .max-w-7xl { max-width: 80rem; }
    .mx-auto { margin-left: auto; margin-right: auto; }
    .px-4 { padding-left: 1rem; padding-right: 1rem; }
    .sm\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
    .lg\:px-8 { padding-left: 2rem; padding-right: 2rem; }
    .py-12 { padding-top: 3rem; padding-bottom: 3rem; }
    .grid { display: grid; }
    .grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .md\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .gap-8 { gap: 2rem; }
    .flex { display: flex; }
    .items-center { align-items: center; }
    .space-x-2 > :not([hidden]) ~ :not([hidden]) { margin-left: 0.5rem; }
    .mb-4 { margin-bottom: 1rem; }
    .h-10 { height: 2.5rem; }
    .w-auto { width: auto; }
    .text-xl { font-size: 1.25rem; line-height: 1.75rem; }
    .font-bold { font-weight: 700; }
    .text-gray-400 { color: rgb(156 163 175); }
    .text-sm { font-size: 0.875rem; line-height: 1.25rem; }
    .text-lg { font-size: 1.125rem; line-height: 1.75rem; }
    .font-semibold { font-weight: 600; }
    .space-y-2 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.5rem; }
    .hover\:text-white:hover { color: rgb(255 255 255); }
    .transition { transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
    .border-t { border-top-width: 1px; }
    .border-gray-700 { border-color: rgb(55 65 81); }
    .mt-8 { margin-top: 2rem; }
    .pt-8 { padding-top: 2rem; }
    .text-center { text-align: center; }

    @media (min-width: 768px) {
        .md\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    }

    @media (min-width: 640px) {
        .sm\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
    }

    @media (min-width: 1024px) {
        .lg\:px-8 { padding-left: 2rem; padding-right: 2rem; }
    }

    /* Scroll to Top Button */
    .scroll-to-top {
        position: fixed;
        bottom: 2rem;
        right: 2rem;
        width: 3rem;
        height: 3rem;
        background: var(--color-primary);
        color: var(--color-primary-foreground);
        border: none;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: var(--shadow-lg);
        opacity: 0;
        visibility: hidden;
        transform: translateY(1rem);
        transition: all 0.3s ease;
        z-index: 50;
    }

    .scroll-to-top.visible {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .scroll-to-top:hover {
        background: hsl(207 90% 48%);
        transform: translateY(-0.125rem);
    }

    /* Responsive Design */
    @media (max-width: 768px) {
        .docs-container {
            grid-template-columns: 1fr;
            gap: 0;
            padding: 0 var(--space-md);
        }

        .docs-sidebar {
            display: none;
        }

        .nav-container {
            padding: 0 var(--space-md);
        }

        .brand-text {
            display: none;
        }

        .docs-title {
            font-size: 2rem;
        }

        .docs-subtitle {
            font-size: 1.125rem;
        }

        .feature-grid {
            grid-template-columns: 1fr;
        }

        .method-grid,
        .result-components,
        .improvement-tips,
        .privacy-highlights,
        .support-options {
            grid-template-columns: 1fr;
        }

        .subject-categories {
            grid-template-columns: 1fr;
        }

        footer .grid {
            grid-template-columns: 1fr;
        }

        .step-item {
            flex-direction: column;
            gap: var(--space-md);
        }

        .step-number {
            align-self: flex-start;
        }
    }

    @media (max-width: 480px) {
        .docs-content {
            padding: var(--space-lg) 0;
        }

        .hero-section {
            margin-bottom: var(--space-2xl);
        }

        .docs-title {
            font-size: 1.75rem;
        }

        .content-section {
            margin-bottom: var(--space-2xl);
        }

        .scroll-to-top {
            bottom: 1rem;
            right: 1rem;
            width: 2.5rem;
            height: 2.5rem;
        }
    }

    /* Print Styles */
    @media print {
        .site-header,
        .docs-sidebar,
        .scroll-to-top,
        footer {
            display: none;
        }

        .docs-container {
            grid-template-columns: 1fr;
            max-width: none;
            padding: 0;
        }

        .docs-content {
            padding: 0;
        }

        body {
            font-size: 12pt;
            line-height: 1.5;
        }

        .docs-title {
            font-size: 24pt;
        }

        .content-section h2 {
            font-size: 18pt;
            page-break-after: avoid;
        }

        .content-section h3 {
            font-size: 14pt;
            page-break-after: avoid;
        }
    }

    /* Accessibility Improvements */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }

        html {
            scroll-behavior: auto;
        }
    }

    /* Focus styles for keyboard navigation */
    .nav-item:focus,
    .nav-link:focus,
    .scroll-to-top:focus {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }

    /* High contrast mode support */
    @media (prefers-contrast: high) {
        :root {
            --color-border: hsl(0 0% 20%);
        }
        
        .feature-card,
        .method-card,
        .component,
        .tip,
        .highlight,
        .support-card,
        .category,
        .info-box {
            border-width: 2px;
        }
    }
}