/**
 * TAMER Blog System - Accessibility CSS
 * WCAG 2.1 AA Compliant Blog Interface
 * 
 * This stylesheet provides comprehensive accessibility features for the blog system:
 * - High contrast support
 * - Screen reader optimization
 * - Keyboard navigation
 * - Font size controls
 * - Motion preferences
 * 
 * @version 1.0.0
 * @author The Anger Management Educational Resource
 */

/* ====================================
   ACCESSIBILITY FOUNDATION
   ==================================== */

/* Skip Links for Blog Navigation */
.tamer-blog-skip-links {
    position: absolute;
    top: -9999px;
    left: -9999px;
    z-index: 999999;
}

.tamer-blog-skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    z-index: 999999;
    background: #1976d2;
    color: #ffffff;
    padding: 8px 16px;
    text-decoration: none;
    font-weight: bold;
    border-radius: 0 0 4px 4px;
    font-size: 16px;
}

.tamer-blog-skip-link:focus {
    position: absolute;
    left: 6px;
    top: 6px;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
}

/* Screen Reader Only Content */
.tamer-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.tamer-sr-only.focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: inherit;
}

/* ====================================
   ACCESSIBILITY CONTROLS
   ==================================== */

.tamer-accessibility-toolbar {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999998;
    background: #ffffff;
    border: 2px solid #1976d2;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.tamer-accessibility-toolbar.collapsed {
    padding: 8px;
}

.tamer-accessibility-toggle {
    background: #1976d2;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s ease-in-out;
    min-height: 44px;
    min-width: 44px;
}

.tamer-accessibility-toggle:hover {
    background: #0d47a1;
}

.tamer-accessibility-toggle:focus {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

.tamer-accessibility-controls {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tamer-accessibility-toolbar.collapsed .tamer-accessibility-controls {
    display: none;
}

.tamer-a11y-control {
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
    text-align: left;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tamer-a11y-control:hover {
    background: #eeeeee;
    border-color: #bdbdbd;
}

.tamer-a11y-control:focus {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
    border-color: #1976d2;
}

.tamer-a11y-control.active {
    background: #e3f2fd;
    border-color: #1976d2;
    color: #0d47a1;
}

.tamer-a11y-status {
    font-size: 12px;
    color: #666666;
    margin-left: 8px;
}

.tamer-a11y-control.active .tamer-a11y-status {
    color: #0d47a1;
    font-weight: 600;
}

/* ====================================
   HIGH CONTRAST MODE
   ==================================== */

.tamer-high-contrast .tamer-blog-container,
.tamer-high-contrast .tamer-blog-post,
.tamer-high-contrast .tamer-blog-card {
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
}

.tamer-high-contrast .tamer-blog-header,
.tamer-high-contrast .tamer-blog-footer {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
}

.tamer-high-contrast .tamer-blog-link,
.tamer-high-contrast .tamer-blog-title a {
    color: #0000ff !important;
    text-decoration: underline !important;
}

.tamer-high-contrast .tamer-blog-link:visited {
    color: #800080 !important;
}

.tamer-high-contrast .tamer-blog-link:hover,
.tamer-high-contrast .tamer-blog-link:focus {
    background: #ffff00 !important;
    color: #000000 !important;
}

.tamer-high-contrast .tamer-btn,
.tamer-high-contrast .tamer-button {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #000000 !important;
}

.tamer-high-contrast .tamer-btn:hover,
.tamer-high-contrast .tamer-button:hover {
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
}

.tamer-high-contrast .tamer-blog-meta,
.tamer-high-contrast .tamer-blog-excerpt {
    color: #000000 !important;
}

.tamer-high-contrast .tamer-blog-tag {
    background: #000000 !important;
    color: #ffffff !important;
    border: 1px solid #ffffff !important;
}

/* ====================================
   LARGE TEXT MODE
   ==================================== */

.tamer-large-text {
    font-size: 120% !important;
}

.tamer-large-text .tamer-blog-container,
.tamer-large-text .tamer-blog-post {
    font-size: 20px !important;
    line-height: 1.8 !important;
}

.tamer-large-text .tamer-blog-title {
    font-size: 2.5rem !important;
}

.tamer-large-text .tamer-blog-subtitle {
    font-size: 1.75rem !important;
}

.tamer-large-text .tamer-blog-meta {
    font-size: 18px !important;
}

.tamer-large-text .tamer-btn,
.tamer-large-text .tamer-button {
    font-size: 18px !important;
    padding: 16px 24px !important;
    min-height: 52px !important;
}

/* ====================================
   REDUCED MOTION MODE
   ==================================== */

.tamer-reduced-motion *,
.tamer-reduced-motion *::before,
.tamer-reduced-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

.tamer-reduced-motion .tamer-blog-card:hover {
    transform: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

/* System-level reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .tamer-blog-container *,
    .tamer-blog-post *,
    .tamer-blog-card * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ====================================
   KEYBOARD NAVIGATION
   ==================================== */

/* Enhanced Focus Indicators */
.tamer-blog-container a:focus,
.tamer-blog-container button:focus,
.tamer-blog-container input:focus,
.tamer-blog-container select:focus,
.tamer-blog-container textarea:focus,
.tamer-blog-link:focus,
.tamer-blog-card:focus {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(0, 95, 204, 0.3);
    z-index: 100;
    position: relative;
}

/* Skip focus outline for mouse users */
.using-mouse .tamer-blog-container :focus {
    outline: none;
    box-shadow: none;
}

/* Focus visible polyfill support */
.js-focus-visible .tamer-blog-container :focus:not(.focus-visible) {
    outline: none;
    box-shadow: none;
}

.js-focus-visible .tamer-blog-container .focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* Keyboard navigation for blog cards */
.tamer-blog-card {
    position: relative;
    transition: all 0.15s ease-in-out;
}

.tamer-blog-card:focus-within {
    box-shadow: 0 4px 20px rgba(0, 95, 204, 0.2);
    transform: translateY(-2px);
}

.tamer-blog-card[tabindex]:focus {
    cursor: pointer;
}

/* Blog navigation keyboard shortcuts */
.tamer-blog-nav-hint {
    position: absolute;
    left: -9999px;
    background: #1976d2;
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 1000;
}

.tamer-blog-nav-hint.visible {
    position: fixed;
    top: 50px;
    right: 20px;
    left: auto;
}

/* ====================================
   SCREEN READER SUPPORT
   ==================================== */

/* Live Regions for Dynamic Content */
.tamer-live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.tamer-live-region[aria-live] {
    position: static;
    width: auto;
    height: auto;
    clip: auto;
}

/* ARIA Labels and Descriptions */
.tamer-blog-post[role="article"] {
    position: relative;
}

.tamer-blog-meta {
    font-size: 0.9rem;
    color: #666666;
}

.tamer-blog-reading-time {
    font-style: italic;
    color: #666666;
}

.tamer-blog-reading-time::before {
    content: "⏱ ";
    speak: none;
}

/* Enhanced link context */
.tamer-blog-read-more::after {
    content: " (opens blog post)";
    speak: literal-punctuation;
    position: absolute;
    left: -10000px;
}

.tamer-external-link::after {
    content: " (external link)";
    speak: literal-punctuation;
    position: absolute;
    left: -10000px;
}

/* ====================================
   BLOG-SPECIFIC ACCESSIBILITY
   ==================================== */

/* Blog Post Structure */
.tamer-blog-post {
    margin-bottom: 2rem;
}

.tamer-blog-post-header {
    margin-bottom: 1.5rem;
}

.tamer-blog-title {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.75rem;
    color: #212121;
}

.tamer-blog-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s ease-in-out;
}

.tamer-blog-title a:hover {
    color: #1976d2;
    text-decoration: underline;
}

/* Blog Meta Information */
.tamer-blog-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #666666;
}

.tamer-blog-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.tamer-blog-meta-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Blog Content */
.tamer-blog-content {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #333333;
}

.tamer-blog-content h2,
.tamer-blog-content h3,
.tamer-blog-content h4 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #212121;
}

.tamer-blog-content p {
    margin-bottom: 1rem;
    max-width: 70ch; /* Optimal reading width */
}

.tamer-blog-content img {
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
    border-radius: 4px;
}

.tamer-blog-content figure {
    margin: 2rem 0;
    text-align: center;
}

.tamer-blog-content figcaption {
    font-size: 0.9rem;
    color: #666666;
    font-style: italic;
    margin-top: 0.5rem;
}

/* Blog Tags and Categories */
.tamer-blog-taxonomy {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}

.tamer-blog-tags,
.tamer-blog-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tamer-blog-tag,
.tamer-blog-category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: #f5f5f5;
    color: #666666;
    border-radius: 20px;
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.15s ease-in-out;
    border: 2px solid transparent;
}

.tamer-blog-tag:hover,
.tamer-blog-category:hover {
    background-color: #1976d2;
    color: #ffffff;
}

.tamer-blog-tag:focus,
.tamer-blog-category:focus {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* ====================================
   RESPONSIVE ACCESSIBILITY
   ==================================== */

/* Mobile Accessibility Improvements */
@media (max-width: 768px) {
    .tamer-accessibility-toolbar {
        position: fixed;
        top: 10px;
        right: 10px;
        left: auto;
        transform: none;
    }
    
    .tamer-blog-title {
        font-size: 1.75rem;
    }
    
    .tamer-blog-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .tamer-blog-content {
        font-size: 1rem;
    }
    
    .tamer-blog-content p {
        max-width: none;
    }
    
    /* Larger touch targets on mobile */
    .tamer-btn,
    .tamer-button,
    .tamer-blog-link {
        min-height: 48px;
        min-width: 48px;
        padding: 12px 16px;
    }
    
    .tamer-blog-tag,
    .tamer-blog-category {
        min-height: 44px;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

/* ====================================
   PRINT ACCESSIBILITY
   ==================================== */

@media print {
    .tamer-accessibility-toolbar,
    .tamer-blog-skip-links,
    .tamer-live-region {
        display: none !important;
    }
    
    .tamer-blog-container,
    .tamer-blog-post {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.4;
    }
    
    .tamer-blog-title {
        font-size: 18pt;
        font-weight: bold;
        page-break-after: avoid;
    }
    
    .tamer-blog-content h2,
    .tamer-blog-content h3 {
        font-size: 14pt;
        font-weight: bold;
        page-break-after: avoid;
        margin-top: 20pt;
        margin-bottom: 10pt;
    }
    
    .tamer-blog-post {
        page-break-inside: avoid;
        margin-bottom: 20pt;
    }
    
    .tamer-blog-link {
        color: black !important;
        text-decoration: underline;
    }
    
    .tamer-blog-link[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #666;
    }
}

/* ====================================
   DARK MODE ACCESSIBILITY
   ==================================== */

@media (prefers-color-scheme: dark) {
    .tamer-blog-container,
    .tamer-blog-post,
    .tamer-blog-card {
        background-color: #121212;
        color: #ffffff;
    }
    
    .tamer-blog-title,
    .tamer-blog-content h2,
    .tamer-blog-content h3,
    .tamer-blog-content h4 {
        color: #ffffff;
    }
    
    .tamer-blog-content {
        color: #e0e0e0;
    }
    
    .tamer-blog-meta {
        color: #b0b0b0;
    }
    
    .tamer-blog-tag,
    .tamer-blog-category {
        background-color: #2e2e2e;
        color: #e0e0e0;
    }
    
    .tamer-blog-tag:hover,
    .tamer-blog-category:hover {
        background-color: #1976d2;
        color: #ffffff;
    }
    
    .tamer-accessibility-toolbar {
        background-color: #1e1e1e;
        border-color: #1976d2;
        color: #ffffff;
    }
    
    .tamer-a11y-control {
        background-color: #2e2e2e;
        border-color: #404040;
        color: #e0e0e0;
    }
    
    .tamer-a11y-control:hover {
        background-color: #3e3e3e;
        border-color: #606060;
    }
    
    .tamer-a11y-control.active {
        background-color: #0d47a1;
        border-color: #1976d2;
        color: #ffffff;
    }
}

/* ====================================
   UTILITY CLASSES
   ==================================== */

/* Visibility utilities */
.tamer-show-on-focus {
    position: absolute;
    left: -9999px;
}

.tamer-show-on-focus:focus {
    position: static;
    left: auto;
}

/* Text utilities */
.tamer-text-center { text-align: center; }
.tamer-text-left { text-align: left; }
.tamer-text-right { text-align: right; }

/* Spacing utilities */
.tamer-mt-1 { margin-top: 0.5rem; }
.tamer-mt-2 { margin-top: 1rem; }
.tamer-mt-3 { margin-top: 1.5rem; }
.tamer-mb-1 { margin-bottom: 0.5rem; }
.tamer-mb-2 { margin-bottom: 1rem; }
.tamer-mb-3 { margin-bottom: 1.5rem; }

/* Flexbox utilities */
.tamer-flex { display: flex; }
.tamer-flex-col { flex-direction: column; }
.tamer-items-center { align-items: center; }
.tamer-justify-center { justify-content: center; }
.tamer-justify-between { justify-content: space-between; }

/* This completes the comprehensive blog accessibility CSS framework */