/**
 * NexusTools - 无障碍访问样式
 */

/* ========== 焦点样式 ========== */
:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--neon-pink);
    outline-offset: 2px;
    border-radius: 4px;
}

/* 按钮焦点 */
button:focus-visible,
.btn:focus-visible,
a:focus-visible {
    outline: 2px solid var(--neon-pink);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(255, 182, 217, 0.2);
}

/* 输入框焦点 */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: none;
    border-color: var(--neon-pink);
    box-shadow: 0 0 0 3px rgba(255, 182, 217, 0.2);
}

/* ========== 跳过导航链接 ========== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: var(--neon-pink);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--radius);
    z-index: 10000;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 16px;
}

/* ========== 屏幕阅读器专用 ========== */
.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-focusable:focus,
.sr-only-focusable:active {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ========== 高对比度模式 ========== */
@media (prefers-contrast: high) {
    :root {
        --glass-border: rgba(255, 255, 255, 0.5);
        --text-secondary: rgba(255, 255, 255, 0.9);
        --text-muted: rgba(255, 255, 255, 0.7);
    }
    
    .btn,
    .tool-btn,
    .card {
        border-width: 2px;
    }
    
    a {
        text-decoration: underline;
    }
}

/* ========== 减少动画模式 ========== */
@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;
    }
    
    .skeleton::after {
        animation: none;
    }
    
    .glow-orb {
        animation: none;
    }
}

/* ========== 键盘导航指示器 ========== */
.keyboard-nav-active *:focus {
    outline: 2px solid var(--neon-pink) !important;
    outline-offset: 2px !important;
}

/* ========== 工具提示无障碍 ========== */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 1000;
    pointer-events: none;
}

[data-tooltip]:hover::before,
[data-tooltip]:focus::before {
    opacity: 1;
    visibility: visible;
}

/* ========== 表单标签关联 ========== */
label {
    cursor: pointer;
}

label[for] {
    display: inline-block;
}

/* 必填字段指示 */
.required::after {
    content: ' *';
    color: var(--danger, #EF9A9A);
}

/* ========== 错误状态 ========== */
[aria-invalid="true"] {
    border-color: var(--danger, #EF9A9A) !important;
}

.error-message {
    color: var(--danger, #EF9A9A);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ========== 实时区域 ========== */
[aria-live] {
    /* 确保屏幕阅读器能够读取 */
}

.toast-container[aria-live="polite"] {
    /* 通知区域 */
}

/* ========== 禁用状态 ========== */
[disabled],
[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ========== 加载状态 ========== */
[aria-busy="true"] {
    cursor: wait;
}

/* ========== 展开/收起状态 ========== */
[aria-expanded="false"] + .collapse-content {
    display: none;
}

[aria-expanded="true"] + .collapse-content {
    display: block;
}

/* ========== 选中状态 ========== */
[aria-selected="true"] {
    background: var(--bg-card-hover);
}

[aria-current="page"] {
    font-weight: 600;
    color: var(--neon-pink);
}

/* ========== 触摸目标大小 ========== */
@media (pointer: coarse) {
    button,
    .btn,
    a,
    input[type="checkbox"],
    input[type="radio"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    .tool-btn {
        padding: 14px 20px;
    }
    
    .nav-link {
        padding: 12px 16px;
    }
}

/* ========== 文本可读性 ========== */
body {
    line-height: 1.6;
    letter-spacing: 0.01em;
}

/* 确保足够的颜色对比度 */
.text-muted {
    color: var(--text-muted);
}

/* ========== 链接样式 ========== */
a:not(.btn):not(.nav-link):not(.tool-card) {
    text-decoration-skip-ink: auto;
}

a:not(.btn):not(.nav-link):not(.tool-card):hover {
    text-decoration: underline;
}

/* ========== 图片替代文本 ========== */
img:not([alt]) {
    outline: 3px solid var(--danger, #EF9A9A);
}

/* ========== 表格无障碍 ========== */
table {
    border-collapse: collapse;
}

th {
    text-align: left;
    font-weight: 600;
}

th[scope="col"],
th[scope="row"] {
    /* 正确使用 scope 属性 */
}

/* ========== 打印样式 ========== */
@media print {
    .skip-link,
    .floating-toolbar,
    .search-modal,
    nav,
    footer {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    a[href]::after {
        content: ' (' attr(href) ')';
        font-size: 0.8em;
    }
}
