/* 
 * Reader Mode Theme for BSSG
 * Simulates browser reader mode with emphasis on text,
 * white/sepia background, very readable serif font,
 * and almost no graphic elements
 * 
 * IMPROVEMENTS APPLIED:
 * - Added comprehensive reduced motion support
 * - Enhanced accessibility with focus outlines
 * - Added text browser fallbacks
 * - Optimized performance while maintaining reading focus
 */

:root {
    /* Color scheme - light sepia by default */
    --background-color: #f8f1e3;
    --text-color: #333333;
    --heading-color: #222222;
    --link-color: #0c4684;
    --link-visited: #551a8b;
    --muted-color: #666666;
    --border-color: #e0d7c5;
    --highlight-color: #fffcf7;
    --blockquote-bg: #f4ece0;
    --code-bg: #f4ece0;
    
    /* Typography - ENHANCED fallbacks for text browsers */
    --font-serif: 'Georgia', 'Times New Roman', serif;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    --font-mono: 'Consolas', 'Menlo', 'Courier New', 'Courier', monospace;
    
    /* Sizing for optimal reading */
    --content-width: 90%;
    --max-content-width: 740px; /* Optimal line length for reading */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --spacing-xxl: 4rem;
    --line-height: 1.7;
    --border-radius: 2px;
    
    /* Transitions - OPTIMIZED for performance */
    --transition-fast: 0.15s;
    --transition-base: 0.2s;
}

/* REDUCED MOTION SUPPORT - Disable animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
        transform: none !important;
    }
    
    html {
        scroll-behavior: auto !important;
    }
}

/* Base elements */
html {
    font-size: 20px; /* Larger base font size for comfortable reading */
    scroll-behavior: smooth;
}

/* ACCESSIBILITY: Respect reduced motion preference for scroll behavior */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

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

.container {
    width: var(--content-width);
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: var(--spacing-md) var(--spacing-md) var(--spacing-xl);
    background-color: transparent; /* No box around content */
}

/* Minimal header */
header {
    margin: var(--spacing-lg) 0 var(--spacing-xl);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

/* Simple site title */
.site-title {
    font-family: var(--font-serif);
    font-weight: normal;
    font-size: 2.2rem;
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.site-title a {
    color: var(--heading-color);
    text-decoration: none;
    transition: color var(--transition-base) ease;
    /* ACCESSIBILITY: Focus outline */
    outline: none;
}

.site-title a:hover {
    color: var(--link-color);
}

/* ACCESSIBILITY: Focus states for site title */
.site-title a:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* Site description */
header p {
    margin: var(--spacing-xs) 0 0;
    font-style: italic;
    color: var(--muted-color);
    font-size: 1rem;
    line-height: 1.5;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

/* Minimalist navigation */
nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
    font-family: var(--font-sans);
    font-size: 0.85rem;
}

nav a {
    color: var(--muted-color);
    text-decoration: none;
    padding: var(--spacing-xs) 0;
    transition: color var(--transition-base) ease;
    position: relative;
    /* ACCESSIBILITY: Focus outline */
    outline: none;
}

nav a:hover, 
nav a.active {
    color: var(--link-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

/* ACCESSIBILITY: Focus states for navigation */
nav a:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* Content area */
main {
    min-height: 70vh;
    padding-bottom: var(--spacing-xl);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-serif);
    color: var(--heading-color);
    line-height: 1.3;
    margin: var(--spacing-lg) 0 var(--spacing-md);
    font-weight: normal;
    text-align: center;
}

h1 {
    font-size: 2.2rem;
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    text-align: center;
    line-height: 1.2;
}

h2 {
    font-size: 1.8rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--spacing-xs);
    margin-top: var(--spacing-xl);
    margin-bottom: var(--spacing-md);
}

h3 {
    font-size: 1.5rem;
    margin-top: var(--spacing-lg);
}

h4 {
    font-size: 1.3rem;
    font-style: italic;
    margin-top: var(--spacing-lg);
}

p {
    margin: var(--spacing-md) 0;
    font-size: 1rem;
    hyphens: auto;
    text-align: left;
    line-height: var(--line-height);
}

/* First paragraph styling for articles */
article .article-content > p:first-of-type:first-letter {
    float: left;
    font-size: 3.5em;
    line-height: 0.8;
    margin-right: 0.1em;
    padding-top: 0.1em;
    color: var(--heading-color);
}

/* Links */
a {
    color: var(--link-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    transition: color var(--transition-base) ease;
    /* ACCESSIBILITY: Focus outline */
    outline: none;
}

a:hover {
    color: var(--heading-color);
}

a:visited {
    color: var(--link-visited);
}

/* ACCESSIBILITY: Focus states for general links */
a:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* Lists */
ul, ol {
    margin: var(--spacing-md) auto var(--spacing-lg);
    padding-left: var(--spacing-lg);
    list-style-position: outside;
    text-align: left;
    max-width: 85%;
}

li {
    margin-bottom: var(--spacing-xs);
    line-height: var(--line-height);
}

/* Quotes */
blockquote {
    margin: var(--spacing-lg) auto;
    padding: var(--spacing-md) var(--spacing-lg);
    background-color: var(--blockquote-bg);
    border-left: 3px solid var(--border-color);
    font-style: italic;
    max-width: 85%;
    text-align: left;
}

blockquote p:first-child {
    margin-top: 0;
}

blockquote p:last-child {
    margin-bottom: 0;
}

blockquote cite {
    display: block;
    margin-top: var(--spacing-sm);
    font-size: 0.9rem;
    color: var(--muted-color);
    text-align: right;
}

/* Code blocks - simplified */
pre, code {
    font-family: var(--font-mono);
    background-color: var(--code-bg);
    font-size: 0.85rem;
    border-radius: var(--border-radius);
}

code {
    padding: 0.15em 0.3em;
}

pre {
    padding: var(--spacing-sm);
    margin: var(--spacing-md) 0 var(--spacing-lg);
    overflow-x: auto;
    line-height: 1.5;
    white-space: pre-wrap;
    text-align: left;
}

pre code {
    padding: 0;
    background: none;
}

/* Simple horizontal rule */
hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: var(--spacing-xl) auto;
    width: 50%;
}

/* Article styling */
article {
    margin-bottom: var(--spacing-xxl);
    text-align: left;
}

article .article-content {
    text-align: left;
}

article h1 {
    font-size: 2.2rem;
    text-align: center;
    margin-bottom: var(--spacing-md);
}

/* Fix for both article meta and page-meta alignment */
article .meta,
.meta,
.page-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--spacing-md);
    color: var(--muted-color);
    font-size: 0.9rem;
    margin: var(--spacing-sm) 0 var(--spacing-xl);
    font-style: italic;
    text-align: center;
    line-height: 1.5;
}

/* Reading time - TEXT BROWSER FALLBACK */
.reading-time {
    display: flex;
    align-items: center;
    gap: 0.3em;
}

/* TEXT BROWSER FALLBACK: Add "Time: " prefix for reading time */
.reading-time::before {
    content: "Time: ";
    font-style: normal;
}

/* Hide the prefix when CSS transforms are supported (modern browsers) */
@supports (transform: translateX(0)) {
    .reading-time::before {
        content: "•";
        font-style: normal;
    }
}

/* Simplified tags */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    justify-content: center;
    margin-top: var(--spacing-md);
}

.tags a {
    color: var(--muted-color);
    font-style: normal;
    font-size: 0.85rem;
    transition: color var(--transition-base) ease;
    /* ACCESSIBILITY: Focus outline */
    outline: none;
}

.tags a:hover {
    color: var(--link-color);
}

/* ACCESSIBILITY: Focus states for tags */
.tags a:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* Tags list page */
.tags-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    justify-content: center;
    margin: var(--spacing-lg) auto;
}

.tags-list li {
    margin: 0;
}

.tags-list a {
    display: inline-block;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color var(--transition-base) ease;
    /* ACCESSIBILITY: Focus outline */
    outline: none;
}

.tags-list a:hover {
    color: var(--link-color);
    text-decoration: underline;
}

/* ACCESSIBILITY: Focus states for tags list */
.tags-list a:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* Minimal featured images */
.featured-image, 
.index-image, 
.tag-image, 
.archive-image {
    margin: var(--spacing-xl) auto;
    text-align: center;
    max-width: 95%;
}

.featured-image img, 
.index-image img, 
.tag-image img, 
.archive-image img {
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    display: block;
}

/* Image caption */
figcaption {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--muted-color);
    text-align: center;
    margin-top: var(--spacing-xs);
    line-height: 1.4;
}

/* Pull quote for longform content */
.pull-quote {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    line-height: 1.5;
    font-style: italic;
    color: var(--heading-color);
    margin: var(--spacing-xl) auto;
    padding: 0 var(--spacing-lg);
    text-align: center;
    position: relative;
    max-width: 85%;
}

.pull-quote::before,
.pull-quote::after {
    content: '"';
    font-size: 3.5rem;
    line-height: 0;
    position: relative;
    color: var(--border-color);
}

/* Post list */
.posts-list {
    margin-top: var(--spacing-xl);
    text-align: center;
}

.posts-list article {
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.posts-list article:last-child {
    border-bottom: none;
}

.posts-list h3 {
    margin-top: 0;
    text-align: center;
    margin-bottom: var(--spacing-sm);
}

.posts-list h3 a {
    color: var(--heading-color);
    text-decoration: none;
    transition: color var(--transition-base) ease;
    /* ACCESSIBILITY: Focus outline */
    outline: none;
}

.posts-list h3 a:hover {
    color: var(--link-color);
    text-decoration: underline;
}

/* ACCESSIBILITY: Focus states for post list links */
.posts-list h3 a:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* Minimal footer */
footer {
    margin-top: var(--spacing-xxl);
    padding: var(--spacing-md) 0 var(--spacing-lg);
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted-color);
    font-family: var(--font-sans);
    border-top: 1px solid var(--border-color);
}

footer p {
    margin: var(--spacing-xs) 0;
    text-align: center;
}

footer a {
    color: var(--muted-color);
    text-decoration: underline;
    transition: color var(--transition-base) ease;
    /* ACCESSIBILITY: Focus outline */
    outline: none;
}

footer a:hover {
    color: var(--link-color);
}

/* ACCESSIBILITY: Focus states for footer links */
footer a:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* Pagination - simplified */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
    font-family: var(--font-sans);
    font-size: 0.9rem;
}

.pagination a {
    color: var(--muted-color);
    text-decoration: none;
    padding: var(--spacing-xs) var(--spacing-sm);
    transition: color var(--transition-base) ease;
    /* ACCESSIBILITY: Focus outline */
    outline: none;
}

.pagination a:hover {
    color: var(--link-color);
    text-decoration: underline;
}

/* ACCESSIBILITY: Focus states for pagination */
.pagination a:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

.pagination .page-info {
    color: var(--muted-color);
    font-style: italic;
}

/* Utility */
.text-center {
    text-align: center;
}

/* Toggle for light/dark/sepia modes - purely aesthetic */
.theme-toggle {
    position: fixed;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    display: flex;
    gap: var(--spacing-xs);
    z-index: 1000;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    background: var(--background-color);
    padding: var(--spacing-xs);
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.theme-toggle button {
    background: none;
    border: 1px solid var(--border-color);
    padding: 0.25em 0.6em;
    cursor: pointer;
    border-radius: var(--border-radius);
    color: var(--muted-color);
    transition: all var(--transition-base) ease;
    /* ACCESSIBILITY: Focus outline */
    outline: none;
}

.theme-toggle button:hover {
    background-color: var(--highlight-color);
    color: var(--heading-color);
}

.theme-toggle button.active {
    background-color: var(--border-color);
    color: var(--heading-color);
    font-weight: bold;
}

/* ACCESSIBILITY: Focus states for theme toggle buttons */
.theme-toggle button:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* Dark mode */
.theme-dark {
    --background-color: #1a1a1a;
    --text-color: #e0e0e0;
    --heading-color: #ffffff;
    --link-color: #82b1ff;
    --link-visited: #bb86fc;
    --muted-color: #a0a0a0;
    --border-color: #333333;
    --highlight-color: #2d2d2d;
    --blockquote-bg: #2d2d2d;
    --code-bg: #2d2d2d;
}

/* Light (white) mode */
.theme-light {
    --background-color: #ffffff;
    --text-color: #333333;
    --heading-color: #222222;
    --link-color: #0c4684;
    --link-visited: #551a8b;
    --muted-color: #666666;
    --border-color: #dddddd;
    --highlight-color: #f7f7f7;
    --blockquote-bg: #f7f7f7;
    --code-bg: #f7f7f7;
}

/* Responsive styles */
@media (max-width: 768px) {
    html {
        font-size: 18px;
    }
    
    body {
        width: 100%;
        overflow-x: hidden;
        padding: 0;
    }
    
    .container {
        width: 95%;
        padding: var(--spacing-sm) var(--spacing-sm) var(--spacing-lg);
        margin: 0 auto;
        box-sizing: border-box;
        max-width: 100%;
    }
    
    h1 {
        font-size: 1.8rem;
        margin-top: var(--spacing-md);
    }
    
    h2 {
        font-size: 1.4rem;
        margin-top: var(--spacing-lg);
    }
    
    h3 {
        font-size: 1.2rem;
        margin-top: var(--spacing-md);
    }
    
    .pull-quote {
        font-size: 1.2rem;
        padding: 0 var(--spacing-sm);
        margin: var(--spacing-lg) auto;
        width: 90%;
    }
    
    article .meta,
    .meta,
    .page-meta {
        flex-direction: column;
        align-items: center;
        gap: var(--spacing-xs);
        margin-bottom: var(--spacing-lg);
    }
    
    blockquote {
        padding: var(--spacing-sm);
        max-width: 90%;
    }
    
    ul, ol {
        padding-left: var(--spacing-md);
        max-width: 90%;
    }
    
    img, figure {
        max-width: 100%;
        height: auto;
    }
    
    .featured-image, .index-image, .tag-image, .archive-image {
        max-width: 100%;
    }
    
    .theme-toggle {
        top: var(--spacing-xs);
        right: var(--spacing-xs);
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .container {
        width: 100%;
        padding: var(--spacing-sm);
    }
    
    nav {
        gap: var(--spacing-sm);
    }
    
    nav a {
        font-size: 0.8rem;
    }
}

/* Print styles */
@media print {
    body {
        background: #ffffff;
        color: #000000;
        font-size: 12pt;
        line-height: 1.5;
    }
    
    .container {
        width: 100%;
        max-width: none;
        padding: 0;
        margin: 0;
    }
    
    a {
        color: #000000;
        text-decoration: none;
    }
    
    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.9em;
        color: #666666;
    }
    
    nav, .theme-toggle {
        display: none;
    }
    
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        page-break-inside: avoid;
        color: #000000;
    }
    
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
    
    blockquote, pre {
        border: 1px solid #999;
        page-break-inside: avoid;
        background: #fff !important;
    }
    
    p, h2, h3 {
        orphans: 3;
        widows: 3;
    }
    
    article, blockquote, ul, ol, pre {
        break-inside: avoid;
    }
}

/* Center images within the main content */
.page-content img {
    display: block;
    margin-left: auto;
    margin-right: auto;
    max-width: 100%; /* Keep images responsive */
    height: auto;    /* Maintain aspect ratio */
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-md);
} 
