/* One keyboard-focus treatment across the site and standalone labs.
   Use the surrounding surface's token; dark standalone labs keep the cyan fallback.
   Override component and vendor focus styles, including embedded controls. */
:is(a, button, input, select, textarea, summary, label, [tabindex]) {
    -webkit-tap-highlight-color: transparent;
}

/* Text inputs can match :focus-visible even when clicked. */
:root[data-pointer-focus] :focus,
:focus:not(:focus-visible) {
    outline: none !important;
    box-shadow: none !important;
}

:where(:root:not([data-pointer-focus])) :focus-visible,
:where(:root:not([data-pointer-focus])) .switch:has(> input:focus-visible) {
    outline: 2px solid var(--focus-ring, var(--color-logo-cyan, #00bed0)) !important;
    outline-offset: 3px !important;
    border-radius: var(--corner-radius, 8px) !important;
    box-shadow: none !important;
}

/* Coordinate editors also draw a focus ring on their surrounding field. */
:where(:root:not([data-pointer-focus])) .coordinate-field:has(input:focus-visible) {
    border-color: var(--focus-ring, var(--color-logo-cyan, #00bed0)) !important;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus-ring, var(--color-logo-cyan, #00bed0)) 18%, transparent) !important;
}

/* Custom switches hide their checkbox, so frame the visible control. */
.switch > input:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* Keep the ring visible inside clipped media containers. */
iframe:focus-visible {
    outline-offset: -3px !important;
}

/* Skip links sit over the navy header; contrast their ring with their own surface. */
:is(.home-skip-link, .contents-skip-link, .about-skip-link, .contact-skip-link, .lesson-skip-link):focus-visible {
    outline-offset: -4px !important;
}

/* Large reading and simulation surfaces keep focus without a cyan frame. */
:is(canvas, iframe.simulation-frame, #lesson-content) {
    -webkit-tap-highlight-color: transparent;
}

:is(canvas, iframe.simulation-frame, #lesson-content):focus {
    outline: none !important;
    box-shadow: none !important;
}
