/* SPDX-License-Identifier: AGPL-3.0-only */
/* ---------- Accessibility: more contrast and forced colors (e.g. Windows High Contrast) ---------- */

/* The system asks for more contrast: brighter text, outlined controls and a thicker focus ring. */
@media (prefers-contrast: more) {
    :root {
        --bg: #000;
        --surface: #0b0c10;
        --surface-2: #16181f;
        --border: #8a91a3;
        --border-strong: #c4c9d4;
        --switch-off: #7c8396;
        --text: #fff;
        --muted: #d0d4dd;
        --link: #b4b7fb;
    }

    :root[data-theme='light'] {
        --bg: #fff;
        --surface: #fff;
        --surface-2: #f1f2f5;
        --border: #5b6273;
        --border-strong: #3d4352;
        --switch-off: #4b5263;
        --text: #000;
        --muted: #2e323b;
        --link: #3730a3;
    }

    button:focus-visible,
    input:focus-visible,
    select:focus-visible {
        outline: 3px solid var(--text);
        outline-offset: 2px;
    }

    .person-menu button:focus-visible {
        outline: 2px solid var(--text);
        outline-offset: -2px;
    }

    /* The tile's menu is dark in both themes. */
    .tile-menu button:focus-visible {
        outline: 2px solid #fff;
        outline-offset: -2px;
    }

    .controls-group > .ctrl-btn,
    .more-wrap > .ctrl-btn,
    .round-btn,
    .tile-tools button,
    .host-actions button,
    .reaction-picker button {
        border: 1px solid var(--border);
    }

    .ctrl-btn[data-tooltip]:hover::after,
    .ctrl-btn[data-tooltip]:focus-visible::after {
        border: 1px solid var(--border);
        background: #000;
    }

    .tile.speaking {
        outline: 3px solid var(--speaking);
        outline-offset: -3px;
    }
}

/* Forced colors replace backgrounds and shadows with the system's, so anything drawn only with them
   (icon buttons, on / selected states, the speaking ring, switches) gets a border or system colors. */
@media (forced-colors: active) {
    .primary-btn,
    .ctrl-btn,
    .round-btn,
    .tile-tools button,
    .host-actions button,
    .reaction-picker button,
    .person-status button,
    .person-more,
    .person-badges .hand-tag,
    .bg-delete,
    .share-card-header .ghost-btn,
    .invite-link .ghost-btn,
    .muted-hint .ghost-btn {
        border: 1px solid ButtonText;
    }

    .ctrl-btn.active,
    .round-btn.active,
    .ctrl-btn.recording,
    .more-btn[aria-expanded='true'],
    .notes-toolbar .ghost-btn[aria-pressed='true'],
    .tile.pinned .pin-btn,
    .tile.spotlit .spotlight-btn {
        forced-color-adjust: none;
        border-color: Highlight;
        background: Highlight;
        color: HighlightText;
    }

    .ctrl-btn[data-tooltip]:hover::after,
    .ctrl-btn[data-tooltip]:focus-visible::after {
        border: 1px solid CanvasText;
    }

    input:focus-visible,
    select:focus-visible,
    .person-menu button:focus-visible,
    .tile-menu button:focus-visible {
        outline: 2px solid Highlight;
        outline-offset: 1px;
    }

    .tile-menu [aria-checked='true']::after {
        forced-color-adjust: none;
        background: Highlight;
    }

    .bg-option[aria-checked='true'] {
        outline: 3px solid Highlight;
        outline-offset: 1px;
    }

    .tile.speaking {
        outline: 3px solid Highlight;
        outline-offset: -3px;
    }

    .person.speaking .person-avatar {
        outline: 2px solid Highlight;
        outline-offset: 2px;
    }

    .switch-row input[type='checkbox'] {
        forced-color-adjust: none;
        border: 1px solid CanvasText;
        background: Canvas;
    }

    .switch-row input[type='checkbox']::after {
        top: 2px;
        inset-inline-start: 2px;
        background: CanvasText;
    }

    .switch-row input[type='checkbox']:checked {
        border-color: Highlight;
        background: Highlight;
    }

    .switch-row input[type='checkbox']:checked::after {
        background: HighlightText;
    }

    .switch-row input[type='checkbox']:focus-visible {
        outline: 2px solid Highlight;
        outline-offset: 2px;
    }

    .badge {
        border: 1px solid CanvasText;
    }

    /* Icons drawn as masks are painted with their background, which would be forced away. */
    .netcheck-icon::before,
    .chat-empty::before {
        forced-color-adjust: none;
        background: CanvasText;
    }

    /* Colour is the information here (connection quality, recording, voice activity). */
    .quality,
    .rec-dot,
    .audio-bars {
        forced-color-adjust: none;
    }
}
