/*
  Legend kit · tokens
  The only place a raw value may live. Every part in parts.css, and so every screen in Legend,
  is built from these names. The Kit page reads this file to show itself, so a comment here
  is what the Kit page says about the token.
  Format: one token per line, "--name: value; /* what it is for *\/". "@group Name" starts a group.
*/
:root {
  /* @group Type */
  --font: var(--font-system); /* the face Legend reads in (Settings › Appearance › Font) */
  --font-system: -apple-system, system-ui, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif; /* the system face, like every Apple app */
  --font-rounded: ui-rounded, 'SF Pro Rounded', -apple-system, system-ui, sans-serif; /* the system face, rounded */
  --font-serif: ui-serif, 'New York', 'Iowan Old Style', Georgia, serif; /* a reading serif, built into the Mac */
  --font-mono: var(--mono); /* every word monospaced, for those who think in code */
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; /* code and the text views */
  --type-caption: 12px; /* small print: badges, date pills, paths above notes, the smallest labels */
  --type-callout: 13px; /* every control and its words: menus, buttons, the sidebar, hints, section names, shortcuts */
  --type-body: 15px; /* reading text: notes, chat messages, search results (Settings › Text size changes it) */
  --type-headline: calc(var(--type-body) * 1.2); /* a top-level heading line */
  --type-title: calc(var(--type-body) * 2.25); /* a zoomed-in note's title */
  --weight-regular: 400; /* reading */
  --weight-strong: 600; /* headings, chosen things, the brand */
  --weight-title: 700; /* the big title only */
  --leading: 1.5; /* notes: 15px type on a 22.5px line */
  --leading-ui: 1.4; /* short UI text */
  --leading-title: 1.3; /* the big title */
  --tracking-title: -0.02em; /* big type sits a little tighter */
  --tracking-head: -0.01em; /* headings and the brand */

  /* @group Space */
  --s0: 2px; /* hairline gaps inside a control */
  --s1: 4px; /* between parts of one control */
  --s2: 8px; /* inside a control's edge */
  --s3: 12px; /* between controls */
  --s4: 16px; /* small groups */
  --s5: 24px; /* sections, sheet edges */
  --s6: 32px; /* under a big title */
  --s7: 48px; /* page-level breaks */

  /* @group Size */
  --hair: 1px; /* lines between areas */
  --head-h: 48px; /* pane header and the sidebar's top row */
  --ctl-h: 32px; /* every control: sidebar items, buttons, fields, tools */
  --ctl-sm: 26px; /* chips, segments, swatches, small buttons */
  --ctl-xs: 20px; /* key caps, filter chips */
  --menu-h: 28px; /* one menu line, like Legend App */
  --side-words-x: calc(var(--s2) + var(--icon) + var(--s2)); /* where the sidebar's words start: hints and the status line up with them */
  --side-step: calc(var(--icon) + var(--s2)); /* one folder deeper in the sidebar: a line's icon sits under its folder's words */
  --icon: 16px; /* icons in menus and buttons */
  --icon-sm: 14px; /* icons in the sidebar, fields and Add item */
  --icon-xs: 12px; /* icons inside small things */
  --tool-inset: calc((var(--ctl-h) - var(--icon)) / 2); /* from a tool's edge to its icon: a tool that starts a line pulls back by this, so its icon, not its hit area, meets the edge */
  --dot: 7px; /* a bullet's dot */
  --dot-sm: 5px; /* the sidebar's place dot and status dots */
  --box: 16px; /* a task's checkbox */
  --switch-w: 28px; /* an on/off switch */
  --switch-h: 16px;
  --nudge: 3px; /* how far a menu drifts in as it opens */
  --drag-start: 4px; /* how far you move before a press becomes a drag */
  --nest-x: 36px; /* how far right of a note's words a drop nests under it */
  --scroll-edge: 48px; /* near a pane's top or bottom, dragging scrolls it */
  --preload: 600px; /* how far ahead a long list loads more notes */
  --ctl-in: 24px; /* a button inside a field */
  --stroke: 1.5px; /* an empty checkbox's line */
  --underline: 2px; /* gap under a hovered link */
  --dot-xs: 4px; /* the thinking dots */
  --compose-max: 180px; /* tallest the chat box grows */
  --code-max: 320px; /* tallest a code block grows before it scrolls */

  /* @group Outline */
  --row-pad: var(--row-pad-neutral); /* above and below each note (Settings › Appearance › Density) */
  --row-pad-compact: 2px; /* Compact: more notes on screen */
  --row-pad-neutral: 5px; /* Neutral: Legend App's 32.5px row */
  --row-pad-breathe: 8px; /* Breathe: more air between notes */
  --indent: 30px; /* one level deeper */
  --fold-w: 30px; /* the fold arrow's column, left of the dot */
  --mark-w: 20px; /* the dot, box or number */
  --mark-gap: 8px; /* from the mark to the words */
  --edge-x: calc(var(--fold-w) + (var(--mark-w) - var(--box)) / 2); /* the page's left edge: where the notes' marks begin (32px); titles, paths and headers start here */
  --first-line: calc(var(--type-body) * var(--leading)); /* a note's first line: its arrow, mark and details all centre on it */
  --first-line-head: calc(var(--type-headline) * var(--leading)); /* the first line of a top heading */
  --head-room: var(--s2); /* extra room above a top heading, inside its row */
  --keep-clear: var(--s7); /* the note you're on never sits flush against the top or bottom of the pane */
  --tail: 40vh; /* room under the last note, so the end never sits at the bottom edge */

  /* @group Width */
  --w-side: 216px; /* the sidebar, until you drag its edge */
  --w-side-min: 160px;
  --w-side-max: 360px;
  --w-chat: 380px; /* the chat, until you drag its edge */
  --w-chat-min: 300px;
  --w-chat-max: 720px;
  --w-pane-min: 260px; /* the narrowest a pane gets */
  --w-filter: 240px; /* the filter field */
  --w-menu-min: 220px; /* the narrowest menu */
  --w-menu: 280px; /* a note's menu, Legend App's width */
  --w-menu-max: 320px; /* the widest plain menu */
  --w-menu-wide: 340px; /* menus with two columns */
  --w-panel: 280px; /* the links list and the drag label */
  --w-setting: 300px; /* a choice in Settings */
  --w-sheet: 640px; /* search, commands, import */
  --w-window: 880px; /* the Settings window */
  --w-win-nav: 200px; /* the Settings window's list of pages */
  --w-theme-card: 150px; /* a theme you can pick */
  --h-theme-card: 64px; /* the picture of a theme */
  --w-chat-narrow: 320px; /* the chat on a smaller screen */
  --w-lede: 560px; /* the longest a reading line gets on the Kit page */
  --w-swatch: 44px; /* one priority colour */
  --sheet-top: 12vh; /* how far down a sheet opens */
  --sheet-max: 72vh; /* tallest a sheet gets */
  --h-window: 82vh; /* the Settings window's height */

  /* @group Corner */
  --r-xs: 3px; /* highlights and links inside words */
  --r-sm: 4px; /* key caps, small things inside a control */
  --r: 6px; /* every control */
  --r-lg: 10px; /* menus and drop zones */
  --r-xl: 14px; /* sheets and chat bubbles */
  --r-full: 999px; /* pills, badges, dots, switches */

  /* @group Motion */
  --ease: cubic-bezier(.2, .8, .2, 1); /* everything moves on this curve */
  --quick: 100ms; /* a fill under the pointer */
  --swift: 150ms; /* a control changing state */
  --calm: 180ms; /* a title or a line fading in */
  --blink: 1.2s; /* the thinking dots */

  /* @group Timing */
  --save-typing: 500ms; /* a note saves this long after you stop typing */
  --save-notes: 700ms; /* notes are written to this browser this long after a change */
  --save-view: 300ms; /* panes, widths and choices are remembered this long after a change */
  --filter-wait: 160ms; /* a pane filters this long after you stop typing */
  --status-clears: 6000ms; /* the sidebar's status line clears itself after this */
  --helper-wait: 4000ms; /* how long to wait for the Mac helper before saying it isn't there */
  --pair-check: 800ms; /* how often to look whether the helper's connect window has closed */
  --link-life: 2000ms; /* a download link is kept this long, then freed */

  /* @group Amount */
  --notes-per-load: 300; /* a long list shows this many notes, then the next batch as you scroll */
  --link-choices: 6; /* notes offered after [[ */

  /* @group Layer */
  --z-head: 2; /* pane header over its notes */
  --z-edge: 5; /* column edges */
  --z-float: 30; /* chat over everything on a phone */
  --z-scrim: 40; /* behind a sheet */
  --z-menu: 50; /* menus */
  --z-drop: 59; /* the drop line */
  --z-drag: 60; /* the note you're dragging */

  /* @group Choices (what Settings › Appearance offers, so its choices have one home too) */
  --choices-body: 13 14 15 16 17 18; /* sizes for notes, in points */
  --choices-callout: 12 13 14; /* sizes for menus, buttons, the sidebar, hints and shortcuts */
  --choices-caption: 11 12 13; /* sizes for small print: badges, date pills, paths */
  --choices-headline: 1.1 1.2 1.35; /* a heading's size, times the notes' */
  --choices-title: 1.8 2.25 2.6; /* a title's size, times the notes' */
  --choices-weight: 400 500 600 700; /* Regular, Medium, Semibold, Bold */

  /* @group Looks (each theme's four picks; every other colour is worked out from them, kit/patterns/theme.ts) */
  --look-legend-light-background: #ffffff; /* Legend, light */
  --look-legend-light-sidebar: #f7f7f8;
  --look-legend-light-text: #1d1d1f;
  --look-legend-light-accent: #2f7cf6;
  --look-legend-dark-background: #19191b; /* Legend, dark */
  --look-legend-dark-sidebar: #131315;
  --look-legend-dark-text: #e9e9eb;
  --look-legend-dark-accent: #2f7cf6;
  --look-paper-light-background: #fbf9f5; /* Paper: warm white, a reading serif */
  --look-paper-light-sidebar: #f2eee6;
  --look-paper-light-text: #1c1915;
  --look-paper-light-accent: #b25f2a;
  --look-sepia-light-background: #f6efde; /* Sepia: cream and brown, easy on the eyes at night */
  --look-sepia-light-sidebar: #ebe0c6;
  --look-sepia-light-text: #24190e;
  --look-sepia-light-accent: #8b5e34;
  --look-graphite-dark-background: #1c1c1e; /* Graphite: neutral grey, no colour at all */
  --look-graphite-dark-sidebar: #161618;
  --look-graphite-dark-text: #e6e6e8;
  --look-graphite-dark-accent: #8e8e93;
  --look-midnight-dark-background: #0f1420; /* Midnight: deep blue-black */
  --look-midnight-dark-sidebar: #0b0f19;
  --look-midnight-dark-text: #dde5f2;
  --look-midnight-dark-accent: #5b8cff;
  --look-contrast-light-background: #ffffff; /* High contrast, light */
  --look-contrast-light-sidebar: #efefef;
  --look-contrast-light-text: #000000;
  --look-contrast-light-accent: #0040dd;
  --look-contrast-dark-background: #000000; /* High contrast, dark */
  --look-contrast-dark-sidebar: #0d0d0d;
  --look-contrast-dark-text: #ffffff;
  --look-contrast-dark-accent: #4aa3ff;

  /* @group Color */
  --blue: #2f7cf6; /* chosen, selected, the cursor, links in chat */
  --on-blue: #ffffff; /* words on blue */
  --blue-strong: #2b72e2; /* the accent as a fill under words: just dark enough that white words read at 4.5:1 (a look works it out, kit/patterns/theme.ts › strongFill) */
  --red: #e5484d; /* priority high, late, errors */
  --on-red: #ffffff;
  --orange: #f5a524; /* priority medium */
  --yellow: #f5d90a; /* priority low, stars */
  --on-yellow: #1d1d1f; /* words on orange or yellow */
  --green: #30a46c; /* done */
  --on-green: #ffffff;
  --marker: #e4ff3a; /* search highlight */
  --on-marker: #141414;
  --knob: #ffffff; /* a switch's knob */
  --scrim: rgba(0, 0, 0, .32); /* the dim behind a sheet */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .18); /* a chosen segment */
  --knob-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}

[data-theme='dark'] {
  color-scheme: dark;
  /* The only raw colours in a theme: two short scales and the words. Everything else names a step. */
  --surface-1: #131315; /* surfaces, darkest first: the sidebar */
  --surface-2: #19191b; /* the page */
  --surface-3: #232326; /* menus, sheets, fields */
  --surface-4: #2a2a2e; /* a field you're typing in */
  --surface-5: #3a3a3f; /* raised: a chosen segment, a folded note's ring */
  --fill-1: rgba(255, 255, 255, .045); /* fills over any surface, faintest first: hover */
  --fill-2: rgba(255, 255, 255, .07); /* at rest: chips, pills, code, lines */
  --fill-3: rgba(255, 255, 255, .09); /* pressed and chosen */
  --fill-4: rgba(255, 255, 255, .16); /* a scrollbar */
  --fill-5: rgba(255, 255, 255, .26); /* dots and empty boxes */
  --ink: #e9e9eb; /* words */
  --muted: #9b9ba1; /* quieter words */
  --faint: #6c6c72; /* hints */
  --link: #78aefc; /* links in notes */
  --bg: var(--surface-2); /* the page */
  --side: var(--surface-1); /* the sidebar */
  --menu: var(--surface-3); /* menus and sheets */
  --field: var(--surface-3); /* a field at rest */
  --field-on: var(--surface-4); /* a field you're typing in */
  --seg-on: var(--surface-5); /* the chosen segment */
  --hover: var(--fill-1); /* under the pointer */
  --chip: var(--fill-2); /* a control's fill */
  --pill: var(--fill-2); /* a date pill */
  --code: var(--fill-2); /* code */
  --line: var(--fill-2); /* hairlines */
  --press: var(--fill-3); /* pressed, chosen, keyboard focus */
  --scroll-thumb: var(--fill-4); /* a scrollbar */
  --ghost: var(--fill-5); /* dots, empty boxes */
  --sel: color-mix(in srgb, var(--blue) 26%, var(--bg)); /* selected notes */
  --sel-text: color-mix(in srgb, var(--blue) 40%, transparent); /* selected words */
  --drop: color-mix(in srgb, var(--blue) 22%, var(--menu)); /* a drop zone you're over */
  --shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 8px 28px rgba(0, 0, 0, .45); /* menus and sheets */
}

[data-theme='light'] {
  color-scheme: light;
  --surface-1: #ffffff;
  --surface-2: #f7f7f8;
  --surface-3: #f1f1f3;
  --surface-4: #e9e9ec;
  --surface-5: #dcdce0;
  --fill-1: rgba(0, 0, 0, .035);
  --fill-2: rgba(0, 0, 0, .055);
  --fill-3: rgba(0, 0, 0, .08);
  --fill-4: rgba(0, 0, 0, .2);
  --fill-5: rgba(0, 0, 0, .28);
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --faint: #a1a1a6;
  --link: #1f6feb;
  --bg: var(--surface-1);
  --side: var(--surface-2);
  --menu: var(--surface-1);
  --field: var(--surface-3);
  --field-on: var(--surface-4);
  --seg-on: var(--surface-1);
  --hover: var(--fill-1);
  --chip: var(--fill-2);
  --pill: var(--fill-2);
  --code: var(--fill-2);
  --line: var(--fill-3);
  --press: var(--fill-3);
  --scroll-thumb: var(--fill-4);
  --ghost: var(--fill-5);
  --sel: color-mix(in srgb, var(--blue) 18%, var(--bg));
  --sel-text: color-mix(in srgb, var(--blue) 26%, transparent);
  --drop: color-mix(in srgb, var(--blue) 22%, var(--menu));
  --shadow: 0 0 0 1px rgba(0, 0, 0, .06), 0 8px 28px rgba(0, 0, 0, .12);
}


