/* Accessibility Enhancements */

/* Focus indicators - 更明顯的焦點指示 */
:focus {
    outline: 2px solid var(--primary-color, #00d9ff);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--primary-color, #00d9ff);
    outline-offset: 2px;
}

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color, #00d9ff);
    color: #000;
    padding: 8px 16px;
    z-index: 10000;
    transition: top 0.3s;
    text-decoration: none;
    font-weight: bold;
}

.skip-link:focus {
    top: 0;
}

/* Screen reader only content */
.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 {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --text-color: #ffffff;
        --bg-color: #000000;
        --primary-color: #00ffff;
        --border-color: #ffffff;
    }
    
    .stat-card, .chart-card, .settings-section {
        border: 2px solid #ffffff;
    }
}

/* Reduced motion preference */
@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;
    }
    
    .particles-container,
    .matrix-bg,
    .glow-effect {
        display: none !important;
    }
}

/* Ensure sufficient color contrast for text */
.low-contrast-warning {
    color: var(--warning-color, #ffbb00) !important;
}

/* Interactive elements */
button, 
[role="button"],
a,
input,
select,
textarea {
    min-height: 44px;  /* Minimum touch target size */
    min-width: 44px;
}

/* Exception for inline links */
p a, li a, span a {
    min-height: auto;
    min-width: auto;
}

/* Keyboard navigation indicators */
[tabindex]:focus {
    box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.5);
}

/* Form accessibility */
label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
}

input:invalid,
select:invalid,
textarea:invalid {
    border-color: var(--danger-color, #ff4444);
}

.form-error {
    color: var(--danger-color, #ff4444);
    font-size: 0.875em;
    margin-top: 4px;
}

/* Required field indicator */
.required::after {
    content: " *";
    color: var(--danger-color, #ff4444);
}

/* Disabled state */
[disabled],
.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Status indicators with icons (not just color) */
.status-success::before { content: "✓ "; }
.status-warning::before { content: "⚠ "; }
.status-error::before { content: "✕ "; }
.status-info::before { content: "ℹ "; }

/* Loading state announcement */
[aria-busy="true"] {
    cursor: wait;
}

[aria-busy="true"]::after {
    content: "載入中...";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

/* Table accessibility */
table {
    border-collapse: collapse;
}

th {
    text-align: left;
    font-weight: 600;
}

th, td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color, #333);
}

tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Responsive font scaling — 全站字體放大 */
html {
    font-size: 112%; /* ~18px base (原 100%=16px) */
}

@media (max-width: 640px) {
    html {
        font-size: 100%; /* 手機維持原大小 (原 90%) */
    }
}

/* Print styles */
@media print {
    .no-print,
    nav,
    .effects-container,
    .theme-switcher-container {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .stat-card,
    .chart-card {
        break-inside: avoid;
        border: 1px solid #ccc !important;
    }
}
