/**
 * Hiro Accessibility Styles
 * WCAG 2.2 AA Compliant Accessibility Features
 */

/* ============================================
   SKIP LINK
   ============================================ */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #007bff;
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    text-decoration: none;
    font-weight: bold;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* ============================================
   FOCUS INDICATORS
   ============================================ */

*:focus {
    outline: 3px solid #007bff;
    outline-offset: 2px;
}

/* High visibility focus for interactive elements */
a:focus,
button:focus,
input:focus,
[role="button"]:focus {
    outline: 3px solid #007bff;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(0, 123, 255, 0.3);
}

/* Remove focus outline for mouse users, keep for keyboard */
.js-focus-visible *:focus:not(.focus-visible) {
    outline: none;
}

.js-focus-visible *:focus.focus-visible {
    outline: 3px solid #007bff;
    outline-offset: 2px;
}

/* ============================================
   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;
    }

    /* Disable hover effects that rely on motion */
    .image-container:hover,
    .splash-image:hover,
    .crypto-card:hover,
    .product-card:hover {
        transform: none;
    }

    .image-container:hover img,
    .splash-image:hover img {
        transform: none;
    }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }

    .image-container {
        border: 2px solid #000;
    }

    .login-btn,
    .buy-btn,
    .copy-btn,
    .submit-btn {
        border: 2px solid #000;
    }
}

/* ============================================
   SCREEN READER ONLY TEXT
   ============================================ */

.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;
}

/* ============================================
   COLOR CONTRAST ENHANCEMENTS
   ============================================ */

/* Ensure WCAG AA compliance (4.5:1 for normal text) */
body {
    color: #333;
    background-color: #f0f0f0;
}

/* Links */
a {
    color: #007bff;
    text-decoration: underline;
}

a:hover {
    color: #0056b3;
    text-decoration: none;
}

/* Buttons */
button,
.login-btn,
.submit-btn,
.buy-btn,
.copy-btn,
.amount-btn {
    color: #fff;
    background-color: #007bff;
}

button:hover,
.login-btn:hover,
.submit-btn:hover,
.buy-btn:hover,
.copy-btn:hover,
.amount-btn:hover {
    background-color: #0056b3;
}

/* Error states */
.error-text {
    color: #721c24;
    background-color: #f8d7da;
    padding: 10px;
    border-radius: 5px;
    border-left: 4px solid #dc3545;
}

/* Success states */
.success-text {
    color: #155724;
    background-color: #d4edda;
    padding: 10px;
    border-radius: 5px;
    border-left: 4px solid #28a745;
}

/* ============================================
   TOUCH TARGETS (Minimum 44×44px)
   ============================================ */

button,
a,
input[type="submit"],
input[type="button"],
[role="button"] {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 16px;
}

/* Ensure clickable images have adequate touch target */
.image-container,
.splash-image {
    min-height: 44px;
    min-width: 44px;
}

/* ============================================
   MODAL ACCESSIBILITY
   ============================================ */

/* Prevent background scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Modal focus trap indicator */
.modal[aria-hidden="true"] {
    display: none;
}

.modal[aria-hidden="false"] {
    display: flex;
}

/* Ensure modal is announced */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

/* ============================================
   INTERSTITIAL ACCESSIBILITY
   ============================================ */

#interstitial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

#interstitial-overlay .interstitial-close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   FORM ACCESSIBILITY
   ============================================ */

/* Ensure labels are properly associated */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

.form-group input:focus {
    border-color: #007bff;
    outline: 3px solid #007bff;
    outline-offset: 2px;
}

/* Required field indicator */
.form-group label .required {
    color: #dc3545;
    font-weight: bold;
    margin-left: 4px;
}

/* Error messages */
.form-group .error-message {
    color: #721c24;
    font-size: 14px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group .error-message::before {
    content: "⚠";
    font-weight: bold;
}

/* ============================================
   IMAGE ACCESSIBILITY
   ============================================ */

/* Ensure images don't overflow */
img {
    max-width: 100%;
    height: auto;
}

/* Loading state for images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* ============================================
   NAVIGATION ACCESSIBILITY
   ============================================ */

/* Current page indication */
.nav-links a[aria-current="page"] {
    font-weight: bold;
    color: #007bff;
    border-bottom: 2px solid #007bff;
}

/* Accessible search box */
.search-box input {
    border: 2px solid #ddd;
    padding: 10px 16px;
    font-size: 16px;
}

.search-box input:focus {
    border-color: #007bff;
    outline: 3px solid #007bff;
    outline-offset: 2px;
}

/* ============================================
   AD ACCESSIBILITY
   ============================================ */

/* Ad containers */
[data-ad-placement] {
    position: relative;
}

[data-ad-placement]::before {
    content: attr(aria-label);
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Ad close buttons */
.interstitial-close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    line-height: 1;
}

/* ============================================
   RESPONSIVE TYPOGRAPHY
   ============================================ */

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    line-height: 1.6;
    font-size: 16px;
}

/* Responsive font sizing */
@media (max-width: 768px) {
    html {
        font-size: 16px;
    }

    h1 {
        font-size: 28px;
    }

    h2 {
        font-size: 24px;
    }

    h3 {
        font-size: 20px;
    }
}

/* ============================================
   ZOOM SUPPORT
   ============================================ */

/* Ensure content doesn't break at 200% zoom */
@media (max-width: 320px) {
    html {
        font-size: 14px;
    }
}

/* Prevent horizontal scroll */
body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* ============================================
   PRINT ACCESSIBILITY
   ============================================ */

@media print {
    /* Hide ads when printing */
    [data-ad-placement],
    #interstitial-overlay {
        display: none !important;
    }

    /* Ensure good contrast */
    body {
        background: white;
        color: black;
    }

    a {
        color: black;
        text-decoration: underline;
    }
}

/* ============================================
   DARK MODE SUPPORT (Optional)
   ============================================ */

@media (prefers-color-scheme: dark) {
    /* Uncomment if dark mode is desired
    body {
        background-color: #1a1a1a;
        color: #f0f0f0;
    }

    header {
        background-color: #2d2d2d;
    }

    a {
        color: #4da6ff;
    }
    */
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Focus visible polyfill helper */
.focus-visible {
    outline: 3px solid #007bff;
    outline-offset: 2px;
}

/* Hide element visually but keep accessible */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Show visually hidden element when focused */
.visually-hidden:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ============================================
   ANNOUNCEMENTS
   ============================================ */

/* Live region for dynamic content */
.sr-only-live {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Make live regions visible when they have content */
.sr-only-live:not(:empty) {
    position: static;
    width: auto;
    height: auto;
    padding: 10px;
    margin: 10px 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background: #007bff;
    color: white;
    border-radius: 5px;
}