/* Slice 08 v2 — design tokens (Epic 525, Claire 2026-10-02).
   Structure, names, type roles, radius scale and the 112% product scale are TetherCX's
   (`tokens.css` export 2026-10-02). Values are Pocket Social's: PS Purple #935da6 is
   --primary; PS Blue #6d8bc2 is --accent and --ring (FACTS brand colors).
   This is the only stylesheet allowed to hold colour literals or declare font families
   besides css/base.css (Stylelint, scripts/test-stylelint.mjs).

   Contrast (WCAG 2.x, on #ffffff unless noted):
     --primary-foreground on --primary       4.82:1  AA
     --accent-foreground on --accent         5.23:1  AA  (white on PS Blue is 3.43:1, fails)
     --link on --card / --background         5.14:1 / 4.85:1  AA
     --secondary-foreground on --secondary   7.62:1
     --muted-foreground on --muted           4.73:1  AA
     --success-text / --warning-text on their 10% tint  4.54:1 / 4.57:1  AA */

@font-face {
  font-family: "Geist";
  src: url("../fonts/geist/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("../fonts/space-grotesk/SpaceGrotesk-Variable-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("../fonts/space-grotesk/SpaceGrotesk-Variable-latin-ext.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* §1 fonts — exactly two webfonts plus the system mono stack */
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-heading: "Space Grotesk", "Geist", ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --font-icon: "Font Awesome 6 Free";

  /* §3 type roles (Tether names). 1rem = 17.92px under html.product-type-scale. */
  --text-display-size: 1.875rem;
  --text-display-size-sm: 3rem;
  --text-display-line-height: 1.2;
  --text-display-line-height-sm: 1;
  --text-display-weight: 600;
  --text-display-tracking: -0.025em;
  --text-h1-size: 1.5rem;
  --text-h1-line-height: 1.333;
  --text-h1-weight: 600;
  --text-h1-tracking: -0.025em;
  --text-h2-size: 1.25rem;
  --text-h2-line-height: 1.4;
  --text-h2-weight: 600;
  --text-h2-tracking: -0.025em;
  --text-h3-size: 1.125rem;
  --text-h3-line-height: 1.556;
  --text-h3-weight: 600;
  --text-h3-tracking: -0.025em;
  --text-title-size: 1rem;
  --text-title-line-height: 1.375;
  --text-title-weight: 500;
  --text-title-tracking: 0;
  --text-body-size: 0.875rem;
  --text-body-line-height: 1.429;
  --text-body-weight: 400;
  --text-body-lg-size: 1rem;
  --text-body-lg-line-height: 1.5;
  --text-small-size: 0.75rem;
  --text-small-line-height: 1.333;
  --text-label-size: 0.875rem;
  --text-label-line-height: 1;
  --text-label-weight: 500;
  --text-mono-size: 0.75rem;
  --text-mono-line-height: 1.333;
  /* Pocket Social addition: the enlarged top bar (§7) */
  --text-nav-size: 1rem;
  --text-nav-weight: 600;
  --text-nav-tracking: 0.06em;
  --text-nav-transform: uppercase;

  /* §4 brand */
  --primary: #935da6;
  --primary-foreground: #ffffff;
  --primary-hover: color-mix(in srgb, var(--primary) 85%, #000000);
  --secondary: #f6f2f8;
  --secondary-foreground: #643f71;
  --accent: #6d8bc2;
  --accent-foreground: #17161f;

  /* §4 ink / neutral */
  --foreground: #17161f;
  --muted: #f1f0f6;
  --muted-foreground: #6b6880;
  --border: #e0deea;
  --input: #e0deea;
  --ring: #6d8bc2;

  /* §4 surface */
  --background: #f8f8fb;
  --card: #ffffff;
  --card-foreground: #17161f;
  --popover: #ffffff;
  --popover-foreground: #17161f;
  --sidebar: #f3f2f9;
  --sidebar-foreground: #2a2840;
  --sidebar-primary: var(--primary);
  --sidebar-primary-foreground: #ffffff;
  --sidebar-accent: #f0e8f3;
  --sidebar-accent-foreground: #643f71;
  --sidebar-border: #dad8e6;
  --sidebar-ring: var(--ring);

  /* §4 semantic — Tether hues. There is no info token; informational uses --primary. */
  --success: #459173;
  --warning: #dc932e;
  --destructive: #bd413f;
  --destructive-foreground: #ffffff;
  /* Text-strength shades of the semantic hues: --success / --warning are below 4.5:1 as
     small text on white, so words and counts use these. */
  --success-text: #3a7a61;
  --warning-text: #986520;
  --destructive-text: #bd413f;

  /* Links derive from --accent, darkened until small text passes AA on --card and --background. */
  --link: color-mix(in srgb, var(--accent) 79%, #000000);
  --link-hover: color-mix(in srgb, var(--accent) 65%, #000000);

  /* §4 charts */
  --chart-1: var(--primary);
  --chart-2: #3ea3d7;
  --chart-3: var(--success);
  --chart-4: var(--muted-foreground);
  --chart-5: var(--destructive);

  /* §5 shape, shadow, spacing */
  --radius: 0.5rem;
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-md: calc(var(--radius) * 0.8);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.4);
  --radius-2xl: calc(var(--radius) * 1.8);
  --radius-3xl: calc(var(--radius) * 2.2);
  --radius-4xl: calc(var(--radius) * 2.6);
  --spacing: 0.25rem;
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-header: 0 1px 2px 0 rgb(23 22 31 / 0.06);
  --overlay: rgb(23 22 31 / 0.4);
  /* Palette primitives for literal-free CSS: text/icons on solid fills and photos, and the shadow / mask base. Same in both modes. */
  --on-fill: #ffffff;
  --scrim: #000000;

  /* §7 component dimensions */
  --control-h-xs: 1.5rem;
  --control-h-sm: 1.75rem;
  --control-h: 2rem;
  --control-h-lg: 2.25rem;
  --sheet-max-w: 42rem;
  --topbar-pad-x: 1.25rem;
  --topbar-pad-y: 0.875rem;
  --topbar-logo-h: 2.25rem;
  --topbar-icon-btn: 2.75rem;
  --topbar-icon: 1.5rem;
  --icon-size: 1rem;
  --icon-size-badge: 0.75rem;

  /* Bootstrap 5.3 bridge so un-migrated Bootstrap markup reads the v2 values. */
  --bs-primary: var(--primary);
  --bs-primary-rgb: 147, 93, 166;
  --bs-body-font-family: var(--font-sans);
  --bs-body-font-size: var(--text-body-size);
  --bs-body-line-height: var(--text-body-line-height);
  --bs-body-color: var(--foreground);
  --bs-body-bg: var(--background);
  --bs-font-monospace: var(--font-mono);
  --bs-border-color: var(--border);
  --bs-secondary-color: var(--muted-foreground);
  --bs-link-color: var(--link);
  --bs-link-hover-color: var(--link-hover);
  --bs-code-color: var(--foreground);
  --bs-border-radius: var(--radius-lg);
  --bs-border-radius-sm: var(--radius-md);
  --bs-border-radius-lg: var(--radius-xl);
  --bs-focus-ring-color: color-mix(in srgb, var(--ring) 50%, transparent);

  /* Dropdowns: Bootstrap's default hover is a light gray that vanishes in light mode
     and goes white-on-white under color-scheme:dark. Resolve through our tokens. */
  --bs-tertiary-bg: var(--muted);
  --bs-dropdown-color: var(--popover-foreground);
  --bs-dropdown-bg: var(--popover);
  --bs-dropdown-border-color: var(--border);
  --bs-dropdown-link-color: var(--foreground);
  --bs-dropdown-link-hover-color: var(--foreground);
  --bs-dropdown-link-hover-bg: var(--muted);
  --bs-dropdown-link-active-color: var(--primary-foreground);
  --bs-dropdown-link-active-bg: var(--primary);
  --bs-dropdown-link-disabled-color: var(--muted-foreground);

  /* v1 --ps-* names (Slice 08 #5), aliased to v2 until the migration ends. */
  --ps-accent: var(--primary);
  --ps-accent-deep: var(--primary-hover);
  --ps-accent-tint: var(--secondary);
  --ps-ink: var(--foreground);
  --ps-ink-2: var(--sidebar-foreground);
  --ps-muted: var(--muted-foreground);
  --ps-muted-2: color-mix(in srgb, var(--muted-foreground) 65%, var(--card));
  --ps-border: var(--border);
  --ps-border-2: var(--muted);
  --ps-ground: var(--background);
  --ps-surface: var(--card);
  --ps-good: var(--success-text);
  --ps-good-bg: color-mix(in srgb, var(--success) 10%, var(--card));
  --ps-warn: var(--warning-text);
  --ps-warn-bg: color-mix(in srgb, var(--warning) 10%, var(--card));
  --ps-bad: var(--destructive-text);
  --ps-bad-bg: color-mix(in srgb, var(--destructive) 10%, var(--card));
  --ps-caution: var(--warning-text);
  --ps-caution-bg: color-mix(in srgb, var(--warning) 10%, var(--card));
  --ps-info: var(--primary);
  --ps-info-bg: var(--secondary);
  --ps-chart-declines: var(--chart-1);
  --ps-chart-recovered: var(--chart-3);
  --ps-chart-saved: var(--chart-2);
  --ps-chart-pending: var(--warning);
  --ps-chart-churned: var(--chart-5);

  --ps-font: var(--font-sans);
  --ps-fs-11: var(--text-small-size);
  --ps-fs-12: var(--text-small-size);
  --ps-fs-13: var(--text-body-size);
  --ps-fs-14: var(--text-body-size);
  --ps-fs-16: var(--text-body-lg-size);
  --ps-fs-18: var(--text-h3-size);
  --ps-fs-22: var(--text-h2-size);
  --ps-fs-24: var(--text-h1-size);
  --ps-fs-28: var(--text-display-size);
  --ps-fs-36: var(--text-display-size);

  --ps-s-2: calc(var(--spacing) * 0.5);
  --ps-s-4: var(--spacing);
  --ps-s-6: calc(var(--spacing) * 1.5);
  --ps-s-8: calc(var(--spacing) * 2);
  --ps-s-10: calc(var(--spacing) * 2.5);
  --ps-s-12: calc(var(--spacing) * 3);
  --ps-s-14: calc(var(--spacing) * 3.5);
  --ps-s-16: calc(var(--spacing) * 4);
  --ps-s-20: calc(var(--spacing) * 5);
  --ps-s-24: calc(var(--spacing) * 6);
  --ps-s-32: calc(var(--spacing) * 8);

  --ps-r-6: var(--radius-md);
  --ps-r-8: var(--radius-lg);
  --ps-r-12: var(--radius-xl);
  --ps-r-pill: 50%;

  --ps-topbar-h: calc(var(--topbar-icon-btn) + var(--topbar-pad-y) * 2 + 1px);
  --ps-leftpane-w: 15rem;
  --ps-content-max: 80rem;
  --ps-offcanvas-w: 32rem;
  --ps-offcanvas-wide-w: var(--sheet-max-w);
  --ps-modal-w: 42rem;
  --ps-scrim: var(--overlay);
  --ps-shadow-card: var(--shadow-xs);
}

/* Dark: same structure, lifted lightness, same hues. The dashboard toggle sets
   body.dark-mode + html[data-theme="dark"] (js/features.js); `.dark` is Tether's name. */
.dark,
:root[data-theme="dark"],
body.dark-mode {
  --primary: #b48ac4;
  --primary-foreground: #17161f;
  --primary-hover: color-mix(in srgb, var(--primary) 85%, #ffffff);
  --secondary: #352940;
  --secondary-foreground: #e9dcef;
  --accent: #6d8bc2;
  --accent-foreground: #17161f;
  --foreground: #f4f3f8;
  --muted: #262531;
  --muted-foreground: #a3a0b5;
  --border: #2f2d3b;
  --input: #3a3847;
  --ring: #6d8bc2;
  --background: #121118;
  --card: #1b1a23;
  --card-foreground: #f4f3f8;
  --popover: #1b1a23;
  --popover-foreground: #f4f3f8;
  --sidebar: #16151d;
  --sidebar-foreground: #dcdae6;
  --sidebar-primary-foreground: #17161f;
  --sidebar-accent: #352940;
  --sidebar-accent-foreground: #e9dcef;
  --sidebar-border: #2a2836;
  --success: #5fb291;
  --warning: #e5a54c;
  --destructive: #e8726f;
  --destructive-foreground: #17161f;
  --success-text: #5fb291;
  --warning-text: #e5a54c;
  --destructive-text: #e8726f;
  --link: color-mix(in srgb, var(--accent) 85%, #ffffff);
  --link-hover: color-mix(in srgb, var(--accent) 70%, #ffffff);
  --shadow-header: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --overlay: rgb(0 0 0 / 0.55);
  --bs-primary-rgb: 180, 138, 196;
  --ps-shadow-card: 0 1px 2px rgb(0 0 0 / 0.4);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #b48ac4;
    --primary-foreground: #17161f;
    --primary-hover: color-mix(in srgb, var(--primary) 85%, #ffffff);
    --secondary: #352940;
    --secondary-foreground: #e9dcef;
    --accent: #6d8bc2;
    --accent-foreground: #17161f;
    --foreground: #f4f3f8;
    --muted: #262531;
    --muted-foreground: #a3a0b5;
    --border: #2f2d3b;
    --input: #3a3847;
    --ring: #6d8bc2;
    --background: #121118;
    --card: #1b1a23;
    --card-foreground: #f4f3f8;
    --popover: #1b1a23;
    --popover-foreground: #f4f3f8;
    --sidebar: #16151d;
    --sidebar-foreground: #dcdae6;
    --sidebar-primary-foreground: #17161f;
    --sidebar-accent: #352940;
    --sidebar-accent-foreground: #e9dcef;
    --sidebar-border: #2a2836;
    --success: #5fb291;
    --warning: #e5a54c;
    --destructive: #e8726f;
    --destructive-foreground: #17161f;
    --success-text: #5fb291;
    --warning-text: #e5a54c;
    --destructive-text: #e8726f;
    --link: color-mix(in srgb, var(--accent) 85%, #ffffff);
    --link-hover: color-mix(in srgb, var(--accent) 70%, #ffffff);
    --shadow-header: 0 1px 2px 0 rgb(0 0 0 / 0.4);
    --overlay: rgb(0 0 0 / 0.55);
    --bs-primary-rgb: 180, 138, 196;
    --ps-shadow-card: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}
