/* ═══════════════════════════════════════════════════════════════════════════
   COMIC RELIEF — the site display face
   ═══════════════════════════════════════════════════════════════════════════

   Self-hosted from dashboard/public/fonts/. Two weights, both real files in the
   repository — nothing here depends on a network fetch at build or run time.

   ── WHY THIS FACE AND NOT SMILE MOON ────────────────────────────────────────

   Smile Moon could not be obtained: the only distribution is DaFont, which is
   unreachable from the environment these changes were made in, and its licence
   is not stated as permitting commercial use or redistribution — so committing
   the file to this repository would have been a licence risk even with the file
   in hand.

   Comic Relief is a libre, metrically-equivalent replacement for Comic Sans MS
   under the SIL Open Font License 1.1, which explicitly permits commercial use,
   bundling and redistribution. The licence text ships alongside the fonts at
   dashboard/public/fonts/OFL.txt, which OFL section 2 requires.

   Source: https://github.com/loudifier/Comic-Relief (release v1.210)

   ── SWAPPING IN A DIFFERENT FACE ────────────────────────────────────────────

   Put the woff2 in dashboard/public/fonts/, change the two `src` lines below and
   the family name in --font-display / --font-sans. Nothing else in the codebase
   names a font family, so that is the whole change — it reaches every heading,
   the wordmark, the live numbers and the body copy on both /home and /dashboard.

   ── NOTES ON THE DECLARATIONS ───────────────────────────────────────────────

   `font-display: swap` is load-bearing, not decoration: without it the browser
   blocks text painting for up to 3s while the file loads, so a slow connection
   would get invisible headings instead of fallback ones.

   Two real weights are declared rather than one, so the browser uses the drawn
   Bold for headings instead of synthesising a smeared faux-bold from Regular.
   400 and 700 are the only weights that exist; anything else in the sheets snaps
   to the nearer of the two.

   No `size-adjust`: Comic Relief is metrically equivalent to Comic Sans and its
   x-height is close enough to Inter's that the fallback swap does not reflow
   noticeably.
   ═══════════════════════════════════════════════════════════════════════════ */

@font-face {
    font-family: 'Comic Relief';
    src: url('/fonts/ComicRelief-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Comic Relief';
    src: url('/fonts/ComicRelief-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* =========================================================
   tokens.css — the design primitives, defined exactly once.

   Loaded FIRST, before styles.css / starfield.css / landing.css, by every
   page that renders UI: dashboard.html, home.html, terms.html, privacy.html.

   ── WHY THIS FILE EXISTS ──────────────────────────────────────────────────
   The rebrand from the old indigo accent to Nico Pro's electric blue could
   have been done as a find-and-replace over three stylesheets. It was not,
   because the old accent was not written down once — it was restated as
   `#6366f1` in five places, `#4f46e5` in two, `#818cf8` in one, `#a5b4fc` in
   seven, and `rgba(99, 102, 241, <alpha>)` in thirty-four more. A sweep over
   that is 49 edits that all have to agree, and the next palette change is 49
   more.

   So the hexes live here and nowhere else. styles.css and landing.css map
   these primitives onto the semantic names they already used (`--accent`,
   `--accent-2`, `--accent-grad`, `--radius`, `--trans`), which means every
   existing `var(--accent)` use site was re-toned without being touched.

   The palette itself mirrors utils/brand.js COLORS, which is the server-side
   authority and the same source the logo generator draws from. Keep the two
   in step: the mark, the embed sidebars and this UI are meant to be one hue.

   ── FOUR THINGS ARE DELIBERATE HERE ───────────────────────────────────────

   1. CHANNEL TRIPLETS (`--accent-rgb: 30 144 255`). A hex cannot be given an
      alpha in `var()`, so a tokenised accent is useless for the thirty-odd
      translucent washes the UI is built from. Storing the channels lets any
      rule write `rgb(var(--accent-rgb) / .12)` and still track the token.

   2. FILL vs TEXT vs INK ARE THREE DIFFERENT TOKENS, because the accent is
      not contrast-safe in all three roles and pretending otherwise is how the
      old sheet ended up shipping white 14px text on #6366f1 at 4.47:1 — a
      fail, narrowly, that nobody noticed because it looked fine.

          white on #1E90FF (accent)      3.24:1  ✗ AA normal text
          white on #0A5CE0 (accentDeep)  5.74:1  ✓
          #1E90FF on #0a0b0f (dark bg)   5.97:1  ✓
          #5AC8FF on #0a0b0f (dark bg)  10.25:1  ✓
          #1E90FF on #f7f8fa (light bg)  3.05:1  ✗ AA normal text
          #0A5CE0 on #f7f8fa (light bg)  5.40:1  ✓

      Hence: `--accent-fill` (a control that carries a label) is always the
      deep blue; `--accent-ink` (accent-coloured text and links) is the bright
      blue on dark and the deep blue on light; `--accent` stays the mid blue
      and is only ever used for strokes, focus rings, icons and glows, where
      the 3:1 non-text threshold applies.

   3. MOTION IS A SCALE, NOT A GUESS. Four durations and three easings, chosen
      by ROLE rather than by feel, so a hover and a full-screen transition
      cannot end up the same length (the old sheet had .15s, .18s, .2s, .25s,
      .28s, .3s, .45s, .5s, .6s and a 0.3s bouncy overshoot on card hover).

   4. NO `@media (prefers-reduced-motion)` BLOCK LIVES HERE. styles.css
      already owns one global block at the very end of the file; a second one
      here would be a second place to look. The durations below are what that
      block neutralises.
   ========================================================= */

:root {
    /* ═══ 1. Brand primitives — mirror of utils/brand.js COLORS ═══════════
     * These nine values are the only place a brand hex is written. */
    --nico-accent: #1E90FF;
    /* ring + "PRO"  */
    --nico-accent-bright: #5AC8FF;
    /* hovers, glows */
    --nico-accent-deep: #0A5CE0;
    /* pressed, fills */
    --nico-ice: #EAF6FF;
    /* chrome highlight */
    --nico-chrome: #A9D4F5;
    /* chrome mid-tone */
    --nico-ink: #03060E;
    /* page, near-black  */
    --nico-surface: #0A1020;
    /* raised surface */
    --nico-glow: #2B8CFF;
    /* additive glow */

    /* Channel triplets, for `rgb(var(--x) / a)`. Space-separated on purpose:
     * that is the CSS Color 4 form and the only one that composes in var(). */
    --accent-rgb: 30 144 255;
    --accent-bright-rgb: 90 200 255;
    --accent-deep-rgb: 10 92 224;
    --glow-rgb: 43 140 255;
    --ice-rgb: 234 246 255;

    /* ═══ 2. Accent roles ════════════════════════════════════════════════ */

    /* A filled control that carries a text label. Deep blue in BOTH themes:
     * see the contrast table above — the mid blue fails AA behind white text
     * at every size the UI actually uses. */
    --accent-fill: var(--nico-accent-deep);
    --accent-fill-hover: #0B66F2;
    --on-accent: #FFFFFF;

    /* Accent-coloured TEXT (links, active labels, counters). Bright on dark. */
    --accent-ink: var(--nico-accent-bright);

    /* Translucent accent washes. Named rather than inlined so "the accent
     * tint on a hovered card" is one decision, not fourteen. */
    --accent-wash: rgb(var(--accent-rgb) / .10);
    --accent-wash-2: rgb(var(--accent-rgb) / .16);
    --accent-wash-3: rgb(var(--accent-rgb) / .24);
    --accent-line: rgb(var(--accent-rgb) / .32);
    --accent-line-2: rgb(var(--accent-rgb) / .48);

    /* Gradients.
     *
     * --grad-brand  SURFACES. Every one of its ~14 use sites is a tile, chip or
     *               avatar that hosts a white glyph on top: the sidebar logo, the
     *               user avatar's initial, the guild picker's fallback letter, the
     *               feature and band icon chips. So it runs accent -> accentDeep
     *               and NOT bright -> accent -> deep, because white on
     *               #5AC8FF is 1.88:1 — a white 21px icon in the top-left corner
     *               of a 42px chip would have been all but invisible there. Across
     *               accent -> deep, white is 3.24:1 at the lightest point, which
     *               clears the 3:1 threshold that icons and large glyphs are held
     *               to. 160deg rather than 135deg so the lightest part is the top
     *               EDGE, where nothing sits, rather than the top-left quadrant.
     *
     *               The bright end of the ramp has not gone anywhere: it is where
     *               it belongs, in --grad-text, the glows and the focus ring.
     *
     * --grad-text   background-clip:text. Constrained to the AA-safe end of the
     *               ramp, and flattened entirely in the light theme. */
    --grad-brand: linear-gradient(160deg,
            var(--nico-accent) 0%,
            var(--nico-accent-deep) 100%);
    --grad-text: linear-gradient(135deg,
            var(--nico-accent-bright) 0%,
            var(--nico-accent) 100%);

    /* Glows. Tied to the accent so a re-tone carries into the shadows too,
     * which is where the old indigo survived longest. */
    --glow-sm: 0 6px 18px -8px rgb(var(--glow-rgb) / .70);
    --glow-md: 0 10px 26px -10px rgb(var(--glow-rgb) / .70);
    --glow-lg: 0 18px 44px -18px rgb(var(--glow-rgb) / .80);

    /* ═══ 2b. Typography ═════════════════════════════════════════════════
     *
     * ── WHY THESE EXIST ──────────────────────────────────────────────────
     *
     * There were no font tokens at all. `font-family` was written out
     * longhand in FIFTEEN places across three stylesheets:
     *
     *   styles.css      'Inter', system-ui, … (the body stack)
     *                   'JetBrains Mono', monospace          (×1)
     *                   Consolas, "Courier New", monospace   (×2)  ← a third stack
     *                   "gg sans", "Noto Sans", …            (×1)  ← a fourth
     *   landing.css     'JetBrains Mono', monospace          (×3)
     *   starfield.css   'JetBrains Mono', monospace          (×1)
     *
     * So "change the font of the site" meant editing three sheets and
     * reconciling four different stacks that had already drifted — two
     * separate monospace stacks were in use for the same purpose, and the
     * Discord-lookalike stack appeared once with no way to find it.
     *
     * Three roles, one definition each:
     *
     *   --font-display  headings, the wordmark, big numbers. This is the
     *                   BRAND face and the one to change for a restyle.
     *   --font-sans     body copy, controls, labels. Optimised for reading
     *                   at 13–16px, which a display face usually is not.
     *   --font-mono     ids, snowflakes, keys, code. Tabular and unambiguous.
     *
     * Display and body are deliberately SEPARATE tokens. A decorative face
     * set as the body font makes a control panel — which is mostly 13px
     * labels, numbers and Discord ids — materially harder to read, and
     * snowflakes in a display face are genuinely ambiguous between 0/O and
     * 1/l. Setting --font-display alone restyles every heading on both the
     * landing page and the dashboard.
     *
     * ── CHANGING THE SITE FACE ───────────────────────────────────────────
     *
     * 1. Put the woff2 at dashboard/public/fonts/ (see the README there).
     * 2. Point the @font-face `src` at it, at the top of this file.
     * 3. Name it first in --font-display (and --font-sans for body copy).
     *
     * That is the whole change, and it reaches every surface, because
     * nothing hard-codes a family any more. */
    --font-display:
        'Comic Relief', 'Inter', system-ui, -apple-system, BlinkMacSystemFont,
        'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    --font-sans:
        'Comic Relief', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
        Roboto, 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;

    /* One monospace stack, replacing the two that had diverged. Consolas is
     * kept ahead of the generic because it was in the stack this consolidates
     * and it is the better Windows default; ui-monospace picks up SF Mono on
     * Apple platforms without naming it. */
    --font-mono:
        'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas,
        'Liberation Mono', 'Courier New', monospace;

    /* The Discord-native stack, for surfaces that deliberately imitate a
     * Discord message (the embed/message previews). Tokenised so it is
     * findable — it appeared exactly once, inline, with no comment. */
    --font-discord:
        'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;

    /* ═══ 3. Shape ═══════════════════════════════════════════════════════
     * One radius ramp. styles.css and landing.css alias their own names onto
     * these so `--radius`, `--radius-sm`, `--lp-radius` all resolve here. */
    --r-xs: 6px;
    --r-sm: 9px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-pill: 999px;

    /* ═══ 4. Spacing ═════════════════════════════════════════════════════
     * A 4px-derived ramp. styles.css already exposed --sp-1..7; the names are
     * kept identical so nothing that uses them has to change. */
    --sp-1: .25rem;
    --sp-2: .5rem;
    --sp-3: .75rem;
    --sp-4: 1rem;
    --sp-5: 1.5rem;
    --sp-6: 2rem;
    --sp-7: 3rem;

    /* ═══ 5. Motion ══════════════════════════════════════════════════════
     * Durations by ROLE:
     *   dur-1  colour / opacity on a small control. Must feel instant.
     *   dur-2  the default. Hover, focus, small transforms.
     *   dur-3  something with area: dropdown, drawer, accordion, toast.
     *   dur-4  a whole screen: the boot splash and the first route paint.
     * Nothing in this UI should transition for longer than dur-4, and a
     * hover should never use anything above dur-2. */
    --dur-1: 110ms;
    --dur-2: 170ms;
    --dur-3: 260ms;
    --dur-4: 380ms;

    /* Easings.
     *   ease-standard  symmetric, for state that can go either way (hover).
     *   ease-out       decelerate, for things ARRIVING (panels, toasts).
     *   ease-in        accelerate, for things LEAVING.
     * No overshoot/back curve anywhere: on a control panel a button that
     * springs past its resting size reads as a glitch, not as polish. */
    --ease-standard: cubic-bezier(.2, .6, .3, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --ease-in: cubic-bezier(.5, 0, .9, .3);

    /* Ready-made pairs. `--trans` keeps its original name because ~120 rules
     * already say `var(--trans)`; it is now a token composition rather than a
     * literal `.18s ease`, so the easing upgrade reached all of them. */
    --trans: var(--dur-2) var(--ease-standard);
    --trans-fast: var(--dur-1) var(--ease-standard);
    --trans-panel: var(--dur-3) var(--ease-out);
    --trans-screen: var(--dur-4) var(--ease-out);

    /* ═══ 6. Elevation ═══════════════════════════════════════════════════
     * Four steps, and each one means a specific place in the stack:
     *   e-1  a card sitting on the page
     *   e-2  a sticky bar / raised control
     *   e-3  a popover: dropdown, user menu, toast
     *   e-4  a modal
     * Depth is carried by the shadow ramp, not by a per-component guess. */
    --e-1: 0 1px 2px rgb(0 0 0 / .28);
    --e-2: 0 4px 14px -4px rgb(0 0 0 / .38);
    --e-3: 0 12px 32px -8px rgb(0 0 0 / .48);
    --e-4: 0 28px 64px -16px rgb(0 0 0 / .60);

    /* ═══ 7. Focus ═══════════════════════════════════════════════════════
     * One ring, one offset, one colour, applied through :focus-visible so a
     * mouse click never paints it. The bright blue is used because it clears
     * 3:1 against both the dark page (10.25:1) and every card tint on it. */
    --focus-color: var(--nico-accent-bright);
    --focus-w: 2px;
    --focus-offset: 2px;
    --focus-ring: 0 0 0 3px rgb(var(--accent-bright-rgb) / .32);

    /* ═══ 8. Viewport safe areas ══════════════════════════════════════════
     * Both documents set `viewport-fit=cover`, which is what makes these
     * report real values — and also what makes anything pinned to a viewport
     * edge land under the notch or the home indicator unless it opts in.
     * Tokenised with a 0px fallback so they are safe to use unconditionally
     * inside calc()/max() on browsers with no env() support. */
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);

    /* ═══ 9. Touch targets ═══════════════════════════════════════════════
     * 44px is the smallest control that is reliably hit with a thumb, and the
     * figure both platform guidelines and WCAG 2.5.5 settle on. Kept as a
     * token because it is asserted in a dozen places across two sheets. */
    --tap: 44px;
}

/* ── A NOTE ON THE UNUSED TOKENS ───────────────────────────────────────────────
 * `node scripts/audit-css-tokens.js` reports a handful of properties defined
 * here that nothing currently references: --nico-ice, --nico-chrome,
 * --nico-surface, --r-xs, --ease-in, --trans-screen. That is deliberate and the
 * script treats it as informational rather than an error, for two reasons:
 *
 *   - The PALETTE is a mirror of utils/brand.js and is complete on purpose. If
 *     only the six colours the CSS happens to use today were listed, the next
 *     person needing the chrome mid-tone would write #A9D4F5 inline and the
 *     centralisation would start unravelling from there. (--nico-ice is also the
 *     source of --ice-rgb, which IS used, for every neutral wash in the sheet.)
 *
 *   - The SCALES are complete for the same reason: a radius ramp missing its
 *     smallest step invites a bare `4px`.
 *
 * What the script IS for is the opposite direction — a `var()` naming a property
 * that does not exist. That is silent and destructive, and it found two live
 * instances on its first run (`--amber`, `--card`); see styles.css. */

/* ═══════════════════════════════════════════════════════════════════════════
   LIGHT THEME
   Only the tokens whose ROLE changes are re-declared. The primitives do not
   move — the palette is the same nine colours; what changes is which end of
   the accent ramp is legible.
   ═══════════════════════════════════════════════════════════════════════════ */
html[data-theme="light"] {
    /* Accent text has to come DOWN the ramp on a white page: the bright blue
     * is 1.88:1 on white, which is not a colour, it is a suggestion. */
    --accent-ink: var(--nico-accent-deep);

    /* Gradient-clipped text is flattened to the deep blue. A gradient that
     * starts at 3.05:1 fails AA for anything under 18.66px, and `.grad-text`
     * is used on the 17.6px brand wordmark at the phone breakpoint. A solid
     * fill is 5.40:1 at every size, and on a light page the gradient was
     * barely legible as a gradient anyway. */
    --grad-text: linear-gradient(135deg, var(--nico-accent-deep), var(--nico-accent-deep));

    /* Washes need more alpha to register against white than against near-black. */
    --accent-wash: rgb(var(--accent-deep-rgb) / .07);
    --accent-wash-2: rgb(var(--accent-deep-rgb) / .12);
    --accent-wash-3: rgb(var(--accent-deep-rgb) / .18);
    --accent-line: rgb(var(--accent-deep-rgb) / .28);
    --accent-line-2: rgb(var(--accent-deep-rgb) / .45);

    /* Shadows on a light surface are a fraction of the strength: the same
     * alphas read as soot. */
    --e-1: 0 1px 2px rgb(15 23 42 / .06);
    --e-2: 0 4px 14px -4px rgb(15 23 42 / .10);
    --e-3: 0 12px 32px -8px rgb(15 23 42 / .14);
    --e-4: 0 28px 64px -16px rgb(15 23 42 / .20);

    --glow-sm: 0 6px 18px -8px rgb(var(--accent-deep-rgb) / .40);
    --glow-md: 0 10px 26px -10px rgb(var(--accent-deep-rgb) / .38);
    --glow-lg: 0 18px 44px -18px rgb(var(--accent-deep-rgb) / .40);

    /* The bright ring vanishes on white; the mid blue is 3.24:1, which clears
     * the 3:1 non-text threshold a focus indicator is judged against. */
    --focus-color: var(--nico-accent);
    --focus-ring: 0 0 0 3px rgb(var(--accent-rgb) / .28);
}
