/* 无障碍设计CSS文件 */

/* 屏幕阅读器专用内容 */
.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;
}

/* 当获得焦点时显示屏幕阅读器内容 */
.sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 0.5rem 1rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    z-index: 10000;
}

/* 跳转链接样式 */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    z-index: 10000;
    font-weight: 500;
}

.skip-link:focus {
    top: 6px;
}

/* 焦点指示器增强 */
*:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* 移除默认焦点样式，使用自定义样式 */
*:focus:not(:focus-visible) {
    outline: none;
}

/* 键盘导航时的焦点样式 */
*:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(var(--accent-color-rgb), 0.2);
}

/* 按钮和链接的焦点样式 */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(var(--accent-color-rgb), 0.2);
}

/* 卡片和交互元素的焦点样式 */
.figure-card:focus-visible,
.timeline-item:focus-visible,
.news-card:focus-visible,
.heritage-card:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(var(--accent-color-rgb), 0.2);
    transform: translateY(-2px);
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000000;
        --secondary-color: #0066cc;
        --accent-color: #ff6600;
        --text-color: #000000;
        --background-color: #ffffff;
        --light-gray: #f0f0f0;
        --medium-gray: #666666;
        --dark-gray: #333333;
    }
    
    .hero {
        background: linear-gradient(135deg, #000000 0%, #333333 100%);
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .card,
    .figure-card,
    .news-card,
    .heritage-card {
        border: 1px solid var(--medium-gray);
    }
}

/* 减少动画偏好支持 */
@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;
    }
    
    .fade-in,
    .fade-in-up,
    .slide-in,
    .animate-in {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* 字体大小偏好支持 */
@media (prefers-font-size: large) {
    html {
        font-size: 18px;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #ffffff;
        --secondary-color: #4a9eff;
        --accent-color: #ff8c42;
        --text-color: #e0e0e0;
        --background-color: #121212;
        --light-gray: #2a2a2a;
        --medium-gray: #404040;
        --dark-gray: #cccccc;
        --white: #121212;
        --black: #ffffff;
    }
    
    body {
        background-color: var(--background-color);
        color: var(--text-color);
    }
    
    .hero {
        background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    }
    
    .card,
    .figure-card,
    .news-card,
    .heritage-card,
    .sidebar-section {
        background-color: var(--light-gray);
        color: var(--text-color);
    }
    
    .modal-content {
        background-color: var(--light-gray);
        color: var(--text-color);
    }
    
    input,
    select,
    textarea {
        background-color: var(--medium-gray);
        color: var(--text-color);
        border-color: var(--medium-gray);
    }
    
    input:focus,
    select:focus,
    textarea:focus {
        border-color: var(--accent-color);
    }
}

/* 错误状态样式 */
.error,
[aria-invalid="true"] {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2);
}

.field-error {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.field-error::before {
    content: "⚠️";
    font-size: 0.75rem;
}

/* 成功状态样式 */
.success,
[aria-valid="true"] {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

/* 加载状态样式 */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 禁用状态样式 */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* 工具提示样式 */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip::after {
    content: attr(aria-label);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--dark-gray);
    color: white;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
}

.tooltip:hover::after,
.tooltip:focus::after {
    opacity: 1;
}

/* 键盘导航指示器 */
.keyboard-navigation {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-md);
    font-size: 0.875rem;
    z-index: 10000;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.keyboard-navigation.show {
    opacity: 1;
    transform: translateY(0);
}

/* 语音识别指示器 */
.voice-recognition {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    z-index: 1000;
}

.voice-recognition:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

.voice-recognition.listening {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--accent-color-rgb), 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(var(--accent-color-rgb), 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--accent-color-rgb), 0);
    }
}

/* 文本缩放支持 */
@media (min-resolution: 2dppx) {
    html {
        font-size: 16px;
    }
}

/* 大字体模式 */
.large-text {
    font-size: 1.2em;
    line-height: 1.6;
}

.large-text h1 { font-size: 3rem; }
.large-text h2 { font-size: 2.4rem; }
.large-text h3 { font-size: 1.8rem; }
.large-text h4 { font-size: 1.4rem; }
.large-text h5 { font-size: 1.2rem; }
.large-text h6 { font-size: 1.1rem; }

/* 高对比度模式 */
.high-contrast {
    filter: contrast(150%);
}

.high-contrast .hero {
    background: #000000;
    color: #ffffff;
}

.high-contrast .card,
.high-contrast .figure-card,
.high-contrast .news-card,
.high-contrast .heritage-card {
    background: #ffffff;
    color: #000000;
    border: 2px solid #000000;
}

.high-contrast .btn {
    border: 2px solid currentColor;
    font-weight: 600;
}

/* 无图片模式 */
.no-images img {
    display: none;
}

.no-images .figure-card,
.no-images .news-card,
.no-images .heritage-card {
    padding-top: 1rem;
}

/* 简化布局模式 */
.simplified-layout .hero-stats,
.simplified-layout .hero-actions,
.simplified-layout .sidebar,
.simplified-layout .gallery-thumbnails {
    display: none;
}

.simplified-layout .newspaper-layout {
    grid-template-columns: 1fr;
}

.simplified-layout .info-grid,
.simplified-layout .news-grid,
.simplified-layout .heritage-grid {
    grid-template-columns: 1fr;
}

/* 打印样式 */
@media print {
    .header,
    .footer,
    .sidebar,
    .hero-actions,
    .btn,
    .search-container,
    .modal,
    .voice-recognition,
    .keyboard-navigation {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: #000000;
        background: #ffffff;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .section {
        page-break-inside: avoid;
        margin-bottom: 2rem;
    }
    
    .section-title {
        page-break-after: avoid;
    }
    
    .figure-card,
    .news-card,
    .heritage-card {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #cccccc;
    }
    
    a {
        color: #000000;
        text-decoration: underline;
    }
    
    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666666;
    }
}

/* 触摸设备优化 */
@media (pointer: coarse) {
    button,
    .btn,
    .nav-link,
    .figure-card,
    .news-card,
    .heritage-card {
        min-height: 44px;
        min-width: 44px;
    }
    
    .search-input {
        min-height: 44px;
    }
    
    .thumbnail {
        min-width: 60px;
        min-height: 60px;
    }
}

/* 语音浏览器支持 */
@media speech {
    .hero-stats,
    .article-meta,
    .news-stats {
        speak: literal-punctuation;
    }
    
    .sr-only {
        speak: always;
    }
    
    img {
        speak: always;
    }
    
    .decorative {
        speak: none;
    }
}

/* 无障碍工具栏 */
.accessibility-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    z-index: 10000;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.accessibility-toolbar.show {
    transform: translateY(0);
}

.accessibility-toolbar button {
    background: transparent;
    border: 1px solid white;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.accessibility-toolbar button:hover,
.accessibility-toolbar button:focus {
    background: white;
    color: var(--primary-color);
}

.accessibility-toolbar button.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

/* 响应式无障碍调整 */
@media (max-width: 768px) {
    .accessibility-toolbar {
        flex-wrap: wrap;
        padding: 0.25rem;
        gap: 0.5rem;
    }
    
    .accessibility-toolbar button {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }
    
    .voice-recognition {
        width: 50px;
        height: 50px;
        bottom: 1rem;
        right: 1rem;
        font-size: 1.2rem;
    }
}

/* 颜色盲友好设计 */
.colorblind-friendly .article-category,
.colorblind-friendly .heritage-category {
    position: relative;
}

.colorblind-friendly .article-category::before,
.colorblind-friendly .heritage-category::before {
    content: "●";
    margin-right: 0.25rem;
}

.colorblind-friendly .article-category[data-category="文化保护"]::before {
    content: "■";
}

.colorblind-friendly .article-category[data-category="学术研究"]::before {
    content: "▲";
}

.colorblind-friendly .article-category[data-category="文化活动"]::before {
    content: "♦";
}

.colorblind-friendly .article-category[data-category="旅游发展"]::before {
    content: "★";
}
