/**
 * Ava CMS Default Theme Stylesheet
 * 
 * A clean, modern theme focused on readability and simplicity.
 * This stylesheet is designed to be educational and easy to customize.
 * 
 * Structure:
 *   1. CSS Custom Properties (design tokens)
 *   2. CSS Reset
 *   3. Layout & Structure
 *   4. Header & Navigation
 *   5. Footer
 *   6. Typography & Content
 *   7. Archive & Lists
 *   8. Cards & Taxonomy Index
 *   9. Search
 *   10. Pagination
 *   11. Error Pages
 *   12. Utilities
 *   13. Responsive Styles
 * 
 * @see https://ava.addy.zone/docs/theming
 */


/* ==========================================================================
   1. CSS CUSTOM PROPERTIES
   Define your design tokens here. Change these values to quickly restyle
   the entire theme. CSS custom properties are inherited by all elements.
   ========================================================================== */

:root {
    /* Colors - Primary palette */
    --color-primary: #6366f1;           /* Indigo - main accent color */
    --color-primary-dark: #4f46e5;      /* Darker shade for hover states */
    --color-primary-light: #818cf8;     /* Lighter shade for subtle accents */
    
    /* Colors - Text */
    --color-text: #1e293b;              /* Primary text color */
    --color-text-light: #64748b;        /* Secondary/muted text */
    --color-text-inverse: #ffffff;      /* Text on dark backgrounds */
    
    /* Colors - Backgrounds */
    --color-bg: #ffffff;                /* Main background */
    --color-bg-alt: #f8fafc;            /* Alternate/offset background */
    --color-bg-accent: #f1f5f9;         /* Accent background for code, etc. */
    
    /* Colors - Borders & Lines */
    --color-border: #e2e8f0;            /* Standard border color */
    --color-border-light: #f1f5f9;      /* Subtle borders */
    
    /* Typography - Font families */
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 
                 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', 
                 'SF Mono', Consolas, monospace;
    --font-serif: 'Georgia', 'Times New Roman', serif;
    
    /* Layout - Widths */
    --max-width: 720px;                 /* Content width (articles, pages) */
    --max-width-wide: 1080px;           /* Wide layout (header, footer) */
    
    /* Spacing - Use these for consistent margins and padding */
    --space-xs: 0.25rem;    /* 4px */
    --space-sm: 0.5rem;     /* 8px */
    --space-md: 1rem;       /* 16px */
    --space-lg: 1.5rem;     /* 24px */
    --space-xl: 2rem;       /* 32px */
    --space-2xl: 3rem;      /* 48px */
    --space-3xl: 4rem;      /* 64px */
    
    /* Border radius */
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --radius-full: 9999px;  /* Pill shape */
    
    /* Shadows - Subtle depth */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 
              0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 
                 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08),
                 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition: 0.2s ease;
    --transition-slow: 0.3s ease;
}


/* ==========================================================================
   2. CSS RESET
   Normalize browser defaults for consistent cross-browser styling.
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Images and media - responsive by default */
img, video, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Links - clean defaults */
a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-dark);
}


/* ==========================================================================
   3. LAYOUT & STRUCTURE
   Containers and structural elements for page layout.
   ========================================================================== */

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.container-wide {
    max-width: var(--max-width-wide);
}

/* Main content area - pushes footer to bottom */
.site-main {
    flex: 1;
    padding: var(--space-3xl) 0;
}


/* ==========================================================================
   4. HEADER & NAVIGATION
   Site header with logo and navigation.
   ========================================================================== */

.site-header {
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    max-width: var(--max-width-wide);
}

/* Site logo/name */
.site-logo {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: -0.02em;
    transition: color var(--transition-fast);
}

.site-logo:hover {
    color: var(--color-primary);
}

/* Navigation */
.site-nav {
    display: flex;
    gap: 0;
    height: 100%;
    align-items: stretch;
}

.site-nav a {
    display: flex;
    align-items: center;
    color: var(--color-text-light);
    font-size: 0.9375rem;
    font-weight: 500;
    padding: 0 var(--space-md);
    position: relative;
    transition: color var(--transition-fast);
    height: 64px;
}

.site-nav a:hover {
    color: var(--color-text);
}

/* Active navigation state - indicator sits on the header's bottom border */
.site-nav a.active {
    color: var(--color-primary);
}

.site-nav a.active::after {
    content: '';
    position: absolute;
    bottom: -1px; /* Sits exactly on the header border */
    left: var(--space-md);
    right: var(--space-md);
    height: 2px;
    background: var(--color-primary);
    border-radius: 1px 1px 0 0;
}

/* Hover underline for non-active items */
.site-nav a:not(.active)::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: var(--space-md);
    right: var(--space-md);
    height: 2px;
    background: var(--color-border);
    border-radius: 1px 1px 0 0;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.site-nav a:not(.active):hover::after {
    opacity: 1;
}

/* Mobile hamburger menu toggle */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    padding: var(--space-sm);
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    border-radius: 1px;
    transition: var(--transition);
}


/* ==========================================================================
   5. FOOTER
   Site footer with copyright and links.
   ========================================================================== */

.site-footer {
    background: var(--color-bg-alt);
    border-top: 1px solid var(--color-border);
    padding: var(--space-xl) 0;
    margin-top: auto; /* Pushes footer to bottom */
}

.site-footer .container {
    max-width: var(--max-width-wide);
}

.footer-content {
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.875rem;
}

.footer-content a {
    color: var(--color-text-light);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--transition-fast);
}

.footer-content a:hover {
    color: var(--color-primary);
}

/* ==========================================================================
   6. TYPOGRAPHY & CONTENT
   Styles for article content, headings, and prose.
   ========================================================================== */

/* Page headers (used on archive, search, taxonomy pages) */
.page-header {
    margin-bottom: var(--space-2xl);
    text-align: center;
}

.page-header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.03em;
    color: var(--color-text);
    background: linear-gradient(135deg, var(--color-text) 0%, var(--color-text-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-header .subtitle {
    margin-top: var(--space-sm);
    color: var(--color-text-light);
    font-size: 1.125rem;
}

/* Article/entry container */
.entry {
    max-width: var(--max-width);
    margin: 0 auto;
}

.entry-header {
    margin-bottom: var(--space-2xl);
}

.entry-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.03em;
    margin-bottom: var(--space-md);
    background: linear-gradient(135deg, var(--color-text) 0%, #475569 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Article meta (date, categories) */
.entry-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
    color: var(--color-text-light);
    font-size: 0.875rem;
    margin-top: var(--space-sm);
}

.entry-meta time {
    font-weight: 500;
}

.entry-meta span {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.entry-meta span::before {
    content: "·";
    color: var(--color-border);
    font-weight: bold;
}

.entry-meta a {
    color: var(--color-primary);
    font-weight: 500;
    transition: color var(--transition-fast);
}

.entry-meta a:hover {
    color: var(--color-primary-dark);
}

/* Article content - prose styles */
.entry-content {
    font-size: 1.0625rem;
    line-height: 1.8;
}

/* Vertical rhythm - consistent spacing between elements */
.entry-content > * + * {
    margin-top: 1.5em;
}

/* Headings in content */
.entry-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2.5em;
    margin-bottom: 0.75em;
    letter-spacing: -0.02em;
    color: var(--color-text);
}

.entry-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 2em;
    margin-bottom: 0.5em;
    color: var(--color-text);
}

.entry-content h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    color: var(--color-text);
}

/* Links in content - subtle underline that highlights on hover */
.entry-content a {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--color-border);
    transition: text-decoration-color var(--transition-fast);
}

.entry-content a:hover {
    text-decoration-color: var(--color-primary);
}

/* Images */
.entry-content img {
    border-radius: var(--radius);
    margin: var(--space-xl) 0;
    box-shadow: var(--shadow);
}

/* Blockquotes - left border accent */
.entry-content blockquote {
    border-left: 3px solid var(--color-primary);
    padding-left: var(--space-lg);
    margin-left: 0;
    color: var(--color-text-light);
    font-style: italic;
}

/* Code blocks */
.entry-content pre {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-lg);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Inline code */
.entry-content code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--color-bg-accent);
    padding: 0.2em 0.4em;
    border-radius: var(--radius-sm);
    color: var(--color-primary-dark);
}

/* Remove background from code inside pre */
.entry-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* Lists */
.entry-content ul, 
.entry-content ol {
    padding-left: 1.5em;
}

.entry-content li {
    margin: 0.5em 0;
}

.entry-content li::marker {
    color: var(--color-primary);
}

/* Horizontal rules */
.entry-content hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: var(--space-2xl) 0;
}

/* Tables */
.entry-content table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-xl) 0;
    font-size: 0.9375rem;
}

.entry-content th,
.entry-content td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border);
    text-align: left;
}

.entry-content th {
    font-weight: 600;
    background: var(--color-bg-alt);
}

/* Optional Markdown extensions */
.entry-content mark {
    padding: 0.1em 0.2em;
    border-radius: var(--radius-sm);
    background: #fef08a;
    color: var(--color-text);
}

.entry-content dl {
    display: grid;
    grid-template-columns: minmax(8rem, 1fr) minmax(0, 3fr);
    gap: var(--space-sm) var(--space-lg);
}

.entry-content dt {
    font-weight: 600;
}

.entry-content dd {
    color: var(--color-text-light);
}

.entry-content .table-of-contents {
    padding: var(--space-lg) var(--space-xl);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius);
    background: var(--color-bg-alt);
}

.entry-content .table-of-contents li {
    margin: var(--space-xs) 0;
}

.entry-content .heading-permalink {
    margin-right: var(--space-xs);
    color: var(--color-text-light);
    text-decoration: none;
    opacity: 0;
}

.entry-content :is(h1, h2, h3, h4, h5, h6):is(:hover, :focus-within) .heading-permalink,
.entry-content .heading-permalink:focus {
    opacity: 1;
}

.entry-content .footnotes {
    margin-top: var(--space-2xl);
    color: var(--color-text-light);
    font-size: 0.875rem;
}

.entry-content .footnotes ol {
    padding-left: 1.25em;
}

.entry-content .footnote:target {
    color: var(--color-text);
    background: var(--color-bg-alt);
}

.entry-content .footnote-ref,
.entry-content .footnote-backref {
    font-weight: 600;
    text-decoration: none;
}

/* Article footer (tags) */
.entry-footer {
    margin-top: var(--space-2xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

/* Tag pills */
.entry-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.tag {
    display: inline-block;
    padding: var(--space-xs) var(--space-md);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    color: var(--color-text-light);
    transition: all var(--transition-fast);
}

.tag:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-text-inverse);
}

/* ==========================================================================
   7. ARCHIVE & LISTS
   Styles for content listings (blog index, search results, etc.)
   ========================================================================== */

.archive-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.archive-item {
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--color-border);
    transition: transform var(--transition-fast);
}

.archive-item:last-child {
    border-bottom: none;
}

.archive-item h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    line-height: 1.4;
}

.archive-item h2 a {
    color: var(--color-text);
    transition: color var(--transition-fast);
}

.archive-item h2 a:hover {
    color: var(--color-primary);
}

.archive-item .meta {
    font-size: 0.875rem;
    color: var(--color-text-light);
    margin-bottom: var(--space-sm);
}

.archive-item .excerpt {
    color: var(--color-text-light);
    line-height: 1.6;
}


/* ==========================================================================
   8. CARDS & TAXONOMY INDEX
   Card-based layouts for taxonomy term listings.
   ========================================================================== */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-lg);
}

.card {
    display: block;
    padding: var(--space-lg);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

/* Subtle gradient accent on hover */
.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
    opacity: 0;
    transition: opacity var(--transition);
}

.card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.card:hover::before {
    opacity: 1;
}

.card-title {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-xs);
    font-size: 1.0625rem;
}

.card-count {
    font-size: 0.875rem;
    color: var(--color-text-light);
}

.card-description {
    font-size: 0.875rem;
    color: var(--color-text-light);
    margin-top: var(--space-sm);
    line-height: 1.5;
}


/* ==========================================================================
   9. SEARCH
   Search form and results styling.
   ========================================================================== */

.search-form {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-2xl);
}

.search-input {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    font-size: 1rem;
    font-family: inherit;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    transition: all var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.search-input::placeholder {
    color: var(--color-text-light);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md) var(--space-xl);
    font-size: 0.9375rem;
    font-family: inherit;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--color-text-inverse);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    color: var(--color-text-inverse);
}

.btn-primary:active {
    transform: translateY(0);
}

.search-results-info {
    color: var(--color-text-light);
    margin-bottom: var(--space-lg);
    font-size: 0.9375rem;
}

.search-empty {
    text-align: center;
    padding: var(--space-3xl) 0;
    color: var(--color-text-light);
}

.search-empty p {
    font-size: 1.125rem;
}


/* ==========================================================================
   10. PAGINATION
   Page navigation for lists.
   ========================================================================== */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    margin-top: var(--space-2xl);
    padding-top: var(--space-xl);
    border-top: 1px solid var(--color-border);
}

.pagination a {
    font-weight: 500;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
}

.pagination a:hover {
    background: var(--color-bg-alt);
}

.pagination-info {
    color: var(--color-text-light);
    font-size: 0.875rem;
}


/* ==========================================================================
   11. ERROR PAGES
   404 and other error pages.
   ========================================================================== */

.error-page {
    text-align: center;
    padding: var(--space-3xl) 0;
}

.error-page h1 {
    font-size: 6rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-text-light) 0%, var(--color-border) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-md);
    line-height: 1;
}

.error-page p {
    color: var(--color-text-light);
    font-size: 1.125rem;
    margin-bottom: var(--space-xl);
}


/* ==========================================================================
   12. UTILITIES
   Helper classes for common patterns.
   ========================================================================== */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--color-text-light);
}


/* ==========================================================================
   13. RESPONSIVE STYLES
   Mobile and tablet adaptations.
   ========================================================================== */

/* Tablet and smaller */
@media (max-width: 768px) {
    :root {
        --space-3xl: 2.5rem;
    }

    .entry-content dl {
        display: block;
    }

    .entry-content dd + dt {
        margin-top: var(--space-md);
    }

    .entry-content .table-of-contents {
        padding: var(--space-md) var(--space-lg);
    }
    
    .entry-header h1 {
        font-size: 2rem;
    }
    
    .page-header h1 {
        font-size: 1.75rem;
    }
    
    .error-page h1 {
        font-size: 4rem;
    }
}

/* Mobile */
@media (max-width: 640px) {
    .site-header .container {
        position: relative;
    }
    
    /* Mobile navigation - hidden by default, shown when .open */
    .site-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--color-bg);
        border-bottom: 1px solid var(--color-border);
        padding: var(--space-sm) 0;
        gap: 0;
        display: none;
        box-shadow: var(--shadow-lg);
        height: auto;
    }
    
    .site-nav.open {
        display: flex;
    }
    
    .site-nav a {
        height: auto;
        padding: var(--space-sm) var(--space-lg);
    }
    
    /* Hide underline indicators on mobile, use left border instead */
    .site-nav a::after,
    .site-nav a.active::after {
        display: none;
    }
    
    .site-nav a.active {
        background: var(--color-bg-alt);
        border-left: 3px solid var(--color-primary);
    }
    
    /* Show hamburger menu on mobile */
    .nav-toggle {
        display: flex;
    }
    
    /* Hamburger to X animation */
    .nav-toggle.open span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .nav-toggle.open span:nth-child(2) {
        opacity: 0;
    }
    
    .nav-toggle.open span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }
    
    /* Stack search form vertically */
    .search-form {
        flex-direction: column;
    }
    
    /* Single column cards on mobile */
    .card-grid {
        grid-template-columns: 1fr;
    }
    
    .entry-header h1 {
        font-size: 1.75rem;
    }
}
