/*
 * TurnUpCity WCAG 2.2 AA — Front-End Accessibility Stylesheet
 *
 * 1.  Skip navigation link
 * 2.  Forced focus-visible ring (keyboard navigation)
 * 3.  Removes outline:none overrides and restores them properly
 * 9.  Accessible marquee replacement (2.2.2 Pause Stop Hide)
 * 10. Forced focus ring for stripped elements (2.4.7)
 * 11. Small target size indicator (2.5.8 WCAG 2.2)
 */

/* ─────────────────────────────────────────────────────────────────────────────
   1. Skip link (WCAG 2.4.1 Bypass Blocks)
───────────────────────────────────────────────────────────────────────────── */

.tuc-skip-link {
    position: absolute;
    top: -999px;
    left: 6px;
    z-index: 100000;
    display: inline-block;
    padding: 10px 20px;
    background: #135e96;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    transition: top 0.1s ease;
    outline: none;
}

.tuc-skip-link:focus,
.tuc-skip-link:focus-visible {
    top: 0;
    outline: 3px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px #135e96;
}

/* ─────────────────────────────────────────────────────────────────────────────
   2. Universal keyboard focus ring (WCAG 2.4.3 Focus Order / 2.4.7 Focus Visible)
   Applied via .tuc-focus-visible class added by JS, or :focus-visible natively.
───────────────────────────────────────────────────────────────────────────── */

/* Modern: use :focus-visible pseudo-class */
:focus-visible {
    outline: 3px solid #005fcc !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(0, 95, 204, 0.25) !important;
    border-radius: 2px;
}

/* Legacy JS polyfill class */
.tuc-focus-visible {
    outline: 3px solid #005fcc !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(0, 95, 204, 0.25) !important;
    border-radius: 2px;
}

/* Suppress ring on mouse click (but not on keyboard) */
:focus:not(:focus-visible):not(.tuc-focus-visible) {
    outline: none;
    box-shadow: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   3. Override common theme patterns that remove outlines entirely
   Re-enables them only for keyboard users.
───────────────────────────────────────────────────────────────────────────── */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid #005fcc !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(0, 95, 204, 0.25) !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   4. Visible text resize support (WCAG 1.4.4 Resize Text)
   Use relative units. These rules reinforce if theme uses px.
───────────────────────────────────────────────────────────────────────────── */

/* Ensure body font scales with browser setting */
html {
    /* Don't override the theme; just ensure the base is accessible */
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

/* ─────────────────────────────────────────────────────────────────────────────
   5. High-contrast / forced-colours support (WCAG 1.4.11)
───────────────────────────────────────────────────────────────────────────── */

@media (forced-colors: active) {
    .tuc-skip-link {
        border: 2px solid ButtonText;
        background: ButtonFace;
        color: ButtonText;
    }
    :focus-visible,
    .tuc-focus-visible {
        outline: 3px solid Highlight !important;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   6. Reduced motion support (WCAG 2.3.3 Animation from Interactions – AAA,
      but good practice for AA and covered by 1.4.3 guidance)
───────────────────────────────────────────────────────────────────────────── */

@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;
    }
}
/* ─────────────────────────────────────────────────────────────────────────────
   7. Text Spacing – WCAG 1.4.12
      Content must not lose functionality when all four spacing properties are
      overridden simultaneously.
───────────────────────────────────────────────────────────────────────────── */

body,
body * {
    overflow-wrap: break-word;
    word-break: break-word;
}

.entry-content,
.post-content,
article,
main {
    max-width: 100%;
    overflow: visible;
}

/* ─────────────────────────────────────────────────────────────────────────────
   8. Reflow – WCAG 1.4.10
      Content must be presentable without horizontal scrolling at 320 CSS px.
───────────────────────────────────────────────────────────────────────────── */

@media screen and (max-width: 320px) {
    img,
    video,
    canvas,
    svg,
    iframe,
    table {
        max-width: 100% !important;
        height: auto;
    }

    .sticky,
    .fixed-nav,
    [style*="position:fixed"],
    [style*="position: fixed"] {
        position: static !important;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   9. Accessible marquee replacement (WCAG 2.2.2 Pause Stop Hide)
───────────────────────────────────────────────────────────────────────────── */

.tuc-marquee-wrapper {
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tuc-marquee-ticker {
    display: inline-block;
    white-space: nowrap;
    animation: tuc-scroll 20s linear infinite;
}

@keyframes tuc-scroll {
    from { transform: translateX(100%); }
    to   { transform: translateX(-100%); }
}

@media (prefers-reduced-motion: reduce) {
    .tuc-marquee-ticker {
        animation: none;
        white-space: normal;
    }
}

.tuc-marquee-pause {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   10. Forced focus ring for elements stripped of outline by JS (2.4.7)
───────────────────────────────────────────────────────────────────────────── */

.tuc-force-focus-visible:focus,
.tuc-force-focus-visible:focus-visible {
    outline: 3px solid #005fcc !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(0, 95, 204, 0.25) !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   11. Small target size indicator (2.5.8 WCAG 2.2) — development helper
   DISABLED: This was causing all links to show red outlines in production
───────────────────────────────────────────────────────────────────────────── */

/*
[data-tuc-small-target="true"] {
    outline: 2px dashed #dc2626 !important;
    outline-offset: 2px !important;
}
*/

/* ─────────────────────────────────────────────────────────────────────────────
   12. Enhanced text spacing support (WCAG 1.4.12)
───────────────────────────────────────────────────────────────────────────── */

/* REDUCED SCOPE: Only apply to content areas, not entire page */
.entry-content,
.post-content,
article p,
article li {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Ensure text containers don't clip with increased spacing - removed !important */
.entry-content,
.post-content {
    overflow: visible;
}

/* ─────────────────────────────────────────────────────────────────────────────
   13. Content on hover/focus (WCAG 1.4.13)
───────────────────────────────────────────────────────────────────────────── */

/* Ensure hover content is dismissible and doesn't obscure */
[title]:hover::after,
[data-tooltip]:hover::after {
    pointer-events: none;
}

/* Tooltips should be keyboard accessible */
[title]:focus-visible::after,
[data-tooltip]:focus-visible::after {
    content: attr(title) attr(data-tooltip);
    position: absolute;
    z-index: 10000;
    background: #333;
    color: #fff;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    white-space: normal;
    max-width: 250px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   14. Minimum target size (WCAG 2.5.8) - DISABLED to prevent layout breakage
   Target sizing is now handled via JavaScript padding only when needed
───────────────────────────────────────────────────────────────────────────── */

/* DISABLED: These rules were breaking menu layouts and designs
a,
button,
input[type="checkbox"],
input[type="radio"],
[role="button"],
[role="link"] {
    min-height: 24px;
    min-width: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

p a,
li a {
    display: inline;
    min-height: unset;
    min-width: unset;
    padding: 2px 0;
}
*/

/* ─────────────────────────────────────────────────────────────────────────────
   15. Form error handling (WCAG 3.3.1, 3.3.3, 3.3.4)
───────────────────────────────────────────────────────────────────────────── */

/* Error summary container */
.tuc-form-errors {
    color: #d32f2f;
    background: #ffebee;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 2px solid #d32f2f;
    border-radius: 4px;
}

.tuc-form-errors:empty {
    display: none;
}

.tuc-form-errors h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    color: #d32f2f;
}

.tuc-form-errors ul {
    margin: 0;
    padding-left: 1.5rem;
}

/* Individual field errors */
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
    border: 2px solid #d32f2f !important;
    background-color: #ffebee;
}

input[aria-invalid="true"]:focus,
select[aria-invalid="true"]:focus,
textarea[aria-invalid="true"]:focus {
    outline: 3px solid #d32f2f !important;
    outline-offset: 2px;
}

.tuc-field-error {
    color: #d32f2f;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

/* Required field indicator */
input[required]::after,
select[required]::after,
textarea[required]::after {
    content: "*";
    color: #d32f2f;
    margin-left: 0.25rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   16. Enhanced focus appearance (WCAG 2.4.11, 2.4.12, 2.4.13)
───────────────────────────────────────────────────────────────────────────── */

/* Ensure focus is never obscured by sticky/fixed elements */
:focus {
    scroll-margin: 100px;
    scroll-padding: 100px;
}

/* Enhanced focus appearance with better contrast */
*:focus-visible {
    outline: 3px solid #005fcc !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 5px rgba(0, 95, 204, 0.3) !important;
}- ONLY if element has no visible focus already */
*:focus-visible:not([class*="focus"]):not([class*="active"]) {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px rgba(0, 95, 204, 0.3)─────────────────── */

/* Ensure drag-and-drop elements are keyboard accessible */
[draggable="true"] {
    cursor: move;
}

[draggable="true"]:focus {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

[aria-grabbed="true"] {
    opacity: 0.7;
    cursor: grabbing;
}

/* ─────────────────────────────────────────────────────────────────────────────
   18. ARIA live regions (WCAG 4.1.3)
───────────────────────────────────────────────────────────────────────────── */

[role="alert"],
[role="status"] {
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

[role="alert"] {
    background: #ffebee;
    border-left: 4px solid #d32f2f;
    color: #333;
}

[role="status"] {
    background: #e3f2fd;
    border-left: 4px solid #1976d2;
    color: #333;
}

/* ─────────────────────────────────────────────────────────────────────────────
   19. Orientation support (WCAG 1.3.4)
───────────────────────────────────────────────────────────────────────────── */

/* Ensure content works in all orientations */
@media (orientation: portrait), (orientation: landscape) {
    body, html {
        overflow-x: hidden;
        max-width: 100vw;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   20. Audio/Video controls (WCAG 1.4.2, 2.2.2)
───────────────────────────────────────────────────────────────────────────── */

video,
audio {
    max-width: 100%;
}

video:not([controls]),
audio:not([controls]) {
    display: none;
}

/* Ensure media controls are keyboard accessible */
video:focus,
audio:focus {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}
