/*
 * OneQode theming for the WorkAdventure client, for everything the admin API
 * cannot reach.
 *
 * services/space-admin/src/lib/branding.ts covers what IS official: WA feeds
 * map-details `backgroundColor` -> `--contrast*` and `primaryColor` ->
 * `--secondary*`, which between them carry ~260 of the rules in WA's bundle.
 * This file is the remainder, and each block below says which lever was missing.
 *
 * Loaded by a <link> that STARTUP_COMMAND seds into the play image's index.html
 * at container start - see the play service in ../../docker-compose.yml. That
 * puts it last in <head>, i.e. after WA's own bundle, so a selector that MATCHES
 * WA's own specificity wins on document order and nothing here needs !important
 * except the two inline-style cases. Beware the rules WA hangs off a descendant
 * selector - a bare class loses to those, so those are restated in full below.
 *
 * WA's own :root block for the two official prefixes is injected after </body>,
 * later than this file, so it keeps winning for the steps it defines. That is
 * deliberate: we only fill in the steps it omits.
 *
 * VERSION-fragile by nature. It cannot take the site down - a stale selector
 * just stops applying - but a WA upgrade needs a look at the rendered UI rather
 * than only a smoke test.
 */

@font-face {
    font-family: "Space Grotesk";
    src: url("/static/oq-chrome/SpaceGrotesk-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Space Grotesk";
    src: url("/static/oq-chrome/SpaceGrotesk-500.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Space Grotesk";
    src: url("/static/oq-chrome/SpaceGrotesk-600.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Space Grotesk";
    src: url("/static/oq-chrome/SpaceGrotesk-700.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/*
 * font.family.sans. Saans (font.family.display) is deliberately not here: only
 * the SemiBold cut is licensed to us, and WA's HUD has no heading/body split to
 * spend a display face on.
 *
 * Every WA element inherits from html/body except the ones listed here, which
 * set a family of their own. The doubled class names match the specificity of
 * WA's Svelte-scoped rules (`.loader.svelte-1m0og40`) without hard-coding a
 * build hash that changes on every upgrade.
 *
 * The heading family is WA's `Bebas Neue, Arial`, and no Bebas Neue @font-face
 * ships in the bundle - so those uppercase section labels were already rendering
 * as Arial upstream. Saans (font.family.display) is deliberately not the answer:
 * only its SemiBold cut is licensed to us.
 *
 * `say-bubble`/`thinking-text` (Comic Jens) and the error screen's Press Start 2P
 * ellipsis are left alone - both are deliberately not the UI face.
 *
 * Space Grotesk is not condensed and Roboto Condensed is, so text runs wider
 * here than upstream sizes its panels for. Worth a look at long labels.
 */
html,
body,
.btn,
.font-main,
.font-sans,
.font-\[roboto\],
.font-\[\'Roboto_Condensed\'\],
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6,
.ql-container,
.ql-toolbar.ql-snow,
.loader.loader,
.refresh.refresh,
main.mapDeletedScreen.mapDeletedScreen {
    font-family: "Space Grotesk", system-ui, sans-serif;
}

/*
 * Form controls do not inherit type - the UA stylesheet gives them a font of
 * their own - and WA's Tailwind build ships no preflight rule undoing that.
 * Every label in the action bar and its dropdowns sits inside a <button>, so
 * this one rule is most of the visible HUD. It is also why that HUD never
 * looked like Roboto Condensed upstream either: it has always been Arial.
 */
button,
input,
select,
textarea,
optgroup {
    font-family: inherit;
}

/*
 * The name tag under every avatar is built in JS from inline styles - Roboto at
 * 10px, on a 50%-opacity #1B2A41 pill - so no class reaches it and both need the
 * flag. The border stays WA's availability-status colour, which is the point of it.
 */
.username-display {
    background: rgba(13, 13, 13, 0.6) !important;
}

.username-display p {
    font-family: "Space Grotesk", system-ui, sans-serif !important;
}

/* color.surface.bg. Inline style on <body> in index.html, so this needs the flag. */
body {
    background-color: #000000 !important;
}

:root {
    /*
     * WA's neutral ramp is a blue-tinted grey (hue 220-228, 8-14% saturation)
     * and carries the avatars, cards, light buttons and inputs. The remake
     * neutrals are pure greys, so this drops the hue and keeps every step's
     * lightness: same contrast relationships WA designed against, without the
     * cast. No official lever reaches this prefix at all.
     */
    --neutral-100: 0 0% 98%;
    --neutral-200: 0 0% 94%;
    --neutral-300: 0 0% 88%;
    --neutral-400: 0 0% 86%;
    --neutral-500: 0 0% 71%;
    --neutral-600: 0 0% 61%;
    --neutral: 0 0% 54%;
    --neutral-800: 0 0% 46%;
    --neutral-900: 0 0% 38%;
    --neutral-1000: 0 0% 31%;
    --neutral-1100: 0 0% 23%;
    --neutral-1200: 0 0% 15%;
    --neutral-1300: 0 0% 8%;

    /* color.brand.blue.500. WA ships all 13 primary steps as one purple. */
    --primary-100: 212 100% 58%;
    --primary-200: 212 100% 58%;
    --primary-300: 212 100% 58%;
    --primary-400: 212 100% 58%;
    --primary-500: 212 100% 58%;
    --primary-600: 212 100% 58%;
    --primary: 212 100% 58%;
    --primary-800: 212 100% 58%;
    --primary-900: 212 100% 58%;
    --primary-1000: 212 100% 58%;
    --primary-1100: 212 100% 58%;
    --primary-1200: 212 100% 58%;
    --primary-1300: 212 100% 58%;

    /*
     * The steps getPalette never emits - it runs -50, -100..-400, bare, -600..-900
     * and stops - so these stayed WA navy and indigo while the rest of both ramps
     * became ours. Values continue the ramps backgroundColor/primaryColor produce.
     * Do not add -900 here: WA emits it, from a block later in the document.
     */
    --contrast-500: 0 0% 22%;
    --contrast-1000: 0 0% 1%;
    --contrast-1100: 0 0% 0%;
    --secondary-500: 212 100% 62%;
}

/*
 * WA's legacy named colours: cyan #56eaff, #1b1b29 / #4d4b67 purple-navy, and
 * #ff475a. Compiled to literal rgb() in the bundle, so no variable reaches them.
 *
 * Several of these live in WA under a descendant selector rather than on the bare
 * class, so document order alone loses to them - those are restated at WA's own
 * specificity below. The ancestors are stable component classes, not the hashed
 * Svelte ones, so this couples to markup no more than the class name already does.
 */
.bg-light-blue {
    background-color: #2a8dff;
}

.text-light-blue {
    color: #2a8dff;
}

/*
 * NOT a bare `.light` - upstream also defines `.light { font-weight: 300 }` as a
 * typography utility, so a bare selector paints every `h4 light` and
 * `btn light text-black bg-white` in the client blue.
 */
.bottom-action-bar .bottom-action-section .megaphone-confirm button[type="button"].light {
    background-color: #2a8dff;
    color: #ffffff;
}

.bottom-action-bar .bottom-action-section .border-top-light {
    border-top-color: #2a8dff;
}

.chatWindow nav .background {
    background-color: #2a8dff;
}

.scrollable-content::-webkit-scrollbar-thumb:active {
    background-color: #2a8dff;
}

/* Doubled to match `.connecting-spinner.svelte-<hash>:after` without the hash. */
.connecting-spinner.connecting-spinner:after {
    border-color: #2a8dff transparent;
}

/* color.surface.raised. */
.bg-dark-purple {
    background-color: #0d0d0d;
}

.wa-message .actions .action .caption {
    background-color: #0d0d0d;
    /* color.border.strong, not border.default: upstream #928ebb is a mid-tone meant to
       be seen against a dark panel, and #1f1f1f disappears into one. */
    border-color: #333333;
}

/*
 * The file-attachment actions popup. Upstream is #1b1b29f2, so the alpha has to
 * survive. NOT a bare `.actions`: the chat message action row is also `.actions`
 * and has no background upstream at all.
 */
.wa-message-body .file .actions {
    background-color: rgba(13, 13, 13, 0.95);
}

.bg-dark-purple\/70 {
    background-color: rgba(13, 13, 13, 0.7);
}

.text-dark-purple {
    color: #0d0d0d;
}

.wa-message .actions .action .caption:after {
    border-top-color: #0d0d0d;
}

.bottom-action-bar .bottom-action-section .megaphone-confirm:before {
    border-top-color: rgba(13, 13, 13, 0.95);
}

/*
 * color.border.strong, not border.default: upstream #4d4b67 is a mid-tone meant to
 * be seen against a dark panel, and #1f1f1f disappears into one.
 */
.border-light-purple {
    border-color: #333333;
}

.bottom-action-bar .bottom-action-section .megaphone-confirm button[type="button"].dark:hover {
    background-color: #1f1f1f;
}

/* color.text.error / color.border.error. */
.bg-pop-red {
    background-color: #ef4444;
}

button.button-state.error {
    background-color: #ef4444;
}

.text-pop-red,
.error {
    color: #f87171;
    border-color: #ef4444;
}
