/* Folio's design tokens: the one place for colours, type, spacing, radii and the font (#14, direction A).
   The server pages link this file before pages.css; the web UI links the same file from index.html (/css/tokens.css).
   Names say what a token is for, not what colour it is, so a dark mode can later swap the values without touching
   components. docs/dev/ui.md explains when to use which. A test checks the contrast of the text pairs. */

/* Inter 4.1 (variable, SIL Open Font License 1.1: ../fonts/OFL.txt), served by Folio itself. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/InterVariable.woff2") format("woff2");
}

/* The italic of the same release (#36: pages use italics). Not preloaded: the browser fetches it only when italic
   text shows. */
@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/InterVariable-Italic.woff2") format("woff2");
}

:root {
  color-scheme: light;

  /* Grounds and surfaces */
  --bg: #F7F6F3;              /* page ground, sidebar */
  --surface: #FFFFFF;         /* content panel, cards, lists, inputs */
  --surface-hover: #FAF9F6;   /* row hover, table header */
  --fill-hover: #EFEDE7;      /* nav and icon button hover, neutral pill */
  --fill-selected: #EAE7E0;   /* selected nav item, space key badge */

  /* Lines */
  --line: #E6E3DC;            /* borders of panels, cards, lists, menus (decorative) */
  --line-soft: #EFEDE7;       /* row dividers */
  --line-strong: #8A857B;     /* input borders: at least 3:1 on surface and bg */

  /* Text */
  --ink: #1B1A17;             /* text, selected filter chip */
  --ink-2: #4A4741;           /* secondary text on fills */
  --muted: #66635C;           /* meta text, labels */
  --faint: #A8A399;           /* empty check circles, unassigned avatar; never text */
  --on-accent: #FFFFFF;       /* text and icons on --accent */

  /* Accent: brick red, never a status */
  --accent: #CC3D0C;          /* primary button, selected tab underline, logo, selected space key, focus ring */
  --accent-strong: #B33608;   /* accent hover; accent-coloured text on white (overdue dates, link hover) */
  --accent-soft: #FDE9E1;     /* agent label chip */
  --accent-ink: #8A2C06;      /* text on --accent-soft, links */

  /* Status: always together with its word */
  --status-todo-bg: #EFEDE7;
  --status-todo-fg: #4A4741;
  --status-doing-bg: #E6EEFE;
  --status-doing-fg: #1D4BAF;
  --status-waiting-bg: #FDF1D3;
  --status-waiting-fg: #7A4E00;
  --status-done-bg: #E3F1E7;
  --status-done-fg: #1C6B3A;  /* also the filled check */

  /* Errors and destructive actions */
  --danger: #B3261E;
  --danger-soft: #FCE8E6;

  /* Avatars: white initials on each, picked from the user id */
  --avatar-1: #9A3412;
  --avatar-2: #7A4E00;
  --avatar-3: #9D174D;
  --avatar-4: #6B21A8;
  --avatar-5: #3F4F8C;
  --avatar-6: #1D4BAF;
  --avatar-7: #0F5E6E;
  --avatar-8: #5C4033;

  /* Type. Every text size is its standard size times --text-scale, which the web UI sets from the user's text size
     (#142, the rules at the end of this file). The server pages and print always use 1. */
  --font-sans: "Inter", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --text-scale: 1;
  --text-label: max(11px, calc(11.5px * var(--text-scale)));  /* uppercase, 0.04em tracking, 600; never below 11px */
  --text-meta: calc(12px * var(--text-scale));          /* meta and pills: 400–600 */
  --text-ui: calc(13.5px * var(--text-scale));          /* UI text, nav, buttons: 400–600 */
  --text-body: calc(14px * var(--text-scale));          /* body text in the UI */
  --leading-body: 1.5;
  --text-page: calc(15px * var(--text-scale));          /* page body text (Markdown pages) */
  --leading-page: 1.65;
  --text-section: calc(15px * var(--text-scale));       /* section heading in lists */
  --text-section-page: calc(19.5px * var(--text-scale)); /* section heading in pages */
  --text-heading-1: calc(24px * var(--text-scale));     /* Markdown heading 1 */
  --text-heading-2: calc(19.5px * var(--text-scale));   /* Markdown heading 2 */
  --text-heading-3: calc(17px * var(--text-scale));     /* Markdown heading 3: a step above page text */
  --text-title-input: calc(20.5px * var(--text-scale)); /* a task's title while it is edited */
  --text-screen-title: calc(26px * var(--text-scale));
  --text-screen-title-small: calc(22.5px * var(--text-scale)); /* the screen title below 480px */
  --leading-screen-title: 1.25;
  --tracking-screen-title: -0.015em;
  --text-page-title: calc(32px * var(--text-scale));
  --text-page-title-small: calc(26px * var(--text-scale)); /* the page title below 720px */
  --leading-page-title: 1.2;
  --tracking-page-title: -0.02em;
  --tracking-label: 0.04em;
  --weight-heading: 650;

  /* Spacing: a 4px base */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 56px;

  /* Radii */
  --radius-key: 6px;          /* keys, kbd */
  --radius-control: 10px;     /* buttons, inputs, nav items, menu items */
  --radius-card: 14px;        /* lists, cards, panels, menus */
  --radius-panel: 16px;       /* the main content panel */
  --radius-pill: 999px;       /* pills, chips, avatars */

  /* Sizes */
  --control-height: 40px;
  --touch-target: 44px;       /* controls below 720px, inputs on the server pages */
  --row-min-height: 56px;

  /* Widths (#46): how wide a screen's content may be; running text keeps a reading width in it, left-aligned. */
  --content-width: 1280px;    /* lists, tables, the page tree, the task view: the most a screen's content grows to */
  --reading-width: 720px;     /* running text: about 70 characters */
  --form-width: 928px;        /* an app's settings form, which has no narrower width of its own */

  /* Only floating things (menus, popovers, the folded sidebar) have a shadow */
  --shadow-float: 0 6px 18px rgba(60, 30, 10, 0.18);
  --scrim: rgba(27, 26, 23, 0.32);  /* behind the folded sidebar on phones */

  /* Focus: on every interactive element */
  --focus-ring: 2px solid var(--accent);
  --focus-offset: 2px;

  --duration-fast: 120ms;
}

/* The user's text size (#142), from My account: the web UI sets data-text-size on <html> before it renders anything.
   Body text is 13, 14, 15 and 16px. Only on screens: print keeps the standard size, and the server pages never set it. */
@media screen {
  :root[data-text-size="small"] {
    --text-scale: calc(13 / 14);
  }

  :root[data-text-size="large"] {
    --text-scale: calc(15 / 14);
  }

  :root[data-text-size="larger"] {
    --text-scale: calc(16 / 14);
  }
}
