/*
 * M2R Clumio Edition: brand tokens.
 * Source: STYLE-GUIDE.md (Commvault palette, AWS Resilience Day dark deck)
 * and the Mission Earth pack v3 state colours (brand/mission-earth/art/tokens.json,
 * api/shared/MISSION-EARTH.md section 6, decision ME-D5).
 * Dark theme is the default. Light theme: <html data-theme="light">.
 *
 * Two layers, two jobs:
 *   --cv-* and --m2r-*  chrome: Commvault Crocus for buttons, links and focus,
 *                       surfaces, text and hairlines.
 *   --st-*              state: how far a thing is trusted. Each colour means one
 *                       thing and is always backed by a shape or a label.
 * Old state names (--m2r-threat, --m2r-ok, --m2r-warn) still work and point at
 * the state layer. Registration (claimed versus evidenced) is in registration.css.
 *
 * Brand assets that ship next to this file (copied verbatim from icons/,
 * never tinted or recoloured):
 *   /brand/clumio.svg                        Clumio mark (works on dark and light)
 *   /brand/commvault-horizontal-white.png    Commvault lockup for dark surfaces
 *   /brand/commvault-horizontal-crocus.png   Commvault lockup for light surfaces
 *   /brand/icons/white-*.png                 official icons for dark surfaces
 *   /brand/icons/crocus-*.png                official icons for light surfaces
 *   /brand/fonts/                            Pixelify Sans (SIL OFL 1.1), see SOURCE.md
 */

/* Pixel display face for fluid labels that are not drawn on the pixel grid.
   Pixel type never carries evidence: logs, ids and tables stay in --m2r-mono. */
@font-face {
    font-family: "Pixelify Sans";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("fonts/PixelifySans-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    /* Brand palette (constant across themes) */
    --cv-crocus: #834895;          /* primary accent, the Commvault purple */
    --cv-midnight: #00053A;        /* headings on light, dark panels */
    --cv-crocus-light: #C1A3C9;    /* borders, secondary accents */
    --cv-crocus-bright: #C07FD6;   /* highlights on dark */
    --cv-lavender: #C9A6FF;        /* lavender accent, Blue team */
    --cv-pink: #E92B62;            /* brand emphasis only, never a state */
    --cv-indigo: #6E74B7;          /* borders, muted */
    --cv-grey: #C4C7E3;            /* borders, muted */
    --cv-code-light: #F4F2F8;      /* code panel fill on white */
    --cv-success-light: #15803D;   /* legacy: not a game state, see --st-* */
    --cv-danger-light: #DC2626;
    --cv-warning-light: #B45309;   /* legacy: amber is not a game state */

    /* ---------------------------------------------------------- state layer */
    /* Values from the pack's art/tokens.json (uiSteps). Colour says how far a
       thing is trusted, never what class it is: classes are shape, size,
       motion and label. Every role is text-safe (4.5:1) on every surface
       except --st-ghost and --st-dolos, which are graphics only. */
    --st-verified: #f2d27a;        /* brass 3: evidenced, recovered, gate passed. Brass means this and nothing else */
    --st-verified-soft: rgba(242, 210, 122, 0.12);
    --st-claimed: #9a8774;         /* ink secondary: asserted, not yet evidenced. Pair with the ghost or a dashed ring */
    --st-claimed-soft: rgba(154, 135, 116, 0.14);
    --st-ghost: #4a3b3b;           /* the registration ghost: next darker ink step. Decoration only, never text */
    --st-health: #439d70;          /* a green health check. It is a claim: always next to the claimed mark */
    --st-health-soft: rgba(67, 157, 112, 0.14);
    --st-untrusted: #ee5a22;       /* ember 2: corrupted, forged, adversary. Never chrome */
    --st-untrusted-soft: rgba(238, 90, 34, 0.14);
    --st-legit: #58d0ee;           /* cyan 2: legitimate new data that must be kept */
    --st-legit-soft: rgba(88, 208, 238, 0.14);
    --st-dolos: #946a74;           /* plum: Dolos only. Graphics, not text */

    /* Dark theme (default) */
    --m2r-bg: #0A0A0F;
    --m2r-surface-0: #15141B;      /* deepest panel */
    --m2r-surface-1: #17161D;      /* panel */
    --m2r-surface-2: #1C1B23;      /* raised panel, rows, inputs */
    --m2r-surface-code: #141319;
    --m2r-scrim: rgba(10, 10, 15, 0.86);
    --m2r-scrim-soft: rgba(10, 10, 15, 0.55);

    --m2r-text: #F4F2FA;
    --m2r-mute: #A4A1B3;           /* secondary text */
    --m2r-dim: #6E6B7E;            /* decoration and disabled marks only: never text */
    --m2r-hairline: #6E6B7E;       /* structure: 3:1 on every surface (panels do not separate by tone) */
    --m2r-hairline-strong: #8A8799;

    --m2r-accent: var(--cv-crocus);
    --m2r-accent-hover: #9657AA;
    --m2r-accent-text: #FFFFFF;    /* text on accent fill */
    --m2r-accent-soft: rgba(131, 72, 149, 0.22);
    --m2r-glow: var(--cv-crocus-bright);   /* chrome highlight: focus, selection, links. Not a glow any more */
    --m2r-glow-2: var(--cv-lavender);
    --m2r-link: var(--cv-lavender);

    /* Emphasis, teams and danger are chrome (identity), not state */
    --m2r-emph: #F04A79;           /* brand pink for emphasis text and numbers, lifted to 4.5:1 on dark surfaces */
    --m2r-team-blue: var(--cv-lavender);
    --m2r-team-red: var(--m2r-emph);
    --m2r-danger: #C81E50;         /* destructive button fill, white text 5.6:1 */

    /* Old state names, kept so every page still works. New code uses --st-*. */
    --m2r-threat: var(--st-untrusted);           /* was pink */
    --m2r-threat-soft: var(--st-untrusted-soft);
    --m2r-ok: var(--st-health);                  /* was green "clean, verified": now a health claim. Verified is --st-verified */
    --m2r-ok-soft: var(--st-health-soft);
    --m2r-warn: var(--st-claimed);               /* was amber "unscanned, caution" */
    --m2r-warn-soft: var(--st-claimed-soft);
    --m2r-unknown: var(--m2r-mute);

    /* Source colours for recovery points (a class, not a state) */
    --m2r-vault: var(--cv-lavender);      /* Clumio SecureVault, outer ring */
    --m2r-snapshot: var(--cv-grey);       /* same-account snapshot, inner orbit */

    /* Type: Arial for UI (brand guideline), Consolas for code, clocks and evidence */
    --m2r-font: Arial, "Helvetica Neue", Helvetica, sans-serif;
    --m2r-mono: Consolas, "Cascadia Mono", "SFMono-Regular", Menlo, monospace;
    --m2r-font-pixel: "Pixelify Sans", ui-monospace, monospace;   /* display labels only */

    /* Type scale. rem, so the game page's --m2r-z scales it with everything else. Display sizes of
       2rem and up (titles, clocks, join codes) may be fluid: clamp() with these as the floor. */
    --m2r-fs-xs: 0.75rem;          /* eyebrows, chips, table heads, small print */
    --m2r-fs-sm: 0.875rem;         /* secondary text, hints, dense controls */
    --m2r-fs-md: 1rem;             /* body */
    --m2r-fs-lg: 1.125rem;         /* lead lines, card titles */
    --m2r-fs-xl: 1.25rem;          /* sub heads */
    --m2r-fs-2xl: 1.5rem;          /* section heads */
    --m2r-fs-3xl: 1.75rem;
    /* Arial ships 400 and 700 only: any other weight renders as one of these */
    --m2r-fw-regular: 400;
    --m2r-fw-bold: 700;

    /* Shape and spacing: one 0.25rem scale (4 px at 16 px) for padding, margin and gap.
       Anything under it is a 1 or 2 px hairline nudge. */
    --m2r-radius-sm: 6px;
    --m2r-radius: 10px;
    --m2r-radius-lg: 16px;
    --m2r-hairline-w: 1px;
    --m2r-space-1: 0.25rem;
    --m2r-space-2: 0.5rem;
    --m2r-space-3: 0.75rem;
    --m2r-space-4: 1rem;
    --m2r-space-5: 1.5rem;
    --m2r-space-6: 2rem;
    --m2r-space-7: 3rem;
    --m2r-space-8: 4rem;

    /* Touch: booth targets stay at or above 48px */
    --m2r-touch: max(48px, 3.4rem);

    /* Elevation is a drop shadow. Rings are 1px and never blur: no glows. */
    --m2r-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    --m2r-glow-shadow: 0 0 0 1px var(--m2r-glow);
    --m2r-threat-shadow: 0 0 0 1px var(--st-untrusted);

    /* Motion. Chrome (hover, menus) may ease. State changes step, never ease,
       and nothing flashes faster than 2 a second. The snap is 4 steps of 90 ms. */
    --m2r-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --m2r-steps: steps(4, end);
    --m2r-snap-step: 90ms;

    color-scheme: dark;
}

[data-theme="light"] {
    /* The pack is dark-only. Light values are the darker steps of the same
       ramps, chosen for 4.5:1 on white (brand owner to confirm). */
    --st-verified: #7a5a22;        /* brass 1 */
    --st-verified-soft: rgba(122, 90, 34, 0.10);
    --st-claimed: #766555;         /* ink, between steps 1 and 2 */
    --st-claimed-soft: rgba(118, 101, 85, 0.10);
    --st-ghost: #d0bfa2;           /* on light the dimmer copy is the paler step */
    --st-health: #2a7350;
    --st-health-soft: rgba(42, 115, 80, 0.10);
    --st-untrusted: #9c2a18;       /* ember 1 */
    --st-untrusted-soft: rgba(156, 42, 24, 0.10);
    --st-legit: #1b6f8c;
    --st-legit-soft: rgba(27, 111, 140, 0.10);
    --st-dolos: #5a3a52;           /* robe 2 */

    --m2r-bg: #F7F6FA;
    --m2r-surface-0: #EEECF4;
    --m2r-surface-1: #FFFFFF;
    --m2r-surface-2: var(--cv-code-light);
    --m2r-surface-code: var(--cv-code-light);
    --m2r-scrim: rgba(247, 246, 250, 0.90);
    --m2r-scrim-soft: rgba(247, 246, 250, 0.60);

    --m2r-text: var(--cv-midnight);
    --m2r-mute: #4F4D66;
    --m2r-dim: #77758C;
    --m2r-hairline: #7F819E;
    --m2r-hairline-strong: #666885;

    --m2r-accent: var(--cv-crocus);
    --m2r-accent-hover: #6F3B80;
    --m2r-accent-text: #FFFFFF;
    --m2r-accent-soft: rgba(131, 72, 149, 0.12);
    --m2r-glow: var(--cv-crocus);
    --m2r-glow-2: #5C62A6;         /* indigo deepened to 4.5:1 */
    --m2r-link: var(--cv-crocus);

    --m2r-emph: #C81E50;           /* pink deepened for contrast on white */
    --m2r-team-blue: var(--cv-crocus);

    --m2r-vault: var(--cv-crocus);
    --m2r-snapshot: #5C62A6;

    --m2r-shadow: 0 8px 28px rgba(0, 5, 58, 0.14);

    color-scheme: light;
}

/* Logo and icon swaps by theme: mark both variants, CSS shows one. */
.m2r-on-dark { display: inline-block; }
.m2r-on-light { display: none; }
[data-theme="light"] .m2r-on-dark { display: none; }
[data-theme="light"] .m2r-on-light { display: inline-block; }

/* Fluid display label in the pack's spirit. Pixel faces drawn on the grid use
   M2R.pixText (game/src/ui/pix-text.js). */
.m2r-pixel { font-family: var(--m2r-font-pixel); letter-spacing: 0.02em; }
