/* ============ 0. type ============ */
/* Saira is the app's one face, self-hosted, latin + latin-ext, weights
   400-700. Nothing here requests an external server. */

@font-face{font-family:"Saira";font-style:normal;font-weight:400 700;font-display:swap;
  src:url("fonts/saira.woff2") format("woff2")}

/* The skins' own faces, one each at most: Slab heads in Bebas Neue,
   Doodle is written in Caveat, Ink's numbers are Cormorant Garamond. */

/* page-only: the download page is set in Figtree. build.py leaves it out of the app. */
@font-face{font-family:"Figtree";font-style:normal;font-weight:400 700;font-display:swap;
  src:url("fonts/figtree.woff2") format("woff2")}

/* Radius ladder. Plain border-radius, chosen to sit as close to the n=4
   superellipse in nit-core.js as a circular arc can. --r-*-sq is the
   superellipse radius each rung stands in for. */
:root{
  --r-xs:4px;        /* graph bars, stripes, cells, under 12px */
  --r-sm:6px;        /* chips, tags, inputs, icon buttons, up to 32px */
  --r-md:10px;       /* buttons, tiles, cards, 32-64px */
  --r-lg:16px;       /* panels, sheets, dialogs, above 64px */
  --r-pill:999px;
  --r-circle:50%;

  --r-xs-sq:7px;
  --r-sm-sq:11px;
  --r-md-sq:18px;
  --r-lg-sq:29px;
}

/* Where the real curve is available, take it, at the radius it was drawn for.
   Which elements get it, and which circles and pills opt out, is each
   surface's own business — see web/style.css and worker/public/index.html. */
@supports (corner-shape: squircle){
  :root{
    --r-xs:var(--r-xs-sq);
    --r-sm:var(--r-sm-sq);
    --r-md:var(--r-md-sq);
    --r-lg:var(--r-lg-sq);
  }
}

/* Spacing. The 8px grid, one token per rung; the rung is the name.
   4 is the half-step for tight inline pairs. Nothing between, nothing above. */
:root{
  --sp-4:4px;
  --sp-8:8px;
  --sp-16:16px;
  --sp-24:24px;
  --sp-32:32px;
  --sp-48:48px;
  --sp-64:64px;
}

/* Border widths. Not spacing, and not on the grid. --bw-2 is also the focus
   ring offset, which DESIGN.md measures at the same 2px. */
:root{
  --bw-1:1px;   /* separators, card edges, dividers */
  --bw-2:2px;   /* focus ring, thickened selection */
}

/* Scrollbars. One for the whole product: it sits in its own track, clear of
   what it scrolls, and grows a step under the pointer so it reads as a handle. */
:root{
  --fade:var(--sp-24);   /* how far what scrolls fades into an edge that has more past it */
}

/* Motion. MOTION.md is the language; these are its words. Nit's own timing
   lives in nit-core.js. */
:root{
  --ease:cubic-bezier(0.2, 0, 0, 1);         /* the standard curve: quick out, long settle */
  --ease-out:cubic-bezier(0.16, 1, 0.3, 1);  /* arriving: decelerates, no overshoot */
  --ease-in:cubic-bezier(0.4, 0, 1, 1);      /* leaving: accelerates away */
  --ease-open:cubic-bezier(0.25, 0.1, 0, 1); /* opening to fit: a quick start, a soft landing */
  --ease-hold:cubic-bezier(0.4, 0, 0.8, 0.8); /* a held card growing: a soft start, still moving at the end */
  --ease-swing:cubic-bezier(0.37, 0, 0.63, 1); /* a swing back and forth: as slow at either end as a pendulum */
  --ease-snap:cubic-bezier(0.05, 0.9, 0.1, 1); /* snaps away, then settles: most of the way in the first few frames */
  --ease-lift:cubic-bezier(0.3, 1.3, 0.5, 1); /* a lift: quick, then a breath past and back */
  /* How often it happens decides how long it takes (MOTION.md). Once a
     session: 250-350ms. Several times a minute: 120-180ms. Driven by the
     measurement: never animated. */
  --dur-state:120ms;   /* changing while it stays put */
  --dur-move:180ms;    /* arriving or leaving, often */
  --dur-quick:160ms;   /* a frequent hand-off arriving: a tab, a group, a seg */
  --dur-quick-exit:100ms; /* and the one it replaces leaving */
  --dur-exit:220ms;    /* the outgoing half of a hand-off */
  --dur-enter:300ms;   /* the incoming half */
  --dur-expand:240ms;  /* closing, and changing height */
  --dur-open:280ms;    /* opening to the height of what is inside */
  --dur-grow:260ms;    /* a card growing into its detail: it answers the click at once */
  --dur-shrink:220ms;  /* and going back into its place */
  --dur-data:839ms;    /* tracking incoming data, or catching the eye */

  --overlap:0.8;       /* an entrance starts when the exit is this far done */
  --rise:16px;         /* how far something arriving travels into place */
  --sink:8px;          /* how far something leaving drifts away */
  --stagger:30ms;      /* between the items of one group, top to bottom */
  --press:1.015;       /* something pulled: barely larger */
  --hold-grow:1.02;    /* a card being held: a slow creep, most of the way to the lift */
  --lifted:1.035;      /* and where it settles, lifted out of the board */
  --recede:.97;        /* an open watch under its own menu: sat back */
  --sitback:.985;      /* the board behind anything open: sat back a touch */
  --sidestep:12px;     /* an open watch stepping aside for its own menu */
  --wiggle:0.28deg;    /* while one is held out, how far each other card trembles either side of upright */
  --pane-hold-grow:1.01; /* a panel column being held: a tall thing grows less */
  --pile-w:240px;      /* a box in the pile, drawn this wide */
  --pile-step:12px;    /* under the pointer, each box in the pile shows this much more of itself */
  --pile-shade:0 -4px 24px color-mix(in srgb,var(--black) 24%,transparent);   /* a box in the pile, on the one in front: barely there */
  --pane-lifted:1.025;   /* and lifted, ready to carry */
  --dur-wiggle:240ms;  /* one whole tremble, there and back: quick, like an icon waiting to be moved */
  --dur-pop:260ms;     /* the lift and its settle */
  --dur-unpile:160ms;  /* the whole pile going home, every box at once */
  --dur-pile:320ms;    /* a pile opening out under the pointer, and closing up again */
  --dur-live:1800ms;   /* one ring of the live dot: something is being watched right now */
  --planet-hover:1.04; /* a planet under the pointer in the welcome */
  --lift:0 12px 32px color-mix(in srgb,var(--black) 70%,transparent);   /* its very soft shadow */
  --hold-grace:80ms;   /* a press that moves before this is a pull, not a hold */
  --hold:680ms;        /* holding a card this long picks it up; with the pop after it, 1s in all */
  --pane-hold:1000ms;  /* holding a panel column this long lifts it */
}
/* Windows' animation effects off: nothing travels, things fade, quickly */
@media (prefers-reduced-motion: reduce){
  :root{
    --rise:0px; --sink:0px; --stagger:0ms; --press:1; --hold-grow:1; --lifted:1; --recede:1; --sitback:1; --sidestep:0px; --planet-hover:1; --wiggle:0deg; --pane-hold-grow:1; --pane-lifted:1;
    --dur-move:120ms; --dur-exit:100ms; --dur-enter:120ms; --dur-expand:120ms; --dur-open:120ms; --dur-data:120ms;
    --dur-grow:120ms; --dur-shrink:120ms; --dur-quick:100ms; --dur-quick-exit:80ms; --dur-pile:120ms;
  }
}

/* --font is the face. --fontSize normalises x-height against the scale's
   reference face, --fontTrack corrects density, --fontLine keeps a corrected
   face's text lines as tall as the scale's, --fontCh makes a measure in ch
   hold as much text as it does in the app's face. All leave the type scale
   untouched. */
:root{
  --font:"Saira","Figtree",system-ui,sans-serif;
  --fontSize:1;
  --fontTrack:0em;
  --fontLine:1;
  --fontCh:1;
}
:root[data-font="saira"],[data-font="saira"]{
  --font:"Saira",system-ui,sans-serif;     --fontSize:0.980; --fontTrack:-0.007em}

/* Type scale. One row per role in DESIGN.md: size, weight, line height and
   tracking. Sizes are the uncorrected value — a component multiplies by
   --fontSize and adds --fontTrack, so the correction resolves on the element
   and a nested [data-font] still works. */
:root{
  --t-wordmark-size:clamp(40px, 13.4vw, 150px);
  --t-wordmark-weight:700; --t-wordmark-line:.88; --t-wordmark-track:-.03em;

  --t-metric-xl-size:60px;          /* twice --t-metric-lg-size, and the cap */
  --t-metric-xl-weight:500; --t-metric-xl-line:1; --t-metric-xl-track:-.02em;

  --t-display-size:48px;
  --t-display-weight:500; --t-display-line:1;    --t-display-track:-.02em;

  --t-metric-lg-size:30px;
  --t-metric-lg-weight:500; --t-metric-lg-line:1;  --t-metric-lg-track:-.01em;

  --t-verdict-size:24px;
  --t-verdict-weight:600; --t-verdict-line:1.25; --t-verdict-track:0em;

  --t-heading-size:18px;
  --t-heading-weight:700; --t-heading-line:1.3;  --t-heading-track:0em;

  --t-subheading-size:16px;
  --t-subheading-weight:600; --t-subheading-line:1.4; --t-subheading-track:0em;

  --t-body-size:15px;
  --t-body-weight:400; --t-body-line:1.55; --t-body-track:0em;

  --t-button-size:15px;
  --t-button-weight:600; --t-button-line:1; --t-button-track:0em;

  --t-body-sm-size:13px;
  --t-body-sm-weight:400; --t-body-sm-line:1.5; --t-body-sm-track:0em;

  --t-metric-size:13px;
  --t-metric-weight:400; --t-metric-line:1.4; --t-metric-track:0em;

  /* a heading inside a window, a form label, a column's or a tile's name: Title Case, never capitals */
  --t-label-size:13px;
  --t-label-weight:600; --t-label-line:1.3; --t-label-track:0em;

  /* the one capitalised role, and only on a status chip */
  --t-label-micro-size:11px;
  --t-label-micro-weight:600; --t-label-micro-line:1.2; --t-label-micro-track:.12em;

  --t-floor:11px;                   /* nothing renders smaller, whatever a face's correction does */
}

/* Colour tokens, three layers.
   1. System: GitHub Primer's dark palette (@primer/primitives 7, the
      classic dark theme), by scale and step. Step 0 is the lightest.
   2. Roles: the colours that carry the most weight, by name. Nothing swaps
      them; a game theme changes the background only.
   3. Product: every colour name used in app.js, style.css and the download
      page, resolved to a role or a system step. Nothing else in the code names a colour.
   No shadow tokens live here, apart from Nit's. */

/* ============ 1. colour system ============ */

:root,[data-theme="dark"]{
  /* canvas.inset: the darkest surface Primer has */
  --black:#010409;

  --gray-0:#f0f6fc;  --gray-1:#c9d1d9;  --gray-2:#b1bac4;  --gray-3:#8b949e;
  --gray-4:#6e7681;  --gray-5:#484f58;  --gray-6:#30363d;  --gray-7:#21262d;
  --gray-8:#161b22;  --gray-9:#0d1117;

  /* Status: three chosen colours. Each scale is one source (step 3, the fill)
     and steps derived from it by mixing, so no other hue enters: step 2 is
     lifted toward Gray 0 for text, step 9 is sunk into the card surface for
     badges and tints. */
  /* good */
  --cyan-3:#22d3ee;
  --cyan-2:color-mix(in srgb,var(--cyan-3) 85%,var(--gray-0));
  --cyan-9:color-mix(in srgb,var(--cyan-3) 16%,var(--gray-9));
  /* informational */
  --blue-3:#58a6ff;  --blue-4:#388bfd;  --blue-9:#051d4d;
  /* slow or degraded */
  --gold-3:#fbbf24;
  --gold-2:color-mix(in srgb,var(--gold-3) 85%,var(--gray-0));
  --gold-9:color-mix(in srgb,var(--gold-3) 16%,var(--gray-9));
  /* broken: the darkest of the three, so its text step is lifted further */
  --crimson-3:#fb4870;
  --crimson-2:color-mix(in srgb,var(--crimson-3) 75%,var(--gray-0));
  --crimson-9:color-mix(in srgb,var(--crimson-3) 16%,var(--gray-9));
}

/* ============ 2. roles ============ */

:root,[data-theme]{
  --canvas:var(--black);      /* the window and the sidebar */
  --surface:var(--gray-9);    /* cards and panels */
  --raised:var(--gray-8);     /* dialogs and popovers, over the surface */
  --primary:var(--gray-0);    /* the main action */
  --primaryInk:var(--black);  /* text on it */
  --secondary:var(--gray-7);  /* quiet controls, chips, wells */
  --accent:var(--gray-0);     /* what is selected: the mark beside it */
}

/* ============ 3. product ============ */

:root,[data-theme]{
  /* surfaces, darkest to lightest */
  --bg:var(--canvas);         /* the window */
  --panel:var(--surface);     /* cards and panels */
  --elev:var(--raised);       /* raised: dialogs, Nit's bubble */
  --ctl:var(--secondary);     /* controls, chips, wells */

  /* hairlines */
  --line:var(--gray-7);
  --line2:var(--gray-6);
  --lineHover:var(--gray-5);  /* a hovered edge: one step up, never a bright outline */

  /* text: three steps, all of them comfortably readable on every surface */
  --txt:var(--gray-0);        /* full strength */
  --mute:var(--gray-1);       /* secondary */
  --dim:var(--gray-3);        /* muted: labels, captions, units */
  --off:var(--gray-4);        /* disabled controls only, never text to read */
  --fg:var(--txt);
  --fg-dim:var(--mute);
  --fg-faint:var(--dim);

  /* knocked out of a --mute chip */
  --muteInk:var(--black);

  /* the four meanings: fill paints dots, bars and fills; ink is text; bg sits
     behind a badge or a pill; wash tints a whole card */
  --fast:var(--cyan-3);    --fastInk:var(--cyan-2);   --fastBg:var(--cyan-9);
  --info:var(--blue-4);    --infoInk:var(--blue-3);   --infoBg:var(--blue-9);
  --slow:var(--gold-3);    --slowInk:var(--gold-2);   --slowBg:var(--gold-9);
  --bad:var(--crimson-3);  --badInk:var(--crimson-2); --badBg:var(--crimson-9);
  --slowWash:var(--gold-9);
  --badWash:var(--crimson-9);
  --ok:var(--fastInk);
  --warn:var(--slowInk);
  --green:var(--fast);
  --mid:var(--slow);       --midInk:var(--slowInk);
  --hot:var(--bad);        --hotInk:var(--badInk);

  /* primary action: never a status colour */
  --btnFill:var(--primary);
  --invTxt:var(--black);
  --invMute:var(--gray-5);
  --btnTxt:var(--primaryInk);
  --new:var(--gray-0);
  --blue:var(--gray-0);

  /* logo has its own token so it never resolves to a status colour */
  --logoInk:var(--gray-0);

  /* scrollbar thumb: quiet at rest, a step brighter under the pointer */

  /* scrim */
  --ovBg:color-mix(in srgb,var(--black) 85%,transparent);   /* behind anything open: shapes, never anything readable */
  --ovDeep:color-mix(in srgb,var(--black) 50%,transparent); /* over that, while an open watch has its menu out: the board one step further back */
  --ovBack:color-mix(in srgb,var(--black) 55%,transparent); /* an open watch under its own menu: dimmer, still there */

  /* clickable or not: what answers a click has this edge at rest; what only
     shows has none. The one hover is this layer laid over whatever is there */
  --actEdge:var(--line2);
  --hoverLayer:color-mix(in srgb,var(--gray-0) 2%,transparent);
  /* a row that only shows: a strip of its own, never a hairline */
  --rowBg:color-mix(in srgb,var(--ctl) 50%,transparent);
}
:root{ --act-border:var(--bw-1) solid var(--actEdge); }

/* The download page has no data-theme and still reads the old Radix names,
   in its CSS and its scripts. Each is the nearest Primer step. Scoped to it,
   because red-9 is a fill there. Its status names follow the app's status
   colours, so the page shows what the app shows. */
:root:not([data-theme]){
  --slate-1:var(--black);   --slate-2:var(--gray-9);  --slate-3:var(--gray-7);
  --slate-5:var(--gray-6);  --slate-6:var(--gray-6);  --slate-7:var(--gray-5);
  --slate-8:var(--gray-4);  --slate-9:var(--gray-4);  --slate-11:var(--gray-2);
  --slate-12:var(--gray-0);
  --jade-9:var(--cyan-3);   --jade-11:var(--cyan-2);
  --amber-9:var(--gold-3);  --amber-11:var(--gold-2);
  --red-9:var(--crimson-3); --red-11:var(--crimson-2);
}

/* Nit is left exactly as he was: his own colours, not the palette's. */
:root,[data-theme]{
  --robot:#111113;
  --robotEdge:color-mix(in srgb,#edeef0 9%,transparent);
  --robotEye:#edeef0;
  --eye:#edeef0;
  --robotGlowIn:205,236,255;
  --robotGlowOut:150,210,255;
  --robotGlow:1;
}

/* ============ game themes ============ */
/* One hue per game, and it is used for one thing only: the dark fade over
   that game's poster behind the board. Never a card, text, a control, a
   window or a status. Matches a nested [data-gtheme] too, for the picker. */
:root{ --gt:transparent; }
[data-gtheme="halo"]{    --gt:#4fc3b0; }   /* the energy shield */
[data-gtheme="vt2"]{     --gt:#7fbf4a; }   /* warpstone green */
[data-gtheme="gow"]{     --gt:#8fb4d6; }   /* Leviathan frost */
[data-gtheme="cp77"]{    --gt:#f3e600; }   /* Night City yellow */
[data-gtheme="doom"]{    --gt:#ff5a1f; }   /* hellfire from below */
[data-gtheme="rdr2"]{    --gt:#c4904f; }   /* dust at sundown */
[data-gtheme="cs2"]{     --gt:#e0a33a; }   /* the orange of the map overlay */
[data-gtheme="dota2"]{   --gt:#c2402c; }   /* the Dire's red */
[data-gtheme="apex"]{    --gt:#e0403a; }   /* the Apex red */
[data-gtheme="rust"]{    --gt:#ce5a2b; }   /* corrugated rust */
[data-gtheme="pubg"]{    --gt:#d8b45a; }   /* map khaki */
[data-gtheme="rivals"]{  --gt:#9b6bff; }   /* comic-book violet */

/* The glass. Only the desktop shows through, and only behind the whole
   window: Windows blurs it, and the page lays its own dark over it so the
   desktop is a hint, never readable. Every surface inside the window (the
   sidebar, the watches, every window and an open watch, popovers) is solid
   (--glass-body) with grain over it, and shows nothing of Nitpick through
   itself. Its edge is a thin bright rim, never a border. A window adds a
   strong black shadow and a faint sheen that follows the pointer. */
:root{
  --r-win:28px;                                  /* a window's corners */
  --glass-blur:10px;                             /* the whole pane */
  --glass-frost:30px;                            /* a popover's frost */
  --glass-sat:1.6; --glass-bright:1.04; --glass-contrast:1.04;
  /* page-only: the download page's window still frosts the top, graded away downward */
  --glass-mask-1:linear-gradient(to bottom,#000 0%,#000 38%,transparent 84%);
  --glass-mask-2:linear-gradient(to bottom,#000 0%,transparent 44%);
  --glass-body:linear-gradient(180deg,#111720,#0a0e14);   /* every surface: solid */
  --glass-window:rgba(10,14,20,.80);             /* the page over the desktop's blur: a hint of what is behind */
  /* the rim: a thin band of light inside the edge, brightest where the light catches it */
  --glass-rim-w:4px;
  --rimin:0px;                                   /* the rim's width inside a watch's border, where a look has a rim */
  --glass-rim:linear-gradient(155deg,rgba(255,255,255,.26),rgba(255,255,255,.07) 24%,rgba(255,255,255,.02) 52%,rgba(255,255,255,.06) 80%,rgba(255,255,255,.18));
  --glass-rim-line:rgba(255,255,255,.12);        /* its outer hairline */
  --glass-tint-top:rgba(10,14,20,.62);
  --glass-tint-bottom:rgba(10,14,20,.40);
  --glass-plate:rgba(5,8,13,.30);                /* behind the lower text */
  --glass-plate-h:58%;
  --glass-sheen:rgba(255,255,255,.015);
  --glass-edge-top:rgba(255,255,255,.14);        /* light along the top edge */
  --glass-bounce:rgba(255,255,255,.10);          /* light bounced along the bottom edge */
  --glass-ring:rgba(255,255,255,.07);
  --glass-grain:.40;
  /* contact and ambient: a strong black shadow under anything open */
  --glass-shadow:0 2px 12px rgba(0,0,0,.7),0 28px 80px rgba(0,0,0,.8);
  /* the watches and the sidebar on the board: a little raised off what is behind them */
  --glass-raise:0 1px 3px rgba(0,0,0,.45),0 8px 24px rgba(0,0,0,.35);
}

/* A faint grain laid over a shallow gradient, so a dark one never shows its
   8-bit steps as lines. Monochrome noise at 4%: felt, not seen. */
:root{
  --grain:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='128' height='128'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .045 0'/%3E%3C/filter%3E%3Crect width='128' height='128' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============ selection ============ */

::selection{ background:var(--ctl); color:var(--txt) }

/* ============ nit ============ */
/* The interface has no shadows. This one is Nit's: robot.js reads it through
   rTheme() and paints it on his canvas, so he sits on a surface. */

:root,[data-theme="dark"]{
  --shadow:rgba(0,0,0,.9);
}

