/*
 * OGameX accessibility layer (WCAG 2.2 AA, phase 1).
 * Loaded after the game bundle so it can override legacy rules such as
 * ":focus, :active { outline: 0; }".
 */

/* ---- Visible keyboard focus (2.4.7, 2.4.11) -------------------------------
 * Yellow outline plus a dark ring so it stays visible on both the dark game
 * background and light panels. Only for keyboard focus (:focus-visible), so
 * mouse users see no change.
 */
:focus-visible,
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible {
    outline: 3px solid #ffd43b !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 5px #000 !important;
    border-radius: 2px;
}

/* ---- Screen-reader-only text --------------------------------------------- */
.a11y-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ---- Skip link (2.4.1) ----------------------------------------------------- */
.a11y-skip-link {
    position: absolute;
    left: 8px;
    top: -100px;
    z-index: 100000;
    padding: 10px 16px;
    background: #000;
    color: #fff !important;
    font: bold 16px/1.2 Verdana, Arial, sans-serif;
    border: 3px solid #ffd43b;
    border-radius: 4px;
    text-decoration: none !important;
}
.a11y-skip-link:focus,
.a11y-skip-link:focus-visible {
    top: 8px;
}

/* The main region receives programmatic focus from the skip link; no outline needed there */
#a11y-main:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* Elements turned into buttons by a11y.js keep their look but show a pointer */
[data-a11y-button] {
    cursor: pointer;
}
[data-a11y-button][aria-disabled="true"] {
    cursor: default;
}

/* ---- Reduced motion (2.2.2, 2.3.3) ---------------------------------------
 * Applies with the OS preference or with the in-game option (html.a11y-reduce-motion,
 * set by a11y.js, which also sets the class when the OS preference is on).
 */
@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;
    }
}
html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}
/* The incoming-attack alert is an animated GIF: replace it with a static red marker */
html.a11y-reduce-motion #attack_alert.soon a {
    background: #b00000 !important;
    border: 2px solid #fff;
    border-radius: 4px;
    box-sizing: border-box;
}
html.a11y-reduce-motion #attack_alert.soon a::after {
    content: "!";
    display: block;
    color: #fff;
    font: bold 22px/36px Verdana, Arial, sans-serif;
    text-align: center;
}

/* ---- Contrast fixes for everyone (1.4.3), measured in the live game ------- */
/* galaxy footer counters (#616161 on black = 3.4:1) */
#galaxyContent #probes, #galaxyContent #recycler, #galaxyContent #rockets, #galaxyContent #slots,
#probes, #recycler, #rockets, #slots, #galaxyHeaderDiscoveryCount { color: #a8a8a8 !important; }
/* expedition template button title (#444 on black = 2.2:1) */
.expedtionFleetTemplateBtnTitle { color: #9e9e9e !important; }
/* message tabs (#848484 on #22313b = 3.6:1) */
#messages a.txt_link, #messagecontainercomponent a.txt_link, .tabs_btn a.txt_link { color: #bdbdbd; }
/* own row in the highscore (#848484 on blue = 2.9:1) */
#highscoreContent .myrank .playername, .myrank span.playername, tr.myrank .playername { color: #d6d6d6 !important; }

/* ---- Interface size (1.4.4): html.a11y-zoom-125 / -150 ---------------------
 * The legacy layout uses fixed pixel sizes everywhere, so the whole page is scaled.
 */
html.a11y-zoom-125 body { zoom: 1.25; }
html.a11y-zoom-150 body { zoom: 1.5; }

/* ---- High contrast (html.a11y-contrast) ----------------------------------- */
html.a11y-contrast body,
html.a11y-contrast body * {
    text-shadow: none !important;
}
html.a11y-contrast body { color: #fff; }
html.a11y-contrast #pageContent :is(p, span, td, th, li, div, label, dt, dd) {
    color: #f2f2f2;
}
html.a11y-contrast a,
html.a11y-contrast a:visited {
    color: #8fd3ff !important;
    text-decoration: underline !important;
}
html.a11y-contrast a.menubutton,
html.a11y-contrast a.menubutton span,
html.a11y-contrast .btn_blue,
html.a11y-contrast input[type="submit"],
html.a11y-contrast button {
    text-decoration: none !important;
}
html.a11y-contrast .overmark,
html.a11y-contrast .overmark *,
html.a11y-contrast .red,
html.a11y-contrast .error {
    color: #ff8080 !important;
}
html.a11y-contrast .undermark,
html.a11y-contrast .green,
html.a11y-contrast .success {
    color: #7dff7d !important;
}
html.a11y-contrast input,
html.a11y-contrast select,
html.a11y-contrast textarea {
    background: #000 !important;
    color: #fff !important;
    border: 2px solid #fff !important;
}
html.a11y-contrast .ui-dialog,
html.a11y-contrast .tpd-tooltip .tpd-content {
    background: #000 !important;
    color: #fff !important;
    border: 2px solid #fff !important;
}

/* ---- Tech tree text alternative ------------------------------------------- */
.a11y-techtree-list {
    margin: 12px 8px;
    color: #ddd;
    font-size: 12px;
}
.a11y-techtree-list summary {
    cursor: pointer;
    color: #8fd3ff;
    font-weight: bold;
    padding: 4px 0;
}
.a11y-techtree-list ul { margin: 6px 0 0 18px; list-style: disc; }
.a11y-techtree-list li { margin: 3px 0; }
.a11y-techtree-list li.met span[aria-hidden] { color: #7dff7d; }
.a11y-techtree-list li.notmet span[aria-hidden] { color: #ff8080; }

/* ---- Accessibility settings dialog ---------------------------------------- */
.a11y-settings fieldset { border: 1px solid #556; margin: 10px 0; padding: 8px 10px; }
.a11y-settings legend { font-weight: bold; color: #fff; padding: 0 4px; }
.a11y-settings label { display: block; margin: 6px 0; color: #eee; font-size: 13px; line-height: 1.4; cursor: pointer; }
.a11y-settings input[type="checkbox"], .a11y-settings input[type="radio"] { width: 18px; height: 18px; margin-right: 8px; vertical-align: middle; }
.a11y-settings p { color: #ddd; font-size: 13px; margin: 4px 0 8px; }
.a11y-settings button { margin-top: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
