/* Design tokens: the one place every colour, font, size, corner, space and shadow is defined.
   Loaded first on every page. Other stylesheets only use these (var(--name)); they never define them.

   Layers:
   1. Palette: raw colours that are the same in light and dark mode. Use these only when a colour must
      not change with the theme (the hero card, artwork on the landing page).
   2. Theme: what each colour is for (page, card, text, brand, "behind", errors), light then dark.
   3. Scales: type, corners and spacing. Pick the nearest step; don't invent new values.
   4. Components: the look of every button, card and pill row. Change a value here and every one of them
      on every page follows (buttons and cards are styled in css/components.css; each list's rows read
      the --row-* values where the list is styled).

   Brand rules: navy and periwinkle, no green. Orange only ever means "behind". */

/* ---------- 1. Palette ---------- */
:root {
  /* Brand scale, darkest to lightest. 600 is the main brand colour. */
  --brand-1000: #0C0D20;  /* hero card gradient, bottom */
  --brand-950: #12132A;
  --brand-900: #16182B;
  --brand-850: #1B1E56;
  --brand-800: #1C1F5A;
  --brand-700: #262A72;
  --brand-750: #20236A;   /* hero card gradient, top */
  --brand-650: #2B2F7A;
  --brand-600: #2A2E7F;   /* main brand colour */
  --brand-550: #3A3FA0;
  --brand-500: #3B409A;
  --brand-450: #4C52C9;
  --brand-400: #6A6FD0;
  --brand-300: #8C92EE;
  --brand-200: #A3A8F4;   /* brand colour in dark mode */
  --brand-150: #C9CCF8;   /* periwinkle */
  --brand-120: #DADCFB;
  --brand-100: #D6D8FB;
  --brand-75:  #E2E3F4;
  --brand-dark-soft: #242851;
  --on-brand: #F4F5FA;    /* text on navy */

  /* Greys */
  --grey-50: #FCFCFD;
  --grey-100: #F1F2F4;
  --grey-200: #E7E8EE;
  --grey-300: #D9DBE3;
  --grey-500: #7E8194;
  --grey-600: #62657B;
  --grey-700: #474A60;

  /* Orange: only for "behind" */
  --orange-500: #E8590C;
  --orange-700: #A3400A;
  --orange-100: #FCE6D8;
  --orange-200: #FFB089;  /* "behind" figures on the navy card */
  --orange-300: #F7BB78;  /* landing artwork */
  --orange-900: #2B1A10;

  /* Amber: only for "check this" warnings */
  --amber-500: #F2B33D;
  --amber-700: #B7791F;
  --violet-700: #4A3B8F;  /* landing glow */

  /* Surfaces that stay dark in both themes (sidebar, footer) */
  --night-bg: #0E0F1C;
  --night-text: #D6D8EA;
  --night-muted: #C9CBDC;
  --night-subtle: #8E91A8;
  --night-link: #9A9DB8;
  --night-faint: #6E7190;
  --night-line: #262845;
  --night-ring: #2A2D45;
  --night-dock: #23253C;

  /* Landing page tints */
  --tint-a-from: #EEEFFA; --tint-a-to: #DFE1F5;
  --tint-b-from: #EAF0F8; --tint-b-to: #DCE4F3;
  --tint-c-from: #F6F6FB; --tint-c-to: #E3E5F7;
  --tint-a-dark-from: #1B1E36; --tint-a-dark-to: #22264A;
  --tint-b-dark-from: #181C31; --tint-b-dark-to: #1F2442;
  --tint-c-dark-from: #171A2E; --tint-c-dark-to: #23274C;

  /* Fonts (also update the Google Fonts link in each page) */
  --font-display: "Bricolage Grotesque", "Geist", system-ui, sans-serif;
  --font-body: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, Menlo, monospace;

  /* ---------- 3. Scales ---------- */
  /* Type: nine steps. Nothing smaller than 12px except the tiny screens drawn on the landing and sign-in pages. */
  --text-12: .75rem;
  --text-13: .8125rem;
  --text-14: .875rem;
  --text-16: 1rem;
  --text-18: 1.125rem;
  --text-22: 1.375rem;
  --text-28: 1.75rem;
  --text-40: 2.5rem;
  --text-52: 3.25rem;

  /* Corners: pills and circles are fully round; then cards, fields, small parts, and tiny marks (grid squares). */
  --r-pill: 999px;
  --r-card: 22px;
  --r-control: 14px;
  --r-sm: 8px;
  --r-xs: 4px;
  --r-media: 28px;   /* photo and phone frames on the landing page */

  /* Spacing: a 4px grid */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;

  /* Motion and layout */
  --ease: cubic-bezier(.16, 1, .3, 1);
  --spring: cubic-bezier(.32, .72, 0, 1);
  --page-max: 1760px;
  --page-gutter: clamp(24px, 4vw, 80px);
}

/* ---------- 2. Theme: light ---------- */
:root {
  color-scheme: light;
  --bg: var(--grey-100);           /* the page */
  --surface: var(--grey-50);       /* cards, sheets, pill rows */
  --surface-2: var(--grey-200);
  --ink: var(--brand-900);         /* main text */
  --ink-2: var(--grey-700);
  --ink-3: var(--grey-600);        /* quiet text: 5.1:1 on the page */
  --line: var(--grey-300);
  --brand: var(--brand-600);       /* buttons, links, money in, active states */
  --brand-ink: #FFFFFF;            /* text on --brand */
  --brand-soft: var(--brand-75);
  --navy: var(--brand-950);        /* the hero card */
  --hero-bg: var(--brand-600);
  --hero-ink: var(--on-brand);
  --tint: var(--brand-150);        /* highlight on navy */
  --tint-ink: var(--brand-950);
  --badge: var(--brand-600);       /* initials, ticks, menu icons */
  --late: var(--orange-500);       /* "behind": squares, icons, big figures */
  --late-ink: var(--orange-700);   /* "behind" text */
  --late-soft: var(--orange-100);
  --neg: #B42318;                  /* errors */
  --neg-soft: #F6E1DF;
  --sq-empty: var(--grey-200);
  --sq-line: var(--grey-500);
  --theme-bar: var(--grey-100);
  --faded: color-mix(in srgb, var(--ink-3) 78%, transparent);
  --tint-a: linear-gradient(165deg, var(--tint-a-from) 0%, var(--tint-a-to) 100%);
  --tint-b: linear-gradient(165deg, var(--tint-b-from) 0%, var(--tint-b-to) 100%);
  --tint-c: linear-gradient(100deg, var(--tint-c-from) 0%, var(--tint-c-to) 100%);

  /* Shadows */
  --pill-shadow: 0 1px 0 rgb(18 19 42 / .03), 0 6px 18px -12px rgb(42 46 127 / .35);
  --lift: 0 1px 0 rgb(14 15 28 / .04), 0 18px 40px -24px rgb(27 30 86 / .35);
  --shadow: 0 1px 1px rgb(22 24 43 / .03), 0 24px 48px -28px rgb(42 46 127 / .22);
  --shadow-lift: 0 2px 4px rgb(22 24 43 / .04), 0 32px 64px -32px rgb(42 46 127 / .32);
  --hairline: color-mix(in srgb, var(--ink) 9%, transparent);
  --highlight: inset 0 1px 0 rgb(255 255 255 / .7);
  /* Bezel: a card sitting in a slightly larger tray, like glass in a frame. Use with a shadow after it. */
  --bezel: 0 0 0 1px var(--hairline), 0 0 0 6px color-mix(in srgb, var(--brand-600) 5%, transparent), 0 0 0 7px color-mix(in srgb, var(--brand-900) 6%, transparent);
  /* Soft periwinkle glow under lifted, important things */
  --glow: 0 30px 60px -32px color-mix(in srgb, var(--brand-600) 45%, transparent), 0 0 48px -16px color-mix(in srgb, var(--brand-150) 70%, transparent);
}
/* The app (app.html, <html data-shell="app">) uses the flatter ledger shadows and plain hairlines in light mode */
:root[data-shell="app"] {
  --shadow: var(--lift);
  --shadow-lift: 0 0 0 1px var(--line), 0 24px 48px -20px rgb(14 15 28 / .45);
  --hairline: var(--line);
}

/* ---------- 2. Theme: dark ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--night-bg);
  --surface: #16182A;
  --surface-2: #20233A;
  --ink: #ECEDF4;
  --ink-2: #B4B6C9;
  --ink-3: #9295AB;
  --line: var(--night-ring);
  --brand: var(--brand-200);
  --brand-ink: var(--night-bg);
  --brand-soft: var(--brand-dark-soft);
  --navy: var(--brand-850);
  --hero-bg: var(--brand-650);
  --hero-ink: #ECEDF4;
  --badge: var(--brand-650);
  --late: #FF8A4C;
  --late-ink: #FF8A4C;
  --late-soft: #3A2218;
  --neg: #FF8A7A;
  --neg-soft: #3A1D22;
  --sq-empty: #24263D;
  --sq-line: #6A6C8C;
  --theme-bar: var(--night-bg);
  --faded: color-mix(in srgb, var(--ink-3) 66%, transparent);
  --tint-a: linear-gradient(165deg, var(--tint-a-dark-from) 0%, var(--tint-a-dark-to) 100%);
  --tint-b: linear-gradient(165deg, var(--tint-b-dark-from) 0%, var(--tint-b-dark-to) 100%);
  --tint-c: linear-gradient(100deg, var(--tint-c-dark-from) 0%, var(--tint-c-dark-to) 100%);

  --pill-shadow: 0 0 0 1px var(--line);
  --lift: 0 18px 40px -24px rgb(0 0 0 / .9);
  --shadow: 0 1px 1px rgb(0 0 0 / .3), 0 24px 48px -28px rgb(0 0 0 / .7);
  --shadow-lift: 0 2px 4px rgb(0 0 0 / .3), 0 32px 64px -32px rgb(0 0 0 / .8);
  --hairline: rgb(255 255 255 / .09);
  --highlight: inset 0 1px 0 rgb(255 255 255 / .06);
  --bezel: 0 0 0 1px rgb(255 255 255 / .08), 0 0 0 6px rgb(255 255 255 / .03), 0 0 0 7px rgb(255 255 255 / .06);
  --glow: 0 30px 60px -32px rgb(0 0 0 / .8), 0 0 48px -16px color-mix(in srgb, var(--brand-200) 25%, transparent);

  --btn-primary-hover: color-mix(in srgb, var(--brand) 85%, #fff);
}

/* ---------- 4. Components ---------- */
:root {
  /* Buttons (.btn with .btn-primary / .btn-secondary / .btn-ghost / .btn-danger, plus .btn-sm and .btn-block) */
  --btn-radius: var(--r-pill);
  --btn-height: 48px;
  --btn-height-sm: 44px;
  --btn-pad: 20px;                 /* space left and right of the label */
  --btn-pad-sm: 16px;
  --btn-size: var(--text-16);
  --btn-size-sm: var(--text-14);
  --btn-weight: 560;
  --btn-press: .98;                /* how far a button shrinks while pressed */
  --btn-primary-bg: var(--brand);
  --btn-primary-ink: var(--brand-ink);
  --btn-primary-hover: color-mix(in srgb, var(--brand) 88%, #000);
  --btn-primary-shine: inset 0 1px 0 rgb(255 255 255 / .14);
  --btn-go-bg: color-mix(in srgb, currentColor 16%, transparent);  /* circle behind a button's arrow: a tint of its label colour, so it shows on light and dark buttons */
  --btn-secondary-bg: var(--surface);
  --btn-secondary-ink: var(--ink);
  --btn-secondary-ring: 1px var(--hairline);       /* outline: thickness and colour */
  --btn-secondary-ring-hover: 1px color-mix(in srgb, var(--ink) 22%, transparent);

  /* Compact pill buttons in the app and member pages (.btn-ink filled, .btn-line outlined) */
  --btn-compact-height: 38px;
  --btn-compact-pad: 16px;
  --btn-compact-size: var(--text-14);
  --btn-compact-weight: 700;
  --btn-compact-press: .97;
  --btn-line-ring: 2px var(--ink);

  /* Cards (.card, and the app's own cards: settings, tiles, statement, group page) */
  --card-bg: var(--surface);
  --card-radius: var(--r-card);
  --card-shadow: var(--pill-shadow);
  /* Featured cards sit in a soft tray (.card-featured, the Summary's to-do and round cards) */
  --card-featured-shadow: var(--bezel), var(--lift);

  /* Space between cards, tiles and pill rows stacked in a list, everywhere in the app and member pages */
  --stack-gap: 12px;
  /* Space between number tiles that sit side by side (Summary tiles, statement and group page boxes) */
  --tile-gap: 16px;
  /* Featured cards sit in a 7px tray on each side, so they need that much more room to show the same gap */
  --stack-gap-featured: calc(var(--stack-gap) + 16px);
  /* Space between sections on the landing page (smaller on phones) */
  --section-gap: clamp(56px, 6vw, 80px);

  /* Pill rows: the members, activity, reminder and settings lists, and the rows on the statement and
     group pages. Their spacing stays with each list; these set the look. */
  --row-bg: var(--surface);
  --row-radius: var(--r-pill);
  --row-shadow: var(--pill-shadow);
  --row-hover-bg: var(--brand-soft);   /* while hovered or pressed */
}
/* The app and the member pages use bolder labels (app only) and a thicker outline on secondary buttons */
:root[data-shell="app"] { --btn-weight: 700; }
:root[data-shell="app"], :root[data-shell="pages"] {
  --btn-secondary-bg: transparent;
  --btn-secondary-ring: 2px var(--line);
  --btn-secondary-ring-hover: 2px var(--ink);
}
:root[data-shell="pages"] { --btn-compact-height: 50px; --btn-compact-pad: 20px; }
