/* SPDX-License-Identifier: AGPL-3.0-only */
/* ---------- Base: theme variables, reset, shared buttons & inputs ---------- */

/* Hidden until the translations are applied (see initI18n in js/i18n.js), so no English flashes first. */
.i18n-loading body {
    visibility: hidden;
}

/* The dark theme is the default; js/theme-init.js sets data-theme="light" on <html> before the page renders. */
:root {
    --bg: #0f1115;
    --surface: #181b22;
    --surface-2: #222631;
    --surface-hover: #2c3140;
    --border: #2c3140;
    /* Outlines of form controls, at least 3:1 against the surfaces (WCAG 1.4.11). */
    --border-strong: #6e768a;
    /* An off switch's track, under a --switch-thumb thumb. */
    --switch-off: #6e768a;
    --switch-thumb: #e8eaf0;
    --text: #e8eaf0;
    --muted: #9aa1b2;
    /* Filled buttons: --on-primary / --on-danger text keeps at least 4.5:1 on them (see test/contrast.test.js). */
    --primary: #5b5ef0;
    --primary-hover: #4f46e5;
    --on-primary: #fff;
    /* Links and accent icons on the dark surfaces. */
    --link: #8b8ff7;
    /* The "LK" of the brand name, matching the logo. */
    --brand-accent: #1fd5f9;
    /* Red text and icons on the dark surfaces; filled red buttons and badges use --danger-fill. */
    --danger: #f25c5c;
    --danger-fill: #dc2626;
    --danger-fill-hover: #b91c1c;
    --on-danger: #fff;
    /* Text on the light tints of status tags (recording, muted, errors, roles, reconnecting). */
    --danger-text: #fca5a5;
    --host-text: #c7d2fe;
    --cohost-text: #99f6e4;
    --warning-text: #fde047;
    --success: #22c55e;
    --speaking: #22d3ee;
    /* --hand fills badges (under dark text); --hand-text is the raised hand on the surfaces. */
    --hand: #fbbf24;
    --hand-text: #fbbf24;
    --private: #c084fc;
    --shadow: rgba(0, 0, 0, 0.5);
    --shadow-soft: rgba(0, 0, 0, 0.4);
    --radius: 14px;
    --controls-h: 76px;
    font-family:
        system-ui,
        -apple-system,
        'Segoe UI',
        Roboto,
        'Helvetica Neue',
        Arial,
        sans-serif;
    color-scheme: dark;
}

/* Same contrast minimums as the dark theme (see test/contrast.test.js). */
:root[data-theme='light'] {
    --bg: #f3f4f7;
    --surface: #ffffff;
    --surface-2: #eceef3;
    --surface-hover: #dfe2e9;
    --border: #d5d9e2;
    --border-strong: #737a8c;
    --switch-off: #737a8c;
    --switch-thumb: #ffffff;
    --text: #1a1d24;
    --muted: #565d6d;
    --link: #4338ca;
    --brand-accent: #0266c4;
    --danger: #c81e1e;
    --danger-text: #b91c1c;
    --host-text: #4338ca;
    --cohost-text: #0f766e;
    --warning-text: #854d0e;
    --success: #15803d;
    --speaking: #0891b2;
    --hand-text: #92400e;
    --private: #7e22ce;
    --shadow: rgba(15, 23, 42, 0.18);
    --shadow-soft: rgba(15, 23, 42, 0.12);
    color-scheme: light;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

/* Read by screen readers, not shown. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

html,
body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--link);
}

.muted {
    color: var(--muted);
}

/* Not Excalidraw's icons (the whiteboard): they're outlines, drawn with fill="none". */
svg:where(:not(.excalidraw svg)) {
    width: 22px;
    height: 22px;
    fill: currentColor;
    flex-shrink: 0;
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

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

input {
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 12px 14px;
    width: 100%;
    transition: border-color 0.15s;
}

input:focus {
    border-color: var(--primary);
    outline: none;
}

select {
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding-block: 11px;
    padding-inline: 14px 36px;
    width: 100%;
    min-width: 0;
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 20px) 50%,
        calc(100% - 15px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    text-overflow: ellipsis;
    cursor: pointer;
}

/* The chevron sits at the end of the line: on the left in right-to-left languages. */
[dir='rtl'] select {
    background-position:
        15px 50%,
        20px 50%;
}

select:focus {
    border-color: var(--primary);
    outline: none;
}

select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.primary-btn {
    background: var(--primary);
    color: var(--on-primary);
    border: 0;
    border-radius: 10px;
    padding: 12px 18px;
    font-weight: 600;
    transition:
        background 0.15s,
        transform 0.05s;
}

.primary-btn:hover {
    background: var(--primary-hover);
}

.primary-btn:active {
    transform: scale(0.98);
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: progress;
}

.ghost-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 14px;
    min-width: 44px;
    font-size: 18px;
}

.ghost-btn:hover {
    background: var(--surface-2);
}

/* Dark / light theme switch (lobby and meeting headers): shows the theme it switches to. */
.theme-toggle {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    transition:
        background 0.15s,
        color 0.15s;
}

.theme-toggle:hover {
    background: var(--surface-2);
    color: var(--text);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

:root[data-theme='light'] .theme-toggle .icon-to-light,
:root:not([data-theme='light']) .theme-toggle .icon-to-dark {
    display: none;
}
